![]() |
BLDC control on ATAVRMC303 with ATxMega128A1
|
,v More...
#include "config.h"#include "mc_drv.h"#include "mc_interface.h"#include "mc_control.h"#include "adc\adc_drv.h"#include "dac\Dac_drv.h"#include "pll\pll_drv.h"#include "comparator\comparator_drv.h"#include "awex_driver.h"#include "TC_driver.h"#include "hires_driver.h"#include "adc_driver.h"
Go to the source code of this file.
Functions | |
| void | ADC_Init () |
| void | ConfigDTI (U8 deadTime) |
| void | init_amplifier_1 (void) |
| init Amplifier 1 More... | |
| __interrupt void | launch_sampling_period (void) |
| Launch the regulation loop (see main.c) . More... | |
| 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_hall (void) |
| Get the value of hall sensors (1 to 6) More... | |
| __interrupt void | mc_hall_a (void) |
| External interruption Sensor (A) mode toggle. More... | |
| 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... | |
| __interrupt void | ovfl_timer0 (void) |
| Timer0 Overflow for speed measurement. More... | |
| void | PWM_Init (unsigned int OCRnRB) |
| Initialization of PWM generator PSC0. More... | |
Variables | |
| char | ADC_State = FREE |
| U16 | average = 0 |
| U8 | count = 1 |
| Bool | current_EOC = FALSE |
| Bool | g_mc_read_enable = FALSE |
| Bool | g_tick = FALSE |
| Use for control the sampling period value. More... | |
| Bool | hall1_old_val = 1 |
| U16 | inrush_delay = 0 |
| Bool | inrush_mask_flag = FALSE |
| volatile char | offset =0 |
| U8 | ovf_timer = 0 |
| char | State = CONV_INIT |
,v
Copyright (c) 2008 Atmel.
Motor Control Driver level :
Definition in file mc_drv.c.
| void ADC_Init | ( | ) |
Definition at line 53 of file mc_drv.c.
References ADC_CalibrationValues_Set(), ADC_Ch_InputMode_and_Gain_Config, ADC_Ch_InputMux_Config, ADC_ConvMode_and_Resolution_Config, ADC_Enable, ADC_FreeRunning_Enable, ADC_Offset_Get(), ADC_Prescaler_Config, ADC_Referance_Config, ADC_Wait_8MHz(), and offset.
Referenced by mc_init_HW().

| void ConfigDTI | ( | U8 | deadTime | ) |
Definition at line 142 of file mc_drv.c.
References AWEX_EnableDeadTimeInsertion(), AWEX_SetDeadTimesSymmetricalUnbuffered, and AWEX_SetOutputOverrideValue.
Referenced by PWM_Init().

| void init_amplifier_1 | ( | void | ) |
| __interrupt void launch_sampling_period | ( | void | ) |
| 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_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().
| __interrupt void mc_hall_a | ( | void | ) |
External interruption Sensor (A) mode toggle.
Definition at line 191 of file mc_drv.c.
References g_mc_read_enable, hall1_old_val, HALL_SENSOR_VALUE, mc_estimation_speed(), and mc_switch_commutation().

| 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().

| __interrupt void ovfl_timer0 | ( | void | ) |
Timer0 Overflow for speed measurement.
Definition at line 327 of file mc_drv.c.
References mc_motor_is_running(), mc_set_motor_measured_speed(), and mci_retry_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().

| U16 average = 0 |
Definition at line 32 of file mc_drv.c.
Referenced by mc_estimation_speed().
| U8 count = 1 |
Definition at line 31 of file mc_drv.c.
Referenced by mc_estimation_speed().
| Bool g_mc_read_enable = FALSE |
Definition at line 38 of file mc_drv.c.
Referenced by mc_estimation_speed(), and mc_hall_a().
| Bool g_tick = FALSE |
Use for control the sampling period value.
Definition at line 39 of file mc_drv.c.
Referenced by launch_sampling_period(), and main().
| Bool hall1_old_val = 1 |
Definition at line 40 of file mc_drv.c.
Referenced by mc_hall_a().
| U16 inrush_delay = 0 |
Definition at line 36 of file mc_drv.c.
Referenced by mc_disable_during_inrush(), and mc_inrush_task().
| Bool inrush_mask_flag = FALSE |
Definition at line 35 of file mc_drv.c.
Referenced by mc_disable_during_inrush(), and mc_inrush_task().
| volatile char offset =0 |
Definition at line 47 of file mc_drv.c.
Referenced by ADC_Init(), ADC_Offset_Get(), ADC_ResultCh_GetLowByte(), and mc_ADC_Scheduler().