#include "config.h"#include "mc_interface.h"#include "mc_control.h"#include "mc_drv.h"
Go to the source code of this file.
Functions | |
| U8 | mc_get_potentiometer_value (void) |
| Get the potentiometer value. | |
| void | mc_init () |
| use to init programm | |
| void | mc_set_measured_period (U16 measured_period) |
| set Measured of speed (for initialization) | |
| void | mc_set_potentiometer_value (U8 potentiometer) |
| Set the 'mc_potentiometer_value' variable with the potentiometer value. | |
| void | mci_backward (void) |
| void | mci_forward (void) |
| U16 | mci_get_measured_current (void) |
| Get the current measured in the motor. | |
| U8 | mci_get_measured_speed (void) |
| Measured of speed. | |
| U8 | mci_get_motor_direction (void) |
| U8 | mci_get_ref_speed (void) |
| Bool | mci_motor_is_running (void) |
| get the motor state | |
| void | mci_retry_run (void) |
| mci_retry_run retry to run if speed is null | |
| void | mci_run (void) |
| mci_run run the motor with parameter | |
| void | mci_set_ref_speed (U8 speed) |
| void | mci_stop (void) |
| mci_stop stop the motor And reset the speed measured value. | |
| void | mci_store_measured_current (U16 current) |
| Set the variable 'mc_measured_current' for initialization. | |
Variables | |
| U8 | mc_potentiometer_value = 0 |
| Motor Input to set the motor speed. | |
| Bool | mci_direction = CW |
| User Input parameter to set motor direction. | |
| U32 | mci_measured_current = 0 |
| Motor Input parameter to get the motor current. | |
| U16 | mci_measured_period = (U16)K_SPEED |
| Motor Input parameter to get the motor speed. | |
| U8 | mci_ref_speed = 0 |
| User Input parameter to set motor speed. | |
| Bool | mci_run_stop = FALSE |
| User Input parameter to launch or stop the motor. | |
| U8 | motor_state |
| U8 | new_position |
| Bool | overcurrent |
| U8 | ramp_up_index |
| U8 | ru_period_counter |
| U8 | ru_step_length |
| U8 mc_get_potentiometer_value | ( | void | ) |
Get the potentiometer value.
Definition at line 244 of file mc_interface.c.
References mc_potentiometer_value.
Referenced by main(), and mc_regulation_loop().
00245 { 00246 return mc_potentiometer_value; 00247 }
| void mc_init | ( | void | ) |
use to init programm
Definition at line 129 of file mc_interface.c.
References K_SPEED, mc_init_HW(), mc_set_measured_period(), mci_forward(), mci_set_ref_speed(), and mci_stop().
Referenced by main().
00130 { 00131 mc_init_HW(); 00132 Enable_interrupt(); 00133 mci_stop(); 00134 mci_forward(); 00135 mci_set_ref_speed(0); 00136 mc_set_measured_period(K_SPEED); 00137 }
| void mc_set_measured_period | ( | U16 | measured_period | ) |
set Measured of speed (for initialization)
Definition at line 197 of file mc_interface.c.
References mci_measured_period.
Referenced by mc_estimation_speed(), and mc_init().
00198 { 00199 mci_measured_period = (mci_measured_period * 3 + measured_period * 4) / 4; 00200 }
| void mc_set_potentiometer_value | ( | U8 | potentiometer | ) |
Set the 'mc_potentiometer_value' variable with the potentiometer value.
Definition at line 254 of file mc_interface.c.
References mc_potentiometer_value.
Referenced by ADC_end_of_conversion().
00255 { 00256 mc_potentiometer_value = potentiometer; 00257 }
| void mci_backward | ( | void | ) |
Definition at line 177 of file mc_interface.c.
References CCW, and mci_direction.
Referenced by main(), and ushell_task().
00178 { 00179 mci_direction = CCW; 00180 }
| void mci_forward | ( | void | ) |
Definition at line 167 of file mc_interface.c.
References CW, and mci_direction.
Referenced by mc_init(), and ushell_task().
00168 { 00169 mci_direction = CW; 00170 }
| U16 mci_get_measured_current | ( | void | ) |
Get the current measured in the motor.
Definition at line 224 of file mc_interface.c.
References mci_measured_current.
Referenced by mc_control_current(), and ushell_task().
00225 { 00226 return mci_measured_current/64; 00227 }
| U8 mci_get_measured_speed | ( | void | ) |
Measured of speed.
Definition at line 208 of file mc_interface.c.
References K_SPEED, and mci_measured_period.
Referenced by mc_control_speed(), and ushell_task().
00209 { 00210 U16 measured_speed; 00211 00212 if (mci_measured_period == 0) {mci_measured_period += 1 ;} // warning DIV by 0 00213 measured_speed = (K_SPEED * 4)/ (mci_measured_period); 00214 if(measured_speed > 255) measured_speed = 255; // Variable saturation 00215 00216 return measured_speed; 00217 }
| U8 mci_get_motor_direction | ( | void | ) |
Definition at line 187 of file mc_interface.c.
References mci_direction.
Referenced by compute_new_position(), mc_switch_commutation(), and thirty_degres_interrupt().
00188 { 00189 return mci_direction; 00190 }
| U8 mci_get_ref_speed | ( | void | ) |
Definition at line 157 of file mc_interface.c.
References mci_ref_speed.
Referenced by mc_regulation_loop().
00158 { 00159 return mci_ref_speed; 00160 }
| Bool mci_motor_is_running | ( | void | ) |
get the motor state
Definition at line 107 of file mc_interface.c.
References mci_run_stop.
Referenced by mc_switch_commutation(), and thirty_degres_interrupt().
00108 { 00109 return mci_run_stop; 00110 }
| void mci_retry_run | ( | void | ) |
mci_retry_run retry to run if speed is null
Definition at line 94 of file mc_interface.c.
References mc_disable_during_inrush(), mc_get_hall(), mc_regulation_loop(), mc_switch_commutation(), mci_run_stop, and TRUE.
00095 { 00096 mci_run_stop = TRUE; 00097 mc_regulation_loop(); 00098 mc_switch_commutation(mc_get_hall()); 00099 mc_disable_during_inrush(); /* disable overcurrent during inrush */ 00100 }
| void mci_run | ( | void | ) |
mci_run run the motor with parameter
Definition at line 70 of file mc_interface.c.
References ALIGN_DUTY, ALIGN_TIME, FALSE, mc_disable_during_inrush(), mc_duty_cycle(), mc_regulation_loop(), mc_switch_commutation(), mci_run_stop, motor_state, MS_001, MS_ALIGN, new_position, overcurrent, PSC_Init(), ramp_up_index, RAMP_UP_STEP_MAX, ru_period_counter, ru_step_length, and TRUE.
Referenced by main(), and ushell_task().
00071 { 00072 if (!(PCTL & (1<<PRUN))) /* if there is an overcurrent */ 00073 { 00074 PSC_Init(); 00075 } 00076 overcurrent = FALSE; 00077 mci_run_stop = TRUE; 00078 mc_regulation_loop(); 00079 mc_disable_during_inrush(); /* disable overcurrent during inrush */ 00080 new_position = MS_001; 00081 mc_switch_commutation((Motor_Position)new_position); 00082 mc_duty_cycle(ALIGN_DUTY); 00083 ru_period_counter = ALIGN_TIME; 00084 motor_state=MS_ALIGN; 00085 ru_step_length = RAMP_UP_STEP_MAX; 00086 ramp_up_index = 0; 00087 }
| void mci_set_ref_speed | ( | U8 | speed | ) |
Definition at line 144 of file mc_interface.c.
References mci_ref_speed.
Referenced by main(), mc_init(), and ushell_task().
00145 { 00146 mci_ref_speed = speed; 00147 }
| void mci_stop | ( | void | ) |
mci_stop stop the motor And reset the speed measured value.
Definition at line 118 of file mc_interface.c.
References FALSE, mc_duty_cycle(), mci_run_stop, motor_state, and MS_STOP.
Referenced by mc_init(), mc_overcurrent_detect(), and ushell_task().
00119 { 00120 mci_run_stop=FALSE; 00121 motor_state=MS_STOP; 00122 mc_duty_cycle(0); // Motor Voltage = 0 00123 }
| void mci_store_measured_current | ( | U16 | current | ) |
Set the variable 'mc_measured_current' for initialization.
Definition at line 234 of file mc_interface.c.
References mci_measured_current.
Referenced by ADC_end_of_conversion().
00235 { 00236 mci_measured_current = ((63*mci_measured_current)+(64*current))>>6; 00237 }
Motor Input to set the motor speed.
Definition at line 55 of file mc_interface.c.
Referenced by mc_get_potentiometer_value(), and mc_set_potentiometer_value().
| Bool mci_direction = CW |
User Input parameter to set motor direction.
Definition at line 48 of file mc_interface.c.
Referenced by mci_backward(), mci_forward(), mci_get_motor_direction(), and ushell_task().
Motor Input parameter to get the motor current.
Definition at line 54 of file mc_interface.c.
Referenced by mci_get_measured_current(), and mci_store_measured_current().
| U16 mci_measured_period = (U16)K_SPEED |
Motor Input parameter to get the motor speed.
Definition at line 53 of file mc_interface.c.
Referenced by mc_set_measured_period(), and mci_get_measured_speed().
| U8 mci_ref_speed = 0 |
User Input parameter to set motor speed.
Definition at line 50 of file mc_interface.c.
Referenced by mci_get_ref_speed(), and mci_set_ref_speed().
| Bool mci_run_stop = FALSE |
User Input parameter to launch or stop the motor.
Definition at line 49 of file mc_interface.c.
Referenced by mci_motor_is_running(), mci_retry_run(), mci_run(), mci_stop(), and ushell_task().
1.5.7.1