![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
LIGHT2
Diff: CAN/function_CAN.cpp
- Revision:
- 47:fdcb8bd86fd6
- Parent:
- 46:2694daea349b
- Child:
- 48:889798ff9329
diff -r 2694daea349b -r fdcb8bd86fd6 CAN/function_CAN.cpp --- a/CAN/function_CAN.cpp Mon Jan 20 08:05:21 2020 +0000 +++ b/CAN/function_CAN.cpp Tue Jan 21 13:39:27 2020 +0000 @@ -727,8 +727,12 @@ vel.ref = (double)temp_vel * 100.0f; torq.ref = (double)temp_torq * 0.1f; } else if(address==CID_RX_REF_PWM) { - int16_t temp_vout = (int16_t) (msg.data[0] | msg.data[1] << 8); - Vout.ref = (double)temp_vout; + int16_t temp_ref_valve_pos = (int16_t) (msg.data[0] | msg.data[1] << 8); + if(temp_ref_valve_pos >= 0){ + valve_pos.ref = (double)DDV_CENTER + (double)temp_ref_valve_pos * ((double)VALVE_MAX_POS-(double)DDV_CENTER)/10000.0f ; + }else{ + valve_pos.ref = (double)DDV_CENTER - (double)temp_ref_valve_pos * ((double)VALVE_MIN_POS-(double)DDV_CENTER)/10000.0f; + } } }