Original Version of STM Board

Dependencies:   FastPWM mbed

Revision:
11:82d8768d7351
Parent:
7:e9086c72bb22
Child:
13:747daba9cf59
diff -r 83a6baa77a2e -r 82d8768d7351 setting.h
--- a/setting.h	Fri Aug 23 01:02:32 2019 +0000
+++ b/setting.h	Fri Aug 23 12:28:08 2019 +0000
@@ -1,8 +1,6 @@
 #include "mbed.h"
 #include "FastPWM.h"
 
-#define PI          3.141592
-
 // pwm 
 #define PIN_V       PB_7
 #define PIN_W       PB_6
@@ -10,6 +8,7 @@
 //#define PWM_ARR     0x8CA       // loop 40k, pwm 20k
 #define PWM_ARR     0x1194      // loop 20k, pwm 10k
 //#define PWM_ARR     0x2328    // loop 10k, pwm 5k
+#define TMR3_COUNT  0x4650      // loop 5k
 
 #define FREQ_5k     5000.0
 #define FREQ_10k    10000.0
@@ -53,3 +52,215 @@
 
 void CurrentControl();
 void ValveControl(unsigned int ControlMode);
+
+
+/*******************************************************************************
+ * COMMON Settings
+ ******************************************************************************/
+#define             LATEST_VERSION      19032
+
+
+
+/*******************************************************************************
+ * COMMON CONSTANTS
+ ******************************************************************************/
+#define             RAD_30              0.523598775598299
+#define             RAD_60              1.047197551196598
+#define             RAD_120             2.094395102393195
+#define             RAD_180             3.141592653589793
+#define             RAD_240             4.188790204786391
+#define             RAD_300             5.235987755982989
+#define             RAD_360             6.283185307179586
+
+#define             SYSFREQ             200000000
+#define             PBCLK               100000000
+
+//#define             TMR_FREQ_10k       10000
+#define             TMR_FREQ_5k       5000
+
+#define             FALSE               0
+#define             TRUE                1
+#define             OUTPUT              0
+#define             INPUT               1
+#define             LOW                 0
+#define             HIGH                1
+#define             DIGITAL             0
+#define             ANALOG              1
+
+#define             PI                  3.141592653589793
+#define             D2R                 0.017453292519943
+#define             R2D                 57.295779513082323
+
+
+/*******************************************************************************
+ * HEADER INCLUDE
+ ******************************************************************************/
+
+/*******************************************************************************
+ * VARIABLE
+ ******************************************************************************/
+
+// Board Information 
+extern uint8_t BNO;
+extern uint8_t CONTROL_MODE;
+extern uint8_t OPERATING_MODE;
+extern uint8_t SETTING_SWITCH;
+extern uint8_t SETTING_SWITCH_OLD;
+extern uint8_t REFERENCE_MODE;
+extern uint16_t CAN_FREQ;
+extern uint8_t DIR_JOINT_ENC;
+extern uint8_t DIR_VALVE;
+extern uint8_t DIR_VALVE_ENC;
+
+extern double SUPPLY_VOLTAGE;
+extern double VALVE_VOLTAGE_LIMIT;
+
+extern double P_GAIN_VALVE_POSITION;
+extern double I_GAIN_VALVE_POSITION;
+extern double D_GAIN_VALVE_POSITION;
+extern double P_GAIN_JOINT_POSITION;
+extern double I_GAIN_JOINT_POSITION;
+extern double D_GAIN_JOINT_POSITION;
+extern double P_GAIN_JOINT_TORQUE;
+extern double I_GAIN_JOINT_TORQUE;
+extern double D_GAIN_JOINT_TORQUE;
+
+extern int16_t VALVE_DEADZONE_PLUS;
+extern int16_t VALVE_DEADZONE_MINUS;
+
+extern int16_t VELOCITY_COMP_GAIN;
+extern int16_t COMPLIANCE_GAIN;
+
+extern int16_t VALVE_CENTER;
+
+extern int16_t VALVE_FF;
+
+extern int16_t BULK_MODULUS;
+
+extern int16_t CHAMBER_VOLUME_A;
+extern int16_t CHAMBER_VOLUME_B;
+
+extern int16_t PISTON_AREA_A;
+extern int16_t PISTON_AREA_B;
+extern double PISTON_AREA_alpha;
+
+
+extern int16_t PRES_SUPPLY;
+extern int16_t PRES_RETURN;
+
+extern int16_t ENC_LIMIT_PLUS;
+extern int16_t ENC_LIMIT_MINUS;
+
+extern int16_t STROKE;
+
+
+extern int16_t VALVE_LIMIT_PLUS;
+extern int16_t VALVE_LIMIT_MINUS;
+
+extern int16_t ENC_PULSE_PER_POSITION;
+extern int16_t TORQUE_SENSOR_PULSE_PER_TORQUE;
+extern double PRES_SENSOR_A_PULSE_PER_BAR;
+extern double PRES_SENSOR_B_PULSE_PER_BAR;
+
+extern int HOMEPOS_OFFSET;
+extern int HOMEPOS_VALVE_OPENING;
+
+extern double FRICTION;
+extern double REF_PERIOD;
+extern double REF_MAG;
+extern int REF_NUM;
+
+
+extern double DAC_REF;
+extern double DAC_RESOL;
+extern double PWM_RESOL;
+
+extern int REF_POSITION;
+extern int REF_VELOCITY;
+extern int16_t REF_TORQUE;
+extern int16_t REF_PRES_DIFF;
+extern int16_t REF_PWM;
+extern int16_t REF_VALVE_POSITION;
+
+extern int REF_MOVE_TIME_5k;
+extern int INIT_REF_PWM;
+extern int INIT_REF_VALVE_POS;
+extern int INIT_REF_POS;
+extern int INIT_REF_VEL;
+extern int INIT_REF_TORQUE;
+extern int INIT_REF_PRES_DIFF;
+
+extern int CUR_POSITION;
+extern int CUR_VELOCITY;
+extern double CUR_TORQUE;
+extern double CUR_PRES_A;
+extern double CUR_PRES_B;
+extern int CUR_PWM;
+extern int CUR_VALVE_POSITION;
+
+extern unsigned int    TMR2_COUNT_LED1;
+extern unsigned int    TMR2_COUNT_LED2;
+extern unsigned int    TMR2_COUNT_CAN_TX;
+
+extern int num_err;
+extern int flag_err[8];
+extern int flag_err_old[8];
+extern int flag_err_rt;
+
+extern int flag_ref_enable;
+
+extern int flag_data_request[5];
+
+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////// SEUNGHOON ADD ///////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+
+extern double CUR_PRES_A_BAR;
+extern double CUR_PRES_B_BAR;
+extern double CUR_TORQUE_NM;
+extern double CUR_TORQUE_NM_PRESS;
+
+extern double PRES_A_VREF;
+extern double PRES_B_VREF;
+extern double TORQUE_VREF;
+
+extern double VALVE_PWM_RAW;
+extern double VALVE_PWM_RAW_FB;
+extern double VALVE_PWM_RAW_FF;
+extern int VALVE_PWM_VALVE_DZ;
+extern int VALVE_INPUT_PWM;
+
+extern double VALVE_GAIN_LPM_PER_V[10];
+extern double VALVE_POS_VS_PWM[18];
+extern long JOINT_VEL[100];
+
+extern int VALVE_MAX_POS;
+extern int VALVE_MIN_POS;
+extern int DDV_CENTER;
+extern int VALVE_POS_NUM;
+
+extern int TMR2_COUNT_FINDHOME;
+extern int TMR2_COUNT_FLOWRATE;
+extern int TMR2_COUNT_DEADZONE;
+extern int TMR2_COUNT_PRES_NULL;
+extern int TMR2_COUNT_TORQUE_NULL;
+extern int TMR2_COUNT_PRES_CALIB;
+extern int TMR2_COUNT_REFERENCE;
+extern int TMR2_COUNT_JOINT;
+extern int TMR2_COUNT_ROTARY_FRIC_TUNE;
+
+extern bool FLAG_REFERENCE_VALVE_PWM;
+extern bool FLAG_REFERENCE_VALVE_POSITION;
+extern bool FLAG_REFERENCE_JOINT_POSITION;
+extern bool FLAG_REFERENCE_JOINT_TORQUE;
+extern bool FLAG_REFERENCE_PRES_DIFF;
+
+extern double TUNING_TIME;
+
+extern double REFERENCE_FREQ;
+extern double REFERENCE_MAG;
+
+extern bool FLAG_FIND_HOME;
+
+extern int MODE_JUMP_STATUS;
+