Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: sm_esc.cpp
- Revision:
- 8:f23601373e8b
- Parent:
- 7:23bb20892c8c
- Child:
- 9:1b54bac6d9a7
--- a/sm_esc.cpp Sun Sep 29 20:22:43 2019 +0000 +++ b/sm_esc.cpp Wed Oct 02 22:25:12 2019 +0000 @@ -3,23 +3,22 @@ PwmOut pwm_ESC(PD_12); DigitalOut relay_ESC(PG_0); -E_STATE_ESC e_stateESC; +E_STATE_ESC e_ESC_state; Timer t_emergency_brake; -int pulsewidth_test = 1650; void init_sm_esc() { - e_stateESC = ESC_DISABLED; + e_ESC_state = ESC_DISABLED; return; } void update_sm_esc() { - E_STATE_ESC next_state = e_stateESC; + E_STATE_ESC next_state = e_ESC_state; - switch(e_stateESC) { + switch(e_ESC_state) { case ESC_DISABLED: - if(b_UTILS_flag_button && !b_UTILS_flag_emergency_stop) { + if(b_UTILS_flag_button_ESC && !b_UTILS_flag_emergency_stop) { next_state = ESC_INIT; } break; @@ -35,18 +34,18 @@ break; } - e_stateESC = next_state; + e_ESC_state = next_state; return; } void output_sm_esc() { - switch(e_stateESC) { + switch(e_ESC_state) { case ESC_DISABLED: if(b_UTILS_flag_emergency_stop) { - pc.printf("EMERGENCY STOP\r\n"); + rs_UTILS_pc.printf("EMERGENCY STOP\r\n"); b_UTILS_flag_emergency_stop = false; - if(b_chassis_with_pushbutton) { + if(b_CHASSIS_with_pushbutton) { relay_ESC = 1; wait(0.5); } @@ -55,14 +54,13 @@ break; case ESC_INIT: - pc.printf("Init esc\r\n"); - odroid.printf("pulsewidth_test: %d\r\n",pulsewidth_test); - b_UTILS_flag_button = false; + rs_UTILS_pc.printf("Init esc\r\n"); + b_UTILS_flag_button_ESC = false; pwm_ESC.period_ms(ESC_PERIOD_DURATION_MS); //20 ms is default pwm_ESC.pulsewidth_us(0); relay_ESC = 1; - if(b_chassis_with_pushbutton) { + if(b_CHASSIS_with_pushbutton) { wait(0.5); relay_ESC = 0; } @@ -79,25 +77,15 @@ break; case ESC_COMMAND: - if(t_emergency_brake.read_ms() < 2000) { - pwm_ESC.pulsewidth_us(pulsewidth_test); - } else { - pc.printf("emergency stop flag raised\r\n"); - b_UTILS_flag_emergency_stop = true; - t_emergency_brake.stop(); - t_emergency_brake.reset(); - } - /*switch(e_stateSections) { + switch(e_SECTIONS_state) { case RUNNING_SECTION: - pwm_ESC.pulsewidth_us(1660); + pwm_ESC.pulsewidth_us(s_UTILS_currentSection->targetSpeed_mps); break; case STOPPED: - pc.printf("emergency stop flag raised\r\n"); - b_UTILS_flag_emergency_stop = true; break; default: break; - }*/ + } break; default: break;