2011

Dependencies:   mbed FastPWM

Committer:
Lightvalve
Date:
Mon Mar 09 12:43:04 2020 +0000
Revision:
58:2eade98630e2
Parent:
57:f4819de54e7a
Child:
60:64181f1d3e60
Integrated finish

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 51:b46bed7fec80 9 #define PWM_ARR 0x1194 // loop 20k, pwm 10k
Lightvalve 51:b46bed7fec80 10 //#define PWM_ARR 0x2328 // loop 10k, pwm 5k
Lightvalve 11:82d8768d7351 11 #define TMR3_COUNT 0x4650 // loop 5k
Lightvalve 23:59218d4a256d 12 #define TMR2_COUNT 0x2710 // loop 500hz with prescale 18
jobuuu 2:a1c0a37df760 13
Lightvalve 30:8d561f16383b 14 #define FREQ_500 500.0f
Lightvalve 30:8d561f16383b 15 #define FREQ_1k 1000.0f
Lightvalve 30:8d561f16383b 16 #define FREQ_5k 5000.0f
Lightvalve 30:8d561f16383b 17 #define FREQ_10k 10000.0f
Lightvalve 30:8d561f16383b 18 #define FREQ_20k 20000.0f
Lightvalve 30:8d561f16383b 19 #define FREQ_40k 40000.0f
Lightvalve 30:8d561f16383b 20 #define DT_500 0.002f
Lightvalve 30:8d561f16383b 21 #define DT_1k 0.0005f
Lightvalve 30:8d561f16383b 22 #define DT_5k 0.0002f
Lightvalve 30:8d561f16383b 23 #define DT_10k 0.0001f
Lightvalve 30:8d561f16383b 24 #define DT_20k 0.00005f
Lightvalve 30:8d561f16383b 25 #define DT_40k 0.000025f
jobuuu 5:a4319f79457b 26
jobuuu 7:e9086c72bb22 27 extern DigitalOut check;
jobuuu 7:e9086c72bb22 28 extern DigitalOut check_2;
jobuuu 7:e9086c72bb22 29 extern AnalogOut dac_1;
jobuuu 7:e9086c72bb22 30 extern AnalogOut dac_2;
jobuuu 7:e9086c72bb22 31
Lightvalve 30:8d561f16383b 32 extern float dtc_v;
Lightvalve 30:8d561f16383b 33 extern float dtc_w;
GiJeongKim 0:51c43836c1d7 34
GiJeongKim 0:51c43836c1d7 35 // I2C
GiJeongKim 0:51c43836c1d7 36 extern I2C i2c; // SDA, SCL (for K22F)
GiJeongKim 0:51c43836c1d7 37 extern const int i2c_slave_addr1;
GiJeongKim 0:51c43836c1d7 38 extern unsigned int value; // 10bit output of reading sensor AS5510
GiJeongKim 0:51c43836c1d7 39
GiJeongKim 0:51c43836c1d7 40 // SPI
Lightvalve 16:903b5a4433b4 41 //extern SPI eeprom; //(SPI_MOSI, SPI_MISO, SPI_SCK);
Lightvalve 16:903b5a4433b4 42 //extern DigitalOut eeprom_cs;
GiJeongKim 0:51c43836c1d7 43 extern SPI enc;
GiJeongKim 0:51c43836c1d7 44 extern DigitalOut enc_cs;
GiJeongKim 0:51c43836c1d7 45
GiJeongKim 0:51c43836c1d7 46 // UART
jobuuu 7:e9086c72bb22 47 extern Serial pc; //Serial pc(PA_9,PA_10); _ UART
jobuuu 7:e9086c72bb22 48
jobuuu 7:e9086c72bb22 49 // CAN
jobuuu 7:e9086c72bb22 50 extern CAN can;
jobuuu 7:e9086c72bb22 51 extern CANMessage msg;
jobuuu 7:e9086c72bb22 52
jobuuu 7:e9086c72bb22 53 // Board Information
jobuuu 7:e9086c72bb22 54
jobuuu 7:e9086c72bb22 55
jobuuu 7:e9086c72bb22 56 // User Function
jobuuu 7:e9086c72bb22 57
jobuuu 7:e9086c72bb22 58 void CurrentControl();
jobuuu 7:e9086c72bb22 59 void ValveControl(unsigned int ControlMode);
Lightvalve 11:82d8768d7351 60
Lightvalve 11:82d8768d7351 61
Lightvalve 11:82d8768d7351 62 /*******************************************************************************
Lightvalve 11:82d8768d7351 63 * COMMON Settings
Lightvalve 11:82d8768d7351 64 ******************************************************************************/
Lightvalve 11:82d8768d7351 65 #define LATEST_VERSION 19032
Lightvalve 11:82d8768d7351 66
Lightvalve 11:82d8768d7351 67
Lightvalve 11:82d8768d7351 68
Lightvalve 11:82d8768d7351 69 /*******************************************************************************
Lightvalve 11:82d8768d7351 70 * COMMON CONSTANTS
Lightvalve 11:82d8768d7351 71 ******************************************************************************/
Lightvalve 30:8d561f16383b 72 #define RAD_30 0.523598775598299f
Lightvalve 30:8d561f16383b 73 #define RAD_60 1.047197551196598f
Lightvalve 30:8d561f16383b 74 #define RAD_120 2.094395102393195f
Lightvalve 30:8d561f16383b 75 #define RAD_180 3.141592653589793f
Lightvalve 30:8d561f16383b 76 #define RAD_240 4.188790204786391f
Lightvalve 30:8d561f16383b 77 #define RAD_300 5.235987755982989f
Lightvalve 30:8d561f16383b 78 #define RAD_360 6.283185307179586f
Lightvalve 11:82d8768d7351 79
Lightvalve 11:82d8768d7351 80 #define SYSFREQ 200000000
Lightvalve 11:82d8768d7351 81 #define PBCLK 100000000
Lightvalve 11:82d8768d7351 82
Lightvalve 11:82d8768d7351 83 //#define TMR_FREQ_10k 10000
Lightvalve 11:82d8768d7351 84 #define TMR_FREQ_5k 5000
Lightvalve 11:82d8768d7351 85
Lightvalve 11:82d8768d7351 86 #define FALSE 0
Lightvalve 11:82d8768d7351 87 #define TRUE 1
Lightvalve 11:82d8768d7351 88 #define OUTPUT 0
Lightvalve 11:82d8768d7351 89 #define INPUT 1
Lightvalve 11:82d8768d7351 90 #define LOW 0
Lightvalve 11:82d8768d7351 91 #define HIGH 1
Lightvalve 11:82d8768d7351 92 #define DIGITAL 0
Lightvalve 11:82d8768d7351 93 #define ANALOG 1
Lightvalve 11:82d8768d7351 94
Lightvalve 30:8d561f16383b 95 #define PI 3.141592653589793f
Lightvalve 30:8d561f16383b 96 #define D2R 0.017453292519943f
Lightvalve 30:8d561f16383b 97 #define R2D 57.295779513082323f
Lightvalve 11:82d8768d7351 98
Lightvalve 11:82d8768d7351 99
Lightvalve 11:82d8768d7351 100 /*******************************************************************************
Lightvalve 11:82d8768d7351 101 * HEADER INCLUDE
Lightvalve 11:82d8768d7351 102 ******************************************************************************/
Lightvalve 11:82d8768d7351 103
Lightvalve 11:82d8768d7351 104 /*******************************************************************************
Lightvalve 11:82d8768d7351 105 * VARIABLE
Lightvalve 11:82d8768d7351 106 ******************************************************************************/
Lightvalve 11:82d8768d7351 107
Lightvalve 11:82d8768d7351 108 // Board Information
Lightvalve 11:82d8768d7351 109 extern uint8_t BNO;
Lightvalve 11:82d8768d7351 110 extern uint8_t CONTROL_MODE;
Lightvalve 11:82d8768d7351 111 extern uint8_t OPERATING_MODE;
Lightvalve 52:8ea76864368a 112 extern uint8_t SENSING_MODE;
Lightvalve 57:f4819de54e7a 113 extern uint8_t CONTROL_UTILITY_MODE;
Lightvalve 52:8ea76864368a 114 extern uint8_t CURRENT_CONTROL_MODE;
Lightvalve 52:8ea76864368a 115 extern uint8_t FLAG_VALVE_DEADZONE;
Lightvalve 11:82d8768d7351 116 extern uint8_t REFERENCE_MODE;
Lightvalve 54:647072f5307a 117 extern int16_t CAN_FREQ;
Lightvalve 17:1865016ca2e7 118 extern int16_t DIR_JOINT_ENC;
Lightvalve 17:1865016ca2e7 119 extern int16_t DIR_VALVE;
Lightvalve 17:1865016ca2e7 120 extern int16_t DIR_VALVE_ENC;
Lightvalve 11:82d8768d7351 121
Lightvalve 30:8d561f16383b 122 extern float SUPPLY_VOLTAGE;
Lightvalve 30:8d561f16383b 123 extern float VALVE_VOLTAGE_LIMIT;
Lightvalve 11:82d8768d7351 124
Lightvalve 30:8d561f16383b 125 extern float P_GAIN_VALVE_POSITION;
Lightvalve 30:8d561f16383b 126 extern float I_GAIN_VALVE_POSITION;
Lightvalve 30:8d561f16383b 127 extern float D_GAIN_VALVE_POSITION;
Lightvalve 30:8d561f16383b 128 extern float P_GAIN_JOINT_POSITION;
Lightvalve 30:8d561f16383b 129 extern float I_GAIN_JOINT_POSITION;
Lightvalve 30:8d561f16383b 130 extern float D_GAIN_JOINT_POSITION;
Lightvalve 30:8d561f16383b 131 extern float P_GAIN_JOINT_TORQUE;
Lightvalve 30:8d561f16383b 132 extern float I_GAIN_JOINT_TORQUE;
Lightvalve 30:8d561f16383b 133 extern float D_GAIN_JOINT_TORQUE;
Lightvalve 11:82d8768d7351 134
Lightvalve 46:2694daea349b 135 extern int16_t K_SPRING;
Lightvalve 46:2694daea349b 136 extern int16_t D_DAMPER;
Lightvalve 46:2694daea349b 137
Lightvalve 54:647072f5307a 138 extern int16_t flag_delay_test;
Lightvalve 54:647072f5307a 139
Lightvalve 36:a46e63505ed8 140 //extern float P_GAIN_VALVE_POSITION_OPP;
Lightvalve 36:a46e63505ed8 141 //extern float I_GAIN_VALVE_POSITION_OPP;
Lightvalve 36:a46e63505ed8 142 //extern float D_GAIN_VALVE_POSITION_OPP;
Lightvalve 36:a46e63505ed8 143 //extern float P_GAIN_JOINT_POSITION_OPP;
Lightvalve 36:a46e63505ed8 144 //extern float I_GAIN_JOINT_POSITION_OPP;
Lightvalve 36:a46e63505ed8 145 //extern float D_GAIN_JOINT_POSITION_OPP;
Lightvalve 36:a46e63505ed8 146 //extern float P_GAIN_JOINT_TORQUE_OPP;
Lightvalve 36:a46e63505ed8 147 //extern float I_GAIN_JOINT_TORQUE_OPP;
Lightvalve 36:a46e63505ed8 148 //extern float D_GAIN_JOINT_TORQUE_OPP;
Lightvalve 36:a46e63505ed8 149
Lightvalve 33:91b17819ec30 150 extern float VALVE_DEADZONE_PLUS;
Lightvalve 33:91b17819ec30 151 extern float VALVE_DEADZONE_MINUS;
Lightvalve 11:82d8768d7351 152
Lightvalve 11:82d8768d7351 153 extern int16_t VELOCITY_COMP_GAIN;
Lightvalve 11:82d8768d7351 154 extern int16_t COMPLIANCE_GAIN;
Lightvalve 11:82d8768d7351 155
Lightvalve 11:82d8768d7351 156 extern int16_t VALVE_CENTER;
Lightvalve 11:82d8768d7351 157
Lightvalve 11:82d8768d7351 158 extern int16_t VALVE_FF;
Lightvalve 11:82d8768d7351 159
Lightvalve 11:82d8768d7351 160 extern int16_t BULK_MODULUS;
Lightvalve 11:82d8768d7351 161
Lightvalve 11:82d8768d7351 162 extern int16_t CHAMBER_VOLUME_A;
Lightvalve 11:82d8768d7351 163 extern int16_t CHAMBER_VOLUME_B;
Lightvalve 11:82d8768d7351 164
Lightvalve 11:82d8768d7351 165 extern int16_t PISTON_AREA_A;
Lightvalve 11:82d8768d7351 166 extern int16_t PISTON_AREA_B;
Lightvalve 30:8d561f16383b 167 extern float PISTON_AREA_alpha;
Lightvalve 57:f4819de54e7a 168 extern float alpha3;
Lightvalve 11:82d8768d7351 169
Lightvalve 11:82d8768d7351 170
Lightvalve 11:82d8768d7351 171 extern int16_t PRES_SUPPLY;
Lightvalve 11:82d8768d7351 172 extern int16_t PRES_RETURN;
Lightvalve 11:82d8768d7351 173
Lightvalve 11:82d8768d7351 174 extern int16_t ENC_LIMIT_PLUS;
Lightvalve 11:82d8768d7351 175 extern int16_t ENC_LIMIT_MINUS;
Lightvalve 11:82d8768d7351 176
Lightvalve 11:82d8768d7351 177 extern int16_t STROKE;
Lightvalve 11:82d8768d7351 178
Lightvalve 11:82d8768d7351 179
Lightvalve 57:f4819de54e7a 180 //extern int16_t VALVE_LIMIT_PLUS;
Lightvalve 57:f4819de54e7a 181 //extern int16_t VALVE_LIMIT_MINUS;
Lightvalve 11:82d8768d7351 182
Lightvalve 48:889798ff9329 183 extern float ENC_PULSE_PER_POSITION;
Lightvalve 48:889798ff9329 184 extern float TORQUE_SENSOR_PULSE_PER_TORQUE;
Lightvalve 48:889798ff9329 185
Lightvalve 30:8d561f16383b 186 extern float PRES_SENSOR_A_PULSE_PER_BAR;
Lightvalve 30:8d561f16383b 187 extern float PRES_SENSOR_B_PULSE_PER_BAR;
Lightvalve 11:82d8768d7351 188
Lightvalve 11:82d8768d7351 189 extern int HOMEPOS_OFFSET;
Lightvalve 11:82d8768d7351 190 extern int HOMEPOS_VALVE_OPENING;
Lightvalve 11:82d8768d7351 191
Lightvalve 30:8d561f16383b 192 extern float FRICTION;
Lightvalve 30:8d561f16383b 193 extern float REF_PERIOD;
Lightvalve 30:8d561f16383b 194 extern float REF_MAG;
Lightvalve 11:82d8768d7351 195 extern int REF_NUM;
Lightvalve 11:82d8768d7351 196
Lightvalve 11:82d8768d7351 197
Lightvalve 30:8d561f16383b 198 extern float DAC_REF;
Lightvalve 30:8d561f16383b 199 extern float DAC_RESOL;
Lightvalve 11:82d8768d7351 200
Lightvalve 11:82d8768d7351 201 extern int REF_POSITION;
Lightvalve 11:82d8768d7351 202 extern int REF_VELOCITY;
Lightvalve 11:82d8768d7351 203 extern int16_t REF_TORQUE;
Lightvalve 11:82d8768d7351 204 extern int16_t REF_PRES_DIFF;
Lightvalve 11:82d8768d7351 205 extern int16_t REF_PWM;
Lightvalve 11:82d8768d7351 206 extern int16_t REF_VALVE_POSITION;
Lightvalve 14:8e7590227d22 207 extern int16_t REF_CURRENT;
Lightvalve 11:82d8768d7351 208
Lightvalve 11:82d8768d7351 209 extern int REF_MOVE_TIME_5k;
Lightvalve 11:82d8768d7351 210 extern int INIT_REF_PWM;
Lightvalve 11:82d8768d7351 211 extern int INIT_REF_VALVE_POS;
Lightvalve 11:82d8768d7351 212 extern int INIT_REF_POS;
Lightvalve 11:82d8768d7351 213 extern int INIT_REF_VEL;
Lightvalve 11:82d8768d7351 214 extern int INIT_REF_TORQUE;
Lightvalve 11:82d8768d7351 215 extern int INIT_REF_PRES_DIFF;
Lightvalve 14:8e7590227d22 216 extern int INIT_REF_CURRENT;
Lightvalve 11:82d8768d7351 217
Lightvalve 11:82d8768d7351 218 extern int CUR_POSITION;
Lightvalve 11:82d8768d7351 219 extern int CUR_VELOCITY;
Lightvalve 30:8d561f16383b 220 extern float CUR_TORQUE;
Lightvalve 30:8d561f16383b 221 extern float CUR_PRES_A;
Lightvalve 30:8d561f16383b 222 extern float CUR_PRES_B;
Lightvalve 11:82d8768d7351 223 extern int CUR_VALVE_POSITION;
Lightvalve 11:82d8768d7351 224
Lightvalve 11:82d8768d7351 225 extern unsigned int TMR2_COUNT_LED1;
Lightvalve 11:82d8768d7351 226 extern unsigned int TMR2_COUNT_LED2;
Lightvalve 11:82d8768d7351 227 extern unsigned int TMR2_COUNT_CAN_TX;
Lightvalve 54:647072f5307a 228 extern unsigned int TMR3_COUNT_TEST;
Lightvalve 11:82d8768d7351 229
Lightvalve 11:82d8768d7351 230 extern int num_err;
Lightvalve 11:82d8768d7351 231 extern int flag_err[8];
Lightvalve 11:82d8768d7351 232 extern int flag_err_old[8];
Lightvalve 11:82d8768d7351 233 extern int flag_err_rt;
Lightvalve 11:82d8768d7351 234
Lightvalve 11:82d8768d7351 235 extern int flag_ref_enable;
Lightvalve 11:82d8768d7351 236
Lightvalve 11:82d8768d7351 237 extern int flag_data_request[5];
Lightvalve 11:82d8768d7351 238
Lightvalve 45:35fa6884d0c6 239 extern int MODE_POS_FT_TRANS;
Lightvalve 45:35fa6884d0c6 240
Lightvalve 57:f4819de54e7a 241 extern float CUR_CURRENT_mA;
Lightvalve 30:8d561f16383b 242 extern float CUR_PRES_A_BAR;
Lightvalve 30:8d561f16383b 243 extern float CUR_PRES_B_BAR;
Lightvalve 30:8d561f16383b 244 extern float CUR_TORQUE_NM;
Lightvalve 30:8d561f16383b 245 extern float CUR_TORQUE_NM_PRESS;
Lightvalve 11:82d8768d7351 246
Lightvalve 30:8d561f16383b 247 extern float PRES_A_VREF;
Lightvalve 30:8d561f16383b 248 extern float PRES_B_VREF;
Lightvalve 30:8d561f16383b 249 extern float TORQUE_VREF;
Lightvalve 11:82d8768d7351 250
Lightvalve 30:8d561f16383b 251 extern float VALVE_PWM_RAW_FB;
Lightvalve 30:8d561f16383b 252 extern float VALVE_PWM_RAW_FF;
Lightvalve 57:f4819de54e7a 253 extern float VALVE_PWM_RAW;
Lightvalve 11:82d8768d7351 254 extern int VALVE_PWM_VALVE_DZ;
Lightvalve 11:82d8768d7351 255
Lightvalve 30:8d561f16383b 256 extern float VALVE_GAIN_LPM_PER_V[10];
Lightvalve 30:8d561f16383b 257 extern float VALVE_POS_VS_PWM[25];
Lightvalve 11:82d8768d7351 258 extern long JOINT_VEL[100];
Lightvalve 11:82d8768d7351 259
Lightvalve 11:82d8768d7351 260 extern int VALVE_MAX_POS;
Lightvalve 11:82d8768d7351 261 extern int VALVE_MIN_POS;
Lightvalve 11:82d8768d7351 262 extern int VALVE_POS_NUM;
Lightvalve 32:4b8c0fedaf2c 263 extern float VALVE_CENTER_OFFSET;
Lightvalve 33:91b17819ec30 264 extern float VALVE_DZ_MINUS_OFFSET;
Lightvalve 33:91b17819ec30 265 extern float VALVE_DZ_PLUS_OFFSET;
Lightvalve 33:91b17819ec30 266 extern float VALVE_DEADZONE_MINUS;
Lightvalve 33:91b17819ec30 267 extern float VALVE_DEADZONE_PLUS;
Lightvalve 11:82d8768d7351 268
Lightvalve 14:8e7590227d22 269 extern int TMR3_COUNT_FINDHOME;
Lightvalve 14:8e7590227d22 270 extern int TMR3_COUNT_FLOWRATE;
Lightvalve 14:8e7590227d22 271 extern int TMR3_COUNT_DEADZONE;
Lightvalve 14:8e7590227d22 272 extern int TMR3_COUNT_PRES_NULL;
Lightvalve 14:8e7590227d22 273 extern int TMR3_COUNT_TORQUE_NULL;
Lightvalve 14:8e7590227d22 274 extern int TMR3_COUNT_PRES_CALIB;
Lightvalve 14:8e7590227d22 275 extern int TMR3_COUNT_REFERENCE;
Lightvalve 14:8e7590227d22 276 extern int TMR3_COUNT_JOINT;
Lightvalve 14:8e7590227d22 277 extern int TMR3_COUNT_ROTARY_FRIC_TUNE;
Lightvalve 11:82d8768d7351 278
Lightvalve 30:8d561f16383b 279 extern float TUNING_TIME;
Lightvalve 11:82d8768d7351 280
Lightvalve 30:8d561f16383b 281 extern float REFERENCE_FREQ;
Lightvalve 30:8d561f16383b 282 extern float REFERENCE_MAG;
Lightvalve 11:82d8768d7351 283
Lightvalve 11:82d8768d7351 284 extern bool FLAG_FIND_HOME;
Lightvalve 11:82d8768d7351 285
Lightvalve 11:82d8768d7351 286 extern int MODE_JUMP_STATUS;
Lightvalve 11:82d8768d7351 287
Lightvalve 30:8d561f16383b 288 extern float CUR_PRES_DIFF_BAR;
Lightvalve 30:8d561f16383b 289 extern float CUR_PRES_A_sum;
Lightvalve 30:8d561f16383b 290 extern float CUR_PRES_B_sum;
Lightvalve 30:8d561f16383b 291 extern float CUR_PRES_A_mean;
Lightvalve 30:8d561f16383b 292 extern float CUR_PRES_B_mean;
Lightvalve 30:8d561f16383b 293 extern float CUR_TORQUE_sum;
Lightvalve 30:8d561f16383b 294 extern float CUR_TORQUE_mean;
Lightvalve 30:8d561f16383b 295 extern float PRES_A_NULL;
Lightvalve 30:8d561f16383b 296 extern float PRES_B_NULL;
Lightvalve 30:8d561f16383b 297 extern float TORQUE_NULL;
Lightvalve 13:747daba9cf59 298
Lightvalve 30:8d561f16383b 299 extern float Ref_Valve_Pos_Old;
Lightvalve 13:747daba9cf59 300
Lightvalve 13:747daba9cf59 301 extern int VALVE_ID_timer;
Lightvalve 13:747daba9cf59 302 extern int VALVE_DZ_timer;
Lightvalve 13:747daba9cf59 303 extern int VALVE_FR_timer;
Lightvalve 35:34ce7b0347b8 304 extern int VALVE_HPL_timer;
Lightvalve 13:747daba9cf59 305 extern int VALVE_POS_TMP;
Lightvalve 13:747daba9cf59 306 extern int JOINT_VEL_TMP;
Lightvalve 13:747daba9cf59 307 extern int DDV_POS_AVG ;
Lightvalve 19:23b7c1ad8683 308 extern int VALVE_POS_AVG[50];
Lightvalve 13:747daba9cf59 309 extern int VALVE_POS_AVG_OLD;
Lightvalve 13:747daba9cf59 310 extern int data_num;
Lightvalve 13:747daba9cf59 311 extern int ID_index;
Lightvalve 13:747daba9cf59 312 extern int DZ_index;
Lightvalve 19:23b7c1ad8683 313 extern int ID_index_array[50];
Lightvalve 13:747daba9cf59 314 extern int first_check;
Lightvalve 30:8d561f16383b 315 extern float init_time;
Lightvalve 13:747daba9cf59 316 extern int VEL_POINT;
Lightvalve 13:747daba9cf59 317 extern int DZ_case;
Lightvalve 13:747daba9cf59 318 extern int START_POS;
Lightvalve 13:747daba9cf59 319 extern int FINAL_POS;
Lightvalve 13:747daba9cf59 320 extern int DZ_DIRECTION;
Lightvalve 13:747daba9cf59 321 extern int FIRST_DZ;
Lightvalve 13:747daba9cf59 322 extern int SECOND_DZ;
Lightvalve 13:747daba9cf59 323 extern int DZ_NUM;
Lightvalve 13:747daba9cf59 324 extern int one_period_end;
Lightvalve 30:8d561f16383b 325 extern float Ref_Vel_Test;
Lightvalve 13:747daba9cf59 326 extern long TMR2_FOR_SLOW_LOGGING;
Lightvalve 19:23b7c1ad8683 327 //extern int velcount;
Lightvalve 13:747daba9cf59 328 extern char max_check;
Lightvalve 13:747daba9cf59 329 extern char min_check;
Lightvalve 13:747daba9cf59 330
Lightvalve 30:8d561f16383b 331 extern float valve_pos_err, valve_pos_err_old, valve_pos_err_diff, valve_pos_err_sum;
Lightvalve 30:8d561f16383b 332 extern float joint_pos_err, joint_pos_err_old, joint_pos_err_diff, joint_pos_err_diff_fil, joint_pos_err_sum;
Lightvalve 30:8d561f16383b 333 extern float joint_torq_err, joint_torq_err_old, joint_torq_err_diff, joint_torq_err_sum;
Lightvalve 30:8d561f16383b 334 extern float VALVE_PWM_RAW_POS, VALVE_PWM_RAW_TORQ;
Lightvalve 13:747daba9cf59 335
Lightvalve 30:8d561f16383b 336 extern float CUR_FLOWRATE;
Lightvalve 30:8d561f16383b 337 extern float VALVE_FF_VOLTAGE;
Lightvalve 13:747daba9cf59 338
Lightvalve 13:747daba9cf59 339 extern int pos_plus_end;
Lightvalve 13:747daba9cf59 340 extern int pos_minus_end;
Lightvalve 13:747daba9cf59 341
Lightvalve 13:747daba9cf59 342 extern bool need_enc_init;
Lightvalve 13:747daba9cf59 343
Lightvalve 13:747daba9cf59 344 extern int temp_time;
Lightvalve 13:747daba9cf59 345
Lightvalve 30:8d561f16383b 346 extern float CUR_VELOCITY_sum;
Lightvalve 30:8d561f16383b 347 extern float temp_vel_sum;
Lightvalve 13:747daba9cf59 348
Lightvalve 13:747daba9cf59 349 extern int DZ_dir;
Lightvalve 13:747daba9cf59 350 extern int DZ_temp_cnt;
Lightvalve 13:747daba9cf59 351 extern int DZ_temp_cnt2;
Lightvalve 13:747daba9cf59 352 extern int DZ_end;
Lightvalve 13:747daba9cf59 353 extern int flag_flowrate;
Lightvalve 13:747daba9cf59 354 extern int fl_temp_cnt;
Lightvalve 13:747daba9cf59 355 extern int fl_temp_cnt2;
Lightvalve 13:747daba9cf59 356 extern int cur_vel_sum;
Lightvalve 13:747daba9cf59 357
Lightvalve 57:f4819de54e7a 358 extern float Cur_Valve_Open_pulse;
Lightvalve 57:f4819de54e7a 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 30:8d561f16383b 374 extern float VALVE_VOLTAGE;
Lightvalve 13:747daba9cf59 375
Lightvalve 30:8d561f16383b 376 extern float freq_fric_tune;
Lightvalve 13:747daba9cf59 377
Lightvalve 14:8e7590227d22 378 extern uint32_t TMR3_COUNT_CAN_TX;
Lightvalve 14:8e7590227d22 379
Lightvalve 57:f4819de54e7a 380 // Current Control Variables
Lightvalve 57:f4819de54e7a 381 extern double I_REF;
Lightvalve 57:f4819de54e7a 382 extern double I_REF_fil;
Lightvalve 57:f4819de54e7a 383 extern double I_ERR;
Lightvalve 57:f4819de54e7a 384 extern double I_ERR_INT;
Lightvalve 57:f4819de54e7a 385 extern double I_REF_fil_old;
Lightvalve 57:f4819de54e7a 386 extern double I_REF_fil_diff;
Lightvalve 57:f4819de54e7a 387
Lightvalve 57:f4819de54e7a 388 // system id
Lightvalve 57:f4819de54e7a 389 extern int cnt_sysid;
Lightvalve 57:f4819de54e7a 390 extern double freq_sysid_Iref;
Lightvalve 57:f4819de54e7a 391
Lightvalve 14:8e7590227d22 392 extern int TMR3_COUNT_IREF;
Lightvalve 30:8d561f16383b 393 extern float CUR_CURRENT;
Lightvalve 30:8d561f16383b 394 extern float u_CUR[3];
Lightvalve 19:23b7c1ad8683 395
Lightvalve 29:69f3f5445d6d 396 extern int FINDHOME_STAGE;
Lightvalve 29:69f3f5445d6d 397 extern int FINDHOME_INIT;
Lightvalve 29:69f3f5445d6d 398 extern int FINDHOME_GOTOLIMIT;
Lightvalve 29:69f3f5445d6d 399 extern int FINDHOME_ZEROPOSE;
Lightvalve 29:69f3f5445d6d 400
Lightvalve 45:35fa6884d0c6 401 extern float alpha_trans;
Lightvalve 45:35fa6884d0c6 402
Lightvalve 57:f4819de54e7a 403
Lightvalve 57:f4819de54e7a 404 extern float V_out;
Lightvalve 57:f4819de54e7a 405 extern float V_rem;
Lightvalve 57:f4819de54e7a 406 extern float V_MAX;
Lightvalve 57:f4819de54e7a 407
Lightvalve 57:f4819de54e7a 408 extern float PWM_out;
Lightvalve 57:f4819de54e7a 409
Lightvalve 57:f4819de54e7a 410 extern double K_v;
Lightvalve 57:f4819de54e7a 411 extern double mV_PER_mA;
Lightvalve 57:f4819de54e7a 412 extern double mV_PER_pulse;
Lightvalve 57:f4819de54e7a 413 extern double mA_PER_pulse;
Lightvalve 57:f4819de54e7a 414
Lightvalve 57:f4819de54e7a 415 extern int timer_while;
Lightvalve 57:f4819de54e7a 416 extern int while_index;
Lightvalve 23:59218d4a256d 417
Lightvalve 23:59218d4a256d 418
Lightvalve 23:59218d4a256d 419
Lightvalve 26:8317d883d4f2 420
Lightvalve 30:8d561f16383b 421
Lightvalve 30:8d561f16383b 422
Lightvalve 32:4b8c0fedaf2c 423
Lightvalve 35:34ce7b0347b8 424
Lightvalve 36:a46e63505ed8 425
Lightvalve 45:35fa6884d0c6 426
Lightvalve 45:35fa6884d0c6 427
Lightvalve 48:889798ff9329 428
Lightvalve 49:e7bcfc244d40 429
Lightvalve 50:3c630b5eba9f 430
Lightvalve 52:8ea76864368a 431
Lightvalve 54:647072f5307a 432
Lightvalve 54:647072f5307a 433
Lightvalve 57:f4819de54e7a 434
Lightvalve 57:f4819de54e7a 435
Lightvalve 58:2eade98630e2 436