![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
LIGHT2
Diff: main.cpp
- Revision:
- 252:a08f301231f1
- Parent:
- 251:91d3ec3a087e
- Child:
- 253:3ffd78cbd029
diff -r 91d3ec3a087e -r a08f301231f1 main.cpp --- a/main.cpp Fri Jul 01 05:37:08 2022 +0000 +++ b/main.cpp Wed Jul 06 08:08:15 2022 +0000 @@ -1297,10 +1297,13 @@ valve_pos_pulse = -10000.0f; } } - if (valve_pos_pulse >= 0) { - valve_pos.ref = valve_pos_pulse/10000.0f * (VALVE_MAX_POS-VALVE_DEADZONE_PLUS) + VALVE_DEADZONE_PLUS; + float valve_control_deadzone = 5.0f; + if(valve_pos_pulse < valve_control_deadzone && valve_pos_pulse > -valve_control_deadzone) { + valve_pos.ref = ((float) VALVE_DEADZONE_PLUS + (float) VALVE_DEADZONE_MINUS) * 0.5f; + } else if (valve_pos_pulse >= valve_control_deadzone) { + valve_pos.ref = valve_pos_pulse/10000.0f * ((float) VALVE_MAX_POS - (float) VALVE_DEADZONE_PLUS) + (float) VALVE_DEADZONE_PLUS; } else { - valve_pos.ref = -valve_pos_pulse/10000.0f * (VALVE_MIN_POS-VALVE_DEADZONE_MINUS) + VALVE_DEADZONE_MINUS; + valve_pos.ref = -valve_pos_pulse/10000.0f * ((float) VALVE_MIN_POS - (float) VALVE_DEADZONE_MINUS) + (float) VALVE_DEADZONE_MINUS; } VALVE_POS_CONTROL_DZ(valve_pos.ref); V_out = Vout.ref;