Definition in file main.c.
#include "config.h"
#include "config_motor.h"
#include "mc_interface.h"
#include "mc_control.h"
#include "mc_drv.h"
#include "ushell_task.h"
#include "adc\adc_drv.h"
#include "comparator\comparator_drv.h"
Include dependency graph for main.c:

Go to the source code of this file.
Functions | |
| void | main (void) |
| void | mc_ramp_up_init (void) |
Variables | |
| U16 | g_regulation_period = 0 |
| Define the sampling period. | |
| U16 | g_speed_monitor_period = 0 |
| Bool | g_tick |
| Use for control the sampling period value. | |
| U8 | new_position = HS_001 |
| U8 | ramp_counter = 0 |
| Bool | ramp_up = FALSE |
| see mc_drv.c Use for sampling time | |
| U8 | tick_divider |
| U8 | tick_divider_min = 50 |
| void main | ( | void | ) |
Definition at line 45 of file main.c.
References CCW, Disable_comparator0_interrupt, Disable_comparator1_interrupt, Disable_comparator2_interrupt, Enable_comparator0_interrupt, Enable_comparator1_interrupt, Enable_comparator2_interrupt, FALSE, g_regulation_period, g_speed_monitor_period, g_tick, HS_001, HS_010, HS_011, HS_100, HS_101, HS_110, mc_ADC_Scheduler(), mc_motor_init(), mc_ramp_up_init(), mc_regulation_loop(), mc_set_Open_Loop(), mc_switch_commutation(), mci_get_measured_speed(), mci_get_motor_direction, mci_run_stop, mci_set_motor_speed(), new_position, PRUN2, ramp_counter, ramp_up, RUN, switch_OFF_LED, switch_ON_LED, tick_divider, tick_divider_min, TRUE, ushell_task(), and ushell_task_init().
00046 { 00047 ushell_task_init(); 00048 00049 // init motor 00050 mc_motor_init(); // launch initialization of the motor 00051 00052 while(1) 00053 { 00054 // Show PSC state according to the Over Current information 00055 if(PCTL2 & (1<<PRUN2)) switch_OFF_LED();// PSC ON 00056 else switch_ON_LED();//PSC OFF => Over_Current 00057 00058 00059 // Launch regulation loop 00060 // Timer 1 generate an IT (g_tick) all 250us 00061 // Sampling period = n * 250us 00062 if (g_tick == TRUE) 00063 { 00064 g_tick = FALSE; 00065 00066 // Get Current and potentiometer value 00067 mc_ADC_Scheduler(); 00068 00069 if (ramp_up == TRUE) 00070 { 00071 /* BEGIN OF RAMP UP SEQUENCE */ 00072 Disable_comparator0_interrupt(); // disable bemf interrupt 00073 Disable_comparator1_interrupt(); // disable bemf interrupt 00074 Disable_comparator2_interrupt(); // disable bemf interrupt 00075 ramp_counter += 1; 00076 if ( ramp_counter >= 40 ) 00077 { 00078 ramp_counter = 0; 00079 if (tick_divider_min > 3) 00080 { 00081 tick_divider_min -= 1; 00082 } 00083 else 00084 { 00085 ramp_up = FALSE; 00086 g_speed_monitor_period = 1; 00087 // mc_set_Speed_Loop(); // speed regulation loop 00088 mc_set_Open_Loop(); // no regulation loop 00089 mci_set_motor_speed(180); 00090 mc_regulation_loop(); 00091 Enable_comparator0_interrupt(); // enable the bemf signal 00092 Enable_comparator1_interrupt(); // enable the bemf signal 00093 Enable_comparator2_interrupt(); // enable the bemf signal 00094 } 00095 } 00096 00097 tick_divider += 1; 00098 if ( tick_divider >= tick_divider_min ) 00099 { 00100 tick_divider = 0; 00101 00102 if (mci_get_motor_direction()==CCW) 00103 { 00104 switch(new_position) 00105 { 00106 /* ramp up CCW */ 00107 case HS_001: 00108 new_position = HS_011; 00109 break; 00110 00111 case HS_101: 00112 new_position = HS_001; 00113 break; 00114 00115 case HS_100: 00116 new_position = HS_101; 00117 break; 00118 00119 case HS_110: 00120 new_position = HS_100; 00121 break; 00122 00123 case HS_010: 00124 new_position = HS_110; 00125 break; 00126 00127 case HS_011: 00128 new_position = HS_010; 00129 break; 00130 00131 default : 00132 new_position = HS_001; 00133 break; 00134 } 00135 00136 } 00137 else 00138 { 00139 switch(new_position) 00140 { 00141 /* ramp_up CW */ 00142 case HS_001: 00143 new_position = HS_101; 00144 break; 00145 00146 case HS_101: 00147 new_position = HS_100; 00148 break; 00149 00150 case HS_100: 00151 new_position = HS_110; 00152 break; 00153 00154 case HS_110: 00155 new_position = HS_010; 00156 break; 00157 00158 case HS_010: 00159 new_position = HS_011; 00160 break; 00161 00162 case HS_011: 00163 new_position = HS_001; 00164 break; 00165 00166 default : 00167 new_position = HS_001; 00168 break; 00169 } 00170 00171 } 00172 mc_switch_commutation(new_position); 00173 } 00174 /* END OF RAMP UP SEQUENCE */ 00175 } 00176 00177 00178 g_regulation_period += 1; 00179 if ( g_regulation_period >= 8 ) //n * 250us = Te : 2mS 00180 { 00181 g_regulation_period = 1; 00182 mc_regulation_loop(); // launch regulation loop 00183 } 00184 00185 00186 /* monitor the speed */ 00187 if (mci_run_stop == RUN) 00188 { 00189 g_speed_monitor_period += 1; 00190 if ( g_speed_monitor_period >= 4000 ) //n * 250us = 1S 00191 { 00192 g_speed_monitor_period = 1; 00193 if (mci_get_measured_speed() > 250) mc_ramp_up_init(); 00194 if (mci_get_measured_speed() < (100/27)) mc_ramp_up_init(); 00195 } 00196 } 00197 00198 /* monitor the uart communication */ 00199 ushell_task(); 00200 00201 } 00202 } 00203 }
Here is the call graph for this function:

| void mc_ramp_up_init | ( | void | ) |
Definition at line 35 of file main.c.
References g_speed_monitor_period, HS_001, new_position, ramp_counter, ramp_up, tick_divider_min, and TRUE.
Referenced by main(), and mci_run().
00036 { 00037 ramp_counter = 0; 00038 tick_divider_min = 50; 00039 new_position = HS_001; 00040 ramp_up = TRUE; 00041 g_speed_monitor_period = 0; 00042 }
Here is the caller graph for this function:

Use for control the sampling period value.
Definition at line 31 of file mc_drv.c.
Referenced by main(), and timer1_periodic_interrupt().
| U8 new_position = HS_001 |
| U8 ramp_counter = 0 |
see mc_drv.c Use for sampling time
Definition at line 27 of file main.c.
Referenced by main(), and mc_ramp_up_init().
| U8 tick_divider_min = 50 |
1.4.7