rainbow

Dependencies:   mbed FastPWM

Committer:
Lightvalve
Date:
Mon Sep 09 06:57:31 2019 +0000
Revision:
20:806196fda269
Parent:
19:23b7c1ad8683
Child:
22:966b35691d69
190909_15_57

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GiJeongKim 0:51c43836c1d7 1 #include "mbed.h"
GiJeongKim 0:51c43836c1d7 2 #include "FastPWM.h"
GiJeongKim 0:51c43836c1d7 3
GiJeongKim 0:51c43836c1d7 4 // pwm
jobuuu 2:a1c0a37df760 5 #define PIN_V PB_7
jobuuu 2:a1c0a37df760 6 #define PIN_W PB_6
jobuuu 2:a1c0a37df760 7 //#define PWM_ARR 0x465 // loop 80k, pwm 40k
jobuuu 2:a1c0a37df760 8 //#define PWM_ARR 0x8CA // loop 40k, pwm 20k
Lightvalve 19:23b7c1ad8683 9 //#define PWM_ARR 0x1194 // loop 20k, pwm 10k
Lightvalve 19:23b7c1ad8683 10 #define PWM_ARR 0x2328 // loop 10k, pwm 5k
Lightvalve 11:82d8768d7351 11 #define TMR3_COUNT 0x4650 // loop 5k
Lightvalve 20:806196fda269 12 #define TMR5_COUNT 0x2710 // loop 500hz with prescale 18
jobuuu 2:a1c0a37df760 13
Lightvalve 20:806196fda269 14 #define FREQ_500 500.0
jobuuu 2:a1c0a37df760 15 #define FREQ_5k 5000.0
jobuuu 2:a1c0a37df760 16 #define FREQ_10k 10000.0
jobuuu 2:a1c0a37df760 17 #define FREQ_20k 20000.0
jobuuu 2:a1c0a37df760 18 #define FREQ_40k 40000.0
Lightvalve 20:806196fda269 19 #define DT_500 0.002
jobuuu 5:a4319f79457b 20 #define DT_5k 0.0002
jobuuu 5:a4319f79457b 21 #define DT_10k 0.0001
jobuuu 5:a4319f79457b 22 #define DT_20k 0.00005
jobuuu 5:a4319f79457b 23 #define DT_40k 0.000025
jobuuu 5:a4319f79457b 24
Lightvalve 19:23b7c1ad8683 25 //extern int CID_RX_CMD;
Lightvalve 19:23b7c1ad8683 26 //extern int CID_RX_REF_POSITION;
Lightvalve 19:23b7c1ad8683 27 //extern int CID_RX_REF_TORQUE;
Lightvalve 19:23b7c1ad8683 28 //extern int CID_RX_REF_PRES_DIFF;
Lightvalve 19:23b7c1ad8683 29 //extern int CID_RX_REF_VOUT;
Lightvalve 19:23b7c1ad8683 30 //extern int CID_RX_REF_VALVE_POSITION;
Lightvalve 19:23b7c1ad8683 31 //extern int CID_RX_REF_CURRENT;
Lightvalve 19:23b7c1ad8683 32 //
Lightvalve 19:23b7c1ad8683 33 //extern int CID_TX_INFO;
Lightvalve 19:23b7c1ad8683 34 //extern int CID_TX_POSITION;
Lightvalve 19:23b7c1ad8683 35 //extern int CID_TX_TORQUE;
Lightvalve 19:23b7c1ad8683 36 //extern int CID_TX_PRES;
Lightvalve 19:23b7c1ad8683 37 //extern int CID_TX_VOUT;
Lightvalve 19:23b7c1ad8683 38 //extern int CID_TX_VALVE_POSITION;
Lightvalve 19:23b7c1ad8683 39
Lightvalve 19:23b7c1ad8683 40
Lightvalve 19:23b7c1ad8683 41
jobuuu 7:e9086c72bb22 42 extern DigitalOut check;
jobuuu 7:e9086c72bb22 43 extern DigitalOut check_2;
jobuuu 7:e9086c72bb22 44 extern AnalogOut dac_1;
jobuuu 7:e9086c72bb22 45 extern AnalogOut dac_2;
jobuuu 7:e9086c72bb22 46
jobuuu 2:a1c0a37df760 47 extern double dtc_v;
jobuuu 2:a1c0a37df760 48 extern double dtc_w;
GiJeongKim 0:51c43836c1d7 49
GiJeongKim 0:51c43836c1d7 50 // I2C
GiJeongKim 0:51c43836c1d7 51 extern I2C i2c; // SDA, SCL (for K22F)
GiJeongKim 0:51c43836c1d7 52 extern const int i2c_slave_addr1;
GiJeongKim 0:51c43836c1d7 53 extern unsigned int value; // 10bit output of reading sensor AS5510
GiJeongKim 0:51c43836c1d7 54
GiJeongKim 0:51c43836c1d7 55 // SPI
Lightvalve 16:903b5a4433b4 56 //extern SPI eeprom; //(SPI_MOSI, SPI_MISO, SPI_SCK);
Lightvalve 16:903b5a4433b4 57 //extern DigitalOut eeprom_cs;
GiJeongKim 0:51c43836c1d7 58 extern SPI enc;
GiJeongKim 0:51c43836c1d7 59 extern DigitalOut enc_cs;
GiJeongKim 0:51c43836c1d7 60
GiJeongKim 0:51c43836c1d7 61 // UART
jobuuu 7:e9086c72bb22 62 extern Serial pc; //Serial pc(PA_9,PA_10); _ UART
jobuuu 7:e9086c72bb22 63
jobuuu 7:e9086c72bb22 64 // CAN
jobuuu 7:e9086c72bb22 65 extern CAN can;
jobuuu 7:e9086c72bb22 66 extern CANMessage msg;
jobuuu 7:e9086c72bb22 67
jobuuu 7:e9086c72bb22 68 // Board Information
jobuuu 7:e9086c72bb22 69
jobuuu 7:e9086c72bb22 70
jobuuu 7:e9086c72bb22 71 // User Function
jobuuu 7:e9086c72bb22 72
jobuuu 7:e9086c72bb22 73 void CurrentControl();
jobuuu 7:e9086c72bb22 74 void ValveControl(unsigned int ControlMode);
Lightvalve 11:82d8768d7351 75
Lightvalve 11:82d8768d7351 76
Lightvalve 11:82d8768d7351 77 /*******************************************************************************
Lightvalve 11:82d8768d7351 78 * COMMON Settings
Lightvalve 11:82d8768d7351 79 ******************************************************************************/
Lightvalve 11:82d8768d7351 80 #define LATEST_VERSION 19032
Lightvalve 11:82d8768d7351 81
Lightvalve 11:82d8768d7351 82
Lightvalve 11:82d8768d7351 83
Lightvalve 11:82d8768d7351 84 /*******************************************************************************
Lightvalve 11:82d8768d7351 85 * COMMON CONSTANTS
Lightvalve 11:82d8768d7351 86 ******************************************************************************/
Lightvalve 11:82d8768d7351 87 #define RAD_30 0.523598775598299
Lightvalve 11:82d8768d7351 88 #define RAD_60 1.047197551196598
Lightvalve 11:82d8768d7351 89 #define RAD_120 2.094395102393195
Lightvalve 11:82d8768d7351 90 #define RAD_180 3.141592653589793
Lightvalve 11:82d8768d7351 91 #define RAD_240 4.188790204786391
Lightvalve 11:82d8768d7351 92 #define RAD_300 5.235987755982989
Lightvalve 11:82d8768d7351 93 #define RAD_360 6.283185307179586
Lightvalve 11:82d8768d7351 94
Lightvalve 11:82d8768d7351 95 #define SYSFREQ 200000000
Lightvalve 11:82d8768d7351 96 #define PBCLK 100000000
Lightvalve 11:82d8768d7351 97
Lightvalve 11:82d8768d7351 98 //#define TMR_FREQ_10k 10000
Lightvalve 11:82d8768d7351 99 #define TMR_FREQ_5k 5000
Lightvalve 11:82d8768d7351 100
Lightvalve 11:82d8768d7351 101 #define FALSE 0
Lightvalve 11:82d8768d7351 102 #define TRUE 1
Lightvalve 11:82d8768d7351 103 #define OUTPUT 0
Lightvalve 11:82d8768d7351 104 #define INPUT 1
Lightvalve 11:82d8768d7351 105 #define LOW 0
Lightvalve 11:82d8768d7351 106 #define HIGH 1
Lightvalve 11:82d8768d7351 107 #define DIGITAL 0
Lightvalve 11:82d8768d7351 108 #define ANALOG 1
Lightvalve 11:82d8768d7351 109
Lightvalve 11:82d8768d7351 110 #define PI 3.141592653589793
Lightvalve 11:82d8768d7351 111 #define D2R 0.017453292519943
Lightvalve 11:82d8768d7351 112 #define R2D 57.295779513082323
Lightvalve 11:82d8768d7351 113
Lightvalve 11:82d8768d7351 114
Lightvalve 11:82d8768d7351 115 /*******************************************************************************
Lightvalve 11:82d8768d7351 116 * HEADER INCLUDE
Lightvalve 11:82d8768d7351 117 ******************************************************************************/
Lightvalve 11:82d8768d7351 118
Lightvalve 11:82d8768d7351 119 /*******************************************************************************
Lightvalve 11:82d8768d7351 120 * VARIABLE
Lightvalve 11:82d8768d7351 121 ******************************************************************************/
Lightvalve 11:82d8768d7351 122
Lightvalve 11:82d8768d7351 123 // Board Information
Lightvalve 11:82d8768d7351 124 extern uint8_t BNO;
Lightvalve 11:82d8768d7351 125 extern uint8_t CONTROL_MODE;
Lightvalve 11:82d8768d7351 126 extern uint8_t OPERATING_MODE;
Lightvalve 11:82d8768d7351 127 extern uint8_t SETTING_SWITCH;
Lightvalve 11:82d8768d7351 128 extern uint8_t SETTING_SWITCH_OLD;
Lightvalve 11:82d8768d7351 129 extern uint8_t REFERENCE_MODE;
Lightvalve 11:82d8768d7351 130 extern uint16_t CAN_FREQ;
Lightvalve 17:1865016ca2e7 131 extern int16_t DIR_JOINT_ENC;
Lightvalve 17:1865016ca2e7 132 extern int16_t DIR_VALVE;
Lightvalve 17:1865016ca2e7 133 extern int16_t DIR_VALVE_ENC;
Lightvalve 11:82d8768d7351 134
Lightvalve 11:82d8768d7351 135 extern double SUPPLY_VOLTAGE;
Lightvalve 11:82d8768d7351 136 extern double VALVE_VOLTAGE_LIMIT;
Lightvalve 11:82d8768d7351 137
Lightvalve 11:82d8768d7351 138 extern double P_GAIN_VALVE_POSITION;
Lightvalve 11:82d8768d7351 139 extern double I_GAIN_VALVE_POSITION;
Lightvalve 11:82d8768d7351 140 extern double D_GAIN_VALVE_POSITION;
Lightvalve 11:82d8768d7351 141 extern double P_GAIN_JOINT_POSITION;
Lightvalve 11:82d8768d7351 142 extern double I_GAIN_JOINT_POSITION;
Lightvalve 11:82d8768d7351 143 extern double D_GAIN_JOINT_POSITION;
Lightvalve 11:82d8768d7351 144 extern double P_GAIN_JOINT_TORQUE;
Lightvalve 11:82d8768d7351 145 extern double I_GAIN_JOINT_TORQUE;
Lightvalve 11:82d8768d7351 146 extern double D_GAIN_JOINT_TORQUE;
Lightvalve 11:82d8768d7351 147
Lightvalve 11:82d8768d7351 148 extern int16_t VALVE_DEADZONE_PLUS;
Lightvalve 11:82d8768d7351 149 extern int16_t VALVE_DEADZONE_MINUS;
Lightvalve 11:82d8768d7351 150
Lightvalve 11:82d8768d7351 151 extern int16_t VELOCITY_COMP_GAIN;
Lightvalve 11:82d8768d7351 152 extern int16_t COMPLIANCE_GAIN;
Lightvalve 11:82d8768d7351 153
Lightvalve 11:82d8768d7351 154 extern int16_t VALVE_CENTER;
Lightvalve 11:82d8768d7351 155
Lightvalve 11:82d8768d7351 156 extern int16_t VALVE_FF;
Lightvalve 11:82d8768d7351 157
Lightvalve 11:82d8768d7351 158 extern int16_t BULK_MODULUS;
Lightvalve 11:82d8768d7351 159
Lightvalve 11:82d8768d7351 160 extern int16_t CHAMBER_VOLUME_A;
Lightvalve 11:82d8768d7351 161 extern int16_t CHAMBER_VOLUME_B;
Lightvalve 11:82d8768d7351 162
Lightvalve 11:82d8768d7351 163 extern int16_t PISTON_AREA_A;
Lightvalve 11:82d8768d7351 164 extern int16_t PISTON_AREA_B;
Lightvalve 11:82d8768d7351 165 extern double PISTON_AREA_alpha;
Lightvalve 11:82d8768d7351 166
Lightvalve 11:82d8768d7351 167
Lightvalve 11:82d8768d7351 168 extern int16_t PRES_SUPPLY;
Lightvalve 11:82d8768d7351 169 extern int16_t PRES_RETURN;
Lightvalve 11:82d8768d7351 170
Lightvalve 11:82d8768d7351 171 extern int16_t ENC_LIMIT_PLUS;
Lightvalve 11:82d8768d7351 172 extern int16_t ENC_LIMIT_MINUS;
Lightvalve 11:82d8768d7351 173
Lightvalve 11:82d8768d7351 174 extern int16_t STROKE;
Lightvalve 11:82d8768d7351 175
Lightvalve 11:82d8768d7351 176
Lightvalve 11:82d8768d7351 177 extern int16_t VALVE_LIMIT_PLUS;
Lightvalve 11:82d8768d7351 178 extern int16_t VALVE_LIMIT_MINUS;
Lightvalve 11:82d8768d7351 179
Lightvalve 11:82d8768d7351 180 extern int16_t ENC_PULSE_PER_POSITION;
Lightvalve 11:82d8768d7351 181 extern int16_t TORQUE_SENSOR_PULSE_PER_TORQUE;
Lightvalve 11:82d8768d7351 182 extern double PRES_SENSOR_A_PULSE_PER_BAR;
Lightvalve 11:82d8768d7351 183 extern double PRES_SENSOR_B_PULSE_PER_BAR;
Lightvalve 11:82d8768d7351 184
Lightvalve 11:82d8768d7351 185 extern int HOMEPOS_OFFSET;
Lightvalve 11:82d8768d7351 186 extern int HOMEPOS_VALVE_OPENING;
Lightvalve 11:82d8768d7351 187
Lightvalve 11:82d8768d7351 188 extern double FRICTION;
Lightvalve 11:82d8768d7351 189 extern double REF_PERIOD;
Lightvalve 11:82d8768d7351 190 extern double REF_MAG;
Lightvalve 11:82d8768d7351 191 extern int REF_NUM;
Lightvalve 11:82d8768d7351 192
Lightvalve 11:82d8768d7351 193
Lightvalve 11:82d8768d7351 194 extern double DAC_REF;
Lightvalve 11:82d8768d7351 195 extern double DAC_RESOL;
Lightvalve 11:82d8768d7351 196
Lightvalve 11:82d8768d7351 197 extern int REF_POSITION;
Lightvalve 11:82d8768d7351 198 extern int REF_VELOCITY;
Lightvalve 11:82d8768d7351 199 extern int16_t REF_TORQUE;
Lightvalve 11:82d8768d7351 200 extern int16_t REF_PRES_DIFF;
Lightvalve 11:82d8768d7351 201 extern int16_t REF_PWM;
Lightvalve 11:82d8768d7351 202 extern int16_t REF_VALVE_POSITION;
Lightvalve 14:8e7590227d22 203 extern int16_t REF_CURRENT;
Lightvalve 11:82d8768d7351 204
Lightvalve 11:82d8768d7351 205 extern int REF_MOVE_TIME_5k;
Lightvalve 11:82d8768d7351 206 extern int INIT_REF_PWM;
Lightvalve 11:82d8768d7351 207 extern int INIT_REF_VALVE_POS;
Lightvalve 11:82d8768d7351 208 extern int INIT_REF_POS;
Lightvalve 11:82d8768d7351 209 extern int INIT_REF_VEL;
Lightvalve 11:82d8768d7351 210 extern int INIT_REF_TORQUE;
Lightvalve 11:82d8768d7351 211 extern int INIT_REF_PRES_DIFF;
Lightvalve 14:8e7590227d22 212 extern int INIT_REF_CURRENT;
Lightvalve 11:82d8768d7351 213
Lightvalve 11:82d8768d7351 214 extern int CUR_POSITION;
Lightvalve 11:82d8768d7351 215 extern int CUR_VELOCITY;
Lightvalve 11:82d8768d7351 216 extern double CUR_TORQUE;
Lightvalve 11:82d8768d7351 217 extern double CUR_PRES_A;
Lightvalve 11:82d8768d7351 218 extern double CUR_PRES_B;
Lightvalve 11:82d8768d7351 219 extern int CUR_PWM;
Lightvalve 11:82d8768d7351 220 extern int CUR_VALVE_POSITION;
Lightvalve 11:82d8768d7351 221
Lightvalve 11:82d8768d7351 222 extern unsigned int TMR2_COUNT_LED1;
Lightvalve 11:82d8768d7351 223 extern unsigned int TMR2_COUNT_LED2;
Lightvalve 11:82d8768d7351 224 extern unsigned int TMR2_COUNT_CAN_TX;
Lightvalve 11:82d8768d7351 225
Lightvalve 11:82d8768d7351 226 extern int num_err;
Lightvalve 11:82d8768d7351 227 extern int flag_err[8];
Lightvalve 11:82d8768d7351 228 extern int flag_err_old[8];
Lightvalve 11:82d8768d7351 229 extern int flag_err_rt;
Lightvalve 11:82d8768d7351 230
Lightvalve 11:82d8768d7351 231 extern int flag_ref_enable;
Lightvalve 11:82d8768d7351 232
Lightvalve 11:82d8768d7351 233 extern int flag_data_request[5];
Lightvalve 11:82d8768d7351 234
Lightvalve 11:82d8768d7351 235 ////////////////////////////////////////////////////////////////////////////////
Lightvalve 11:82d8768d7351 236 ////////////////////////////// SEUNGHOON ADD ///////////////////////////////////
Lightvalve 11:82d8768d7351 237 ////////////////////////////////////////////////////////////////////////////////
Lightvalve 11:82d8768d7351 238
Lightvalve 11:82d8768d7351 239 extern double CUR_PRES_A_BAR;
Lightvalve 11:82d8768d7351 240 extern double CUR_PRES_B_BAR;
Lightvalve 11:82d8768d7351 241 extern double CUR_TORQUE_NM;
Lightvalve 11:82d8768d7351 242 extern double CUR_TORQUE_NM_PRESS;
Lightvalve 11:82d8768d7351 243
Lightvalve 11:82d8768d7351 244 extern double PRES_A_VREF;
Lightvalve 16:903b5a4433b4 245 extern double PRES_A_VREF_TEST;
Lightvalve 11:82d8768d7351 246 extern double PRES_B_VREF;
Lightvalve 16:903b5a4433b4 247 extern double PRES_B_VREF_TEST;
Lightvalve 11:82d8768d7351 248 extern double TORQUE_VREF;
Lightvalve 11:82d8768d7351 249
Lightvalve 11:82d8768d7351 250 extern double VALVE_PWM_RAW_FB;
Lightvalve 11:82d8768d7351 251 extern double VALVE_PWM_RAW_FF;
Lightvalve 11:82d8768d7351 252 extern int VALVE_PWM_VALVE_DZ;
Lightvalve 11:82d8768d7351 253 extern int VALVE_INPUT_PWM;
Lightvalve 11:82d8768d7351 254
Lightvalve 11:82d8768d7351 255 extern double VALVE_GAIN_LPM_PER_V[10];
Lightvalve 17:1865016ca2e7 256 extern double VALVE_POS_VS_PWM[25];
Lightvalve 11:82d8768d7351 257 extern long JOINT_VEL[100];
Lightvalve 11:82d8768d7351 258
Lightvalve 11:82d8768d7351 259 extern int VALVE_MAX_POS;
Lightvalve 11:82d8768d7351 260 extern int VALVE_MIN_POS;
Lightvalve 11:82d8768d7351 261 extern int DDV_CENTER;
Lightvalve 11:82d8768d7351 262 extern int VALVE_POS_NUM;
Lightvalve 11:82d8768d7351 263
Lightvalve 14:8e7590227d22 264 extern int TMR3_COUNT_FINDHOME;
Lightvalve 14:8e7590227d22 265 extern int TMR3_COUNT_FLOWRATE;
Lightvalve 14:8e7590227d22 266 extern int TMR3_COUNT_DEADZONE;
Lightvalve 14:8e7590227d22 267 extern int TMR3_COUNT_PRES_NULL;
Lightvalve 14:8e7590227d22 268 extern int TMR3_COUNT_TORQUE_NULL;
Lightvalve 14:8e7590227d22 269 extern int TMR3_COUNT_PRES_CALIB;
Lightvalve 14:8e7590227d22 270 extern int TMR3_COUNT_REFERENCE;
Lightvalve 14:8e7590227d22 271 extern int TMR3_COUNT_JOINT;
Lightvalve 14:8e7590227d22 272 extern int TMR3_COUNT_ROTARY_FRIC_TUNE;
Lightvalve 11:82d8768d7351 273
Lightvalve 11:82d8768d7351 274 extern bool FLAG_REFERENCE_VALVE_PWM;
Lightvalve 11:82d8768d7351 275 extern bool FLAG_REFERENCE_VALVE_POSITION;
Lightvalve 11:82d8768d7351 276 extern bool FLAG_REFERENCE_JOINT_POSITION;
Lightvalve 11:82d8768d7351 277 extern bool FLAG_REFERENCE_JOINT_TORQUE;
Lightvalve 11:82d8768d7351 278 extern bool FLAG_REFERENCE_PRES_DIFF;
Lightvalve 14:8e7590227d22 279 extern bool FLAG_REFERENCE_CURRENT;
Lightvalve 11:82d8768d7351 280
Lightvalve 11:82d8768d7351 281 extern double TUNING_TIME;
Lightvalve 11:82d8768d7351 282
Lightvalve 11:82d8768d7351 283 extern double REFERENCE_FREQ;
Lightvalve 11:82d8768d7351 284 extern double REFERENCE_MAG;
Lightvalve 11:82d8768d7351 285
Lightvalve 11:82d8768d7351 286 extern bool FLAG_FIND_HOME;
Lightvalve 11:82d8768d7351 287
Lightvalve 11:82d8768d7351 288 extern int MODE_JUMP_STATUS;
Lightvalve 11:82d8768d7351 289
Lightvalve 13:747daba9cf59 290 extern double CUR_PRES_DIFF_BAR;
Lightvalve 13:747daba9cf59 291 extern double CUR_PRES_A_sum;
Lightvalve 13:747daba9cf59 292 extern double CUR_PRES_B_sum;
Lightvalve 13:747daba9cf59 293 extern double CUR_PRES_A_mean;
Lightvalve 13:747daba9cf59 294 extern double CUR_PRES_B_mean;
Lightvalve 13:747daba9cf59 295 extern double CUR_TORQUE_sum;
Lightvalve 13:747daba9cf59 296 extern double CUR_TORQUE_mean;
Lightvalve 13:747daba9cf59 297 extern double PRES_A_NULL;
Lightvalve 13:747daba9cf59 298 extern double PRES_B_NULL;
Lightvalve 13:747daba9cf59 299 extern double TORQUE_NULL;
Lightvalve 13:747daba9cf59 300
Lightvalve 13:747daba9cf59 301 extern double Ref_Valve_Pos_Old;
Lightvalve 13:747daba9cf59 302
Lightvalve 13:747daba9cf59 303 extern int VALVE_ID_timer;
Lightvalve 13:747daba9cf59 304 extern int VALVE_DZ_timer;
Lightvalve 13:747daba9cf59 305 extern int VALVE_FR_timer;
Lightvalve 13:747daba9cf59 306 extern int VALVE_POS_TMP;
Lightvalve 13:747daba9cf59 307 extern int JOINT_VEL_TMP;
Lightvalve 13:747daba9cf59 308 extern int DDV_POS_AVG ;
Lightvalve 19:23b7c1ad8683 309 extern int VALVE_POS_AVG[50];
Lightvalve 13:747daba9cf59 310 extern int VALVE_POS_AVG_OLD;
Lightvalve 13:747daba9cf59 311 extern int data_num;
Lightvalve 13:747daba9cf59 312 extern int ID_index;
Lightvalve 13:747daba9cf59 313 extern int DZ_index;
Lightvalve 19:23b7c1ad8683 314 extern int ID_index_array[50];
Lightvalve 13:747daba9cf59 315 extern int first_check;
Lightvalve 13:747daba9cf59 316 extern double init_time;
Lightvalve 13:747daba9cf59 317 extern int VEL_POINT;
Lightvalve 13:747daba9cf59 318 extern int DZ_case;
Lightvalve 13:747daba9cf59 319 extern int START_POS;
Lightvalve 13:747daba9cf59 320 extern int FINAL_POS;
Lightvalve 13:747daba9cf59 321 extern int DZ_DIRECTION;
Lightvalve 13:747daba9cf59 322 extern int FIRST_DZ;
Lightvalve 13:747daba9cf59 323 extern int SECOND_DZ;
Lightvalve 13:747daba9cf59 324 extern int DZ_NUM;
Lightvalve 13:747daba9cf59 325 extern int one_period_end;
Lightvalve 13:747daba9cf59 326 extern double Ref_Vel_Test;
Lightvalve 13:747daba9cf59 327 extern long TMR2_FOR_SLOW_LOGGING;
Lightvalve 19:23b7c1ad8683 328 //extern int velcount;
Lightvalve 19:23b7c1ad8683 329 extern int Ref_Valve_Pos_FF_CAN;
Lightvalve 13:747daba9cf59 330 extern char max_check;
Lightvalve 13:747daba9cf59 331 extern char min_check;
Lightvalve 13:747daba9cf59 332
Lightvalve 13:747daba9cf59 333 extern double valve_pos_err, valve_pos_err_old, valve_pos_err_diff, valve_pos_err_sum;
Lightvalve 14:8e7590227d22 334 extern double joint_pos_err, joint_pos_err_old, joint_pos_err_diff, joint_pos_err_diff_fil, joint_pos_err_sum;
Lightvalve 13:747daba9cf59 335 extern double joint_torq_err, joint_torq_err_old, joint_torq_err_diff, joint_torq_err_sum;
Lightvalve 13:747daba9cf59 336 extern double VALVE_PWM_RAW_POS, VALVE_PWM_RAW_TORQ;
Lightvalve 13:747daba9cf59 337
Lightvalve 13:747daba9cf59 338 extern double CUR_FLOWRATE;
Lightvalve 13:747daba9cf59 339 extern double VALVE_FF_VOLTAGE;
Lightvalve 13:747daba9cf59 340
Lightvalve 13:747daba9cf59 341 extern int pos_plus_end;
Lightvalve 13:747daba9cf59 342 extern int pos_minus_end;
Lightvalve 13:747daba9cf59 343
Lightvalve 13:747daba9cf59 344 extern bool need_enc_init;
Lightvalve 13:747daba9cf59 345
Lightvalve 13:747daba9cf59 346 extern int temp_time;
Lightvalve 13:747daba9cf59 347
Lightvalve 13:747daba9cf59 348 extern double CUR_VELOCITY_sum;
Lightvalve 13:747daba9cf59 349 extern double temp_vel_sum;
Lightvalve 13:747daba9cf59 350
Lightvalve 13:747daba9cf59 351 extern int DZ_dir;
Lightvalve 13:747daba9cf59 352 extern int DZ_temp_cnt;
Lightvalve 13:747daba9cf59 353 extern int DZ_temp_cnt2;
Lightvalve 13:747daba9cf59 354 extern int DZ_end;
Lightvalve 13:747daba9cf59 355 extern int flag_flowrate;
Lightvalve 13:747daba9cf59 356 extern int fl_temp_cnt;
Lightvalve 13:747daba9cf59 357 extern int fl_temp_cnt2;
Lightvalve 13:747daba9cf59 358 extern int cur_vel_sum;
Lightvalve 13:747daba9cf59 359
Lightvalve 13:747daba9cf59 360 // find home
Lightvalve 13:747daba9cf59 361 extern int CUR_VELOCITY_OLD;
Lightvalve 13:747daba9cf59 362 extern int cnt_findhome;
Lightvalve 13:747daba9cf59 363 extern int cnt_vel_findhome;
Lightvalve 13:747daba9cf59 364 extern int FINDHOME_VELOCITY;
Lightvalve 13:747daba9cf59 365 extern int FINDHOME_VELOCITY_OLD;
Lightvalve 13:747daba9cf59 366 extern int FINDHOME_POSITION;
Lightvalve 13:747daba9cf59 367 extern int FINDHOME_POSITION_OLD;
Lightvalve 13:747daba9cf59 368
Lightvalve 13:747daba9cf59 369 // valve gain
Lightvalve 13:747daba9cf59 370 extern int check_vel_pos_init;
Lightvalve 13:747daba9cf59 371 extern int check_vel_pos_fin;
Lightvalve 13:747daba9cf59 372 extern int check_vel_pos_interv;
Lightvalve 13:747daba9cf59 373 extern int valve_gain_repeat_cnt;
Lightvalve 13:747daba9cf59 374 extern double VALVE_VOLTAGE;
Lightvalve 13:747daba9cf59 375
Lightvalve 13:747daba9cf59 376 extern double freq_fric_tune;
Lightvalve 13:747daba9cf59 377
Lightvalve 14:8e7590227d22 378 extern bool FLAG_VALVE_OUTPUT_CALIB;
Lightvalve 14:8e7590227d22 379
Lightvalve 14:8e7590227d22 380 extern uint32_t TMR3_COUNT_CAN_TX;
Lightvalve 14:8e7590227d22 381
Lightvalve 14:8e7590227d22 382 extern double I_REF;
Lightvalve 14:8e7590227d22 383 extern int TMR3_COUNT_IREF;
Lightvalve 14:8e7590227d22 384 extern double CUR_CURRENT;
Lightvalve 18:b8adf1582ea3 385 extern double u_CUR[3];
Lightvalve 19:23b7c1ad8683 386
Lightvalve 19:23b7c1ad8683 387 //extern int Ref_Valve_Pos_FF_CAN;