![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
2011
Diff: CAN/function_CAN.cpp
- Revision:
- 45:35fa6884d0c6
- Parent:
- 43:b084e5f5d0d5
- Child:
- 46:2694daea349b
diff -r fe7d5cfd2eea -r 35fa6884d0c6 CAN/function_CAN.cpp --- a/CAN/function_CAN.cpp Tue Jan 14 09:11:20 2020 +0000 +++ b/CAN/function_CAN.cpp Thu Jan 16 12:05:15 2020 +0000 @@ -8,11 +8,7 @@ // CAN ID Setting Variables int CID_RX_CMD = 100; int CID_RX_REF_POSITION = 200; -int CID_RX_REF_TORQUE = 300; -int CID_RX_REF_PRES_DIFF = 400; -int CID_RX_REF_VOUT = 500; -int CID_RX_REF_VALVE_POSITION = 600; -int CID_RX_REF_CURRENT = 700; +int CID_RX_REF_PWM = 300; int CID_TX_INFO = 1100; int CID_TX_POSITION = 1200; @@ -32,11 +28,7 @@ CID_RX_CMD = (int) (BNO + INIT_CID_RX_CMD); CID_RX_REF_POSITION = (int) (BNO + INIT_CID_RX_REF_POSITION); - CID_RX_REF_TORQUE = (int) (BNO + INIT_CID_RX_REF_TORQUE); - CID_RX_REF_PRES_DIFF = (int) (BNO + INIT_CID_RX_REF_PRES_DIFF); - CID_RX_REF_VOUT = (int) (BNO + INIT_CID_RX_REF_VOUT); - CID_RX_REF_VALVE_POSITION = (int) (BNO + INIT_CID_RX_REF_VALVE_POSITION); - CID_RX_REF_CURRENT = (int) (BNO + INIT_CID_RX_REF_CURRENT); + CID_RX_REF_PWM = (int) (BNO + INIT_CID_RX_REF_PWM); CID_TX_INFO = (int) (BNO + INIT_CID_TX_INFO); CID_TX_POSITION = (int) (BNO + INIT_CID_TX_POSITION); @@ -88,9 +80,14 @@ break; } - case CRX_SET_REF_UPDATE_ENABLE: { - flag_ref_enable = (int16_t) msg.data[1]; - + case CRX_SET_POS_TORQ_TRANS: { + MODE_POS_FT_TRANS = (int16_t) msg.data[1]; + /* + MODE_POS_FT_TRANS == 0 : Position Control + MODE_POS_FT_TRANS == 1 : Trasition(Position->Torque) + MODE_POS_FT_TRANS == 2 : Torque Control (Convert to 2 automatically 3sec after transition) + MODE_POS_FT_TRANS == 3 : Transition(Toque->Position) + */ break; } @@ -724,23 +721,10 @@ pos.ref = (double)temp_pos * 4.0f; vel.ref = (double)temp_vel * 100.0f; torq.ref = (double)temp_torq * 0.1f; - } else if(address==CID_RX_REF_TORQUE) { - int16_t temp_torq = (int16_t) (msg.data[0] | msg.data[1] << 8); - torq.ref = (double)temp_torq; - } else if(address==CID_RX_REF_PRES_DIFF) { - int16_t temp_presdiff = (int16_t) (msg.data[0] | msg.data[1] << 8); - torq.ref = (double)temp_presdiff; - } else if(address==CID_RX_REF_VOUT) { - int16_t temp_PWM = (int16_t) (msg.data[0] | msg.data[1] << 8); - Vout.ref = (double)temp_PWM; - } else if(address==CID_RX_REF_VALVE_POSITION) { - int16_t temp_valve_pos = (int16_t) (msg.data[0] | msg.data[1] << 8); - valve_pos.ref = (double)temp_valve_pos; - } else if(address==CID_RX_REF_CURRENT) { - int16_t temp_cur = (int16_t) (msg.data[0] | msg.data[1] << 8); - cur.ref = (double)temp_cur; - } - + } 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; + } } /******************************************************************************