![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Original Version of STM Board
Diff: CAN/function_CAN.cpp
- Revision:
- 66:a8e6799dbce3
- Parent:
- 60:64181f1d3e60
- Child:
- 67:c2812cf26c38
diff -r a2d7c63419c2 -r a8e6799dbce3 CAN/function_CAN.cpp --- a/CAN/function_CAN.cpp Tue Apr 14 01:07:30 2020 +0000 +++ b/CAN/function_CAN.cpp Tue May 12 06:23:46 2020 +0000 @@ -20,8 +20,12 @@ // variables uint8_t can_index = 0; +extern DigitalOut LED; -extern DigitalOut LED; +//extern int num_input; +//extern int num_input_array; +extern float input[]; +extern float x_future[]; /******************************************************************************* * CAN functions @@ -690,6 +694,11 @@ flag_delay_test = 1; break; } + case CRX_SET_NN_CONTROL_FLAG: { + NN_Control_Flag = (int16_t) msg.data[1]; + CONTROL_UTILITY_MODE = 1; + break; + } default: break; @@ -722,6 +731,17 @@ torq.ref = (double)temp_torq * 0.1f; + x_future[0] = pos.sen/(float)(ENC_PULSE_PER_POSITION); //mm + for(int i=1;i<num_input_array-1;i++){ + x_future[i] = x_future[i+1]; + } + x_future[num_input_array-1] = pos.ref/(float)(ENC_PULSE_PER_POSITION); //mm + + for(int i=0;i<num_input;i++){ + input[i] = (x_future[2*i+2] - x_future[0])*0.2f+0.5f; + } + + } else if(address==CID_RX_REF_VALVE_POS) { int16_t temp_ref_valve_pos = (int16_t) (msg.data[0] | msg.data[1] << 8);