![]() |
BLDC control on ATAVRMC303 with ATxMega128A1
|

Go to the source code of this file.
Macros | |
| #define | BUSY 1 |
| #define | Clear_EXT1() (PORTB &= ~(1<<PB3)) |
| #define | Clear_EXT10() (PORTD &= ~(1<<PD2)) |
| #define | Clear_EXT2() (PORTB &= ~(1<<PB4)) |
| #define | Clear_EXT3() (PORTC &= ~(1<<PC1)) |
| #define | Clear_EXT4() (PORTC &= ~(1<<PC2)) |
| #define | Clear_EXT5() (PORTB &= ~(1<<PB5)) |
| #define | Clear_EXT6() (PORTE &= ~(1<<PE1)) |
| #define | Clear_EXT7() (PORTD &= ~(1<<PD3)) |
| #define | Clear_EXT8() (PORTD &= ~(1<<PD4)) |
| #define | Clear_EXT9() (PORTE &= ~(1<<PE0)) |
| #define | Clear_Port_Q1() (PORTC.OUTCLR = PIN5_bm) |
| #define | Clear_Port_Q2() (PORTC.OUTCLR = PIN4_bm) |
| #define | Clear_Port_Q3() (PORTC.OUTCLR = PIN3_bm) |
| #define | Clear_Port_Q4() (PORTC.OUTCLR = PIN2_bm) |
| #define | Clear_Port_Q5() (PORTC.OUTCLR = PIN1_bm) |
| #define | Clear_Port_Q6() (PORTC.OUTCLR = PIN0_bm) |
| #define | CONV_CURRENT 2 |
| #define | CONV_INIT 0 |
| #define | CONV_POT 1 |
| #define | Disable_over_current() |
| #define | Enable_over_current() |
| #define | FREE 0 |
| #define | Get_EXT1() ((PINB & (1<<PB3))>>PB3) |
| #define | Get_EXT10() ((PIND & (1<<PD2))>>PD2) |
| #define | Get_EXT2() ((PINB & (1<<PB4))>>PB4) |
| #define | Get_EXT3() ((PINC & (1<<PC1))>>PC1) |
| #define | Get_EXT4() ((PINC & (1<<PC2))>>PC2) |
| #define | Get_EXT5() ((PINB & (1<<PB5))>>PB5) |
| #define | Get_EXT6() ((PINE & (1<<PE1))>>PE1) |
| #define | Get_EXT7() ((PIND & (1<<PD3))>>PD3) |
| #define | Get_EXT8() ((PIND & (1<<PD4))>>PD4) |
| #define | Get_EXT9() ((PINE & (1<<PE0))>>PE0) |
| #define | HALL_A() (PORTE_INT0_vect) |
| #define | HALL_SENSOR_VALUE() (PORTE.IN & 0x07) |
| #define | OUTPUT_ACTIVE_HIGH (1<<POP0) |
| #define | OUTPUT_ACTIVE_LOW (0<<POP0) |
| #define | output_disconnected 0x01 |
| #define | PRESC_DIV_BY_16 (1<<PPRE01)|(0<<PPRE00) |
| #define | PRESC_DIV_BY_4 (0<<PPRE01)|(1<<PPRE00) |
| #define | PRESC_DIV_BY_64 (1<<PPRE01)|(1<<PPRE00) |
| #define | PRESC_NODIV (0<<PPRE01)|(0<<PPRE00) |
| #define | PSC_CENTERED (1<<PMODE01)|(1<<PMODE00) |
| #define | PSC_FOUR_RAMP (1<<PMODE01)|(0<<PMODE00) |
| #define | PSC_ONE_RAMP (0<<PMODE01)|(0<<PMODE00) |
| #define | PSC_TWO_RAMP (0<<PMODE01)|(1<<PMODE00) |
| #define | RAMP_MODE_NUMBER PSC_CENTERED |
| #define | RELEASE_PLOCK (0<<PLOCK0) |
| #define | Set_EXT1() (PORTB |= (1<<PB3)) |
| #define | Set_EXT10() (PORTD |= (1<<PD2)) |
| #define | Set_EXT2() (PORTB |= (1<<PB4)) |
| #define | Set_EXT3() (PORTC |= (1<<PC1)) |
| #define | Set_EXT4() (PORTC |= (1<<PC2)) |
| #define | Set_EXT5() (PORTB |= (1<<PB5)) |
| #define | Set_EXT6() (PORTE |= (1<<PE1)) |
| #define | Set_EXT7() (PORTD |= (1<<PD3)) |
| #define | Set_EXT8() (PORTD |= (1<<PD4)) |
| #define | Set_EXT9() (PORTE |= (1<<PE0)) |
| #define | Set_none() (AWEX_SetOutputOverrideValue(AWEXC,0)) |
| #define | SET_PLOCK (1<<PLOCK0) |
| #define | Set_Port_Q2() (PORTC.OUTSET = PIN4_bm) |
| #define | Set_Port_Q4() (PORTC.OUTSET = PIN2_bm) |
| #define | Set_Port_Q6() (PORTC.OUTSET = PIN0_bm) |
| #define | Set_Q1Q4() AWEX_SetOutputOverrideValue(AWEXC,PIN5_bm | PIN2_bm) |
| #define | Set_Q1Q6() AWEX_SetOutputOverrideValue(AWEXC,PIN5_bm | PIN0_bm) |
| #define | Set_Q3Q2() AWEX_SetOutputOverrideValue(AWEXC,PIN3_bm | PIN4_bm) |
| #define | Set_Q3Q6() AWEX_SetOutputOverrideValue(AWEXC,PIN3_bm | PIN0_bm) |
| #define | Set_Q5Q2() AWEX_SetOutputOverrideValue(AWEXC,PIN1_bm | PIN4_bm) |
| #define | Set_Q5Q4() AWEX_SetOutputOverrideValue(AWEXC,PIN1_bm | PIN2_bm) |
| #define | Set_timer_data_register_to_zero() (TCNT0=0x00) |
| #define | switch_OFF_LED() (PORTE |= (1<<PE2)) |
| #define | switch_ON_LED() (PORTE &= ~(1<<PE2)) |
| #define | Toggle_EXT2() (PINB |= (1<<PINB4)) |
Functions | |
| void | mc_ADC_Scheduler (void) |
| Launch the scheduler for the ADC. More... | |
| void | mc_disable_during_inrush (void) |
| the purpose of this function is to disable the overcurrent detection during startup (inrush current) More... | |
| void | mc_duty_cycle (U8 level) |
| Set the duty cycle values in the PSC according to the value calculate by the regulation loop. More... | |
| void | mc_estimation_speed (void) |
| estimation speed More... | |
| U8 | mc_Get_Current (void) |
| U8 | mc_get_hall (void) |
| Get the value of hall sensors (1 to 6) More... | |
| U8 | mc_Get_Potentiometer (void) |
| void | mc_init_HW (void) |
| init HW More... | |
| void | mc_init_timer0 (void) |
| Timer 0 Configuration The timer 0 is used to generate an IT when an overflow occurs. More... | |
| void | mc_init_timer1 (void) |
| timer 1 Configuration Use to generate a 250us activation for sampling speed regulation More... | |
| void | mc_inrush_task (void) |
| the purpose of this function is to manage the delay used when the overcurrent detection is disabled More... | |
| void | mc_set_Over_Current (U8 Level) |
| Set the Over Current threshold. More... | |
| void | mc_switch_commutation (U8 position) |
| Set the Switching Commutation value on outputs according to sensor or estimation position. More... | |
| void | PWM_Init (unsigned int OCRnRB) |
| Initialization of PWM generator PSC0. More... | |
| #define Disable_over_current | ( | ) |
| #define Enable_over_current | ( | ) |
| #define HALL_SENSOR_VALUE | ( | ) | (PORTE.IN & 0x07) |
Definition at line 53 of file mc_drv.h.
Referenced by mc_get_hall(), and mc_hall_a().
| #define RAMP_MODE_NUMBER PSC_CENTERED |
| #define Set_none | ( | ) | (AWEX_SetOutputOverrideValue(AWEXC,0)) |
Definition at line 66 of file mc_drv.h.
Referenced by mc_switch_commutation().
| #define Set_Q1Q4 | ( | ) | AWEX_SetOutputOverrideValue(AWEXC,PIN5_bm | PIN2_bm) |
Definition at line 68 of file mc_drv.h.
Referenced by mc_switch_commutation().
| #define Set_Q1Q6 | ( | ) | AWEX_SetOutputOverrideValue(AWEXC,PIN5_bm | PIN0_bm) |
Definition at line 70 of file mc_drv.h.
Referenced by mc_switch_commutation().
| #define Set_Q3Q2 | ( | ) | AWEX_SetOutputOverrideValue(AWEXC,PIN3_bm | PIN4_bm) |
Definition at line 72 of file mc_drv.h.
Referenced by mc_switch_commutation().
| #define Set_Q3Q6 | ( | ) | AWEX_SetOutputOverrideValue(AWEXC,PIN3_bm | PIN0_bm) |
Definition at line 74 of file mc_drv.h.
Referenced by mc_switch_commutation().
| #define Set_Q5Q2 | ( | ) | AWEX_SetOutputOverrideValue(AWEXC,PIN1_bm | PIN4_bm) |
Definition at line 76 of file mc_drv.h.
Referenced by mc_switch_commutation().
| #define Set_Q5Q4 | ( | ) | AWEX_SetOutputOverrideValue(AWEXC,PIN1_bm | PIN2_bm) |
Definition at line 78 of file mc_drv.h.
Referenced by mc_switch_commutation().
| void mc_ADC_Scheduler | ( | void | ) |
Launch the scheduler for the ADC.
Definition at line 388 of file mc_drv.c.
References ADC_Ch_Conversion_Complete, ADC_ResultCh_GetWord(), mc_set_potentiometer_value(), and offset.
Referenced by main().

| void mc_disable_during_inrush | ( | void | ) |
the purpose of this function is to disable
the overcurrent detection during startup (inrush current)
Definition at line 422 of file mc_drv.c.
References inrush_delay, and inrush_mask_flag.
Referenced by mci_retry_run(), and mci_run().
| void mc_duty_cycle | ( | U8 | level | ) |
Set the duty cycle values in the PSC according to the value calculate by the regulation loop.
Definition at line 212 of file mc_drv.c.
References TC_SetCompareA, TC_SetCompareB, and TC_SetCompareC.
Referenced by mc_switch_commutation(), mci_retry_run(), and mci_run().
| void mc_estimation_speed | ( | void | ) |
estimation speed
Definition at line 342 of file mc_drv.c.
References average, count, g_mc_read_enable, K_SPEED, mc_set_motor_measured_speed(), and n_SAMPLE.
Referenced by mc_hall_a().

| U8 mc_Get_Current | ( | void | ) |
| U8 mc_get_hall | ( | void | ) |
Get the value of hall sensors (1 to 6)
| return | an unsigned char value of hall sensor |
Definition at line 179 of file mc_drv.c.
References HALL_SENSOR_VALUE.
Referenced by mci_retry_run(), and mci_run().
| U8 mc_Get_Potentiometer | ( | void | ) |
| void mc_init_HW | ( | void | ) |
init HW
Definition at line 95 of file mc_drv.c.
References ADC_Init(), mc_init_timer0(), mc_init_timer1(), and PWM_Init().
Referenced by mc_init().

| void mc_init_timer0 | ( | void | ) |
Timer 0 Configuration The timer 0 is used to generate an IT when an overflow occurs.
Definition at line 313 of file mc_drv.c.
Referenced by mc_init_HW().
| void mc_init_timer1 | ( | void | ) |
timer 1 Configuration Use to generate a 250us activation for sampling speed regulation
Definition at line 283 of file mc_drv.c.
Referenced by mc_init_HW().
| void mc_inrush_task | ( | void | ) |
the purpose of this function is to manage the delay
used when the overcurrent detection is disabled
Definition at line 431 of file mc_drv.c.
References inrush_delay, and inrush_mask_flag.
Referenced by main().
| void mc_set_Over_Current | ( | U8 | Level | ) |
| void mc_switch_commutation | ( | U8 | position | ) |
Set the Switching Commutation value on outputs according to sensor or estimation position.
| position | (1 to 6) and direction (FORWARD or BACKWARD) |
Definition at line 226 of file mc_drv.c.
References CCW, HS_001, HS_010, HS_011, HS_100, HS_101, HS_110, mc_duty_cycle(), mc_get_Duty_Cycle(), mc_get_motor_direction(), mc_get_motor_speed(), mc_motor_is_running(), Set_none, Set_Q1Q4, Set_Q1Q6, Set_Q3Q2, Set_Q3Q6, Set_Q5Q2, and Set_Q5Q4.
Referenced by mc_hall_a(), mci_retry_run(), and mci_run().

| void PWM_Init | ( | unsigned int | OCRnRB | ) |
Initialization of PWM generator PSC0.
Definition at line 153 of file mc_drv.c.
References AWEX_EnableCommonWaveformChannelMode, AWEX_SetOutputOverrideValue, and ConfigDTI().
Referenced by mc_init_HW().
