![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
for learning
Diff: main.cpp
- Revision:
- 233:0a37cdd59651
- Parent:
- 232:0287991a8615
- Child:
- 234:1cdc45c27ba7
--- a/main.cpp Wed Dec 30 11:14:47 2020 +0000 +++ b/main.cpp Thu Dec 31 15:08:02 2020 +0000 @@ -1,4 +1,4 @@ -//201230_4 +//201231_1 CAN request #include "mbed.h" #include "FastPWM.h" #include "INIT_HW.h" @@ -1037,7 +1037,7 @@ // input_NN[ind] = torq.sen / 10000.0f * 8.0f + 0.5f; input_NN[ind] = torq.sen / 10000.0f + 0.5f; ind = ind + 1; - for(int i=2; i<numfuture_f; i++) { + for(int i=0; i<numfuture_f; i++) { // input_NN[ind] = (f_future[time_interval*i+time_interval] - torq.sen)/10000.0f * 8.0f + 0.5f; // input_NN[ind] = (f_future[time_interval*i+time_interval] - torq.sen)/10000.0f + 0.5f; // input_NN[ind] = (f_future[time_interval*i+time_interval])/10000.0f*8.0f+0.5f; @@ -1396,7 +1396,6 @@ float DT_TMR3 = (float)DT_5k; int cnt_trans = 0; double VALVE_POS_RAW_FORCE_FB_LOGGING = 0.0f; -int can_rest =0; extern "C" void TIM3_IRQHandler(void) { @@ -2350,12 +2349,12 @@ case MODE_VALVE_POSITION_CONTROL: { if (OPERATING_MODE == 5) { //SW Valve ////For Test LIMC////////////////////////////////////////// -// VALVE_POS_CONTROL(valve_pos.ref); - for(int i=0; i<9; i++){ - valve_ref_pos_buffer[i] = valve_ref_pos_buffer[i+1]; - } - valve_ref_pos_buffer[9] = valve_pos.ref; - VALVE_POS_CONTROL(valve_ref_pos_buffer[0]); + VALVE_POS_CONTROL(valve_pos.ref); +// for(int i=0; i<9; i++){ +// valve_ref_pos_buffer[i] = valve_ref_pos_buffer[i+1]; +// } +// valve_ref_pos_buffer[9] = valve_pos.ref; +// VALVE_POS_CONTROL(valve_ref_pos_buffer[0]); //////////////////////////////////////////////////////////// V_out = Vout.ref; @@ -2805,6 +2804,10 @@ if (TMR2_COUNT_CAN_TX % (int) ((int) TMR_FREQ_5k/CAN_FREQ) == 0) { + + +/* + // Position, Velocity, and Torque (ID:1200) if (flag_data_request[0] == HIGH) { if ((OPERATING_MODE & 0b01) == 0) { // Rotary Actuator @@ -2821,6 +2824,7 @@ } } } + if (flag_data_request[1] == HIGH) { CAN_TX_TORQUE((int16_t) (return_G[0]*100.0f)); //1300 } @@ -2845,7 +2849,7 @@ } //If it doesn't rest, below can can not work. - for (can_rest = 0; can_rest < 10000; can_rest++) { + for (int can_rest = 0; can_rest < 10000; can_rest++) { ; } @@ -2860,6 +2864,8 @@ //CAN_TX_VALVE_POSITION((int16_t) pos.sen/(float)(ENC_PULSE_PER_POSITION), (int16_t) virt_pos, (int16_t) (logging2*1000.0f), (int16_t) (logging4*1000.0f)); //1600 CAN_TX_VALVE_POSITION((int16_t) (a_hat*0.0001f), (int16_t) 0, (int16_t) 0, (int16_t) 0); //1600 } +*/ + // Others : Reference position, Reference FT, PWM, Current (ID:1300) // if (flag_data_request[1] == HIGH) {