83 if(increment >= (S16)(255)) Duty = 255;
86 if(increment <= (S16)(0)) Duty = 0;
87 else Duty = (U8)(increment);
133 increment = cur_proportional +
cur_integ;
138 if(increment >= (S16)(255)) Duty = 255;
141 if(increment <= (S16)(0)) Duty = 0;
142 else Duty = (U8)(increment);
S16 last_cur_error
Variable for the last error.
U16 mci_get_measured_current(void)
Get the current measured in the motor.
S16 speed_error
Error calculation.
void mc_set_Speed_Loop()
set type of regulation
U8 duty_cycle
Parameter to set PWM Duty Cycle after regulation calculation.
S16 last_speed_error
Variable for the last error.
U8 mc_control_current(U8 cur_cmd)
use to control current , current regulation loop need parameter : Kp_cur, Ki_cur ,Kd_cur and K_cur_scal in config_motor.h need to call in Te ms
U8 regulation_type
Define the type of regulation (OPEN_LOOP or CLOSE_LOOP)
void mc_set_Open_Loop()
set type of regulation
U8 mc_control_speed(U8 speed_cmd)
use to control speed , speed regulation loop need parameter : Kp_speed, Ki_speed ,Kd_speed and K_speed_scal in config_motor.h need to call in Te ms
U8 mc_get_Duty_Cycle()
set type of regulation
S16 cur_error
Error calculation.
void mc_regulation_loop()
launch speed control or no regulation
U8 mci_get_measured_speed(void)
Measured of speed.
U8 mc_get_motor_speed(void)
void mc_set_Current_Loop()
set type of regulation
U8 mc_get_potentiometer_value(void)
Get the potentiometer value.