Sungwoo Kim
/
HydraulicControlBoard_Rainbow_v1_2
rainbow
Diff: function_utilities/function_utilities.cpp
- Revision:
- 13:747daba9cf59
- Parent:
- 12:6f2531038ea4
- Child:
- 14:8e7590227d22
diff -r 6f2531038ea4 -r 747daba9cf59 function_utilities/function_utilities.cpp --- a/function_utilities/function_utilities.cpp Tue Aug 27 05:32:44 2019 +0000 +++ b/function_utilities/function_utilities.cpp Tue Aug 27 06:50:54 2019 +0000 @@ -177,8 +177,100 @@ JUMP_LANDING, //4 }; +double CUR_PRES_DIFF_BAR = 0.0; +double CUR_PRES_A_sum = 0.0; +double CUR_PRES_B_sum = 0.0; +double CUR_PRES_A_mean = 0.0; +double CUR_PRES_B_mean = 0.0; +double CUR_TORQUE_sum = 0.0; +double CUR_TORQUE_mean = 0.0; +double PRES_A_NULL = 200.0; +double PRES_B_NULL = 200.0; +double TORQUE_NULL = 3900; +double Ref_PWM = 0.0; +double Ref_Valve_Pos = 0.0; +double Ref_Joint_Pos = 0.0; +double Ref_Joint_Vel = 0.0; +double Ref_Joint_Torq = 0.0; +double Ref_Valve_Pos_Old = 0.0; +int VALVE_ID_timer = 0; +int VALVE_DZ_timer = 0; +int VALVE_FR_timer = 0; +int VALVE_POS_TMP = 0; +int JOINT_VEL_TMP = 0; +int DDV_POS_AVG = 0; +int VALVE_POS_AVG[100] = {0}; +int VALVE_POS_AVG_OLD = 0; +int data_num = 0; +int ID_index = 0; +int DZ_index = 1; +int ID_index_array[100] = {0}; +int FR_index_array[100] = {0}; +int first_check = 0; +double init_time = 0.0; +int VEL_POINT = 0; +int DZ_case = 0; +int START_POS = 0; +int FINAL_POS = 0; +int DZ_DIRECTION = 0; +int FIRST_DZ = 0; +int SECOND_DZ = 0; +int DZ_NUM = 0; +int one_period_end = 0; +double Ref_Vel_Test = 0.0; +long TMR2_FOR_SLOW_LOGGING = 0; +int velcount = 0; +char max_check = 0; +char min_check = 0; + +double valve_pos_err = 0.0, valve_pos_err_old = 0.0, valve_pos_err_diff = 0.0, valve_pos_err_sum = 0.0; +double joint_pos_err = 0.0, joint_pos_err_old = 0.0, joint_pos_err_diff = 0.0, joint_pos_err_sum = 0.0; +double joint_torq_err = 0.0, joint_torq_err_old = 0.0, joint_torq_err_diff = 0.0, joint_torq_err_sum = 0.0; +double VALVE_PWM_RAW_POS = 0.0, VALVE_PWM_RAW_TORQ = 0.0; + +double CUR_FLOWRATE = 0.0; +double VALVE_FF_VOLTAGE = 0.0; + +int pos_plus_end = 0; +int pos_minus_end = 0; + +bool need_enc_init = false; + +int temp_time = 0; + +double CUR_VELOCITY_sum = 0.0; +double temp_vel_sum = 0.0; + +int DZ_dir = 0; +int DZ_temp_cnt = 0; +int DZ_temp_cnt2 = 0; +int DZ_end = 2; +int flag_flowrate = 0; +int fl_temp_cnt = 0; +int fl_temp_cnt2 = 0; +int cur_vel_sum = 0; + +// find home +int CUR_VELOCITY_OLD = 0; +int cnt_findhome = 0; +int cnt_vel_findhome = 0; +int FINDHOME_VELOCITY = 0; +int FINDHOME_VELOCITY_OLD = 0; +int FINDHOME_POSITION = 0; +int FINDHOME_POSITION_OLD = 0; + +// valve gain +int check_vel_pos_init = 0; +int check_vel_pos_fin = 0; +int check_vel_pos_interv = 0; +int valve_gain_repeat_cnt = 0; +double VALVE_VOLTAGE = 0.0; + +double freq_fric_tune = 1.0; + +bool FLAG_VALVE_OUTPUT_CALIB = false; /******************************************************************************* * General math functions @@ -446,11 +538,10 @@ } -void ENC_SET(int32_t value) { - +void ENC_SET(int32_t value_e) { spi_enc_set_clear(); - enc_offset = value; - CUR_POSITION = value; - ENC_pos_old = ENC_pos_cur = value; + enc_offset = value_e; + CUR_POSITION = value_e; + ENC_pos_old = ENC_pos_cur = value_e; }