Sungwoo Kim
/
HydraulicControlBoard_Rainbow_v1_2_
rainbow
main.cpp@111:93289db9e77a, 2020-09-11 (annotated)
- Committer:
- Lightvalve
- Date:
- Fri Sep 11 13:29:26 2020 +0000
- Revision:
- 111:93289db9e77a
- Parent:
- 110:48dc9bede846
- Child:
- 112:8dcb1600cb90
200911-2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Lightvalve | 111:93289db9e77a | 1 | //200911-2 |
GiJeongKim | 0:51c43836c1d7 | 2 | #include "mbed.h" |
GiJeongKim | 0:51c43836c1d7 | 3 | #include "FastPWM.h" |
GiJeongKim | 0:51c43836c1d7 | 4 | #include "INIT_HW.h" |
jobuuu | 2:a1c0a37df760 | 5 | #include "function_CAN.h" |
GiJeongKim | 0:51c43836c1d7 | 6 | #include "SPI_EEP_ENC.h" |
GiJeongKim | 0:51c43836c1d7 | 7 | #include "I2C_AS5510.h" |
GiJeongKim | 0:51c43836c1d7 | 8 | #include "setting.h" |
Lightvalve | 11:82d8768d7351 | 9 | #include "function_utilities.h" |
Lightvalve | 16:903b5a4433b4 | 10 | #include "stm32f4xx_flash.h" |
Lightvalve | 65:a2d7c63419c2 | 11 | #include "FlashWriter.h" |
Lightvalve | 61:bc8c8270f0ab | 12 | |
Lightvalve | 61:bc8c8270f0ab | 13 | using namespace std; |
Lightvalve | 61:bc8c8270f0ab | 14 | Timer t; |
GiJeongKim | 0:51c43836c1d7 | 15 | |
Lightvalve | 31:66738bfecec5 | 16 | ///191008//// |
Lightvalve | 31:66738bfecec5 | 17 | |
jobuuu | 7:e9086c72bb22 | 18 | // dac & check /////////////////////////////////////////// |
GiJeongKim | 0:51c43836c1d7 | 19 | DigitalOut check(PC_2); |
GiJeongKim | 0:51c43836c1d7 | 20 | DigitalOut check_2(PC_3); |
GiJeongKim | 0:51c43836c1d7 | 21 | AnalogOut dac_1(PA_4); |
GiJeongKim | 0:51c43836c1d7 | 22 | AnalogOut dac_2(PA_5); |
Lightvalve | 14:8e7590227d22 | 23 | AnalogIn adc1(PC_4); //pressure_1 |
Lightvalve | 14:8e7590227d22 | 24 | AnalogIn adc2(PB_0); //pressure_2 |
Lightvalve | 14:8e7590227d22 | 25 | AnalogIn adc3(PC_1); //current |
GiJeongKim | 0:51c43836c1d7 | 26 | |
Lightvalve | 24:ef6e1092e9e6 | 27 | |
jobuuu | 7:e9086c72bb22 | 28 | // PWM /////////////////////////////////////////// |
Lightvalve | 30:8d561f16383b | 29 | float dtc_v=0.0f; |
Lightvalve | 30:8d561f16383b | 30 | float dtc_w=0.0f; |
GiJeongKim | 0:51c43836c1d7 | 31 | |
jobuuu | 7:e9086c72bb22 | 32 | // I2C /////////////////////////////////////////// |
GiJeongKim | 0:51c43836c1d7 | 33 | I2C i2c(PC_9,PA_8); // SDA, SCL (for K22F) |
GiJeongKim | 0:51c43836c1d7 | 34 | const int i2c_slave_addr1 = 0x56; |
GiJeongKim | 0:51c43836c1d7 | 35 | unsigned int value; // 10bit output of reading sensor AS5510 |
GiJeongKim | 0:51c43836c1d7 | 36 | |
jobuuu | 7:e9086c72bb22 | 37 | // SPI /////////////////////////////////////////// |
Lightvalve | 16:903b5a4433b4 | 38 | //SPI eeprom(PB_15, PB_14, PB_13); // EEPROM //(SPI_MOSI, SPI_MISO, SPI_SCK); |
Lightvalve | 16:903b5a4433b4 | 39 | //DigitalOut eeprom_cs(PB_12); |
Lightvalve | 16:903b5a4433b4 | 40 | //FlashWriter writer(6);//2부터 7까지 되는듯 아마 sector |
GiJeongKim | 0:51c43836c1d7 | 41 | SPI enc(PC_12,PC_11,PC_10); |
GiJeongKim | 0:51c43836c1d7 | 42 | DigitalOut enc_cs(PD_2); |
Lightvalve | 11:82d8768d7351 | 43 | DigitalOut LED(PA_15); |
GiJeongKim | 0:51c43836c1d7 | 44 | |
jobuuu | 7:e9086c72bb22 | 45 | // UART /////////////////////////////////////////// |
GiJeongKim | 0:51c43836c1d7 | 46 | Serial pc(PA_9,PA_10); // _ UART |
GiJeongKim | 0:51c43836c1d7 | 47 | |
jobuuu | 7:e9086c72bb22 | 48 | // CAN /////////////////////////////////////////// |
GiJeongKim | 0:51c43836c1d7 | 49 | CAN can(PB_8, PB_9, 1000000); |
GiJeongKim | 0:51c43836c1d7 | 50 | CANMessage msg; |
Lightvalve | 11:82d8768d7351 | 51 | void onMsgReceived() |
Lightvalve | 11:82d8768d7351 | 52 | { |
Lightvalve | 11:82d8768d7351 | 53 | CAN_RX_HANDLER(); |
Lightvalve | 11:82d8768d7351 | 54 | } |
jobuuu | 2:a1c0a37df760 | 55 | |
jobuuu | 7:e9086c72bb22 | 56 | // Variables /////////////////////////////////////////// |
jobuuu | 7:e9086c72bb22 | 57 | State pos; |
jobuuu | 7:e9086c72bb22 | 58 | State vel; |
jobuuu | 7:e9086c72bb22 | 59 | State Vout; |
jobuuu | 7:e9086c72bb22 | 60 | State torq; |
jobuuu | 7:e9086c72bb22 | 61 | State pres_A; |
jobuuu | 7:e9086c72bb22 | 62 | State pres_B; |
jobuuu | 7:e9086c72bb22 | 63 | State cur; |
Lightvalve | 14:8e7590227d22 | 64 | State valve_pos; |
Lightvalve | 14:8e7590227d22 | 65 | |
Lightvalve | 14:8e7590227d22 | 66 | State INIT_Vout; |
Lightvalve | 14:8e7590227d22 | 67 | State INIT_Valve_Pos; |
Lightvalve | 14:8e7590227d22 | 68 | State INIT_Pos; |
Lightvalve | 14:8e7590227d22 | 69 | State INIT_torq; |
jobuuu | 5:a4319f79457b | 70 | |
Lightvalve | 19:23b7c1ad8683 | 71 | extern int CID_RX_CMD; |
Lightvalve | 19:23b7c1ad8683 | 72 | extern int CID_RX_REF_POSITION; |
Lightvalve | 49:e7bcfc244d40 | 73 | extern int CID_RX_REF_VALVE_POS; |
Lightvalve | 45:35fa6884d0c6 | 74 | extern int CID_RX_REF_PWM; |
Lightvalve | 19:23b7c1ad8683 | 75 | |
Lightvalve | 19:23b7c1ad8683 | 76 | extern int CID_TX_INFO; |
Lightvalve | 19:23b7c1ad8683 | 77 | extern int CID_TX_POSITION; |
Lightvalve | 19:23b7c1ad8683 | 78 | extern int CID_TX_TORQUE; |
Lightvalve | 19:23b7c1ad8683 | 79 | extern int CID_TX_PRES; |
Lightvalve | 19:23b7c1ad8683 | 80 | extern int CID_TX_VOUT; |
Lightvalve | 19:23b7c1ad8683 | 81 | extern int CID_TX_VALVE_POSITION; |
Lightvalve | 19:23b7c1ad8683 | 82 | |
Lightvalve | 61:bc8c8270f0ab | 83 | |
Lightvalve | 61:bc8c8270f0ab | 84 | |
Lightvalve | 61:bc8c8270f0ab | 85 | |
jobuuu | 7:e9086c72bb22 | 86 | // ============================================================================= |
jobuuu | 7:e9086c72bb22 | 87 | // ============================================================================= |
jobuuu | 7:e9086c72bb22 | 88 | // ============================================================================= |
jobuuu | 7:e9086c72bb22 | 89 | |
Lightvalve | 12:6f2531038ea4 | 90 | /******************************************************************************* |
Lightvalve | 12:6f2531038ea4 | 91 | * REFERENCE MODE |
Lightvalve | 12:6f2531038ea4 | 92 | ******************************************************************************/ |
Lightvalve | 13:747daba9cf59 | 93 | enum _REFERENCE_MODE { |
Lightvalve | 13:747daba9cf59 | 94 | MODE_REF_NO_ACT = 0, //0 |
Lightvalve | 12:6f2531038ea4 | 95 | MODE_REF_DIRECT, //1 |
Lightvalve | 12:6f2531038ea4 | 96 | MODE_REF_COS_INC, //2 |
Lightvalve | 12:6f2531038ea4 | 97 | MODE_REF_LINE_INC, //3 |
Lightvalve | 12:6f2531038ea4 | 98 | MODE_REF_SIN_WAVE, //4 |
Lightvalve | 12:6f2531038ea4 | 99 | MODE_REF_SQUARE_WAVE, //5 |
Lightvalve | 12:6f2531038ea4 | 100 | }; |
Lightvalve | 12:6f2531038ea4 | 101 | |
Lightvalve | 12:6f2531038ea4 | 102 | /******************************************************************************* |
Lightvalve | 12:6f2531038ea4 | 103 | * CONTROL MODE |
Lightvalve | 12:6f2531038ea4 | 104 | ******************************************************************************/ |
Lightvalve | 13:747daba9cf59 | 105 | enum _CONTROL_MODE { |
Lightvalve | 12:6f2531038ea4 | 106 | //control mode |
Lightvalve | 12:6f2531038ea4 | 107 | MODE_NO_ACT = 0, //0 |
Lightvalve | 47:fdcb8bd86fd6 | 108 | MODE_VALVE_POSITION_CONTROL, //1 |
Lightvalve | 47:fdcb8bd86fd6 | 109 | MODE_JOINT_CONTROL, //2 |
Lightvalve | 50:3c630b5eba9f | 110 | |
Lightvalve | 47:fdcb8bd86fd6 | 111 | MODE_VALVE_OPEN_LOOP, //3 |
Lightvalve | 12:6f2531038ea4 | 112 | MODE_JOINT_POSITION_TORQUE_CONTROL_VALVE_POSITION, //4 |
Lightvalve | 12:6f2531038ea4 | 113 | MODE_VALVE_POSITION_TORQUE_CONTROL_LEARNING, //5 |
Lightvalve | 13:747daba9cf59 | 114 | |
Lightvalve | 12:6f2531038ea4 | 115 | MODE_JOINT_POSITION_PRES_CONTROL_PWM, //6 |
Lightvalve | 12:6f2531038ea4 | 116 | MODE_JOINT_POSITION_PRES_CONTROL_VALVE_POSITION, //7 |
Lightvalve | 12:6f2531038ea4 | 117 | MODE_VALVE_POSITION_PRES_CONTROL_LEARNING, //8 |
Lightvalve | 13:747daba9cf59 | 118 | |
Lightvalve | 12:6f2531038ea4 | 119 | MODE_TEST_CURRENT_CONTROL, //9 |
Lightvalve | 12:6f2531038ea4 | 120 | MODE_TEST_PWM_CONTROL, //10 |
Lightvalve | 21:e5f1a43ea6f9 | 121 | |
Lightvalve | 14:8e7590227d22 | 122 | MODE_CURRENT_CONTROL, //11 |
Lightvalve | 14:8e7590227d22 | 123 | MODE_JOINT_POSITION_TORQUE_CONTROL_CURRENT, //12 |
Lightvalve | 14:8e7590227d22 | 124 | MODE_JOINT_POSITION_PRES_CONTROL_CURRENT, //13 |
Lightvalve | 13:747daba9cf59 | 125 | |
Lightvalve | 12:6f2531038ea4 | 126 | //utility |
Lightvalve | 12:6f2531038ea4 | 127 | MODE_TORQUE_SENSOR_NULLING = 20, //20 |
Lightvalve | 12:6f2531038ea4 | 128 | MODE_VALVE_NULLING_AND_DEADZONE_SETTING, //21 |
Lightvalve | 12:6f2531038ea4 | 129 | MODE_FIND_HOME, //22 |
Lightvalve | 57:f4819de54e7a | 130 | MODE_VALVE_GAIN_SETTING, //23 |
Lightvalve | 12:6f2531038ea4 | 131 | MODE_PRESSURE_SENSOR_NULLING, //24 |
Lightvalve | 12:6f2531038ea4 | 132 | MODE_PRESSURE_SENSOR_CALIB, //25 |
Lightvalve | 12:6f2531038ea4 | 133 | MODE_ROTARY_FRICTION_TUNING, //26 |
Lightvalve | 13:747daba9cf59 | 134 | |
Lightvalve | 12:6f2531038ea4 | 135 | MODE_DDV_POS_VS_PWM_ID = 30, //30 |
Lightvalve | 12:6f2531038ea4 | 136 | MODE_DDV_DEADZONE_AND_CENTER, //31 |
Lightvalve | 12:6f2531038ea4 | 137 | MODE_DDV_POS_VS_FLOWRATE, //32 |
Lightvalve | 57:f4819de54e7a | 138 | MODE_SYSTEM_ID, //33 |
Lightvalve | 12:6f2531038ea4 | 139 | }; |
Lightvalve | 12:6f2531038ea4 | 140 | |
Lightvalve | 65:a2d7c63419c2 | 141 | void SystemClock_Config(void) |
Lightvalve | 65:a2d7c63419c2 | 142 | { |
Lightvalve | 65:a2d7c63419c2 | 143 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
Lightvalve | 65:a2d7c63419c2 | 144 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
Lightvalve | 65:a2d7c63419c2 | 145 | |
Lightvalve | 65:a2d7c63419c2 | 146 | /** Configure the main internal regulator output voltage |
Lightvalve | 65:a2d7c63419c2 | 147 | */ |
Lightvalve | 65:a2d7c63419c2 | 148 | __HAL_RCC_PWR_CLK_ENABLE(); |
Lightvalve | 65:a2d7c63419c2 | 149 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); |
Lightvalve | 65:a2d7c63419c2 | 150 | /** Initializes the CPU, AHB and APB busses clocks |
Lightvalve | 65:a2d7c63419c2 | 151 | */ |
Lightvalve | 65:a2d7c63419c2 | 152 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; |
Lightvalve | 65:a2d7c63419c2 | 153 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
Lightvalve | 65:a2d7c63419c2 | 154 | RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; |
Lightvalve | 65:a2d7c63419c2 | 155 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
Lightvalve | 65:a2d7c63419c2 | 156 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; |
Lightvalve | 65:a2d7c63419c2 | 157 | RCC_OscInitStruct.PLL.PLLM = 8;//8 |
Lightvalve | 65:a2d7c63419c2 | 158 | RCC_OscInitStruct.PLL.PLLN = 180; //180 |
Lightvalve | 65:a2d7c63419c2 | 159 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; |
Lightvalve | 65:a2d7c63419c2 | 160 | RCC_OscInitStruct.PLL.PLLQ = 2; |
Lightvalve | 65:a2d7c63419c2 | 161 | RCC_OscInitStruct.PLL.PLLR = 2; |
Lightvalve | 65:a2d7c63419c2 | 162 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
Lightvalve | 65:a2d7c63419c2 | 163 | { |
Lightvalve | 65:a2d7c63419c2 | 164 | //Error_Handler(); |
Lightvalve | 65:a2d7c63419c2 | 165 | } |
Lightvalve | 65:a2d7c63419c2 | 166 | /** Activate the Over-Drive mode |
Lightvalve | 65:a2d7c63419c2 | 167 | */ |
Lightvalve | 65:a2d7c63419c2 | 168 | if (HAL_PWREx_EnableOverDrive() != HAL_OK) |
Lightvalve | 65:a2d7c63419c2 | 169 | { |
Lightvalve | 65:a2d7c63419c2 | 170 | //Error_Handler(); |
Lightvalve | 65:a2d7c63419c2 | 171 | } |
Lightvalve | 65:a2d7c63419c2 | 172 | /** Initializes the CPU, AHB and APB busses clocks |
Lightvalve | 65:a2d7c63419c2 | 173 | */ |
Lightvalve | 65:a2d7c63419c2 | 174 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |
Lightvalve | 65:a2d7c63419c2 | 175 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; |
Lightvalve | 65:a2d7c63419c2 | 176 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
Lightvalve | 65:a2d7c63419c2 | 177 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
Lightvalve | 65:a2d7c63419c2 | 178 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; |
Lightvalve | 65:a2d7c63419c2 | 179 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; |
Lightvalve | 65:a2d7c63419c2 | 180 | |
Lightvalve | 65:a2d7c63419c2 | 181 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) |
Lightvalve | 65:a2d7c63419c2 | 182 | { |
Lightvalve | 65:a2d7c63419c2 | 183 | //Error_Handler(); |
Lightvalve | 65:a2d7c63419c2 | 184 | } |
Lightvalve | 65:a2d7c63419c2 | 185 | } |
Lightvalve | 65:a2d7c63419c2 | 186 | |
Lightvalve | 99:7bbcb3c0fb06 | 187 | float u_past[num_array_u_past] = {0.0f}; |
Lightvalve | 68:328e1be06f5d | 188 | float x_past[num_array_x_past] = {0.0f}; |
Lightvalve | 85:a3b46118b5cd | 189 | float x_future[num_array_x_future] = {0.0f}; |
Lightvalve | 68:328e1be06f5d | 190 | float f_past[num_array_f_past] = {0.0f}; |
Lightvalve | 68:328e1be06f5d | 191 | float f_future[num_array_f_future] = {0.0f}; |
Lightvalve | 66:a8e6799dbce3 | 192 | |
Lightvalve | 73:f80dc3970c99 | 193 | float input_NN[num_input] = { 0.0f }; |
Lightvalve | 65:a2d7c63419c2 | 194 | |
Lightvalve | 111:93289db9e77a | 195 | const float h1[num_input][32] = { |
Lightvalve | 111:93289db9e77a | 196 | {-0.5549973249435425f,0.8768957853317261f,0.09650412201881409f,0.24851557612419128f,-0.030186515301465988f,-0.10503339767456055f,-0.16243299841880798f,-0.1012694388628006f,-0.17202284932136536f,0.0038828651886433363f,0.2429600954055786f,-0.22321639955043793f,-0.2678239345550537f,0.09377405047416687f,-0.19232401251792908f,0.1060103252530098f,-0.4086070656776428f,0.18299975991249084f,-0.32800766825675964f,-0.10222791880369186f,-0.35377758741378784f,0.09747585654258728f,-0.3031907379627228f,-0.0722002387046814f,-0.015438207425177097f,0.1674489974975586f,-0.16104386746883392f,-0.020340800285339355f,0.3390881419181824f,-0.17127496004104614f,0.06583423912525177f,0.02365354634821415f}, |
Lightvalve | 111:93289db9e77a | 197 | {-0.5140904784202576f,1.802839756011963f,0.2721617817878723f,0.2552260458469391f,0.005723567213863134f,-0.14306120574474335f,0.18916600942611694f,-0.01718241721391678f,-0.09363629668951035f,0.08362014591693878f,0.27739882469177246f,-0.1465436816215515f,-0.05722622573375702f,0.17776066064834595f,0.04180806875228882f,-0.08746688067913055f,-0.4267401397228241f,0.01310769934207201f,0.2637748420238495f,0.11253026872873306f,-0.0928034633398056f,-0.1100652664899826f,-0.0866384208202362f,0.25256627798080444f,0.11583297699689865f,0.26763588190078735f,0.11561140418052673f,-0.07117867469787598f,0.06925801932811737f,0.08939173817634583f,0.025751285254955292f,0.04056354612112045f}, |
Lightvalve | 111:93289db9e77a | 198 | {0.2908337116241455f,1.9345721006393433f,-0.0038479268550872803f,0.2460736334323883f,0.027719123288989067f,-0.14455747604370117f,0.09766381233930588f,-0.07469607889652252f,0.023745449259877205f,-0.014074495993554592f,0.1612796038389206f,0.02426053024828434f,-0.11591038107872009f,0.31654080748558044f,-0.28905919194221497f,-0.27905717492103577f,-0.4644099473953247f,-0.28356316685676575f,0.1289939284324646f,0.34010887145996094f,0.1374463587999344f,-0.1395411342382431f,0.12350606918334961f,-0.2247280478477478f,0.16758419573307037f,0.13248568773269653f,-0.14138396084308624f,-0.14598605036735535f,-0.6143582463264465f,0.27591514587402344f,-0.06936990469694138f,-0.2276267111301422f}, |
Lightvalve | 111:93289db9e77a | 199 | {0.014919288456439972f,0.8462927341461182f,-0.18711818754673004f,1.7169139385223389f,-0.11782031506299973f,-0.4051613211631775f,0.06353594362735748f,-0.5361209511756897f,0.3316388726234436f,-0.5792112350463867f,-0.35297247767448425f,0.510019063949585f,-0.20880702137947083f,0.21087929606437683f,-0.11680684983730316f,-1.108352541923523f,1.2171339988708496f,-0.25848352909088135f,-0.23431266844272614f,0.03679851070046425f,-0.29174768924713135f,-0.08014044165611267f,-0.13406386971473694f,-0.26563718914985657f,0.01664377935230732f,0.12903746962547302f,0.12193542718887329f,-0.03078395314514637f,0.055805303156375885f,0.12058231234550476f,-0.015879614278674126f,0.11237641423940659f}, |
Lightvalve | 111:93289db9e77a | 200 | {0.06727614998817444f,-0.19447815418243408f,0.07664334774017334f,-3.289839267730713f,-0.2341507524251938f,3.0233073234558105f,-0.030563730746507645f,-1.0927037000656128f,-0.18823972344398499f,-0.5661014914512634f,-0.8137605786323547f,1.575478434562683f,0.11876024305820465f,0.013919633813202381f,-0.22851628065109253f,2.7398576736450195f,1.0657321214675903f,-0.2109011709690094f,0.10224029421806335f,-0.212050199508667f,0.061001237481832504f,0.2149595022201538f,-0.2236560881137848f,-0.06796601414680481f,0.052188288420438766f,-0.31218889355659485f,0.036975473165512085f,-0.5947616100311279f,2.1079158782958984f,-0.1487281620502472f,-0.10598565638065338f,-0.021861236542463303f}, |
Lightvalve | 111:93289db9e77a | 201 | {0.10944844782352448f,0.08481812477111816f,0.27807939052581787f,-0.24680021405220032f,0.9184458255767822f,1.51350736618042f,-0.19825877249240875f,0.22346614301204681f,-0.3255809545516968f,-0.7702114582061768f,1.2050813436508179f,0.6697520613670349f,-0.10150232166051865f,-1.1368283033370972f,0.19959628582000732f,0.7601221203804016f,0.18227435648441315f,-0.33317211270332336f,-0.3353314995765686f,-0.26803967356681824f,0.05996573343873024f,-0.008817970752716064f,0.1147087812423706f,0.3015863299369812f,0.969081699848175f,0.18968838453292847f,-0.2666270434856415f,1.0817092657089233f,-0.49324920773506165f,-0.0011968016624450684f,-0.6789158582687378f,-0.10069727152585983f}, |
Lightvalve | 111:93289db9e77a | 202 | {-0.16714653372764587f,-0.22078187763690948f,0.14843863248825073f,-0.16687650978565216f,0.6331403851509094f,0.8896927237510681f,-0.22739233076572418f,0.1937950998544693f,-0.13269852101802826f,-0.4603324234485626f,0.44943761825561523f,0.18886254727840424f,0.016859780997037888f,-0.5811019539833069f,-0.1665383130311966f,0.3616390824317932f,0.07132945209741592f,-0.11663476377725601f,0.2749055027961731f,-0.16971218585968018f,-0.21101048588752747f,-0.1614212840795517f,-0.23933082818984985f,-0.223466694355011f,0.4593464434146881f,-0.14157472550868988f,-0.10264839231967926f,0.3197772800922394f,-0.4842132329940796f,-0.031773269176483154f,-0.15459232032299042f,0.058029334992170334f}, |
Lightvalve | 111:93289db9e77a | 203 | {0.06547479331493378f,0.008711201138794422f,0.15168696641921997f,-0.03261690214276314f,0.32004988193511963f,-0.005622576922178268f,-0.016663318499922752f,0.15775597095489502f,0.23933224380016327f,0.07812093943357468f,0.06328822672367096f,-0.289379358291626f,0.02518923580646515f,-0.26473143696784973f,0.0499650239944458f,0.4153742492198944f,-0.18384186923503876f,-0.30320557951927185f,-0.33621424436569214f,-0.060710761696100235f,-0.1309119462966919f,0.020663440227508545f,-0.11643148958683014f,-0.025921106338500977f,0.35802432894706726f,0.01617935299873352f,-0.3111790418624878f,0.06786756217479706f,-0.23781399428844452f,0.003934144973754883f,0.07942681759595871f,0.18824386596679688f}, |
Lightvalve | 111:93289db9e77a | 204 | {-0.07761932164430618f,0.0945894867181778f,0.12494269013404846f,0.13152939081192017f,-0.27321603894233704f,-0.6603643894195557f,-0.07748483121395111f,-0.13726256787776947f,-0.02937302365899086f,0.3532249927520752f,-0.22989411652088165f,0.08077867329120636f,0.03110603801906109f,0.3703298270702362f,0.22008126974105835f,-0.11594834178686142f,-0.4816214442253113f,0.012397116981446743f,0.12267253547906876f,-0.01222713477909565f,-0.33934450149536133f,-0.020349353551864624f,-0.27003389596939087f,0.07697224617004395f,-0.42190366983413696f,-0.07489721477031708f,-0.08116541802883148f,0.019913367927074432f,0.28361597657203674f,-0.1086675226688385f,0.13248927891254425f,0.03974803909659386f}, |
Lightvalve | 111:93289db9e77a | 205 | {-0.3010596036911011f,0.3982500731945038f,-0.22278577089309692f,0.252787709236145f,-0.2283351719379425f,-0.6769713163375854f,0.16400250792503357f,-0.45796144008636475f,-0.2718566060066223f,0.44359269738197327f,-0.4421471059322357f,0.05107002705335617f,0.002674868330359459f,0.45658165216445923f,-0.2440950870513916f,-0.8691561222076416f,0.1355404108762741f,0.2601526081562042f,0.08024941384792328f,-0.023476023226976395f,-0.24644076824188232f,0.14930570125579834f,-0.10644422471523285f,-0.29311618208885193f,-0.4298771619796753f,0.05133715271949768f,0.12382996082305908f,-0.19605278968811035f,0.346666157245636f,0.2767742872238159f,0.29475823044776917f,0.12010034918785095f}, |
Lightvalve | 111:93289db9e77a | 206 | {-0.18162256479263306f,-0.1843947470188141f,-0.060682862997055054f,0.061431434005498886f,-1.340694546699524f,-1.1265767812728882f,0.07892224937677383f,-0.31683415174484253f,-0.2528810203075409f,0.5439277291297913f,-0.9198852181434631f,-0.8414495587348938f,-0.23697304725646973f,1.135300636291504f,0.01561826467514038f,-0.6690000295639038f,0.05162588879466057f,-0.26449376344680786f,0.17733198404312134f,-0.10266680270433426f,0.09142167866230011f,-0.2309320867061615f,0.21849101781845093f,0.010328710079193115f,-0.9104908108711243f,0.09358248114585876f,0.07340890169143677f,-1.362223505973816f,0.5899525880813599f,0.02698659896850586f,0.29089462757110596f,0.11591790616512299f}, |
Lightvalve | 111:93289db9e77a | 207 | {0.16239318251609802f,-0.8852085471153259f,-0.28074589371681213f,0.27869588136672974f,-0.35394349694252014f,-1.0620883703231812f,-0.16018594801425934f,-0.18174774944782257f,-0.309278279542923f,0.8313618302345276f,0.35396403074264526f,-0.38282737135887146f,-0.10479026287794113f,0.018967464566230774f,-0.2727475166320801f,-0.637644350528717f,-1.0137202739715576f,-0.20914039015769958f,-0.28837206959724426f,-0.09804096817970276f,0.19977138936519623f,0.2074018120765686f,-0.21301458775997162f,0.29898685216903687f,-0.3063725531101227f,0.192124605178833f,0.308285653591156f,-0.12744085490703583f,0.42813849449157715f,0.1348828673362732f,0.047758929431438446f,-0.09322920441627502f}, |
Lightvalve | 111:93289db9e77a | 208 | {0.16610150039196014f,-1.2725626230239868f,0.17577719688415527f,0.561373770236969f,-0.10644831508398056f,-0.889015793800354f,-0.27063801884651184f,-0.04091417416930199f,-0.17987392842769623f,0.8136709332466125f,-0.13073813915252686f,-0.37499094009399414f,-0.31904900074005127f,0.043367061764001846f,0.05913722515106201f,-1.03632652759552f,-0.8771762251853943f,0.15525749325752258f,-0.026301899924874306f,-0.15697745978832245f,-0.29377415776252747f,0.02479115128517151f,0.011343330144882202f,-0.002705395221710205f,0.015216371044516563f,0.02754300832748413f,0.3120383620262146f,-0.2562366724014282f,0.25270625948905945f,-0.31464317440986633f,0.1813870370388031f,0.042772985994815826f}, |
Lightvalve | 111:93289db9e77a | 209 | {-0.19705000519752502f,-0.6178469657897949f,0.057266801595687866f,0.7703638076782227f,0.041649166494607925f,-0.6464152336120605f,0.17727656662464142f,-0.1536043882369995f,-0.11153905838727951f,0.7199433445930481f,0.7088598608970642f,-0.5713542699813843f,-0.042250778526067734f,0.08392687886953354f,0.09772798418998718f,-1.595205307006836f,-1.5327260494232178f,0.03707598149776459f,-0.1115458533167839f,-0.1690705567598343f,-0.2675037980079651f,-0.01396968960762024f,0.10836946964263916f,-0.30204448103904724f,0.1585797220468521f,-0.13537266850471497f,0.23587000370025635f,-0.19212594628334045f,0.008908407762646675f,0.2203761339187622f,-0.014040830545127392f,0.17387545108795166f}, |
Lightvalve | 111:93289db9e77a | 210 | {0.14984130859375f,-0.39736050367355347f,0.23348617553710938f,-0.3494146466255188f,-0.17855070531368256f,0.13934549689292908f,0.06768791377544403f,-0.15335479378700256f,0.032426122575998306f,0.42427369952201843f,0.2606595456600189f,0.5648385882377625f,0.09768744558095932f,-0.30517274141311646f,0.03607487678527832f,-0.6766859889030457f,-1.9688489437103271f,-0.10961295664310455f,0.2235242873430252f,-0.2857018709182739f,0.2236296832561493f,0.23995733261108398f,0.024087339639663696f,0.2164597511291504f,0.053514543920755386f,0.1771809458732605f,0.18153810501098633f,-0.5757332444190979f,-0.06988154351711273f,-0.09508240222930908f,-0.5335040092468262f,-0.221766859292984f}, |
Lightvalve | 111:93289db9e77a | 211 | {-0.2193826287984848f,-0.5374747514724731f,-0.12567082047462463f,-2.7913031578063965f,-0.859361469745636f,1.780104637145996f,-0.2859870493412018f,-0.5403660535812378f,-0.19070780277252197f,0.05212870240211487f,-1.1803473234176636f,1.942721962928772f,-0.018939485773444176f,0.4069802165031433f,0.25621795654296875f,-0.3258415162563324f,0.814672589302063f,-0.17165549099445343f,-0.2667202353477478f,-0.7847774624824524f,0.10423620790243149f,0.06402266025543213f,-0.11836928129196167f,0.039934515953063965f,-0.599066436290741f,-0.11239828169345856f,-0.1133931428194046f,-0.98674076795578f,1.1241964101791382f,0.2547503709793091f,-0.9127485752105713f,0.1149011179804802f}, |
Lightvalve | 111:93289db9e77a | 212 | {-0.2699241042137146f,-0.7621096968650818f,0.2171381115913391f,-0.05037733539938927f,1.4648785591125488f,0.7397952675819397f,0.2712773084640503f,0.4749986231327057f,0.34773555397987366f,-1.9753999710083008f,1.3614425659179688f,-0.6039097309112549f,-0.06383466720581055f,-0.9524223208427429f,-0.03601345419883728f,-1.5155115127563477f,1.5858936309814453f,0.18500369787216187f,0.11511234194040298f,-1.3798738718032837f,0.1400095671415329f,0.27685415744781494f,-0.005791813135147095f,-0.10062649846076965f,-0.4328889846801758f,-0.26325157284736633f,-0.05270814895629883f,1.7869433164596558f,-1.4561344385147095f,-0.14184410870075226f,-3.1208207607269287f,-0.20556804537773132f}, |
Lightvalve | 111:93289db9e77a | 213 | {0.22898969054222107f,-1.0923449993133545f,0.28761178255081177f,1.0929657220840454f,-1.1597645282745361f,-1.5437824726104736f,0.12949399650096893f,-0.2111121416091919f,-0.0010422819759696722f,-0.5134063363075256f,-0.39725160598754883f,-2.126756191253662f,0.1665218621492386f,0.3701869547367096f,0.10303568840026855f,-0.7402879595756531f,2.0048725605010986f,0.01572955772280693f,-0.15320371091365814f,0.18340754508972168f,0.18380583822727203f,-0.2400866597890854f,0.009734302759170532f,0.07569819688796997f,-0.9380505084991455f,0.021602869033813477f,0.09330874681472778f,-0.5457590222358704f,-2.2419583797454834f,0.31292837858200073f,-0.7161174416542053f,-0.07415392249822617f}, |
Lightvalve | 111:93289db9e77a | 214 | {-0.07732547074556351f,-1.4669426679611206f,-0.018198877573013306f,1.733497142791748f,-1.2798469066619873f,-1.8929096460342407f,0.18704187870025635f,-0.21409165859222412f,-0.26913687586784363f,0.5478826761245728f,-0.7865070700645447f,-1.9871313571929932f,0.07078470289707184f,1.5677226781845093f,0.10715800523757935f,-0.4267347753047943f,1.617734670639038f,-0.13909658789634705f,-0.35246598720550537f,0.8162409067153931f,-0.0603049173951149f,-0.21737487614154816f,-0.056176453828811646f,0.2705017924308777f,-1.823738694190979f,-0.11336645483970642f,-0.08713452517986298f,-0.6062920093536377f,0.1412607729434967f,0.1542942225933075f,0.12180112302303314f,-0.36400938034057617f}, |
Lightvalve | 111:93289db9e77a | 215 | {-0.38522428274154663f,-1.4863255023956299f,-0.21064835786819458f,0.21336480975151062f,0.012319735251367092f,-1.2449426651000977f,-0.3318271338939667f,-0.26248374581336975f,-0.2573673129081726f,0.7279641032218933f,-0.44852757453918457f,-0.5130775570869446f,0.08922964334487915f,0.5272676944732666f,0.16669881343841553f,1.453701138496399f,-1.0089435577392578f,-0.1794114112854004f,0.048962514847517014f,-0.03595775365829468f,0.12751427292823792f,0.03320974111557007f,0.04151731729507446f,-0.17835715413093567f,-0.7482700943946838f,-0.0823364406824112f,0.01731693744659424f,0.4874497652053833f,1.2782034873962402f,0.2479429841041565f,0.2709144353866577f,-0.019879739731550217f}, |
Lightvalve | 111:93289db9e77a | 216 | {-0.2841658294200897f,-0.6471507549285889f,-0.06804615259170532f,-0.6768759489059448f,0.16441278159618378f,-0.13797762989997864f,-0.051098939031362534f,-0.17878958582878113f,-0.29077503085136414f,1.3278660774230957f,-0.26632925868034363f,-0.03479018807411194f,-0.28642264008522034f,0.4385105073451996f,-0.14352285861968994f,1.1886452436447144f,-1.5095813274383545f,-0.16642995178699493f,0.03633127734065056f,-0.06017739325761795f,0.18065878748893738f,-0.17827366292476654f,0.1588650643825531f,0.2682499289512634f,-0.27270078659057617f,0.3014773726463318f,-0.09892690181732178f,0.5001164674758911f,0.6138177514076233f,-0.2688840925693512f,0.005932711064815521f,-0.01895717903971672f}, |
Lightvalve | 111:93289db9e77a | 217 | {-0.057659950107336044f,0.032964564859867096f,-0.3055203855037689f,-0.11276672035455704f,0.14146369695663452f,0.19821391999721527f,-0.20970572531223297f,-0.21762727200984955f,-0.07239159941673279f,0.7515203952789307f,-0.14676524698734283f,0.11501897871494293f,-0.3100961446762085f,0.3317854404449463f,-0.0510614812374115f,0.33675050735473633f,-0.45134633779525757f,0.1732131987810135f,-0.1904004067182541f,-0.4676954746246338f,-0.29833462834358215f,-0.037396371364593506f,-0.04696956276893616f,-0.3105055093765259f,-0.09445905685424805f,0.09924682974815369f,0.19071155786514282f,0.04935053735971451f,-0.3727755844593048f,-0.31100425124168396f,0.0020875446498394012f,-0.3163982927799225f}, |
Lightvalve | 111:93289db9e77a | 218 | {-0.1876622885465622f,0.3982551097869873f,-0.13955603539943695f,0.08116590976715088f,0.01594996452331543f,-0.00032240129075944424f,-0.35799023509025574f,0.037732549011707306f,0.04116886854171753f,0.1631990522146225f,0.023498188704252243f,0.13610903918743134f,0.08045294880867004f,0.06805718690156937f,-0.2357269823551178f,-0.27718085050582886f,0.045548342168331146f,0.025416716933250427f,-0.16219155490398407f,-0.6523213386535645f,0.02637885883450508f,-0.22036904096603394f,0.14483293890953064f,-0.23648568987846375f,0.0557633638381958f,0.08651471138000488f,-0.10241064429283142f,-0.07495409995317459f,-0.49400731921195984f,-0.19917014241218567f,-0.05134391039609909f,-0.25454238057136536f}, |
Lightvalve | 111:93289db9e77a | 219 | {-0.002890507224947214f,0.38985371589660645f,0.14412927627563477f,-0.016363581642508507f,0.15386301279067993f,0.13273252546787262f,-0.06690996885299683f,-0.45700135827064514f,-0.42934131622314453f,0.09874602407217026f,-0.21924324333667755f,0.1810167133808136f,-0.20643122494220734f,-0.11461876332759857f,-0.26593083143234253f,-0.17016378045082092f,0.04185843467712402f,0.19379638135433197f,-0.30896225571632385f,0.10383816063404083f,-0.20090889930725098f,0.21268349885940552f,-0.08894717693328857f,-0.049122005701065063f,-0.17275434732437134f,0.2244570255279541f,0.07713767886161804f,-0.18497788906097412f,-0.04580913856625557f,0.0996716320514679f,0.09052678942680359f,0.1899610161781311f}, |
Lightvalve | 111:93289db9e77a | 220 | {-0.2989834249019623f,-0.0886680856347084f,-0.11498735845088959f,0.076726034283638f,0.08607155084609985f,0.11834347248077393f,-0.10653511434793472f,-0.1754452884197235f,0.13760076463222504f,0.019417058676481247f,0.06558504700660706f,-0.17269250750541687f,-0.03799047693610191f,-0.008609723299741745f,-0.1758022904396057f,0.23312468826770782f,0.32029470801353455f,-0.030552709475159645f,-0.08688822388648987f,0.17911973595619202f,-0.12493511289358139f,-0.04495009779930115f,0.16096624732017517f,-0.2661283612251282f,-0.014554467983543873f,-0.26236870884895325f,0.2998650074005127f,-0.18183283507823944f,-0.052910443395376205f,0.0021838247776031494f,-0.010952952317893505f,-0.2833111584186554f}, |
Lightvalve | 111:93289db9e77a | 221 | {-0.3798274099826813f,0.17526905238628387f,0.22676491737365723f,-0.06310396641492844f,-0.08429674059152603f,0.021032223477959633f,-0.12497112900018692f,-0.10837429016828537f,0.06679853796958923f,-0.17533978819847107f,-0.0777849406003952f,0.1700391322374344f,0.16800062358379364f,0.21719373762607574f,0.10714438557624817f,-0.061620160937309265f,-0.31369003653526306f,0.05981208011507988f,0.22887876629829407f,0.07286404818296432f,-0.2671769857406616f,-0.1163475513458252f,0.2862720489501953f,-0.2529933452606201f,0.04029828682541847f,0.2395622730255127f,-0.025946974754333496f,0.2668023705482483f,0.14792044460773468f,0.1531447172164917f,-0.032673899084329605f,-0.3580935001373291f}, |
Lightvalve | 111:93289db9e77a | 222 | {-0.04998239874839783f,0.6871059536933899f,0.06572896242141724f,0.013565510511398315f,-0.03371898829936981f,0.06943904608488083f,0.2516723573207855f,-0.263293594121933f,-0.31873810291290283f,0.05600589141249657f,0.24683892726898193f,0.06935559958219528f,-0.3565635085105896f,-0.16997170448303223f,0.2870509624481201f,0.14678435027599335f,-0.2394721508026123f,-0.024850888177752495f,0.15066401660442352f,-0.17265844345092773f,-0.34199902415275574f,0.2523300051689148f,0.2562907934188843f,-0.2754032015800476f,0.08735863119363785f,-0.22490140795707703f,-0.3025656044483185f,-0.10896103084087372f,-0.23869378864765167f,-0.012988030910491943f,0.02241462469100952f,-0.1308896243572235f}, |
Lightvalve | 65:a2d7c63419c2 | 223 | }; |
Lightvalve | 65:a2d7c63419c2 | 224 | |
Lightvalve | 111:93289db9e77a | 225 | const float h2[32][32] = { |
Lightvalve | 111:93289db9e77a | 226 | {-0.28262630105018616f,-0.10295046865940094f,-0.04925942420959473f,0.050971269607543945f,-0.15490937232971191f,0.16725482046604156f,0.016050614416599274f,0.03806401416659355f,-0.30411389470100403f,-0.10008957982063293f,0.0908159464597702f,-0.11149094998836517f,0.09169831871986389f,-0.09433796256780624f,-0.08317296952009201f,-0.2573889493942261f,0.07803884148597717f,-0.21483641862869263f,0.030773762613534927f,0.028034096583724022f,-0.20074595510959625f,-0.10813955217599869f,-0.23983746767044067f,-0.2460433840751648f,-0.2626775801181793f,0.19191597402095795f,-0.19176992774009705f,-0.2775455713272095f,0.23828622698783875f,0.07137447595596313f,-0.24613501131534576f,-0.21455639600753784f}, |
Lightvalve | 111:93289db9e77a | 227 | {-0.29703569412231445f,0.002147972583770752f,-0.04321768879890442f,0.17127861082553864f,0.039372533559799194f,-0.24937361478805542f,-1.0147807598114014f,-0.2040083259344101f,0.24677053093910217f,0.048597872257232666f,-0.03626091033220291f,-0.21903453767299652f,0.12364552170038223f,0.17729739844799042f,-0.1603364199399948f,-0.8733221888542175f,0.056778669357299805f,-0.2737269401550293f,-0.0741347074508667f,0.05775337293744087f,-0.14897437393665314f,0.05729661509394646f,-0.3051934540271759f,0.07562146335840225f,-0.19067099690437317f,-0.08739247173070908f,-0.1973082274198532f,0.27654072642326355f,-0.28620439767837524f,-0.16291001439094543f,0.19307708740234375f,0.09121111035346985f}, |
Lightvalve | 111:93289db9e77a | 228 | {-0.1579037755727768f,0.28447648882865906f,-0.1789936125278473f,0.20799604058265686f,0.025723248720169067f,0.17740526795387268f,-0.1666354387998581f,-0.06060470640659332f,-0.017253071069717407f,-0.2790656089782715f,-0.16800916194915771f,-0.2990717589855194f,0.07126197218894958f,-0.08032660186290741f,-0.1799015998840332f,-0.1891922950744629f,0.2556300461292267f,0.2080206573009491f,-0.24888339638710022f,0.27691522240638733f,-0.21319638192653656f,-0.14012537896633148f,-0.30466505885124207f,-0.013728171586990356f,-0.1629670113325119f,0.2530798614025116f,0.0633285641670227f,0.0011726915836334229f,-0.14820529520511627f,0.2823629677295685f,0.10884168744087219f,-0.2637729346752167f}, |
Lightvalve | 111:93289db9e77a | 229 | {-0.17369972169399261f,-0.01806354522705078f,-0.23058539628982544f,-0.056480228900909424f,-0.27190759778022766f,-0.31676533818244934f,1.6826895475387573f,-0.07526495307683945f,-0.06944303214550018f,0.09271347522735596f,-3.659794330596924f,-1.378901720046997f,-0.26522207260131836f,0.0071749500930309296f,-0.29093071818351746f,-6.041348934173584f,0.10996055603027344f,0.24023392796516418f,0.41489681601524353f,-0.18462778627872467f,0.5464596152305603f,0.41755738854408264f,-0.21676670014858246f,-0.34753191471099854f,-0.3234001398086548f,0.18147599697113037f,0.25169986486434937f,0.4173973500728607f,-0.22396358847618103f,0.08333839476108551f,0.03394383192062378f,0.26378875970840454f}, |
Lightvalve | 111:93289db9e77a | 230 | {-0.25527071952819824f,0.2506926953792572f,-0.0804666131734848f,-0.0039723115041852f,0.02918580174446106f,-0.49303507804870605f,-1.108476996421814f,-0.024386292323470116f,0.043158918619155884f,-0.2690317630767822f,-0.2899925708770752f,0.6998153924942017f,-0.2618047893047333f,-1.943273901939392f,-0.6057609915733337f,-1.7233401536941528f,-0.10307048261165619f,0.15626338124275208f,0.2237727791070938f,-0.10695213079452515f,1.3816722631454468f,1.8187663555145264f,0.039856430143117905f,-0.49848827719688416f,-0.9802588224411011f,-0.9548362493515015f,1.242735743522644f,-2.4200804233551025f,0.2695164978504181f,-0.4064396917819977f,0.008398771286010742f,-0.19599652290344238f}, |
Lightvalve | 111:93289db9e77a | 231 | {-0.3117655813694f,-0.004258692264556885f,0.032371193170547485f,-0.2693426012992859f,-0.023485273122787476f,-0.29336631298065186f,0.04606656730175018f,-0.17031878232955933f,-0.03548547625541687f,0.08825305104255676f,-1.7471638917922974f,2.018878698348999f,-0.2578849494457245f,-0.9904099106788635f,-0.4349291920661926f,0.5100759267807007f,0.2371552288532257f,0.24713221192359924f,0.7837533354759216f,0.03276149928569794f,1.0735238790512085f,0.05906827747821808f,-0.1307595670223236f,-0.27559101581573486f,-0.3108561933040619f,0.5608378052711487f,1.3712366819381714f,1.299574375152588f,0.05800282955169678f,-0.31251204013824463f,0.17187702655792236f,0.16163703799247742f}, |
Lightvalve | 111:93289db9e77a | 232 | {-0.21433322131633759f,-0.1279313862323761f,-0.11171227693557739f,0.27164509892463684f,-0.26441383361816406f,0.2845393121242523f,0.05489188805222511f,-0.20844537019729614f,-0.26620519161224365f,0.17144301533699036f,-0.10491911321878433f,-0.15244176983833313f,0.29584869742393494f,-0.09937954694032669f,-0.11244286596775055f,0.07188281416893005f,-0.16153597831726074f,0.18742787837982178f,-0.08658026903867722f,0.10941001027822495f,-0.0022920179180800915f,0.4724496901035309f,-0.07988794147968292f,-0.15143592655658722f,-0.2241641879081726f,0.0795900821685791f,0.17865754663944244f,-0.15420465171337128f,-0.11822041869163513f,0.19546762108802795f,-0.16657039523124695f,-0.07910130172967911f}, |
Lightvalve | 111:93289db9e77a | 233 | {0.2000444084405899f,0.11346611380577087f,0.04012581706047058f,0.025473803281784058f,0.22828009724617004f,-0.24462848901748657f,0.21250835061073303f,-0.020913923159241676f,0.2864855229854584f,0.01006925106048584f,-0.21244332194328308f,0.146012082695961f,-0.09209762513637543f,-0.1864805668592453f,-0.23641753196716309f,-0.3981374204158783f,-0.2721019387245178f,0.2706601917743683f,-0.0348653607070446f,-0.11487992107868195f,0.45665961503982544f,-0.13955335319042206f,-0.2325384020805359f,0.13226255774497986f,-0.20009492337703705f,-0.2066667675971985f,0.14619506895542145f,0.1825239062309265f,-0.14135785400867462f,-0.0317494198679924f,0.16089555621147156f,0.03706110268831253f}, |
Lightvalve | 111:93289db9e77a | 234 | {0.28564146161079407f,0.2890130579471588f,-0.021617114543914795f,0.11687019467353821f,0.29321715235710144f,0.07065775990486145f,-0.15634632110595703f,-0.23997274041175842f,0.29470762610435486f,-0.06864601373672485f,0.10125938802957535f,-0.10414101183414459f,0.24146446585655212f,-0.017999317497015f,0.2889692485332489f,0.3795613944530487f,0.046292245388031006f,0.06025278568267822f,0.05989168584346771f,0.24959591031074524f,0.18705208599567413f,0.23671534657478333f,0.28743305802345276f,0.00652727484703064f,0.05568587779998779f,-0.21884143352508545f,-0.11531483381986618f,0.102409727871418f,0.2501918375492096f,-0.14010676741600037f,-0.24744901061058044f,-0.23618105053901672f}, |
Lightvalve | 111:93289db9e77a | 235 | {0.10230162739753723f,0.08643358945846558f,-0.29237738251686096f,-0.2233119159936905f,0.15896368026733398f,-0.29306185245513916f,-0.05484631657600403f,-0.18050217628479004f,0.18755429983139038f,-0.07031691074371338f,0.2590855360031128f,-0.5912851095199585f,-0.00029354883008636534f,-0.12337486445903778f,-0.29559701681137085f,-2.0586349964141846f,-0.015168905258178711f,-0.2859399914741516f,-0.19315965473651886f,-0.2609231770038605f,1.4014286994934082f,0.011335540562868118f,-0.37809649109840393f,-0.017629969865083694f,0.643451988697052f,0.57890385389328f,-0.2781616151332855f,-0.23764504492282867f,0.2113950550556183f,-0.1114145889878273f,-0.0010054409503936768f,-0.47896188497543335f}, |
Lightvalve | 111:93289db9e77a | 236 | {0.032458558678627014f,0.1956864297389984f,-0.033508092164993286f,-0.2971467673778534f,-0.12505969405174255f,-0.24130702018737793f,0.2721092402935028f,0.14285165071487427f,-0.17670965194702148f,0.17403557896614075f,-0.300394743680954f,0.2611115276813507f,-0.14932474493980408f,-0.018416471779346466f,-0.43925654888153076f,-0.8887067437171936f,0.03990337252616882f,0.0716913640499115f,0.5335866808891296f,-0.2766534090042114f,0.9707726240158081f,0.25951915979385376f,-0.0776895210146904f,-0.06159729138016701f,-0.7663754224777222f,1.0766961574554443f,-0.016369229182600975f,-1.0091429948806763f,0.13817378878593445f,-0.09298785775899887f,-0.009185433387756348f,-0.08794822543859482f}, |
Lightvalve | 111:93289db9e77a | 237 | {-0.3981843888759613f,-0.09556084871292114f,0.12328919768333435f,-0.0021208850666880608f,-0.258735328912735f,-0.0034677356015890837f,-1.0868544578552246f,-0.2723599076271057f,0.17735600471496582f,0.009893029928207397f,-0.36947762966156006f,0.25827234983444214f,-0.23116357624530792f,-0.6131993532180786f,0.023685593158006668f,0.8590928912162781f,0.009990394115447998f,0.10842388868331909f,0.2162429392337799f,0.021101126447319984f,-0.667637825012207f,-0.29042550921440125f,-0.05232049897313118f,-0.15440380573272705f,-0.2777888774871826f,-0.7244274616241455f,-0.2193611115217209f,-0.2899381220340729f,-0.288028746843338f,-0.35274428129196167f,0.17687886953353882f,0.20775648951530457f}, |
Lightvalve | 111:93289db9e77a | 238 | {-0.08816954493522644f,0.2728963792324066f,-0.07170480489730835f,0.1482785940170288f,0.07727676630020142f,0.20119628310203552f,0.1266944408416748f,0.02873826026916504f,-0.15294449031352997f,-0.038666754961013794f,-0.11895108968019485f,0.33483585715293884f,0.1312139928340912f,-0.17642268538475037f,0.1620480716228485f,0.12264445424079895f,0.023397088050842285f,0.21900424361228943f,0.16968974471092224f,0.2068612277507782f,-0.38150978088378906f,-0.04455387592315674f,-0.19714993238449097f,0.22523340582847595f,0.15785618126392365f,0.1390477865934372f,-0.12523572146892548f,-0.26378923654556274f,0.18573936820030212f,0.15478622913360596f,0.013760745525360107f,0.010002970695495605f}, |
Lightvalve | 111:93289db9e77a | 239 | {0.08366114646196365f,0.1833711564540863f,-0.0858893096446991f,-0.031472060829401016f,-0.25116482377052307f,0.033648520708084106f,0.9874479174613953f,-0.32130011916160583f,0.000652611255645752f,-0.22920364141464233f,0.8362777829170227f,-0.34970158338546753f,0.1313982754945755f,0.48934945464134216f,-0.20030063390731812f,-0.7390080094337463f,-0.07963520288467407f,0.14483880996704102f,0.24087762832641602f,-0.34227606654167175f,0.1628921926021576f,-0.45626378059387207f,-0.35495632886886597f,0.03081316314637661f,0.7643952369689941f,-0.3257284462451935f,-1.3584414720535278f,0.7051181793212891f,-0.011228948831558228f,0.09819978475570679f,-0.28556761145591736f,-0.15407900512218475f}, |
Lightvalve | 111:93289db9e77a | 240 | {-0.23982827365398407f,0.03880670666694641f,-0.013682037591934204f,-0.11685100197792053f,-0.020662933588027954f,0.30190005898475647f,-0.14934301376342773f,-0.15993990004062653f,0.1152651309967041f,-0.11991468071937561f,-0.15497799217700958f,0.11116543412208557f,-0.2045515924692154f,0.2403949797153473f,-0.21275603771209717f,0.05732181668281555f,-0.2770107090473175f,0.088544100522995f,0.19012078642845154f,-0.07119561731815338f,-0.18914666771888733f,-0.10413256287574768f,-0.16050675511360168f,0.11598068475723267f,-0.03151249885559082f,-0.1937510371208191f,0.18474078178405762f,0.19502457976341248f,0.22045472264289856f,-0.29474368691444397f,0.09864541888237f,0.06054645776748657f}, |
Lightvalve | 111:93289db9e77a | 241 | {-0.2082466185092926f,0.1317739188671112f,0.03260180354118347f,-0.16839730739593506f,-0.05160003900527954f,-0.34285980463027954f,-0.7063789963722229f,-0.06628980487585068f,0.05445769429206848f,0.07657262682914734f,0.9298385977745056f,-1.177181363105774f,0.09547987580299377f,-0.26624470949172974f,0.011975004337728024f,1.283035159111023f,-0.25386664271354675f,-0.18997573852539062f,-0.5879048109054565f,-0.2463037371635437f,-0.9688586592674255f,0.19907180964946747f,-0.3044300675392151f,0.04050491005182266f,0.3465234041213989f,-0.33271512389183044f,0.1334882378578186f,0.28836730122566223f,-0.0006675124168395996f,-0.20010095834732056f,-0.035532981157302856f,0.2545125484466553f}, |
Lightvalve | 111:93289db9e77a | 242 | {-0.09839462488889694f,-0.062024205923080444f,0.10704237222671509f,-0.18723875284194946f,-0.04875987768173218f,0.017238130792975426f,-1.3855080604553223f,0.1011844202876091f,-0.23304778337478638f,-0.035415440797805786f,0.4739813208580017f,-0.622860312461853f,0.06678740680217743f,0.3228601813316345f,0.0332203172147274f,0.2297382652759552f,-0.027234435081481934f,0.19620582461357117f,0.5105021595954895f,-0.2599649131298065f,0.46021199226379395f,0.22599837183952332f,-0.19671492278575897f,-0.42742612957954407f,1.1836682558059692f,0.36187446117401123f,0.5138288736343384f,0.18685299158096313f,-0.2531542181968689f,0.1453099399805069f,-0.21812304854393005f,-0.39502590894699097f}, |
Lightvalve | 111:93289db9e77a | 243 | {0.1379433274269104f,-0.16078773140907288f,0.11784148216247559f,0.2671110928058624f,0.2693568766117096f,0.19759181141853333f,0.06530535221099854f,0.17868870496749878f,0.040603965520858765f,-0.2119520902633667f,0.10295850783586502f,-0.24434831738471985f,-0.07898660004138947f,0.2554645240306854f,-0.22247430682182312f,-0.0708579272031784f,0.18204066157341003f,0.2297056019306183f,0.06115982308983803f,0.05284380912780762f,-0.1371152102947235f,-0.2681243121623993f,0.26029130816459656f,0.2647087275981903f,0.1412506401538849f,0.06283321231603622f,-0.21213923394680023f,0.10197556018829346f,-0.08671019971370697f,-0.019541800022125244f,0.30332449078559875f,0.15016543865203857f}, |
Lightvalve | 111:93289db9e77a | 244 | {0.09298902750015259f,0.2841971218585968f,-0.0814327746629715f,-0.004546761512756348f,-0.017610490322113037f,0.11057800054550171f,-0.2580227553844452f,0.20642486214637756f,-0.2925014793872833f,0.022429823875427246f,-0.12513165175914764f,-0.03889060020446777f,-0.2097223699092865f,-0.0455944687128067f,0.05468165874481201f,0.21256521344184875f,0.1296386420726776f,0.027322769165039062f,0.21420390903949738f,-0.00265491078607738f,0.25592145323753357f,0.094583660364151f,0.06231796741485596f,0.14984634518623352f,0.0016440619947388768f,0.19629231095314026f,-0.11899665743112564f,-0.0703510046005249f,0.14345040917396545f,-0.11986468732357025f,-0.19420018792152405f,0.15971584618091583f}, |
Lightvalve | 111:93289db9e77a | 245 | {-0.3046504855155945f,0.29651907086372375f,0.02990397810935974f,-0.03183019161224365f,0.1826970875263214f,-0.3265538811683655f,0.07501926273107529f,0.2442450225353241f,-0.2325194776058197f,-0.2458522766828537f,0.018704747781157494f,-0.38437169790267944f,-0.3373197913169861f,-0.3312181234359741f,-0.013611641712486744f,0.3175368010997772f,0.2577105462551117f,0.11064860224723816f,-0.11973225325345993f,-0.03098919801414013f,0.5338805913925171f,-0.12447201460599899f,-0.07374785840511322f,-0.023094283416867256f,-0.32630613446235657f,-0.2182334065437317f,-0.22194145619869232f,0.5075826644897461f,-0.2205982804298401f,0.3471736013889313f,-0.1669490486383438f,0.09966504573822021f}, |
Lightvalve | 111:93289db9e77a | 246 | {0.2703488767147064f,-0.16041381657123566f,0.12738299369812012f,-0.03611093759536743f,0.1169431209564209f,0.1861400008201599f,-0.1364862620830536f,0.28177282214164734f,0.1474648416042328f,-0.23766008019447327f,0.004555181600153446f,0.10335490852594376f,0.09594401717185974f,-0.128192737698555f,-0.16805587708950043f,-0.058941617608070374f,-0.22846683859825134f,0.08700510859489441f,-0.3110695779323578f,0.07154610753059387f,-0.19406995177268982f,0.17978695034980774f,-0.18301571905612946f,-0.17816279828548431f,-0.01392077561467886f,0.24960367381572723f,0.14883331954479218f,-0.26011598110198975f,0.08541131019592285f,0.08213254809379578f,-0.29332536458969116f,0.08477649092674255f}, |
Lightvalve | 111:93289db9e77a | 247 | {-0.06283275783061981f,-0.26753589510917664f,-0.10381917655467987f,-0.13344663381576538f,0.2644997537136078f,0.2204643189907074f,0.2924788296222687f,-0.17931663990020752f,-0.09078609943389893f,-0.17306232452392578f,0.02247890830039978f,-0.26996222138404846f,0.22075030207633972f,-0.3029964864253998f,0.21873190999031067f,-0.0030784308910369873f,0.18228653073310852f,0.09971508383750916f,-0.242676243185997f,-0.1424383968114853f,0.19031599164009094f,0.3004438579082489f,-0.23650792241096497f,-0.2683113217353821f,0.29957786202430725f,0.08561205863952637f,-0.1366746425628662f,-0.15950153768062592f,-0.07675467431545258f,-0.2218506634235382f,-0.2795913517475128f,0.1869203746318817f}, |
Lightvalve | 111:93289db9e77a | 248 | {0.2003176510334015f,-0.27792131900787354f,0.055196613073349f,-0.27959588170051575f,0.18430876731872559f,-0.05316638946533203f,0.16156336665153503f,-0.18850930035114288f,0.09482413530349731f,0.021483391523361206f,0.009039878845214844f,0.1586727499961853f,0.11457142233848572f,0.2876913249492645f,-0.24802550673484802f,0.14089101552963257f,-0.06842575967311859f,-0.10107968747615814f,0.06239110231399536f,-0.2528536915779114f,-0.27538973093032837f,0.15457189083099365f,-0.15549622476100922f,0.20245882868766785f,0.08544808626174927f,0.22650876641273499f,-0.05268847942352295f,0.20387354493141174f,0.24724552035331726f,0.21444126963615417f,0.05186706781387329f,-0.11084021627902985f}, |
Lightvalve | 111:93289db9e77a | 249 | {-0.19810965657234192f,0.2745245397090912f,0.1767616868019104f,0.19752147793769836f,0.0650932788848877f,0.29138168692588806f,-0.29061684012413025f,0.010446667671203613f,0.025284886360168457f,-0.10202452540397644f,-0.10358673334121704f,0.14746251702308655f,0.15136101841926575f,0.04500553011894226f,-0.2497977316379547f,-0.29277902841567993f,0.02556520700454712f,-0.09509801864624023f,0.16731274127960205f,-0.25266408920288086f,-0.3004688322544098f,-0.19769597053527832f,-0.14847496151924133f,0.3053832948207855f,0.07563886046409607f,-0.10258816182613373f,-0.060128673911094666f,0.0016401112079620361f,-0.29647189378738403f,-0.18869297206401825f,0.05497395992279053f,0.16092956066131592f}, |
Lightvalve | 111:93289db9e77a | 250 | {-0.15637615323066711f,-0.25281068682670593f,-0.10565309226512909f,-0.10091940313577652f,0.2702934443950653f,-0.12188331037759781f,-2.6136996746063232f,-0.25967976450920105f,-0.06814777851104736f,-0.24531681835651398f,-2.7855517864227295f,-0.44459834694862366f,-0.14011120796203613f,-0.2579585015773773f,-0.11229091882705688f,2.0105178356170654f,0.2015441358089447f,0.04417389631271362f,-0.8707115650177002f,-0.0422603040933609f,-0.018271639943122864f,0.2930816113948822f,-0.3977648913860321f,0.06869768351316452f,-0.48196402192115784f,0.31018897891044617f,1.4650862216949463f,0.009573257528245449f,-0.18211489915847778f,-0.1956188827753067f,0.20075061917304993f,0.3793351352214813f}, |
Lightvalve | 111:93289db9e77a | 251 | {-0.10580866038799286f,-0.17215237021446228f,-0.01352420449256897f,-0.13443149626255035f,-0.10265451669692993f,-0.2169143706560135f,0.30098411440849304f,-0.2986297905445099f,0.07908004522323608f,-0.30061498284339905f,0.10424068570137024f,-0.018799901008605957f,-0.18665757775306702f,0.005998075008392334f,-0.2969498336315155f,0.18525955080986023f,0.2379322350025177f,0.15184926986694336f,0.215760737657547f,-0.19088758528232574f,0.08620095252990723f,0.019999295473098755f,-0.0752219706773758f,0.11181813478469849f,0.1881926953792572f,0.2210972011089325f,0.13236162066459656f,-0.06690356135368347f,-0.18345263600349426f,-0.14861416816711426f,0.08577704429626465f,-0.09683996438980103f}, |
Lightvalve | 111:93289db9e77a | 252 | {0.03951254487037659f,0.23604217171669006f,0.012746036052703857f,-0.12561996281147003f,-0.1283164620399475f,0.25823846459388733f,0.10610169172286987f,0.22718152403831482f,0.1749366819858551f,0.007794857025146484f,0.11289489269256592f,0.2725127637386322f,-0.13616766035556793f,-0.03546282649040222f,-0.1685536652803421f,-0.24492129683494568f,0.15760570764541626f,0.017505377531051636f,-0.273531436920166f,-0.005667984485626221f,0.18370777368545532f,-0.023328542709350586f,0.2379932701587677f,-0.048420339822769165f,0.10376441478729248f,-0.295401930809021f,-0.20498433709144592f,0.22346952557563782f,-0.26649031043052673f,-0.08466874063014984f,0.23347875475883484f,-0.03380200266838074f}, |
Lightvalve | 111:93289db9e77a | 253 | {0.15999209880828857f,-0.11652402579784393f,0.24921879172325134f,0.11206335574388504f,-0.2817712128162384f,-0.3927578926086426f,0.47195965051651f,-0.2109193652868271f,0.23963233828544617f,0.21321198344230652f,0.9258071184158325f,0.47440096735954285f,-0.2849869430065155f,-0.49865594506263733f,-0.33074653148651123f,-2.5518927574157715f,-0.19791248440742493f,0.2487291395664215f,-0.1334983855485916f,-0.4086945354938507f,0.11785566061735153f,1.3073023557662964f,-0.24917633831501007f,-0.2951982319355011f,-0.6017857789993286f,-1.8852335214614868f,0.1603051871061325f,-0.43356651067733765f,-0.03476092219352722f,0.08698701113462448f,0.004408210515975952f,-0.15619716048240662f}, |
Lightvalve | 111:93289db9e77a | 254 | {-0.2073071002960205f,0.009595632553100586f,0.2466227114200592f,0.01420392282307148f,-0.29828932881355286f,-0.5331715941429138f,-0.351082980632782f,-0.3080124258995056f,-0.2516406178474426f,0.012286126613616943f,0.6112899780273438f,0.06557812541723251f,-0.22805161774158478f,-0.824340283870697f,-0.21592645347118378f,0.243668332695961f,-0.24087269604206085f,-0.048499464988708496f,0.11424211412668228f,-0.1290813535451889f,0.7858151197433472f,-0.20150215923786163f,-0.17926840484142303f,0.07562501728534698f,-0.21125690639019012f,-0.005384568590670824f,-0.3091275095939636f,0.06718768924474716f,-0.07090267539024353f,-0.24390411376953125f,-0.2543276250362396f,-0.018764320760965347f}, |
Lightvalve | 111:93289db9e77a | 255 | {-0.01348048448562622f,0.08233943581581116f,0.18838337063789368f,0.21852442622184753f,-0.04740855097770691f,0.19177213311195374f,-0.0060100555419921875f,0.20933791995048523f,0.06356173753738403f,0.063028484582901f,0.09440034627914429f,0.29559019207954407f,-0.2545689642429352f,-0.09652335941791534f,-0.2841038703918457f,-0.03553757071495056f,0.02329021692276001f,-0.08720272779464722f,-0.0750999003648758f,-0.10468094050884247f,-0.03761094808578491f,-0.030853450298309326f,0.2112145721912384f,0.2599640190601349f,-0.2969062626361847f,-0.13667742908000946f,0.24173608422279358f,0.09566575288772583f,0.021116197109222412f,-0.005982398986816406f,-0.26417285203933716f,0.1879688799381256f}, |
Lightvalve | 111:93289db9e77a | 256 | {-0.25928929448127747f,-0.17203155159950256f,0.0620841383934021f,0.01778830587863922f,-0.07396678626537323f,-0.34411129355430603f,0.14942871034145355f,-0.0022616139613091946f,-0.21029016375541687f,0.2210421860218048f,-1.8161520957946777f,-5.139366626739502f,-0.2357577234506607f,-0.010392035357654095f,-0.446238249540329f,-1.4517326354980469f,0.10771593451499939f,-0.29308468103408813f,-5.485420227050781f,-0.1598595678806305f,-1.2829571962356567f,0.08762194961309433f,-0.22302524745464325f,-0.03663624823093414f,-1.5755536556243896f,2.0357444286346436f,-0.38451701402664185f,1.2428606748580933f,0.17976179718971252f,-0.38860374689102173f,0.28763797879219055f,0.08446511626243591f}, |
Lightvalve | 111:93289db9e77a | 257 | {-0.09888127446174622f,-0.22750279307365417f,-0.22503364086151123f,-0.008032619953155518f,-0.012498408555984497f,-0.24329537153244019f,-0.1042325496673584f,0.08175003528594971f,-0.016126900911331177f,0.06972584128379822f,0.05885356292128563f,0.20356176793575287f,-0.031845152378082275f,-0.33328720927238464f,0.18349257111549377f,0.20412376523017883f,-0.09216172993183136f,0.04617339372634888f,-0.06279236078262329f,-0.06833663582801819f,-0.0014530055923387408f,-0.25417202711105347f,-0.06047184765338898f,-0.28923499584198f,-0.00548509368672967f,-0.18183766305446625f,0.3139438033103943f,-0.2903735339641571f,-0.16326025128364563f,0.11664235591888428f,-0.02675291895866394f,0.1267804503440857f}, |
Lightvalve | 65:a2d7c63419c2 | 258 | }; |
Lightvalve | 65:a2d7c63419c2 | 259 | |
Lightvalve | 111:93289db9e77a | 260 | const float h3[32][32] = { |
Lightvalve | 111:93289db9e77a | 261 | {-0.2551194727420807f,-0.09101890027523041f,-0.1038413718342781f,-0.24469062685966492f,-0.05910690873861313f,-0.019935453310608864f,0.23563924431800842f,0.21467849612236023f,-0.11617054045200348f,0.034586966037750244f,-0.08393588662147522f,0.28293344378471375f,0.1244959682226181f,0.16114790737628937f,-0.2476848065853119f,0.13452908396720886f,0.033751994371414185f,0.2061004936695099f,-0.022569477558135986f,-0.10083381831645966f,-0.06274953484535217f,-0.005423676688224077f,-0.14093638956546783f,0.044178664684295654f,0.22429867088794708f,-0.1258748173713684f,0.318147212266922f,-0.1978805810213089f,0.08456003665924072f,0.2922307550907135f,-0.21407078206539154f,-0.1853330433368683f}, |
Lightvalve | 111:93289db9e77a | 262 | {0.05588451027870178f,0.19731858372688293f,-0.055143773555755615f,0.030042022466659546f,-0.13887283205986023f,-0.1361943781375885f,-0.2855546772480011f,0.011247634887695312f,0.1085631251335144f,0.021339505910873413f,0.17599248886108398f,0.09762296080589294f,-0.05771490931510925f,-0.14660483598709106f,-0.21469902992248535f,0.03876742720603943f,-0.21865856647491455f,-0.12651903927326202f,0.22753819823265076f,-0.23926785588264465f,-0.14443452656269073f,0.06739777326583862f,0.14157342910766602f,0.049514561891555786f,-0.1251431256532669f,-0.25851932168006897f,0.0932874083518982f,0.2900666892528534f,-0.023782014846801758f,0.050485759973526f,0.09447437524795532f,0.0058679282665252686f}, |
Lightvalve | 111:93289db9e77a | 263 | {-0.2800689935684204f,-0.038760632276535034f,0.13974270224571228f,0.01585569977760315f,0.11945047974586487f,-0.19458696246147156f,0.11322265863418579f,0.25643888115882874f,-0.061097174882888794f,-0.07816044986248016f,-0.07445238530635834f,-0.22145158052444458f,-0.1081896424293518f,-0.09452249109745026f,0.16234496235847473f,0.1413259506225586f,-0.2648085951805115f,-0.054869145154953f,-0.05491623282432556f,0.17325228452682495f,0.23639705777168274f,0.0748760998249054f,-0.1324603259563446f,0.15828460454940796f,-0.22871175408363342f,-0.027338534593582153f,-0.06307074427604675f,0.13438841700553894f,0.13834497332572937f,0.1633671224117279f,0.259930282831192f,-0.21565306186676025f}, |
Lightvalve | 111:93289db9e77a | 264 | {0.2906629145145416f,0.19203472137451172f,-0.2048129439353943f,0.2633720338344574f,0.05571131780743599f,-0.10277977585792542f,-0.061309605836868286f,-0.17915479838848114f,-0.02168092131614685f,-0.044261813163757324f,-0.09506386518478394f,0.24970653653144836f,0.19422964751720428f,0.07040172815322876f,0.22106656432151794f,-0.23978039622306824f,-0.28915077447891235f,0.030949801206588745f,-0.2734605371952057f,0.1836264431476593f,0.217695951461792f,-0.05513932183384895f,-0.16484108567237854f,-0.27595841884613037f,0.1793176233768463f,-0.11024686694145203f,-0.06155381724238396f,0.029482178390026093f,-0.1661308854818344f,-0.25852420926094055f,0.05653107166290283f,0.0037463903427124023f}, |
Lightvalve | 111:93289db9e77a | 265 | {0.07563930749893188f,-0.0864691436290741f,-0.2677825689315796f,0.1497999131679535f,-0.2632053792476654f,-0.12118913233280182f,-0.09772239625453949f,0.2470131814479828f,-0.2551872134208679f,-0.2740214169025421f,0.2979947626590729f,-0.24627932906150818f,-0.23258495330810547f,-0.1546318233013153f,0.06802645325660706f,-0.048776447772979736f,0.20131775736808777f,0.013118326663970947f,0.0808630883693695f,0.2585393488407135f,-0.03326711058616638f,0.21529874205589294f,0.1718432903289795f,0.20571765303611755f,-0.19813477993011475f,0.12758469581604004f,0.2959180772304535f,-0.20305807888507843f,0.17249789834022522f,-0.09959287941455841f,-0.07189898192882538f,0.007399916648864746f}, |
Lightvalve | 111:93289db9e77a | 266 | {0.10931676626205444f,0.2396949827671051f,0.02465958334505558f,-0.01787710189819336f,-0.18189938366413116f,0.04702233150601387f,-0.061815500259399414f,0.04091137647628784f,-0.1548205316066742f,-0.15699732303619385f,0.08972057700157166f,-0.21529507637023926f,-0.09960521757602692f,-0.18788893520832062f,0.2971965968608856f,0.25175121426582336f,-0.2889891266822815f,-0.13035915791988373f,0.16576141119003296f,0.06524023413658142f,0.043987397104501724f,-0.29416441917419434f,-0.08076366037130356f,0.27409639954566956f,-0.17873622477054596f,-0.18302330374717712f,0.012964649125933647f,0.05726006254553795f,-0.27729424834251404f,-0.29547566175460815f,-0.25800079107284546f,0.24402263760566711f}, |
Lightvalve | 111:93289db9e77a | 267 | {-0.21155381202697754f,0.08702024817466736f,0.39014747738838196f,-0.1001071110367775f,-1.509809970855713f,0.019517995417118073f,0.024466078728437424f,0.2444917857646942f,0.1586996465921402f,-0.3482595980167389f,-0.07352845370769501f,-0.25618287920951843f,-0.42223870754241943f,1.3170944452285767f,0.25543639063835144f,-0.1192857176065445f,-0.18917083740234375f,0.011466026306152344f,0.09649982303380966f,0.45830419659614563f,-2.3485023975372314f,0.0407455638051033f,-1.0573325157165527f,-0.32043763995170593f,0.1070551797747612f,-0.2910519242286682f,-2.1807496547698975f,-1.105339527130127f,1.697184443473816f,-0.09532724320888519f,0.3623135983943939f,0.048518333584070206f}, |
Lightvalve | 111:93289db9e77a | 268 | {-0.01093912124633789f,-0.23583689332008362f,0.28153905272483826f,0.2877257764339447f,0.061600930988788605f,-0.23844322562217712f,0.036741942167282104f,-0.0059101879596710205f,-0.2663145065307617f,-0.27182313799858093f,0.09319102764129639f,-0.08139897882938385f,0.17758730053901672f,-0.0009110257960855961f,0.0685860812664032f,-0.29903873801231384f,0.1317853033542633f,0.20550194382667542f,-0.13298553228378296f,-0.30602920055389404f,0.2254093587398529f,0.1367388367652893f,0.0343703031539917f,0.12564969062805176f,0.05320189520716667f,0.23886635899543762f,-0.2778390347957611f,0.11170581728219986f,0.28547611832618713f,0.17161712050437927f,-0.04008360207080841f,-0.0665527880191803f}, |
Lightvalve | 111:93289db9e77a | 269 | {-0.20420776307582855f,0.1970202624797821f,0.23591408133506775f,-0.282694011926651f,0.09019026160240173f,0.20012763142585754f,0.028453975915908813f,0.23323127627372742f,0.15246456861495972f,-0.1270071268081665f,0.20025727152824402f,0.13077861070632935f,-0.2238168716430664f,-0.20709244906902313f,-0.0045506954193115234f,-0.16448761522769928f,0.28163614869117737f,0.1971360743045807f,0.30405697226524353f,-0.28959211707115173f,-0.2255709171295166f,0.15360668301582336f,0.24163606762886047f,0.19554737210273743f,-0.1804599016904831f,0.07604315876960754f,-0.1459394246339798f,-0.14081311225891113f,-0.29656586050987244f,0.19529584050178528f,-0.05168652534484863f,-0.03415781259536743f}, |
Lightvalve | 111:93289db9e77a | 270 | {0.27550336718559265f,-0.14170598983764648f,-0.21542268991470337f,-0.2159879207611084f,0.06500789523124695f,-0.21155211329460144f,-0.01575431227684021f,0.0617731511592865f,0.13126209378242493f,-0.04922589659690857f,-0.23877641558647156f,-0.06292802095413208f,0.01433342695236206f,0.14592674374580383f,-0.23886999487876892f,0.08878573775291443f,0.1853090226650238f,-0.05102238059043884f,-0.13667166233062744f,-0.24401302635669708f,0.25155118107795715f,-0.20339438319206238f,0.03535670042037964f,0.048473477363586426f,-0.13871997594833374f,-0.15382859110832214f,-0.13837768137454987f,0.26085415482521057f,0.2491457164287567f,0.157204270362854f,0.14108964800834656f,0.12518465518951416f}, |
Lightvalve | 111:93289db9e77a | 271 | {-0.023678362369537354f,0.25109460949897766f,0.518004298210144f,-0.04508405923843384f,-1.1028227806091309f,0.33101585507392883f,-0.3883363902568817f,0.05021946132183075f,0.21238431334495544f,-0.10546183586120605f,0.006881891284137964f,-0.20401835441589355f,-1.6200649738311768f,0.7370647192001343f,0.080221027135849f,-0.2471318244934082f,-0.04395067319273949f,0.13874845206737518f,0.17284107208251953f,-0.4248747229576111f,0.20761384069919586f,-0.6041054129600525f,-0.36403846740722656f,0.1122751235961914f,-0.15158990025520325f,-0.25962090492248535f,-0.007933800108730793f,-0.5516619682312012f,-5.667965412139893f,-0.2912617325782776f,-0.8348024487495422f,-0.5746976137161255f}, |
Lightvalve | 111:93289db9e77a | 272 | {0.2680447995662689f,0.09882985055446625f,-0.6560987234115601f,-0.1302778571844101f,-1.4513405561447144f,0.18741083145141602f,0.061859551817178726f,-0.17794576287269592f,-0.379161536693573f,-0.2937159240245819f,-0.279714971780777f,0.10801465809345245f,-1.219778060913086f,-0.015511374920606613f,0.23152390122413635f,-0.07731422781944275f,0.13388042151927948f,-0.15284278988838196f,0.17393893003463745f,0.06855621188879013f,-1.465748906135559f,0.45337602496147156f,-1.0523481369018555f,0.12623250484466553f,-0.6691119074821472f,0.18312275409698486f,-0.5229504704475403f,-0.3798335790634155f,0.9462501406669617f,-0.1739533692598343f,-0.4351639151573181f,-0.4671085774898529f}, |
Lightvalve | 111:93289db9e77a | 273 | {0.10771462321281433f,0.1270637810230255f,-0.1647956818342209f,-0.00161704421043396f,0.019556356593966484f,0.2866024971008301f,-0.2502448558807373f,-0.05063694715499878f,-0.36160364747047424f,-0.11501708626747131f,0.24353471398353577f,0.11519002914428711f,-0.1879904866218567f,0.1574537307024002f,-0.0055807530879974365f,0.05870962142944336f,-0.0561012327671051f,-0.1419317126274109f,-0.24982497096061707f,-0.05947013199329376f,-0.25784793496131897f,-0.17594656348228455f,0.2986377775669098f,-0.2888573110103607f,-0.055695902556180954f,-0.03866580128669739f,0.09892630577087402f,0.07635774463415146f,0.1267586350440979f,0.024399906396865845f,-0.264041006565094f,-0.037910252809524536f}, |
Lightvalve | 111:93289db9e77a | 274 | {0.07240793108940125f,-0.09701454639434814f,0.039337895810604095f,0.03731954097747803f,-1.2952196598052979f,0.31061816215515137f,0.0445791557431221f,-0.22556400299072266f,-0.00572578189894557f,-0.49267953634262085f,-0.0712733268737793f,-0.23462167382240295f,0.07827995717525482f,-1.054482102394104f,0.13272255659103394f,-0.2217404991388321f,-0.2052614688873291f,0.09794799238443375f,0.05880702659487724f,-0.1727823168039322f,-0.8321938514709473f,-0.5420005917549133f,-1.7485554218292236f,0.13367779552936554f,-0.47536078095436096f,-0.1976800560951233f,-0.24397990107536316f,-0.5303009748458862f,-1.7824138402938843f,-0.29330405592918396f,-0.17450043559074402f,-0.5055950284004211f}, |
Lightvalve | 111:93289db9e77a | 275 | {-0.27890223264694214f,0.08861199021339417f,-0.007417040877044201f,0.20657816529273987f,-0.11464163661003113f,0.07223925739526749f,-0.2505151033401489f,-0.2674597501754761f,-0.22628344595432281f,0.11670660972595215f,0.020896315574645996f,0.04456409811973572f,0.07362725585699081f,0.2750687599182129f,-0.02410009503364563f,0.10129088163375854f,0.22686699032783508f,-0.30486053228378296f,0.09699136018753052f,0.11117806285619736f,0.1420062631368637f,0.0915948823094368f,-0.14579914510250092f,0.11354613304138184f,0.15078094601631165f,-0.025903940200805664f,-0.16701389849185944f,-0.09537258744239807f,0.24030038714408875f,0.06508117914199829f,0.02118399739265442f,-0.003070831298828125f}, |
Lightvalve | 111:93289db9e77a | 276 | {0.3047083914279938f,0.09637480229139328f,0.6663159728050232f,-0.3968810439109802f,1.394707202911377f,1.1879960298538208f,-0.31533196568489075f,-0.25786101818084717f,-0.45381349325180054f,0.002715438837185502f,-0.12802965939044952f,-0.21325801312923431f,1.652679681777954f,-0.20448876917362213f,0.062144935131073f,-0.28920799493789673f,0.03473195433616638f,-0.147878959774971f,-0.051286373287439346f,-0.46827998757362366f,-1.1367347240447998f,0.43894249200820923f,0.9637669324874878f,-0.10900285840034485f,-0.21752621233463287f,-0.031148135662078857f,0.5380248427391052f,0.13976286351680756f,-1.1275972127914429f,0.017086774110794067f,-0.03652779012918472f,-0.2557351291179657f}, |
Lightvalve | 111:93289db9e77a | 277 | {-0.06136500835418701f,-0.11579577624797821f,-0.23311558365821838f,-0.020844489336013794f,0.161813884973526f,0.22929790616035461f,0.11958792805671692f,-0.0384809672832489f,-0.10647237300872803f,-0.09010881185531616f,0.22322741150856018f,-0.1071339100599289f,0.05349445343017578f,-0.23458370566368103f,0.040097206830978394f,0.08616101741790771f,-0.15468145906925201f,-0.21275553107261658f,-0.21210846304893494f,-0.23840199410915375f,0.12352427840232849f,0.282552570104599f,0.14114680886268616f,0.09007054567337036f,-0.05948364734649658f,0.12031787633895874f,-0.184563547372818f,0.07786750793457031f,-0.2169322669506073f,-0.24735762178897858f,-0.0892629474401474f,-0.11765947937965393f}, |
Lightvalve | 111:93289db9e77a | 278 | {0.1169951856136322f,0.06741076707839966f,0.014288008213043213f,-0.1894388198852539f,0.2306886613368988f,0.08970087766647339f,0.29362860321998596f,0.2666439712047577f,-0.1488228738307953f,0.22382596135139465f,-0.1313140094280243f,0.02602824568748474f,0.029441386461257935f,-0.1546926349401474f,0.10762849450111389f,0.06951633095741272f,0.0639207661151886f,0.27696695923805237f,-0.2749756872653961f,0.2684275209903717f,-0.240950807929039f,-0.08405844867229462f,0.26762983202934265f,0.09600964188575745f,-0.20394444465637207f,0.012219250202178955f,-0.09225042164325714f,-0.12637756764888763f,-0.21354423463344574f,-0.29393887519836426f,-0.056166648864746094f,0.002250969409942627f}, |
Lightvalve | 111:93289db9e77a | 279 | {-0.16101892292499542f,0.08832049369812012f,0.7218345403671265f,0.14346855878829956f,1.6714346408843994f,-0.40862950682640076f,0.020126188173890114f,-0.17396175861358643f,1.6681544780731201f,-0.1594701111316681f,0.060176216065883636f,-0.1897185742855072f,0.33592286705970764f,-0.6470072865486145f,-0.2592318058013916f,0.05000441148877144f,0.10359722375869751f,0.14719179272651672f,-0.2130231410264969f,-0.19025570154190063f,1.1770896911621094f,-0.31014513969421387f,1.5579278469085693f,0.13123968243598938f,-0.41480347514152527f,-0.28873488306999207f,1.026596188545227f,0.388054221868515f,-0.5821989178657532f,0.18439257144927979f,-0.1099272072315216f,-0.19634971022605896f}, |
Lightvalve | 111:93289db9e77a | 280 | {0.261911004781723f,-0.2460976243019104f,-0.2993849217891693f,-0.0216875858604908f,0.0666251853108406f,-0.01244714017957449f,-0.06670857965946198f,-0.030254334211349487f,-0.2842422127723694f,0.1197996437549591f,0.01667046546936035f,-0.2924177646636963f,0.27609601616859436f,-0.1634647399187088f,-0.20773646235466003f,-0.10781967639923096f,-0.15712574124336243f,0.16112294793128967f,0.226307213306427f,0.1923319399356842f,0.19387927651405334f,0.08757619559764862f,-0.06879205256700516f,0.14906415343284607f,0.11202559620141983f,0.0025720298290252686f,0.172196626663208f,-0.1669369786977768f,0.09279179573059082f,0.21125611662864685f,-0.05751854181289673f,-0.22727590799331665f}, |
Lightvalve | 111:93289db9e77a | 281 | {0.14277681708335876f,-0.3658076822757721f,-0.5719888806343079f,-0.4293256402015686f,-2.0242974758148193f,0.4469848573207855f,0.3269858956336975f,-0.27022814750671387f,0.06979308277368546f,-0.4726024866104126f,-0.2715148627758026f,0.050719037652015686f,-0.4272148907184601f,0.38357505202293396f,-0.03100520372390747f,-0.2484396994113922f,-0.012858442030847073f,-0.2764144539833069f,0.12210605293512344f,-0.19511310756206512f,-1.1714394092559814f,0.24047309160232544f,0.9077915549278259f,-0.20270410180091858f,0.09234108775854111f,-0.19159743189811707f,0.6707311272621155f,-0.1395704746246338f,-0.5330768823623657f,-0.10488687455654144f,-0.8295623660087585f,-0.08823436498641968f}, |
Lightvalve | 111:93289db9e77a | 282 | {0.29069945216178894f,-0.39432209730148315f,-0.7187185287475586f,-1.2350605726242065f,0.33998313546180725f,-0.7123181223869324f,-0.00625432888045907f,-0.2674146592617035f,-1.0739837884902954f,-0.19378143548965454f,-0.3571389317512512f,-0.23599010705947876f,0.41418182849884033f,-0.7971703410148621f,0.09875330328941345f,-0.038175541907548904f,0.15272922813892365f,-0.009927275590598583f,-0.30229559540748596f,-0.29054272174835205f,-0.3118758201599121f,-1.000040888786316f,0.6674321889877319f,-0.2809290885925293f,-0.36089688539505005f,0.023651927709579468f,0.48456552624702454f,0.6994032263755798f,0.43271538615226746f,0.19045329093933105f,-0.4914795756340027f,-0.6128694415092468f}, |
Lightvalve | 111:93289db9e77a | 283 | {0.1991647183895111f,0.12534403800964355f,-0.04112154245376587f,0.23123982548713684f,-0.2870309352874756f,-0.17046742141246796f,-0.1610087752342224f,-0.031804412603378296f,0.007328375708311796f,-0.25018924474716187f,0.15975651144981384f,-0.057292819023132324f,0.021193383261561394f,0.19422577321529388f,0.2151305377483368f,0.2952744662761688f,-0.21319252252578735f,0.04970458149909973f,0.10210192203521729f,0.3050673305988312f,0.14308568835258484f,-0.03906850144267082f,0.013936702162027359f,0.25299301743507385f,0.01011967658996582f,-0.07015113532543182f,-0.42569056153297424f,-0.1553160846233368f,-0.07337476313114166f,-0.24420931935310364f,0.015819430351257324f,-0.10595546662807465f}, |
Lightvalve | 111:93289db9e77a | 284 | {0.12202468514442444f,0.10608518123626709f,-0.23480777442455292f,-0.2956502139568329f,0.19210411608219147f,0.006585080176591873f,-0.06113804876804352f,-0.11568751931190491f,0.2989203929901123f,-0.3037929832935333f,-0.06917986273765564f,-0.11160935461521149f,-0.21990501880645752f,-0.07006501406431198f,-0.06735922396183014f,0.05864924192428589f,-0.25733181834220886f,-0.17565661668777466f,0.05582946538925171f,-0.17989838123321533f,-0.22137431800365448f,0.28839531540870667f,0.10811747610569f,-0.05681343376636505f,0.1227402538061142f,0.1795230209827423f,0.3393796384334564f,0.07415845990180969f,-0.17302250862121582f,0.2425754964351654f,-0.22172409296035767f,-0.009572982788085938f}, |
Lightvalve | 111:93289db9e77a | 285 | {-0.3055141270160675f,-0.25011783838272095f,0.7311385273933411f,-0.24157972633838654f,-1.0624009370803833f,0.26226386427879333f,-0.17178095877170563f,0.06810887902975082f,-0.06822292506694794f,-0.18939678370952606f,-0.44836026430130005f,-0.1535065621137619f,-0.18740224838256836f,-0.23460710048675537f,-0.023131370544433594f,-0.11770424991846085f,0.08485811203718185f,-0.09997666627168655f,-0.26266708970069885f,-0.49668270349502563f,-0.11813896894454956f,-0.524924099445343f,0.38801339268684387f,0.03961586579680443f,-0.09372541308403015f,-0.02825927734375f,-0.2623272240161896f,-0.7227498888969421f,-0.5388938784599304f,0.1865309774875641f,0.11643480509519577f,-0.42531272768974304f}, |
Lightvalve | 111:93289db9e77a | 286 | {0.1782623827457428f,-0.03538484498858452f,-2.431919574737549f,-0.103914275765419f,-0.7199633121490479f,0.42455410957336426f,-0.33633333444595337f,0.025226306170225143f,-0.2375945746898651f,-0.061203453689813614f,-0.5022079944610596f,-0.3804698884487152f,0.46265190839767456f,0.6709904074668884f,-0.2527656555175781f,-0.4420746862888336f,-0.04571865499019623f,-0.36618950963020325f,-0.056735262274742126f,-0.5319806933403015f,-0.6619629263877869f,-0.8369379639625549f,-0.6938261985778809f,-0.09400374442338943f,-0.14996914565563202f,0.10029953718185425f,0.02721080556511879f,0.43922027945518494f,-0.2712918817996979f,0.1616479754447937f,-0.5210545659065247f,-0.32401105761528015f}, |
Lightvalve | 111:93289db9e77a | 287 | {-0.17396044731140137f,-0.2784900963306427f,-1.1768723726272583f,-0.046097531914711f,-0.025720056146383286f,-0.18957148492336273f,-0.25938647985458374f,-0.1761629432439804f,-0.3817882835865021f,-0.5976799130439758f,0.0671951025724411f,-0.38622695207595825f,0.7638773322105408f,0.6625755429267883f,-0.19851773977279663f,-0.10762731730937958f,0.06343308091163635f,0.10370296239852905f,-0.03213166445493698f,-0.4327969253063202f,-0.14362405240535736f,-1.094070315361023f,0.3622768521308899f,-0.3478490114212036f,0.477831095457077f,-0.2665709853172302f,0.46150633692741394f,-0.02370193414390087f,-0.25181710720062256f,-0.1200934648513794f,-0.42438045144081116f,-0.5009611248970032f}, |
Lightvalve | 111:93289db9e77a | 288 | {-0.12546227872371674f,-0.20327019691467285f,-0.7674700021743774f,0.0025170135777443647f,-0.37905335426330566f,0.7628586888313293f,-0.550694465637207f,-0.16460397839546204f,-1.1577268838882446f,-0.1461954414844513f,-0.19499319791793823f,-0.17696864902973175f,-0.7150746583938599f,-0.6856591701507568f,-0.0649729073047638f,0.09420866519212723f,0.060016900300979614f,-0.3138718008995056f,0.03891023248434067f,-0.25645461678504944f,0.5847378969192505f,0.3709615170955658f,-0.08535157144069672f,0.12858858704566956f,-0.40651488304138184f,0.020356476306915283f,-0.19646024703979492f,0.6749417781829834f,-0.019949205219745636f,-0.000007510185241699219f,-0.01171192992478609f,-0.2876005470752716f}, |
Lightvalve | 111:93289db9e77a | 289 | {0.07555973529815674f,-0.0029259920120239258f,-0.08789914846420288f,0.06678077578544617f,-0.11083845794200897f,0.11010000109672546f,-0.14982634782791138f,0.12075316905975342f,-0.2766430675983429f,0.013024389743804932f,0.18159812688827515f,-0.20200279355049133f,0.2637675702571869f,-0.1856893002986908f,0.2882818281650543f,0.05304515361785889f,-0.15297894179821014f,0.07341468334197998f,0.05268138647079468f,0.1067940890789032f,-0.2661813795566559f,-0.2009473443031311f,0.1843600869178772f,0.2517976462841034f,-0.07343396544456482f,-0.051110416650772095f,-0.23432010412216187f,0.16746872663497925f,-0.2205146849155426f,-0.017525076866149902f,0.20926335453987122f,-0.2141496241092682f}, |
Lightvalve | 111:93289db9e77a | 290 | {0.06582912802696228f,0.2796666920185089f,-0.29963746666908264f,0.0023079216480255127f,0.20337024331092834f,-0.040642574429512024f,0.06556430459022522f,0.29767414927482605f,0.2994321286678314f,-0.16670267283916473f,-0.1203770637512207f,-0.06570860743522644f,-0.0017087480518966913f,0.010199399664998055f,-0.014884740114212036f,-0.05300724506378174f,0.26490333676338196f,0.15243005752563477f,-0.07319167256355286f,0.2962717115879059f,0.33884453773498535f,0.0014916976215317845f,-0.0016991444863379002f,-0.11559568345546722f,-0.21842041611671448f,0.21069613099098206f,-0.12274213880300522f,-0.08704576641321182f,-0.043134164065122604f,-0.2712400257587433f,-0.2183205485343933f,-0.23200613260269165f}, |
Lightvalve | 111:93289db9e77a | 291 | {-0.1299392580986023f,-0.06208275258541107f,-0.18067686259746552f,0.062329649925231934f,-0.22588664293289185f,-0.06877543032169342f,-0.19175797700881958f,0.02903696894645691f,-0.2614779472351074f,0.016345679759979248f,-0.24767392873764038f,0.2033931314945221f,-0.30105409026145935f,0.08271035552024841f,0.13206014037132263f,0.15829482674598694f,-0.21012049913406372f,0.2088232934474945f,0.07014858722686768f,-0.19175665080547333f,0.28649166226387024f,0.05041047930717468f,-0.27260470390319824f,-0.025072306394577026f,0.2722422182559967f,-0.007939159870147705f,-0.22979341447353363f,0.11936154961585999f,0.1298319399356842f,0.18135693669319153f,-0.008151531219482422f,0.15906798839569092f}, |
Lightvalve | 111:93289db9e77a | 292 | {0.07638216018676758f,0.05467941612005234f,-0.30802446603775024f,-0.27756384015083313f,0.5089954137802124f,-0.06644360721111298f,0.2795381247997284f,-0.25668495893478394f,-0.2516498565673828f,0.1293344497680664f,-0.026776641607284546f,0.02524423599243164f,0.13684697449207306f,-0.3884730935096741f,-0.029521822929382324f,-0.19500072300434113f,0.06506577134132385f,-0.011876672506332397f,0.13049617409706116f,0.2874086797237396f,-0.12349185347557068f,0.06480025500059128f,-0.26355814933776855f,-0.17324526607990265f,0.19932076334953308f,0.1901901364326477f,-0.11465026438236237f,0.02828008309006691f,0.4518930912017822f,0.22636333107948303f,-0.21769236028194427f,0.23630231618881226f}, |
Lightvalve | 66:a8e6799dbce3 | 293 | }; |
Lightvalve | 65:a2d7c63419c2 | 294 | |
Lightvalve | 111:93289db9e77a | 295 | const float hout[32] = { 0.3285340666770935f,0.22330839931964874f,-0.10449632257223129f,-0.1374182254076004f,0.3813384771347046f,0.2709670960903168f,-0.05697903409600258f,-0.004911948926746845f,0.20332930982112885f,0.0904858261346817f,0.10222318768501282f,-0.10788039118051529f,-0.1989477574825287f,0.16702288389205933f,0.2356991171836853f,-0.09116881340742111f,0.028592372313141823f,-0.18687331676483154f,0.04106204956769943f,-0.021804936230182648f,0.12847422063350677f,0.007278922479599714f,-0.32173553109169006f,-0.059601761400699615f,0.20722047984600067f,0.2520971894264221f,-0.18482191860675812f,-0.12838873267173767f,-0.15306447446346283f,-0.3257754445075989f,-0.028646055608987808f,-0.07700809091329575f }; |
Lightvalve | 66:a8e6799dbce3 | 296 | |
Lightvalve | 111:93289db9e77a | 297 | const float b1[32] = { 0.5617112517356873f,0.6938236951828003f,-1.7145336866378784f,0.20102094113826752f,1.4396305084228516f,0.8273231983184814f,-0.08430472016334534f,0.9584340453147888f,0.4917953610420227f,-1.3999191522598267f,0.7650651335716248f,1.7081613540649414f,-0.41735661029815674f,-1.2265903949737549f,-1.087764859199524f,1.7399324178695679f,0.5774160623550415f,-0.3081972897052765f,0.22525261342525482f,0.5787962675094604f,-0.34984177350997925f,-1.1118980646133423f,-1.6770726442337036f,-1.2263047695159912f,2.4478845596313477f,-2.0880801677703857f,-1.0489267110824585f,1.045495629310608f,-0.21264487504959106f,-1.0887231826782227f,2.5014867782592773f,-0.4925138056278229f }; |
Lightvalve | 87:471334725012 | 298 | |
Lightvalve | 111:93289db9e77a | 299 | const float b2[32] = { -0.22199000418186188f,-0.7642630338668823f,-1.4564176797866821f,-0.5784978270530701f,-0.6939148902893066f,0.021013928577303886f,0.2593429982662201f,-0.48615601658821106f,-1.20063054561615f,-1.912178635597229f,-0.37001925706863403f,0.7015834450721741f,-0.21979756653308868f,2.167783498764038f,-0.1734119951725006f,0.34847232699394226f,-1.798204779624939f,-1.5844906568527222f,0.7723733186721802f,-0.49491411447525024f,-0.9785985946655273f,0.25206300616264343f,-0.06040634959936142f,-1.3003190755844116f,0.913925290107727f,1.1008470058441162f,0.4028688073158264f,0.26332706212997437f,-0.6323830485343933f,-0.6440863013267517f,-1.178520679473877f,-1.4038468599319458f }; |
Lightvalve | 65:a2d7c63419c2 | 300 | |
Lightvalve | 111:93289db9e77a | 301 | const float b3[32] = { -1.963319182395935f,-0.5200377702713013f,-0.3375231921672821f,-0.13412702083587646f,-0.7709776163101196f,1.1072574853897095f,-0.6176732778549194f,-0.789782702922821f,-0.26726576685905457f,0.1519104242324829f,-0.34401074051856995f,-0.2394605576992035f,-0.4662231504917145f,0.7806915640830994f,-1.1428403854370117f,-0.5101396441459656f,-1.4363644123077393f,-1.1631749868392944f,-0.3078002333641052f,0.14698919653892517f,1.1502156257629395f,0.757956326007843f,-1.0361347198486328f,-0.9573707580566406f,1.1927686929702759f,-0.36519983410835266f,-0.1531694531440735f,0.20401786267757416f,0.691188395023346f,-2.3236680030822754f,-0.22575858235359192f,0.4017392098903656f }; |
Lightvalve | 87:471334725012 | 302 | |
Lightvalve | 111:93289db9e77a | 303 | const float bout[1] = { -0.14703667163848877f }; |
Lightvalve | 65:a2d7c63419c2 | 304 | |
Lightvalve | 66:a8e6799dbce3 | 305 | |
Lightvalve | 87:471334725012 | 306 | float VALVE_POS_RAW_NN = 0.0f; |
Lightvalve | 87:471334725012 | 307 | float DDV_JOINT_POS_FF(float REF_JOINT_VEL); |
Lightvalve | 61:bc8c8270f0ab | 308 | |
GiJeongKim | 0:51c43836c1d7 | 309 | int main() |
GiJeongKim | 0:51c43836c1d7 | 310 | { |
Lightvalve | 66:a8e6799dbce3 | 311 | |
Lightvalve | 65:a2d7c63419c2 | 312 | HAL_Init(); |
Lightvalve | 65:a2d7c63419c2 | 313 | SystemClock_Config(); |
Lightvalve | 65:a2d7c63419c2 | 314 | |
jobuuu | 6:df07d3491e3a | 315 | /********************************* |
jobuuu | 1:e04e563be5ce | 316 | *** Initialization |
jobuuu | 6:df07d3491e3a | 317 | *********************************/ |
Lightvalve | 69:3995ffeaa786 | 318 | LED = 0; |
Lightvalve | 61:bc8c8270f0ab | 319 | pc.baud(9600); |
Lightvalve | 21:e5f1a43ea6f9 | 320 | |
GiJeongKim | 0:51c43836c1d7 | 321 | // i2c init |
Lightvalve | 8:5d2eebdad025 | 322 | i2c.frequency(400 * 1000); // 0.4 mHz |
Lightvalve | 8:5d2eebdad025 | 323 | wait_ms(2); // Power Up wait |
Lightvalve | 8:5d2eebdad025 | 324 | look_for_hardware_i2c(); // Hardware present |
Lightvalve | 8:5d2eebdad025 | 325 | init_as5510(i2c_slave_addr1); |
Lightvalve | 11:82d8768d7351 | 326 | make_delay(); |
jobuuu | 2:a1c0a37df760 | 327 | |
GiJeongKim | 0:51c43836c1d7 | 328 | // // spi init |
Lightvalve | 16:903b5a4433b4 | 329 | //eeprom.format(8,3); |
Lightvalve | 16:903b5a4433b4 | 330 | //eeprom.frequency(5000000); //5M |
GiJeongKim | 0:51c43836c1d7 | 331 | enc.format(8,0); |
GiJeongKim | 0:51c43836c1d7 | 332 | enc.frequency(5000000); //5M |
Lightvalve | 11:82d8768d7351 | 333 | make_delay(); |
Lightvalve | 21:e5f1a43ea6f9 | 334 | |
Lightvalve | 16:903b5a4433b4 | 335 | //rom |
Lightvalve | 19:23b7c1ad8683 | 336 | ROM_CALL_DATA(); |
Lightvalve | 16:903b5a4433b4 | 337 | make_delay(); |
Lightvalve | 13:747daba9cf59 | 338 | |
GiJeongKim | 0:51c43836c1d7 | 339 | // ADC init |
jobuuu | 5:a4319f79457b | 340 | Init_ADC(); |
Lightvalve | 11:82d8768d7351 | 341 | make_delay(); |
jobuuu | 2:a1c0a37df760 | 342 | |
GiJeongKim | 0:51c43836c1d7 | 343 | // Pwm init |
GiJeongKim | 0:51c43836c1d7 | 344 | Init_PWM(); |
GiJeongKim | 0:51c43836c1d7 | 345 | TIM4->CR1 ^= TIM_CR1_UDIS; |
Lightvalve | 11:82d8768d7351 | 346 | make_delay(); |
Lightvalve | 13:747daba9cf59 | 347 | |
Lightvalve | 11:82d8768d7351 | 348 | // TMR3 init |
Lightvalve | 11:82d8768d7351 | 349 | Init_TMR3(); |
Lightvalve | 11:82d8768d7351 | 350 | TIM3->CR1 ^= TIM_CR1_UDIS; |
Lightvalve | 11:82d8768d7351 | 351 | make_delay(); |
Lightvalve | 21:e5f1a43ea6f9 | 352 | |
Lightvalve | 50:3c630b5eba9f | 353 | // TMR2 init |
Lightvalve | 56:6f50d9d3bfee | 354 | // Init_TMR2(); |
Lightvalve | 56:6f50d9d3bfee | 355 | // TIM2->CR1 ^= TIM_CR1_UDIS; |
Lightvalve | 56:6f50d9d3bfee | 356 | // make_delay(); |
Lightvalve | 21:e5f1a43ea6f9 | 357 | |
GiJeongKim | 0:51c43836c1d7 | 358 | // CAN |
jobuuu | 2:a1c0a37df760 | 359 | can.attach(&CAN_RX_HANDLER); |
Lightvalve | 11:82d8768d7351 | 360 | CAN_ID_INIT(); |
Lightvalve | 11:82d8768d7351 | 361 | make_delay(); |
Lightvalve | 34:bb2ca2fc2a8e | 362 | |
Lightvalve | 23:59218d4a256d | 363 | //Timer priority |
Lightvalve | 23:59218d4a256d | 364 | NVIC_SetPriority(TIM3_IRQn, 2); |
Lightvalve | 57:f4819de54e7a | 365 | //NVIC_SetPriority(TIM2_IRQn, 3); |
Lightvalve | 54:647072f5307a | 366 | NVIC_SetPriority(TIM4_IRQn, 3); |
Lightvalve | 34:bb2ca2fc2a8e | 367 | |
Lightvalve | 23:59218d4a256d | 368 | //can.reset(); |
Lightvalve | 19:23b7c1ad8683 | 369 | can.filter(msg.id, 0xFFFFF000, CANStandard); |
Lightvalve | 34:bb2ca2fc2a8e | 370 | |
GiJeongKim | 0:51c43836c1d7 | 371 | // spi _ enc |
GiJeongKim | 0:51c43836c1d7 | 372 | spi_enc_set_init(); |
Lightvalve | 11:82d8768d7351 | 373 | make_delay(); |
Lightvalve | 13:747daba9cf59 | 374 | |
Lightvalve | 11:82d8768d7351 | 375 | //DAC init |
Lightvalve | 58:2eade98630e2 | 376 | if (SENSING_MODE == 0) { |
Lightvalve | 58:2eade98630e2 | 377 | dac_1 = TORQUE_VREF / 3.3f; |
Lightvalve | 58:2eade98630e2 | 378 | dac_2 = 0.0f; |
Lightvalve | 58:2eade98630e2 | 379 | } else if (SENSING_MODE == 1) { |
Lightvalve | 58:2eade98630e2 | 380 | dac_1 = PRES_A_VREF / 3.3f; |
Lightvalve | 58:2eade98630e2 | 381 | dac_2 = PRES_B_VREF / 3.3f; |
Lightvalve | 58:2eade98630e2 | 382 | } |
Lightvalve | 11:82d8768d7351 | 383 | make_delay(); |
Lightvalve | 13:747daba9cf59 | 384 | |
Lightvalve | 19:23b7c1ad8683 | 385 | for (int i=0; i<50; i++) { |
Lightvalve | 11:82d8768d7351 | 386 | if(i%2==0) |
Lightvalve | 38:118df027d851 | 387 | ID_index_array[i] = - i * 0.5f; |
Lightvalve | 11:82d8768d7351 | 388 | else |
Lightvalve | 38:118df027d851 | 389 | ID_index_array[i] = (i+1) * 0.5f; |
Lightvalve | 11:82d8768d7351 | 390 | } |
Lightvalve | 61:bc8c8270f0ab | 391 | |
Lightvalve | 61:bc8c8270f0ab | 392 | |
jobuuu | 6:df07d3491e3a | 393 | /************************************ |
jobuuu | 1:e04e563be5ce | 394 | *** Program is operating! |
jobuuu | 6:df07d3491e3a | 395 | *************************************/ |
GiJeongKim | 0:51c43836c1d7 | 396 | while(1) { |
Lightvalve | 66:a8e6799dbce3 | 397 | // if(timer_while==1000 && OPERATING_MODE==5) { |
Lightvalve | 66:a8e6799dbce3 | 398 | //if(timer_while==1000) { |
Lightvalve | 65:a2d7c63419c2 | 399 | //i2c |
Lightvalve | 66:a8e6799dbce3 | 400 | |
Lightvalve | 65:a2d7c63419c2 | 401 | read_field(i2c_slave_addr1); |
Lightvalve | 65:a2d7c63419c2 | 402 | if(DIR_VALVE_ENC < 0) value = 1023 - value; |
Lightvalve | 65:a2d7c63419c2 | 403 | // if(LED==1) { |
Lightvalve | 65:a2d7c63419c2 | 404 | // LED=0; |
Lightvalve | 65:a2d7c63419c2 | 405 | // } else |
Lightvalve | 65:a2d7c63419c2 | 406 | // LED = 1; |
Lightvalve | 65:a2d7c63419c2 | 407 | timer_while = 0; |
Lightvalve | 66:a8e6799dbce3 | 408 | //} |
Lightvalve | 66:a8e6799dbce3 | 409 | |
Lightvalve | 66:a8e6799dbce3 | 410 | timer_while ++; |
Lightvalve | 66:a8e6799dbce3 | 411 | |
Lightvalve | 87:471334725012 | 412 | //LED = 0; |
Lightvalve | 87:471334725012 | 413 | |
Lightvalve | 73:f80dc3970c99 | 414 | if(NN_Control_Flag == 0) { |
Lightvalve | 73:f80dc3970c99 | 415 | LED = 0; |
Lightvalve | 73:f80dc3970c99 | 416 | } |
Lightvalve | 66:a8e6799dbce3 | 417 | |
Lightvalve | 73:f80dc3970c99 | 418 | else if(NN_Control_Flag == 1) { |
Lightvalve | 111:93289db9e77a | 419 | float output1[32] = { 0.0f }; |
Lightvalve | 111:93289db9e77a | 420 | float output2[32] = { 0.0f }; |
Lightvalve | 111:93289db9e77a | 421 | float output3[32] = { 0.0f }; |
Lightvalve | 66:a8e6799dbce3 | 422 | float output = 0.0f; |
Lightvalve | 65:a2d7c63419c2 | 423 | |
Lightvalve | 111:93289db9e77a | 424 | for (int index2 = 0; index2 < 32; index2++) { |
Lightvalve | 68:328e1be06f5d | 425 | for (int index1 = 0; index1 < num_input; index1++) { |
Lightvalve | 66:a8e6799dbce3 | 426 | output1[index2] = output1[index2] |
Lightvalve | 73:f80dc3970c99 | 427 | + h1[index1][index2] * input_NN[index1]; |
Lightvalve | 66:a8e6799dbce3 | 428 | } |
Lightvalve | 66:a8e6799dbce3 | 429 | output1[index2] = output1[index2] + b1[index2]; |
Lightvalve | 66:a8e6799dbce3 | 430 | if (output1[index2] < 0) { |
Lightvalve | 66:a8e6799dbce3 | 431 | output1[index2] = 0; |
Lightvalve | 66:a8e6799dbce3 | 432 | } |
Lightvalve | 66:a8e6799dbce3 | 433 | } |
Lightvalve | 65:a2d7c63419c2 | 434 | |
Lightvalve | 111:93289db9e77a | 435 | for (int index2 = 0; index2 < 32; index2++) { |
Lightvalve | 111:93289db9e77a | 436 | for (int index1 = 0; index1 < 32; index1++) { |
Lightvalve | 66:a8e6799dbce3 | 437 | output2[index2] = output2[index2] |
Lightvalve | 66:a8e6799dbce3 | 438 | + h2[index1][index2] * output1[index1]; |
Lightvalve | 66:a8e6799dbce3 | 439 | } |
Lightvalve | 66:a8e6799dbce3 | 440 | output2[index2] = output2[index2] + b2[index2]; |
Lightvalve | 66:a8e6799dbce3 | 441 | if (output2[index2] < 0) { |
Lightvalve | 66:a8e6799dbce3 | 442 | output2[index2] = 0; |
Lightvalve | 66:a8e6799dbce3 | 443 | } |
Lightvalve | 66:a8e6799dbce3 | 444 | } |
Lightvalve | 65:a2d7c63419c2 | 445 | |
Lightvalve | 111:93289db9e77a | 446 | for (int index2 = 0; index2 < 32; index2++) { |
Lightvalve | 111:93289db9e77a | 447 | for (int index1 = 0; index1 < 32; index1++) { |
Lightvalve | 66:a8e6799dbce3 | 448 | output3[index2] = output3[index2] |
Lightvalve | 66:a8e6799dbce3 | 449 | + h3[index1][index2] * output2[index1]; |
Lightvalve | 66:a8e6799dbce3 | 450 | } |
Lightvalve | 66:a8e6799dbce3 | 451 | output3[index2] = output3[index2] + b3[index2]; |
Lightvalve | 66:a8e6799dbce3 | 452 | if (output3[index2] < 0) { |
Lightvalve | 66:a8e6799dbce3 | 453 | output3[index2] = 0; |
Lightvalve | 66:a8e6799dbce3 | 454 | } |
Lightvalve | 65:a2d7c63419c2 | 455 | } |
Lightvalve | 66:a8e6799dbce3 | 456 | |
Lightvalve | 66:a8e6799dbce3 | 457 | for (int index2 = 0; index2 < 1; index2++) { |
Lightvalve | 111:93289db9e77a | 458 | for (int index1 = 0; index1 < 32; index1++) { |
Lightvalve | 73:f80dc3970c99 | 459 | output = output + hout[index1] * output3[index1]; |
Lightvalve | 66:a8e6799dbce3 | 460 | } |
Lightvalve | 66:a8e6799dbce3 | 461 | output = output + bout[index2]; |
Lightvalve | 73:f80dc3970c99 | 462 | |
Lightvalve | 66:a8e6799dbce3 | 463 | } |
Lightvalve | 73:f80dc3970c99 | 464 | output = 1.0f/(1.0f+exp(-output)); |
Lightvalve | 101:50159049a518 | 465 | output_normalized = output; |
Lightvalve | 68:328e1be06f5d | 466 | output = output * 20000.0f - 10000.0f; |
Lightvalve | 101:50159049a518 | 467 | |
Lightvalve | 66:a8e6799dbce3 | 468 | if(output>=0) { |
Lightvalve | 66:a8e6799dbce3 | 469 | valve_pos.ref = output*0.0001f*((double)VALVE_MAX_POS - (double) VALVE_CENTER) + (double) VALVE_CENTER; |
Lightvalve | 66:a8e6799dbce3 | 470 | } else { |
Lightvalve | 66:a8e6799dbce3 | 471 | valve_pos.ref = -output*0.0001f*((double)VALVE_MIN_POS - (double) VALVE_CENTER) + (double) VALVE_CENTER; |
Lightvalve | 65:a2d7c63419c2 | 472 | } |
Lightvalve | 87:471334725012 | 473 | |
Lightvalve | 88:d6e591bece22 | 474 | // // torque feedback |
Lightvalve | 88:d6e591bece22 | 475 | // torq.err = f_past[0] - torq.sen; //[N] |
Lightvalve | 88:d6e591bece22 | 476 | //// torq.err_sum += torq.err/(float) TMR_FREQ_5k; //[N] |
Lightvalve | 88:d6e591bece22 | 477 | // torq.err_sum += torq.err/(float) 1500.0f; //[N] |
Lightvalve | 88:d6e591bece22 | 478 | // |
Lightvalve | 88:d6e591bece22 | 479 | // |
Lightvalve | 88:d6e591bece22 | 480 | // valve_pos.ref = ((float) P_GAIN_JOINT_TORQUE * torq.err + (float) I_GAIN_JOINT_TORQUE * torq.err_sum) * 0.01f + DDV_JOINT_POS_FF(vel.sen) + valve_pos.ref * 0.01f; |
Lightvalve | 88:d6e591bece22 | 481 | // |
Lightvalve | 88:d6e591bece22 | 482 | // if(I_GAIN_JOINT_TORQUE != 0) { |
Lightvalve | 88:d6e591bece22 | 483 | // double Ka = 1.0f / (double) I_GAIN_JOINT_TORQUE * 100.0f; |
Lightvalve | 88:d6e591bece22 | 484 | // if(valve_pos.ref>VALVE_MAX_POS) { |
Lightvalve | 88:d6e591bece22 | 485 | // double valve_pos_rem = valve_pos.ref - VALVE_MAX_POS; |
Lightvalve | 88:d6e591bece22 | 486 | // valve_pos_rem = valve_pos_rem * Ka; |
Lightvalve | 88:d6e591bece22 | 487 | // valve_pos.ref = VALVE_MAX_POS; |
Lightvalve | 88:d6e591bece22 | 488 | // torq.err_sum = torq.err_sum - valve_pos_rem/(float) 1500.0f; |
Lightvalve | 88:d6e591bece22 | 489 | // } else if(valve_pos.ref < VALVE_MIN_POS) { |
Lightvalve | 88:d6e591bece22 | 490 | // double valve_pos_rem = valve_pos.ref - VALVE_MIN_POS; |
Lightvalve | 88:d6e591bece22 | 491 | // valve_pos_rem = valve_pos_rem * Ka; |
Lightvalve | 88:d6e591bece22 | 492 | // valve_pos.ref = VALVE_MIN_POS; |
Lightvalve | 88:d6e591bece22 | 493 | // torq.err_sum = torq.err_sum - valve_pos_rem/(float) 1500.0f; |
Lightvalve | 88:d6e591bece22 | 494 | // } |
Lightvalve | 88:d6e591bece22 | 495 | // } |
Lightvalve | 87:471334725012 | 496 | |
Lightvalve | 69:3995ffeaa786 | 497 | |
Lightvalve | 69:3995ffeaa786 | 498 | if(LED==1) { |
Lightvalve | 69:3995ffeaa786 | 499 | LED=0; |
Lightvalve | 69:3995ffeaa786 | 500 | } else |
Lightvalve | 69:3995ffeaa786 | 501 | LED = 1; |
Lightvalve | 69:3995ffeaa786 | 502 | |
Lightvalve | 65:a2d7c63419c2 | 503 | } |
Lightvalve | 62:b5452adfb2cd | 504 | |
Lightvalve | 87:471334725012 | 505 | //LED = 1; |
Lightvalve | 69:3995ffeaa786 | 506 | |
Lightvalve | 66:a8e6799dbce3 | 507 | |
GiJeongKim | 0:51c43836c1d7 | 508 | } |
jobuuu | 1:e04e563be5ce | 509 | } |
jobuuu | 1:e04e563be5ce | 510 | |
Lightvalve | 33:91b17819ec30 | 511 | float DDV_JOINT_POS_FF(float REF_JOINT_VEL) |
Lightvalve | 14:8e7590227d22 | 512 | { |
Lightvalve | 14:8e7590227d22 | 513 | |
Lightvalve | 13:747daba9cf59 | 514 | int i = 0; |
Lightvalve | 48:889798ff9329 | 515 | float Ref_Valve_Pos_FF = 0.0f; |
Lightvalve | 14:8e7590227d22 | 516 | for(i=0; i<VALVE_POS_NUM; i++) { |
Lightvalve | 14:8e7590227d22 | 517 | if(REF_JOINT_VEL >= min(JOINT_VEL[i],JOINT_VEL[i+1]) && REF_JOINT_VEL <= max(JOINT_VEL[i],JOINT_VEL[i+1])) { |
Lightvalve | 14:8e7590227d22 | 518 | if(i==0) { |
Lightvalve | 50:3c630b5eba9f | 519 | if(JOINT_VEL[i+1] == JOINT_VEL[i]) { |
Lightvalve | 57:f4819de54e7a | 520 | Ref_Valve_Pos_FF = (float) VALVE_CENTER; |
Lightvalve | 50:3c630b5eba9f | 521 | } else { |
Lightvalve | 57:f4819de54e7a | 522 | Ref_Valve_Pos_FF = ((float) 10/(JOINT_VEL[i+1] - JOINT_VEL[i]) * (REF_JOINT_VEL - JOINT_VEL[i])) + (float) VALVE_CENTER; |
Lightvalve | 38:118df027d851 | 523 | } |
Lightvalve | 14:8e7590227d22 | 524 | } else { |
Lightvalve | 50:3c630b5eba9f | 525 | if(JOINT_VEL[i+1] == JOINT_VEL[i-1]) { |
Lightvalve | 57:f4819de54e7a | 526 | Ref_Valve_Pos_FF = (float) VALVE_CENTER; |
Lightvalve | 50:3c630b5eba9f | 527 | } else { |
Lightvalve | 57:f4819de54e7a | 528 | Ref_Valve_Pos_FF = ((float) 10*(ID_index_array[i+1] - ID_index_array[i-1])/(JOINT_VEL[i+1] - JOINT_VEL[i-1]) * (REF_JOINT_VEL - JOINT_VEL[i-1])) + (float) VALVE_CENTER + (float) (10*ID_index_array[i-1]); |
Lightvalve | 38:118df027d851 | 529 | } |
Lightvalve | 13:747daba9cf59 | 530 | } |
Lightvalve | 13:747daba9cf59 | 531 | break; |
Lightvalve | 13:747daba9cf59 | 532 | } |
Lightvalve | 13:747daba9cf59 | 533 | } |
Lightvalve | 14:8e7590227d22 | 534 | if(REF_JOINT_VEL > max(JOINT_VEL[VALVE_POS_NUM-1], JOINT_VEL[VALVE_POS_NUM-2])) { |
Lightvalve | 33:91b17819ec30 | 535 | Ref_Valve_Pos_FF = (float) VALVE_MAX_POS; |
Lightvalve | 14:8e7590227d22 | 536 | } else if(REF_JOINT_VEL < min(JOINT_VEL[VALVE_POS_NUM-1], JOINT_VEL[VALVE_POS_NUM-2])) { |
Lightvalve | 33:91b17819ec30 | 537 | Ref_Valve_Pos_FF = (float) VALVE_MIN_POS; |
Lightvalve | 13:747daba9cf59 | 538 | } |
Lightvalve | 36:a46e63505ed8 | 539 | |
Lightvalve | 57:f4819de54e7a | 540 | Ref_Valve_Pos_FF = (float) VELOCITY_COMP_GAIN * 0.01f * (float) (Ref_Valve_Pos_FF - (float) VALVE_CENTER); |
Lightvalve | 13:747daba9cf59 | 541 | return Ref_Valve_Pos_FF; |
Lightvalve | 50:3c630b5eba9f | 542 | |
Lightvalve | 13:747daba9cf59 | 543 | } |
jobuuu | 6:df07d3491e3a | 544 | |
jobuuu | 6:df07d3491e3a | 545 | |
Lightvalve | 30:8d561f16383b | 546 | void VALVE_POS_CONTROL(float REF_VALVE_POS) |
Lightvalve | 14:8e7590227d22 | 547 | { |
Lightvalve | 13:747daba9cf59 | 548 | int i = 0; |
Lightvalve | 13:747daba9cf59 | 549 | |
Lightvalve | 38:118df027d851 | 550 | if(REF_VALVE_POS > VALVE_MAX_POS) { |
Lightvalve | 38:118df027d851 | 551 | REF_VALVE_POS = VALVE_MAX_POS; |
Lightvalve | 38:118df027d851 | 552 | } else if(REF_VALVE_POS < VALVE_MIN_POS) { |
Lightvalve | 38:118df027d851 | 553 | REF_VALVE_POS = VALVE_MIN_POS; |
Lightvalve | 38:118df027d851 | 554 | } |
Lightvalve | 38:118df027d851 | 555 | |
Lightvalve | 89:a7b45368ea0f | 556 | valve_pos_err = (float) (REF_VALVE_POS - value); |
Lightvalve | 13:747daba9cf59 | 557 | valve_pos_err_diff = valve_pos_err - valve_pos_err_old; |
Lightvalve | 13:747daba9cf59 | 558 | valve_pos_err_old = valve_pos_err; |
Lightvalve | 13:747daba9cf59 | 559 | valve_pos_err_sum += valve_pos_err; |
Lightvalve | 89:a7b45368ea0f | 560 | if (valve_pos_err_sum > 1000.0f) valve_pos_err_sum = 1000.0f; |
Lightvalve | 89:a7b45368ea0f | 561 | if (valve_pos_err_sum<-1000.0f) valve_pos_err_sum = -1000.0f; |
Lightvalve | 13:747daba9cf59 | 562 | |
Lightvalve | 13:747daba9cf59 | 563 | VALVE_PWM_RAW_FB = P_GAIN_VALVE_POSITION * valve_pos_err + I_GAIN_VALVE_POSITION * valve_pos_err_sum + D_GAIN_VALVE_POSITION * valve_pos_err_diff; |
Lightvalve | 14:8e7590227d22 | 564 | |
Lightvalve | 18:b8adf1582ea3 | 565 | for(i=0; i<24; i++) { |
Lightvalve | 89:a7b45368ea0f | 566 | if(REF_VALVE_POS >= min(VALVE_POS_VS_PWM[i],VALVE_POS_VS_PWM[i+1]) && (float) REF_VALVE_POS <= max(VALVE_POS_VS_PWM[i],VALVE_POS_VS_PWM[i+1])) { |
Lightvalve | 14:8e7590227d22 | 567 | if(i==0) { |
Lightvalve | 48:889798ff9329 | 568 | VALVE_PWM_RAW_FF = (float) 1000.0f / (float) (VALVE_POS_VS_PWM[i+1] - VALVE_POS_VS_PWM[i]) * ((float) REF_VALVE_POS - VALVE_POS_VS_PWM[i]); |
Lightvalve | 14:8e7590227d22 | 569 | } else { |
Lightvalve | 48:889798ff9329 | 570 | VALVE_PWM_RAW_FF = (float) 1000.0f* (float) (ID_index_array[i+1] - ID_index_array[i-1])/(VALVE_POS_VS_PWM[i+1] - VALVE_POS_VS_PWM[i-1]) * ((float) REF_VALVE_POS - VALVE_POS_VS_PWM[i-1]) + 1000.0f * (float) ID_index_array[i-1]; |
Lightvalve | 13:747daba9cf59 | 571 | } |
Lightvalve | 13:747daba9cf59 | 572 | break; |
Lightvalve | 13:747daba9cf59 | 573 | } |
Lightvalve | 13:747daba9cf59 | 574 | } |
Lightvalve | 59:f308b1656d9c | 575 | Vout.ref = VALVE_PWM_RAW_FF + VALVE_PWM_RAW_FB; |
Lightvalve | 13:747daba9cf59 | 576 | } |
Lightvalve | 13:747daba9cf59 | 577 | |
Lightvalve | 14:8e7590227d22 | 578 | #define LT_MAX_IDX 57 |
Lightvalve | 30:8d561f16383b | 579 | float LT_PWM_duty[LT_MAX_IDX] = {-100.0f, -80.0f, -60.0f, -50.0f, -40.0f, -35.0f, -30.0f, -25.0f, -20.0f, |
Lightvalve | 34:bb2ca2fc2a8e | 580 | -19.0f, -18.0f, -17.0f, -16.0f, -15.0f, -14.0f, -13.0f, -12.0f, -11.0f, -10.0f, |
Lightvalve | 34:bb2ca2fc2a8e | 581 | -9.0f, -8.0f, -7.0f, -6.0f, -5.0f, -4.0f, -3.0f, -2.0f, -1.0f, 0.0f, |
Lightvalve | 34:bb2ca2fc2a8e | 582 | 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, |
Lightvalve | 34:bb2ca2fc2a8e | 583 | 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, |
Lightvalve | 34:bb2ca2fc2a8e | 584 | 25.0f, 30.0f, 35.0f, 40.0f, 50.0f, 60.0f, 80.0f, 100.0f |
Lightvalve | 34:bb2ca2fc2a8e | 585 | }; // duty |
Lightvalve | 67:c2812cf26c38 | 586 | float LT_Voltage_Output[LT_MAX_IDX] = {-230.0f, -215.0f, -192.5f, -185.0f, -177.5f, -170.0f, -164.0f, -160.0f, -150.0f, |
Lightvalve | 67:c2812cf26c38 | 587 | -150.0f, -145.0f, -145.0f, -145.0f, -135.0f, -135.0f, -135.0f, -127.5f, -127.5f, -115.0f, |
Lightvalve | 67:c2812cf26c38 | 588 | -115.0f, -115.0F, -100.0f, -100.0f, -100.0f, -60.0f, -60.0f, -10.0f, -5.0f, 0.0f, |
Lightvalve | 67:c2812cf26c38 | 589 | 7.5f, 14.0f, 14.0f, 14.0f, 42.5f, 42.5f, 42.5f, 80.0f, 80.0f, 105.0f, |
Lightvalve | 67:c2812cf26c38 | 590 | 105.0f, 105.0f, 120.0f, 120.0f, 120.0f, 131.0f, 131.0f, 140.0f, 140.0f, 140.0f, |
Lightvalve | 67:c2812cf26c38 | 591 | 155.0f, 160.0f, 170.0f, 174.0f, 182.0f, 191.0f, 212.0f, 230.0f |
Lightvalve | 34:bb2ca2fc2a8e | 592 | }; // mV |
Lightvalve | 13:747daba9cf59 | 593 | |
Lightvalve | 30:8d561f16383b | 594 | float PWM_duty_byLT(float Ref_V) |
Lightvalve | 14:8e7590227d22 | 595 | { |
Lightvalve | 30:8d561f16383b | 596 | float PWM_duty = 0.0f; |
Lightvalve | 13:747daba9cf59 | 597 | if(Ref_V<LT_Voltage_Output[0]) { |
Lightvalve | 30:8d561f16383b | 598 | PWM_duty = (Ref_V-LT_Voltage_Output[0])/1.5f+LT_PWM_duty[0]; |
Lightvalve | 13:747daba9cf59 | 599 | } else if (Ref_V>=LT_Voltage_Output[LT_MAX_IDX-1]) { |
Lightvalve | 30:8d561f16383b | 600 | PWM_duty = (Ref_V-LT_Voltage_Output[LT_MAX_IDX-1])/1.5f+LT_PWM_duty[LT_MAX_IDX-1]; |
Lightvalve | 13:747daba9cf59 | 601 | } else { |
Lightvalve | 13:747daba9cf59 | 602 | int idx = 0; |
Lightvalve | 13:747daba9cf59 | 603 | for(idx=0; idx<LT_MAX_IDX-1; idx++) { |
Lightvalve | 30:8d561f16383b | 604 | float ini_x = LT_Voltage_Output[idx]; |
Lightvalve | 30:8d561f16383b | 605 | float fin_x = LT_Voltage_Output[idx+1]; |
Lightvalve | 30:8d561f16383b | 606 | float ini_y = LT_PWM_duty[idx]; |
Lightvalve | 30:8d561f16383b | 607 | float fin_y = LT_PWM_duty[idx+1]; |
Lightvalve | 13:747daba9cf59 | 608 | if(Ref_V>=ini_x && Ref_V<fin_x) { |
Lightvalve | 13:747daba9cf59 | 609 | PWM_duty = (fin_y-ini_y)/(fin_x-ini_x)*(Ref_V-ini_x) + ini_y; |
Lightvalve | 13:747daba9cf59 | 610 | break; |
Lightvalve | 13:747daba9cf59 | 611 | } |
Lightvalve | 13:747daba9cf59 | 612 | } |
Lightvalve | 13:747daba9cf59 | 613 | } |
Lightvalve | 14:8e7590227d22 | 614 | |
Lightvalve | 13:747daba9cf59 | 615 | return PWM_duty; |
Lightvalve | 13:747daba9cf59 | 616 | } |
jobuuu | 6:df07d3491e3a | 617 | |
Lightvalve | 57:f4819de54e7a | 618 | |
Lightvalve | 57:f4819de54e7a | 619 | |
Lightvalve | 57:f4819de54e7a | 620 | |
Lightvalve | 57:f4819de54e7a | 621 | |
jobuuu | 2:a1c0a37df760 | 622 | /******************************************************************************* |
jobuuu | 2:a1c0a37df760 | 623 | TIMER INTERRUPT |
jobuuu | 2:a1c0a37df760 | 624 | *******************************************************************************/ |
jobuuu | 2:a1c0a37df760 | 625 | |
Lightvalve | 51:b46bed7fec80 | 626 | float FREQ_TMR4 = (float)FREQ_20k; |
Lightvalve | 51:b46bed7fec80 | 627 | float DT_TMR4 = (float)DT_20k; |
Lightvalve | 57:f4819de54e7a | 628 | long CNT_TMR4 = 0; |
Lightvalve | 57:f4819de54e7a | 629 | int TMR4_FREQ_10k = (int)FREQ_10k; |
jobuuu | 1:e04e563be5ce | 630 | extern "C" void TIM4_IRQHandler(void) |
jobuuu | 1:e04e563be5ce | 631 | { |
Lightvalve | 19:23b7c1ad8683 | 632 | if (TIM4->SR & TIM_SR_UIF ) { |
Lightvalve | 21:e5f1a43ea6f9 | 633 | |
Lightvalve | 21:e5f1a43ea6f9 | 634 | /******************************************************* |
Lightvalve | 21:e5f1a43ea6f9 | 635 | *** Sensor Read & Data Handling |
Lightvalve | 21:e5f1a43ea6f9 | 636 | ********************************************************/ |
Lightvalve | 13:747daba9cf59 | 637 | |
Lightvalve | 57:f4819de54e7a | 638 | //Encoder |
Lightvalve | 57:f4819de54e7a | 639 | if (CNT_TMR4 % (int) ((int) FREQ_TMR4/TMR4_FREQ_10k) == 0) { |
Lightvalve | 57:f4819de54e7a | 640 | ENC_UPDATE(); |
Lightvalve | 57:f4819de54e7a | 641 | } |
Lightvalve | 61:bc8c8270f0ab | 642 | |
Lightvalve | 61:bc8c8270f0ab | 643 | ADC1->CR2 |= 0x40000000; |
Lightvalve | 58:2eade98630e2 | 644 | if (SENSING_MODE == 0) { |
Lightvalve | 58:2eade98630e2 | 645 | // Torque Sensing (0~210)bar ============================================= |
Lightvalve | 58:2eade98630e2 | 646 | float pres_A_new = (((float) ADC1->DR) - 2047.5f); |
Lightvalve | 58:2eade98630e2 | 647 | double alpha_update_ft = 1.0f / (1.0f + FREQ_TMR4 / (2.0f * 3.14f * 100.0f)); // f_cutoff : 200Hz |
Lightvalve | 58:2eade98630e2 | 648 | pres_A.sen = (1.0f - alpha_update_ft) * pres_A.sen + alpha_update_ft * pres_A_new; |
Lightvalve | 67:c2812cf26c38 | 649 | torq.sen = -pres_A.sen / TORQUE_SENSOR_PULSE_PER_TORQUE; |
Lightvalve | 67:c2812cf26c38 | 650 | |
Lightvalve | 67:c2812cf26c38 | 651 | |
Lightvalve | 67:c2812cf26c38 | 652 | // float alpha_update_pres_A = 1.0f/(1.0f + FREQ_TMR4/(2.0f*3.14f*100.0f)); |
Lightvalve | 67:c2812cf26c38 | 653 | //// float pres_A_new = ((float)ADC1->DR - PRES_A_NULL) / PRES_SENSOR_A_PULSE_PER_BAR; |
Lightvalve | 67:c2812cf26c38 | 654 | // float pres_A_new = ((float)ADC1->DR); |
Lightvalve | 67:c2812cf26c38 | 655 | // pres_A.sen = pres_A.sen*(1.0f-alpha_update_pres_A)+pres_A_new*(alpha_update_pres_A); |
Lightvalve | 67:c2812cf26c38 | 656 | // torq.sen = - (pres_A.sen-2048.0f); //pulse -2047~2047 |
Lightvalve | 67:c2812cf26c38 | 657 | |
Lightvalve | 17:1865016ca2e7 | 658 | |
Lightvalve | 58:2eade98630e2 | 659 | } else if (SENSING_MODE == 1) { |
Lightvalve | 58:2eade98630e2 | 660 | // Pressure Sensing (0~210)bar ============================================= |
Lightvalve | 58:2eade98630e2 | 661 | float pres_A_new = (((float)ADC1->DR) - PRES_A_NULL); |
Lightvalve | 58:2eade98630e2 | 662 | float pres_B_new = (((float)ADC2->DR) - PRES_B_NULL); |
Lightvalve | 58:2eade98630e2 | 663 | double alpha_update_pres = 1.0f / (1.0f + FREQ_TMR4 / (2.0f * 3.14f * 200.0f)); // f_cutoff : 500Hz |
Lightvalve | 58:2eade98630e2 | 664 | pres_A.sen = (1.0f - alpha_update_pres) * pres_A.sen + alpha_update_pres * pres_A_new; |
Lightvalve | 58:2eade98630e2 | 665 | pres_B.sen = (1.0f - alpha_update_pres) * pres_B.sen + alpha_update_pres * pres_B_new; |
Lightvalve | 58:2eade98630e2 | 666 | CUR_PRES_A_BAR = pres_A.sen / PRES_SENSOR_A_PULSE_PER_BAR; |
Lightvalve | 58:2eade98630e2 | 667 | CUR_PRES_B_BAR = pres_B.sen / PRES_SENSOR_B_PULSE_PER_BAR; |
Lightvalve | 50:3c630b5eba9f | 668 | |
Lightvalve | 58:2eade98630e2 | 669 | if ((OPERATING_MODE & 0x01) == 0) { // Rotary Actuator |
Lightvalve | 58:2eade98630e2 | 670 | torq.sen = (PISTON_AREA_A * CUR_PRES_A_BAR - PISTON_AREA_B * CUR_PRES_B_BAR) * 0.0001f; // mm^3*bar >> Nm |
Lightvalve | 58:2eade98630e2 | 671 | } else if ((OPERATING_MODE & 0x01) == 1) { // Linear Actuator |
Lightvalve | 58:2eade98630e2 | 672 | torq.sen = (PISTON_AREA_A * CUR_PRES_A_BAR - PISTON_AREA_B * CUR_PRES_B_BAR) * 0.1f; // mm^2*bar >> N |
Lightvalve | 58:2eade98630e2 | 673 | } |
Lightvalve | 58:2eade98630e2 | 674 | } |
Lightvalve | 61:bc8c8270f0ab | 675 | |
Lightvalve | 58:2eade98630e2 | 676 | // //Pressure sensor A |
Lightvalve | 58:2eade98630e2 | 677 | // ADC1->CR2 |= 0x40000000; // adc _ 12bit |
Lightvalve | 58:2eade98630e2 | 678 | // //while((ADC1->SR & 0b10)); |
Lightvalve | 58:2eade98630e2 | 679 | // float alpha_update_pres_A = 1.0f/(1.0f + FREQ_TMR4/(2.0f*3.14f*100.0f)); |
Lightvalve | 58:2eade98630e2 | 680 | // float pres_A_new = ((float)ADC1->DR); |
Lightvalve | 58:2eade98630e2 | 681 | // pres_A.sen = pres_A.sen*(1.0f-alpha_update_pres_A)+pres_A_new*(alpha_update_pres_A); |
Lightvalve | 58:2eade98630e2 | 682 | // torq.sen = - (pres_A.sen-2048.0f); //pulse -2047~2047 //SW just changed the sign to correct the direction of loadcell on LIGHT. Correct later. |
Lightvalve | 58:2eade98630e2 | 683 | // |
Lightvalve | 58:2eade98630e2 | 684 | // |
Lightvalve | 58:2eade98630e2 | 685 | // //Pressure sensor B |
Lightvalve | 58:2eade98630e2 | 686 | // float alpha_update_pres_B = 1.0f/(1.0f + FREQ_TMR4/(2.0f*3.14f*100.0f)); |
Lightvalve | 58:2eade98630e2 | 687 | // float pres_B_new = ((float)ADC2->DR); |
Lightvalve | 58:2eade98630e2 | 688 | // pres_B.sen = pres_B.sen*(1.0f-alpha_update_pres_B)+pres_B_new*(alpha_update_pres_B); |
Lightvalve | 58:2eade98630e2 | 689 | // //torq.sen = pres_A.sen * (float) PISTON_AREA_A - pres_B.sen * (float) PISTON_AREA_B; |
Lightvalve | 17:1865016ca2e7 | 690 | |
Lightvalve | 17:1865016ca2e7 | 691 | |
Lightvalve | 21:e5f1a43ea6f9 | 692 | //Current |
Lightvalve | 21:e5f1a43ea6f9 | 693 | //ADC3->CR2 |= 0x40000000; // adc _ 12bit |
Lightvalve | 25:3e6b574cab5c | 694 | //int raw_cur = ADC3->DR; |
Lightvalve | 21:e5f1a43ea6f9 | 695 | //while((ADC3->SR & 0b10)); |
Lightvalve | 51:b46bed7fec80 | 696 | float alpha_update_cur = 1.0f/(1.0f + FREQ_TMR4/(2.0f*3.14f*500.0f)); // f_cutoff : 500Hz |
Lightvalve | 30:8d561f16383b | 697 | float cur_new = ((float)ADC3->DR-2048.0f)*20.0f/4096.0f; // unit : mA |
Lightvalve | 30:8d561f16383b | 698 | cur.sen=cur.sen*(1.0f-alpha_update_cur)+cur_new*(alpha_update_cur); |
Lightvalve | 25:3e6b574cab5c | 699 | //cur.sen = raw_cur; |
Lightvalve | 58:2eade98630e2 | 700 | |
Lightvalve | 57:f4819de54e7a | 701 | CNT_TMR4++; |
Lightvalve | 21:e5f1a43ea6f9 | 702 | } |
Lightvalve | 11:82d8768d7351 | 703 | TIM4->SR = 0x0; // reset the status register |
Lightvalve | 11:82d8768d7351 | 704 | } |
Lightvalve | 19:23b7c1ad8683 | 705 | |
Lightvalve | 19:23b7c1ad8683 | 706 | |
Lightvalve | 18:b8adf1582ea3 | 707 | int j =0; |
Lightvalve | 54:647072f5307a | 708 | float FREQ_TMR3 = (float)FREQ_5k; |
Lightvalve | 48:889798ff9329 | 709 | float DT_TMR3 = (float)DT_5k; |
Lightvalve | 45:35fa6884d0c6 | 710 | int cnt_trans = 0; |
Lightvalve | 48:889798ff9329 | 711 | double VALVE_POS_RAW_FORCE_FB_LOGGING = 0.0f; |
Lightvalve | 57:f4819de54e7a | 712 | int can_rest =0; |
Lightvalve | 48:889798ff9329 | 713 | |
Lightvalve | 11:82d8768d7351 | 714 | extern "C" void TIM3_IRQHandler(void) |
Lightvalve | 21:e5f1a43ea6f9 | 715 | { |
Lightvalve | 19:23b7c1ad8683 | 716 | if (TIM3->SR & TIM_SR_UIF ) { |
Lightvalve | 57:f4819de54e7a | 717 | |
Lightvalve | 57:f4819de54e7a | 718 | if (((OPERATING_MODE&0b110)>>1) == 0) { |
Lightvalve | 57:f4819de54e7a | 719 | K_v = 0.4f; // Moog (LPM >> mA) , 100bar |
Lightvalve | 57:f4819de54e7a | 720 | mV_PER_mA = 500.0f; // 5000mV/10mA |
Lightvalve | 57:f4819de54e7a | 721 | mV_PER_pulse = 0.5f; // 5000mV/10000pulse |
Lightvalve | 57:f4819de54e7a | 722 | mA_PER_pulse = 0.001f; // 10mA/10000pulse |
Lightvalve | 57:f4819de54e7a | 723 | } else if (((OPERATING_MODE&0b110)>>1) == 1) { |
Lightvalve | 57:f4819de54e7a | 724 | K_v = 0.5f; // KNR (LPM >> mA) , 100bar |
Lightvalve | 57:f4819de54e7a | 725 | mV_PER_mA = 166.6666f; // 5000mV/30mA |
Lightvalve | 57:f4819de54e7a | 726 | mV_PER_pulse = 0.5f; // 5000mV/10000pulse |
Lightvalve | 57:f4819de54e7a | 727 | mA_PER_pulse = 0.003f; // 30mA/10000pulse |
Lightvalve | 57:f4819de54e7a | 728 | } |
Lightvalve | 50:3c630b5eba9f | 729 | |
Lightvalve | 50:3c630b5eba9f | 730 | if(MODE_POS_FT_TRANS == 1) { |
Lightvalve | 48:889798ff9329 | 731 | alpha_trans = (float)(1.0f - cos(3.141592f * (float)cnt_trans * DT_TMR3 /3.0f))/2.0f; |
Lightvalve | 45:35fa6884d0c6 | 732 | cnt_trans++; |
Lightvalve | 46:2694daea349b | 733 | torq.err_sum = 0; |
Lightvalve | 48:889798ff9329 | 734 | if((float)cnt_trans * DT_TMR3 > 3.0f) |
Lightvalve | 45:35fa6884d0c6 | 735 | MODE_POS_FT_TRANS = 2; |
Lightvalve | 50:3c630b5eba9f | 736 | } else if(MODE_POS_FT_TRANS == 3) { |
Lightvalve | 48:889798ff9329 | 737 | alpha_trans = (float)(1.0f + cos(3.141592f * (float)cnt_trans * DT_TMR3 /3.0f))/2.0f; |
Lightvalve | 45:35fa6884d0c6 | 738 | cnt_trans++; |
Lightvalve | 46:2694daea349b | 739 | torq.err_sum = 0; |
Lightvalve | 48:889798ff9329 | 740 | if((float) cnt_trans * DT_TMR3 > 3.0f ) |
Lightvalve | 45:35fa6884d0c6 | 741 | MODE_POS_FT_TRANS = 0; |
Lightvalve | 50:3c630b5eba9f | 742 | } else if(MODE_POS_FT_TRANS == 2) { |
Lightvalve | 58:2eade98630e2 | 743 | alpha_trans = 1.0f; |
Lightvalve | 45:35fa6884d0c6 | 744 | cnt_trans = 0; |
Lightvalve | 50:3c630b5eba9f | 745 | } else { |
Lightvalve | 58:2eade98630e2 | 746 | alpha_trans = 0.0f; |
Lightvalve | 45:35fa6884d0c6 | 747 | cnt_trans = 0; |
Lightvalve | 45:35fa6884d0c6 | 748 | } |
Lightvalve | 45:35fa6884d0c6 | 749 | |
Lightvalve | 50:3c630b5eba9f | 750 | |
Lightvalve | 57:f4819de54e7a | 751 | int UTILITY_MODE = 0; |
Lightvalve | 57:f4819de54e7a | 752 | int CONTROL_MODE = 0; |
Lightvalve | 58:2eade98630e2 | 753 | |
Lightvalve | 57:f4819de54e7a | 754 | if (CONTROL_UTILITY_MODE >= 20 || CONTROL_UTILITY_MODE == 0) { |
Lightvalve | 57:f4819de54e7a | 755 | UTILITY_MODE = CONTROL_UTILITY_MODE; |
Lightvalve | 57:f4819de54e7a | 756 | CONTROL_MODE = MODE_NO_ACT; |
Lightvalve | 57:f4819de54e7a | 757 | } else { |
Lightvalve | 57:f4819de54e7a | 758 | CONTROL_MODE = CONTROL_UTILITY_MODE; |
Lightvalve | 57:f4819de54e7a | 759 | UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 57:f4819de54e7a | 760 | } |
Lightvalve | 56:6f50d9d3bfee | 761 | |
Lightvalve | 56:6f50d9d3bfee | 762 | |
Lightvalve | 56:6f50d9d3bfee | 763 | |
Lightvalve | 57:f4819de54e7a | 764 | // UTILITY MODE ------------------------------------------------------------ |
Lightvalve | 56:6f50d9d3bfee | 765 | |
Lightvalve | 57:f4819de54e7a | 766 | switch (UTILITY_MODE) { |
Lightvalve | 57:f4819de54e7a | 767 | case MODE_NO_ACT: { |
Lightvalve | 13:747daba9cf59 | 768 | break; |
Lightvalve | 13:747daba9cf59 | 769 | } |
Lightvalve | 14:8e7590227d22 | 770 | |
Lightvalve | 14:8e7590227d22 | 771 | case MODE_TORQUE_SENSOR_NULLING: { |
Lightvalve | 13:747daba9cf59 | 772 | // DAC Voltage reference set |
Lightvalve | 14:8e7590227d22 | 773 | if (TMR3_COUNT_TORQUE_NULL < TMR_FREQ_5k * 2) { |
Lightvalve | 15:bd0d12728506 | 774 | CUR_TORQUE_sum += torq.sen; |
Lightvalve | 19:23b7c1ad8683 | 775 | |
Lightvalve | 14:8e7590227d22 | 776 | if (TMR3_COUNT_TORQUE_NULL % 10 == 0) { |
Lightvalve | 30:8d561f16383b | 777 | CUR_TORQUE_mean = CUR_TORQUE_sum / 10.0f; |
Lightvalve | 13:747daba9cf59 | 778 | CUR_TORQUE_sum = 0; |
Lightvalve | 14:8e7590227d22 | 779 | |
Lightvalve | 84:c355d3e52bf1 | 780 | TORQUE_VREF += 0.000003f * (0.0f - CUR_TORQUE_mean); |
Lightvalve | 19:23b7c1ad8683 | 781 | |
Lightvalve | 30:8d561f16383b | 782 | if (TORQUE_VREF > 3.3f) TORQUE_VREF = 3.3f; |
Lightvalve | 59:f308b1656d9c | 783 | if (TORQUE_VREF < 0.0f) TORQUE_VREF = 0.0f; |
Lightvalve | 50:3c630b5eba9f | 784 | |
Lightvalve | 16:903b5a4433b4 | 785 | //spi_eeprom_write(RID_TORQUE_SENSOR_VREF, (int16_t) (TORQUE_VREF * 1000.0)); |
Lightvalve | 30:8d561f16383b | 786 | dac_1 = TORQUE_VREF / 3.3f; |
Lightvalve | 13:747daba9cf59 | 787 | } |
Lightvalve | 13:747daba9cf59 | 788 | } else { |
Lightvalve | 58:2eade98630e2 | 789 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 14:8e7590227d22 | 790 | TMR3_COUNT_TORQUE_NULL = 0; |
Lightvalve | 13:747daba9cf59 | 791 | CUR_TORQUE_sum = 0; |
Lightvalve | 13:747daba9cf59 | 792 | CUR_TORQUE_mean = 0; |
Lightvalve | 19:23b7c1ad8683 | 793 | |
Lightvalve | 16:903b5a4433b4 | 794 | ROM_RESET_DATA(); |
Lightvalve | 19:23b7c1ad8683 | 795 | |
Lightvalve | 30:8d561f16383b | 796 | dac_1 = TORQUE_VREF / 3.3f; |
Lightvalve | 14:8e7590227d22 | 797 | |
Lightvalve | 13:747daba9cf59 | 798 | } |
Lightvalve | 14:8e7590227d22 | 799 | TMR3_COUNT_TORQUE_NULL++; |
Lightvalve | 13:747daba9cf59 | 800 | break; |
Lightvalve | 19:23b7c1ad8683 | 801 | } |
Lightvalve | 14:8e7590227d22 | 802 | |
Lightvalve | 50:3c630b5eba9f | 803 | // case MODE_VALVE_NULLING_AND_DEADZONE_SETTING: { |
Lightvalve | 50:3c630b5eba9f | 804 | // if (TMR3_COUNT_DEADZONE == 0) { |
Lightvalve | 50:3c630b5eba9f | 805 | // if (pos_plus_end == pos_minus_end) need_enc_init = true; |
Lightvalve | 50:3c630b5eba9f | 806 | // else temp_time = 0; |
Lightvalve | 50:3c630b5eba9f | 807 | // } |
Lightvalve | 50:3c630b5eba9f | 808 | // if (need_enc_init) { |
Lightvalve | 50:3c630b5eba9f | 809 | // if (TMR3_COUNT_DEADZONE < (int) (0.5f * (float) TMR_FREQ_5k)) { |
Lightvalve | 50:3c630b5eba9f | 810 | // V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 811 | // pos_plus_end = pos.sen; |
Lightvalve | 50:3c630b5eba9f | 812 | // } else if (TMR3_COUNT_DEADZONE < TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 813 | // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 814 | // pos_minus_end = pos.sen; |
Lightvalve | 50:3c630b5eba9f | 815 | // } else if (TMR3_COUNT_DEADZONE == TMR_FREQ_5k) need_enc_init = false; |
Lightvalve | 50:3c630b5eba9f | 816 | // temp_time = TMR_FREQ_5k; |
Lightvalve | 50:3c630b5eba9f | 817 | // } |
Lightvalve | 50:3c630b5eba9f | 818 | // |
Lightvalve | 50:3c630b5eba9f | 819 | // if (temp_time <= TMR3_COUNT_DEADZONE && TMR3_COUNT_DEADZONE < (temp_time + TMR_FREQ_5k)) { |
Lightvalve | 50:3c630b5eba9f | 820 | // V_out = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen); |
Lightvalve | 50:3c630b5eba9f | 821 | // VALVE_CENTER = VALVE_DEADZONE_PLUS = VALVE_DEADZONE_MINUS = 0; |
Lightvalve | 50:3c630b5eba9f | 822 | // |
Lightvalve | 50:3c630b5eba9f | 823 | // } else if (temp_time <= TMR3_COUNT_DEADZONE && TMR3_COUNT_DEADZONE < (temp_time + (int) (1.9f * (float) TMR_FREQ_5k))) { |
Lightvalve | 50:3c630b5eba9f | 824 | // V_out = 0; |
Lightvalve | 50:3c630b5eba9f | 825 | // CUR_VELOCITY_sum += CUR_VELOCITY; |
Lightvalve | 50:3c630b5eba9f | 826 | // } else if (TMR3_COUNT_DEADZONE == (temp_time + 2 * TMR_FREQ_5k)) { |
Lightvalve | 50:3c630b5eba9f | 827 | // if (CUR_VELOCITY_sum == 0) DZ_dir = 1; |
Lightvalve | 50:3c630b5eba9f | 828 | // else if (CUR_VELOCITY_sum > 0) DZ_dir = 1; |
Lightvalve | 50:3c630b5eba9f | 829 | // else if (CUR_VELOCITY_sum < 0) DZ_dir = -1; |
Lightvalve | 50:3c630b5eba9f | 830 | // else DZ_temp_cnt2 = DZ_end; |
Lightvalve | 50:3c630b5eba9f | 831 | // CUR_VELOCITY_sum = 0; |
Lightvalve | 50:3c630b5eba9f | 832 | // } else if (TMR3_COUNT_DEADZONE > (temp_time + 2 * TMR_FREQ_5k)) { |
Lightvalve | 50:3c630b5eba9f | 833 | // if (TMR3_COUNT_DEADZONE > (temp_time + 10 * TMR_FREQ_5k)) DZ_temp_cnt2 = DZ_end; |
Lightvalve | 50:3c630b5eba9f | 834 | // |
Lightvalve | 50:3c630b5eba9f | 835 | // // Position of Dead Zone |
Lightvalve | 50:3c630b5eba9f | 836 | // // (CUR_VELOCITY < 0) (CUR_VELOCITY == 0) (CUR_VELOCITY > 0) |
Lightvalve | 50:3c630b5eba9f | 837 | // // | / | / |/ |
Lightvalve | 50:3c630b5eba9f | 838 | // // | ______/ ___|___/ ______/| |
Lightvalve | 50:3c630b5eba9f | 839 | // // |/ / | / | |
Lightvalve | 50:3c630b5eba9f | 840 | // // /| / | / | |
Lightvalve | 50:3c630b5eba9f | 841 | // // 0V 0V 0V |
Lightvalve | 50:3c630b5eba9f | 842 | // |
Lightvalve | 50:3c630b5eba9f | 843 | // if (DZ_temp_cnt2 < DZ_end) { |
Lightvalve | 50:3c630b5eba9f | 844 | // if (TMR3_COUNT_DEADZONE % 20 != 0) { |
Lightvalve | 50:3c630b5eba9f | 845 | // CUR_VELOCITY_sum += CUR_VELOCITY; |
Lightvalve | 50:3c630b5eba9f | 846 | // } else { |
Lightvalve | 50:3c630b5eba9f | 847 | // V_out -= DZ_dir; |
Lightvalve | 50:3c630b5eba9f | 848 | // if (CUR_VELOCITY_sum * DZ_dir < 0) DZ_temp_cnt++; |
Lightvalve | 50:3c630b5eba9f | 849 | // CUR_VELOCITY_sum = 0; |
Lightvalve | 50:3c630b5eba9f | 850 | // } |
Lightvalve | 50:3c630b5eba9f | 851 | // if (DZ_temp_cnt == 5) { |
Lightvalve | 50:3c630b5eba9f | 852 | // if (DZ_dir >= 0) VALVE_DEADZONE_MINUS = (int16_t) V_out; |
Lightvalve | 50:3c630b5eba9f | 853 | // else VALVE_DEADZONE_PLUS = (int16_t) V_out; |
Lightvalve | 50:3c630b5eba9f | 854 | // DZ_dir = -DZ_dir; |
Lightvalve | 50:3c630b5eba9f | 855 | // DZ_temp_cnt = 0; |
Lightvalve | 50:3c630b5eba9f | 856 | // DZ_temp_cnt2++; |
Lightvalve | 50:3c630b5eba9f | 857 | // } |
Lightvalve | 50:3c630b5eba9f | 858 | // } else { |
Lightvalve | 50:3c630b5eba9f | 859 | // TMR3_COUNT_DEADZONE = -1; |
Lightvalve | 50:3c630b5eba9f | 860 | // VALVE_CENTER = VALVE_DEADZONE_PLUS / 2 + VALVE_DEADZONE_MINUS / 2; |
Lightvalve | 50:3c630b5eba9f | 861 | // if (VALVE_DEADZONE_PLUS < VALVE_DEADZONE_MINUS) { |
Lightvalve | 50:3c630b5eba9f | 862 | // VALVE_DEADZONE_PLUS = VALVE_CENTER; |
Lightvalve | 50:3c630b5eba9f | 863 | // VALVE_DEADZONE_MINUS = VALVE_CENTER; |
Lightvalve | 50:3c630b5eba9f | 864 | // } |
Lightvalve | 50:3c630b5eba9f | 865 | // V_out = 0; |
Lightvalve | 50:3c630b5eba9f | 866 | // |
Lightvalve | 50:3c630b5eba9f | 867 | // ROM_RESET_DATA(); |
Lightvalve | 50:3c630b5eba9f | 868 | // |
Lightvalve | 50:3c630b5eba9f | 869 | // //spi_eeprom_write(RID_VALVE_DEADZONE_PLUS, VALVE_DEADZONE_PLUS); |
Lightvalve | 50:3c630b5eba9f | 870 | // //spi_eeprom_write(RID_VALVE_DEADZONE_MINUS, VALVE_DEADZONE_MINUS); |
Lightvalve | 50:3c630b5eba9f | 871 | // |
Lightvalve | 50:3c630b5eba9f | 872 | // CONTROL_MODE = MODE_NO_ACT; |
Lightvalve | 50:3c630b5eba9f | 873 | // DZ_temp_cnt2 = 0; |
Lightvalve | 50:3c630b5eba9f | 874 | // } |
Lightvalve | 50:3c630b5eba9f | 875 | // } |
Lightvalve | 50:3c630b5eba9f | 876 | // TMR3_COUNT_DEADZONE++; |
Lightvalve | 50:3c630b5eba9f | 877 | // break; |
Lightvalve | 50:3c630b5eba9f | 878 | // } |
Lightvalve | 14:8e7590227d22 | 879 | |
Lightvalve | 14:8e7590227d22 | 880 | case MODE_FIND_HOME: { |
Lightvalve | 29:69f3f5445d6d | 881 | if (FINDHOME_STAGE == FINDHOME_INIT) { |
Lightvalve | 14:8e7590227d22 | 882 | cnt_findhome = 0; |
Lightvalve | 14:8e7590227d22 | 883 | cnt_vel_findhome = 0; |
Lightvalve | 14:8e7590227d22 | 884 | //REFERENCE_MODE = MODE_REF_NO_ACT; // Stop taking reference data from PODO |
Lightvalve | 59:f308b1656d9c | 885 | pos.ref = pos.sen; |
Lightvalve | 59:f308b1656d9c | 886 | vel.ref = 0.0f; |
Lightvalve | 29:69f3f5445d6d | 887 | FINDHOME_STAGE = FINDHOME_GOTOLIMIT; |
Lightvalve | 29:69f3f5445d6d | 888 | } else if (FINDHOME_STAGE == FINDHOME_GOTOLIMIT) { |
Lightvalve | 67:c2812cf26c38 | 889 | int cnt_check_enc = (TMR_FREQ_5k/20); |
Lightvalve | 29:69f3f5445d6d | 890 | if(cnt_findhome%cnt_check_enc == 0) { |
Lightvalve | 29:69f3f5445d6d | 891 | FINDHOME_POSITION = pos.sen; |
Lightvalve | 29:69f3f5445d6d | 892 | FINDHOME_VELOCITY = FINDHOME_POSITION - FINDHOME_POSITION_OLD; |
Lightvalve | 29:69f3f5445d6d | 893 | FINDHOME_POSITION_OLD = FINDHOME_POSITION; |
Lightvalve | 29:69f3f5445d6d | 894 | } |
Lightvalve | 29:69f3f5445d6d | 895 | cnt_findhome++; |
Lightvalve | 14:8e7590227d22 | 896 | |
Lightvalve | 29:69f3f5445d6d | 897 | if (abs(FINDHOME_VELOCITY) <= 1) { |
Lightvalve | 29:69f3f5445d6d | 898 | cnt_vel_findhome = cnt_vel_findhome + 1; |
Lightvalve | 29:69f3f5445d6d | 899 | } else { |
Lightvalve | 29:69f3f5445d6d | 900 | cnt_vel_findhome = 0; |
Lightvalve | 29:69f3f5445d6d | 901 | } |
Lightvalve | 19:23b7c1ad8683 | 902 | |
Lightvalve | 57:f4819de54e7a | 903 | if ((cnt_vel_findhome < 3*TMR_FREQ_5k) && cnt_findhome < 10*TMR_FREQ_5k) { // wait for 3sec |
Lightvalve | 29:69f3f5445d6d | 904 | //REFERENCE_MODE = MODE_REF_NO_ACT; |
Lightvalve | 67:c2812cf26c38 | 905 | if (HOMEPOS_OFFSET > 0) pos.ref = pos.ref + 12.0f; |
Lightvalve | 67:c2812cf26c38 | 906 | else pos.ref = pos.ref - 12.0f; |
Lightvalve | 61:bc8c8270f0ab | 907 | |
Lightvalve | 59:f308b1656d9c | 908 | // pos.err = pos.ref_home_pos - pos.sen; |
Lightvalve | 59:f308b1656d9c | 909 | // float VALVE_POS_RAW_POS_FB = 0.0f; |
Lightvalve | 59:f308b1656d9c | 910 | // VALVE_POS_RAW_POS_FB = (float) P_GAIN_JOINT_POSITION * pos.err/(float) ENC_PULSE_PER_POSITION * 0.01f; |
Lightvalve | 59:f308b1656d9c | 911 | // valve_pos.ref = VALVE_POS_RAW_POS_FB + (float) VALVE_CENTER; |
Lightvalve | 59:f308b1656d9c | 912 | // VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 61:bc8c8270f0ab | 913 | |
Lightvalve | 59:f308b1656d9c | 914 | CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 59:f308b1656d9c | 915 | alpha_trans = 0.0f; |
Lightvalve | 61:bc8c8270f0ab | 916 | |
Lightvalve | 34:bb2ca2fc2a8e | 917 | |
Lightvalve | 29:69f3f5445d6d | 918 | } else { |
Lightvalve | 29:69f3f5445d6d | 919 | ENC_SET(HOMEPOS_OFFSET); |
Lightvalve | 67:c2812cf26c38 | 920 | // ENC_SET_ZERO(); |
Lightvalve | 29:69f3f5445d6d | 921 | INIT_REF_POS = HOMEPOS_OFFSET; |
Lightvalve | 29:69f3f5445d6d | 922 | REF_POSITION = 0; |
Lightvalve | 29:69f3f5445d6d | 923 | REF_VELOCITY = 0; |
Lightvalve | 29:69f3f5445d6d | 924 | FINDHOME_POSITION = 0; |
Lightvalve | 29:69f3f5445d6d | 925 | FINDHOME_POSITION_OLD = 0; |
Lightvalve | 29:69f3f5445d6d | 926 | FINDHOME_VELOCITY = 0; |
Lightvalve | 29:69f3f5445d6d | 927 | cnt_findhome = 0; |
Lightvalve | 29:69f3f5445d6d | 928 | cnt_vel_findhome = 0; |
Lightvalve | 29:69f3f5445d6d | 929 | FINDHOME_STAGE = FINDHOME_ZEROPOSE; |
Lightvalve | 67:c2812cf26c38 | 930 | |
Lightvalve | 67:c2812cf26c38 | 931 | |
Lightvalve | 67:c2812cf26c38 | 932 | cnt_findhome = 0; |
Lightvalve | 67:c2812cf26c38 | 933 | pos.ref = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 934 | vel.ref = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 935 | pos.ref_home_pos = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 936 | vel.ref_home_pos = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 937 | //FINDHOME_STAGE = FINDHOME_INIT; |
Lightvalve | 67:c2812cf26c38 | 938 | //CONTROL_UTILITY_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 67:c2812cf26c38 | 939 | |
Lightvalve | 67:c2812cf26c38 | 940 | |
Lightvalve | 29:69f3f5445d6d | 941 | } |
Lightvalve | 29:69f3f5445d6d | 942 | } else if (FINDHOME_STAGE == FINDHOME_ZEROPOSE) { |
Lightvalve | 29:69f3f5445d6d | 943 | int T_move = 2*TMR_FREQ_5k; |
Lightvalve | 59:f308b1656d9c | 944 | pos.ref = (0.0f - (float)INIT_REF_POS)*0.5f*(1.0f - cos(3.14159f * (float)cnt_findhome / (float)T_move)) + (float)INIT_REF_POS; |
Lightvalve | 67:c2812cf26c38 | 945 | //pos.ref = 0.0f; |
Lightvalve | 59:f308b1656d9c | 946 | vel.ref = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 947 | |
Lightvalve | 29:69f3f5445d6d | 948 | // input for position control |
Lightvalve | 67:c2812cf26c38 | 949 | |
Lightvalve | 67:c2812cf26c38 | 950 | // CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 67:c2812cf26c38 | 951 | alpha_trans = 0.0f; |
Lightvalve | 61:bc8c8270f0ab | 952 | |
Lightvalve | 67:c2812cf26c38 | 953 | double torq_ref = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 954 | pos.err = (pos.ref - pos.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm] |
Lightvalve | 67:c2812cf26c38 | 955 | vel.err = (0.0f - vel.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm/s] |
Lightvalve | 67:c2812cf26c38 | 956 | pos.err_sum += pos.err/(float) TMR_FREQ_5k; //[mm] |
Lightvalve | 67:c2812cf26c38 | 957 | |
Lightvalve | 67:c2812cf26c38 | 958 | if (((OPERATING_MODE&0b110)>>1) == 0 || ((OPERATING_MODE&0b110)>>1) == 1) { |
Lightvalve | 67:c2812cf26c38 | 959 | |
Lightvalve | 67:c2812cf26c38 | 960 | double I_REF_POS = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 961 | double I_REF_FORCE_FB = 0.0f; // I_REF by Force Feedback |
Lightvalve | 67:c2812cf26c38 | 962 | double I_REF_VC = 0.0f; // I_REF for velocity compensation |
Lightvalve | 67:c2812cf26c38 | 963 | |
Lightvalve | 67:c2812cf26c38 | 964 | double temp_vel_pos = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 965 | double temp_vel_torq = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 966 | double wn_Pos = 2.0f * PI * 5.0f; // f_cut : 5Hz Position Control |
Lightvalve | 67:c2812cf26c38 | 967 | |
Lightvalve | 69:3995ffeaa786 | 968 | if ((OPERATING_MODE & 0x01) == 0) { // Rotary Mode |
Lightvalve | 67:c2812cf26c38 | 969 | temp_vel_pos = (0.01f * (double) P_GAIN_JOINT_POSITION * wn_Pos * pos.err + 0.01f * (double) I_GAIN_JOINT_POSITION * wn_Pos * pos.err_sum + 0.01f * (double) VELOCITY_COMP_GAIN * vel.ref / ENC_PULSE_PER_POSITION) * 3.14159f / 180.0f; // rad/s |
Lightvalve | 67:c2812cf26c38 | 970 | // L when P-gain = 100, f_cut = 10Hz L feedforward velocity |
Lightvalve | 69:3995ffeaa786 | 971 | } else if ((OPERATING_MODE & 0x01) == 1) { |
Lightvalve | 67:c2812cf26c38 | 972 | temp_vel_pos = (0.01f * (double) P_GAIN_JOINT_POSITION * wn_Pos * pos.err + 0.01f * (double) I_GAIN_JOINT_POSITION * wn_Pos * pos.err_sum + 0.01f * (double) VELOCITY_COMP_GAIN * vel.ref / ENC_PULSE_PER_POSITION); // mm/s |
Lightvalve | 67:c2812cf26c38 | 973 | // L when P-gain = 100, f_cut = 10Hz L feedforward velocity |
Lightvalve | 67:c2812cf26c38 | 974 | } |
Lightvalve | 67:c2812cf26c38 | 975 | if (temp_vel_pos > 0.0f) I_REF_POS = temp_vel_pos * ((double) PISTON_AREA_A * 0.00006f / (K_v * sqrt(2.0f * alpha3 / (alpha3 + 1.0f)))); |
Lightvalve | 67:c2812cf26c38 | 976 | else I_REF_POS = temp_vel_pos * ((double) PISTON_AREA_B * 0.00006f / (K_v * sqrt(2.0f / (alpha3 + 1.0f)))); |
Lightvalve | 67:c2812cf26c38 | 977 | |
Lightvalve | 67:c2812cf26c38 | 978 | I_REF = I_REF_POS; |
Lightvalve | 67:c2812cf26c38 | 979 | |
Lightvalve | 67:c2812cf26c38 | 980 | |
Lightvalve | 67:c2812cf26c38 | 981 | |
Lightvalve | 67:c2812cf26c38 | 982 | } else { |
Lightvalve | 67:c2812cf26c38 | 983 | float VALVE_POS_RAW_FORCE_FB = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 984 | VALVE_POS_RAW_FORCE_FB = DDV_JOINT_POS_FF(vel.sen) + (P_GAIN_JOINT_POSITION * 0.01f * pos.err + DDV_JOINT_POS_FF(vel.ref)); |
Lightvalve | 67:c2812cf26c38 | 985 | |
Lightvalve | 67:c2812cf26c38 | 986 | if (VALVE_POS_RAW_FORCE_FB >= 0) { |
Lightvalve | 67:c2812cf26c38 | 987 | valve_pos.ref = VALVE_POS_RAW_FORCE_FB + VALVE_DEADZONE_PLUS; |
Lightvalve | 67:c2812cf26c38 | 988 | } else { |
Lightvalve | 67:c2812cf26c38 | 989 | valve_pos.ref = VALVE_POS_RAW_FORCE_FB + VALVE_DEADZONE_MINUS; |
Lightvalve | 67:c2812cf26c38 | 990 | } |
Lightvalve | 67:c2812cf26c38 | 991 | |
Lightvalve | 67:c2812cf26c38 | 992 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 67:c2812cf26c38 | 993 | |
Lightvalve | 67:c2812cf26c38 | 994 | V_out = (float) Vout.ref; |
Lightvalve | 67:c2812cf26c38 | 995 | |
Lightvalve | 67:c2812cf26c38 | 996 | } |
Lightvalve | 67:c2812cf26c38 | 997 | |
Lightvalve | 67:c2812cf26c38 | 998 | |
Lightvalve | 67:c2812cf26c38 | 999 | |
Lightvalve | 67:c2812cf26c38 | 1000 | |
Lightvalve | 59:f308b1656d9c | 1001 | // pos.err = pos.ref - (float)pos.sen; |
Lightvalve | 59:f308b1656d9c | 1002 | // float VALVE_POS_RAW_POS_FB = 0.0f; |
Lightvalve | 59:f308b1656d9c | 1003 | // VALVE_POS_RAW_POS_FB = (float) P_GAIN_JOINT_POSITION * 0.01f * pos.err/(float) ENC_PULSE_PER_POSITION; |
Lightvalve | 59:f308b1656d9c | 1004 | // valve_pos.ref = VALVE_POS_RAW_POS_FB + (float) VALVE_CENTER; |
Lightvalve | 59:f308b1656d9c | 1005 | // VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 29:69f3f5445d6d | 1006 | |
Lightvalve | 29:69f3f5445d6d | 1007 | cnt_findhome++; |
Lightvalve | 29:69f3f5445d6d | 1008 | if (cnt_findhome >= T_move) { |
Lightvalve | 29:69f3f5445d6d | 1009 | //REFERENCE_MODE = MODE_REF_DIRECT; |
Lightvalve | 29:69f3f5445d6d | 1010 | cnt_findhome = 0; |
Lightvalve | 30:8d561f16383b | 1011 | pos.ref = 0.0f; |
Lightvalve | 30:8d561f16383b | 1012 | vel.ref = 0.0f; |
Lightvalve | 30:8d561f16383b | 1013 | pos.ref_home_pos = 0.0f; |
Lightvalve | 30:8d561f16383b | 1014 | vel.ref_home_pos = 0.0f; |
Lightvalve | 29:69f3f5445d6d | 1015 | FINDHOME_STAGE = FINDHOME_INIT; |
Lightvalve | 57:f4819de54e7a | 1016 | CONTROL_UTILITY_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 29:69f3f5445d6d | 1017 | } |
Lightvalve | 13:747daba9cf59 | 1018 | } |
Lightvalve | 19:23b7c1ad8683 | 1019 | |
Lightvalve | 13:747daba9cf59 | 1020 | break; |
Lightvalve | 13:747daba9cf59 | 1021 | } |
Lightvalve | 14:8e7590227d22 | 1022 | |
Lightvalve | 50:3c630b5eba9f | 1023 | // case MODE_VALVE_GAIN_SETTING: { |
Lightvalve | 50:3c630b5eba9f | 1024 | // if (TMR3_COUNT_FLOWRATE == 0) { |
Lightvalve | 50:3c630b5eba9f | 1025 | // if (pos_plus_end == pos_minus_end) need_enc_init = true; |
Lightvalve | 50:3c630b5eba9f | 1026 | // else { |
Lightvalve | 50:3c630b5eba9f | 1027 | // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1028 | // temp_time = (int) (0.5f * (float) TMR_FREQ_5k); |
Lightvalve | 50:3c630b5eba9f | 1029 | // } |
Lightvalve | 50:3c630b5eba9f | 1030 | // } |
Lightvalve | 50:3c630b5eba9f | 1031 | // if (need_enc_init) { |
Lightvalve | 50:3c630b5eba9f | 1032 | // if (TMR3_COUNT_FLOWRATE < (int) (0.5f * (float) TMR_FREQ_5k)) { |
Lightvalve | 50:3c630b5eba9f | 1033 | // V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1034 | // pos_plus_end = pos.sen; |
Lightvalve | 50:3c630b5eba9f | 1035 | // } else if (TMR3_COUNT_FLOWRATE < TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1036 | // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1037 | // pos_minus_end = pos.sen; |
Lightvalve | 50:3c630b5eba9f | 1038 | // } else if (TMR3_COUNT_FLOWRATE == TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1039 | // need_enc_init = false; |
Lightvalve | 50:3c630b5eba9f | 1040 | // check_vel_pos_init = (int) (0.9f * (float) (pos_plus_end - pos_minus_end)); |
Lightvalve | 50:3c630b5eba9f | 1041 | // check_vel_pos_fin = (int) (0.95f * (float) (pos_plus_end - pos_minus_end)); |
Lightvalve | 50:3c630b5eba9f | 1042 | // check_vel_pos_interv = check_vel_pos_fin - check_vel_pos_init; |
Lightvalve | 50:3c630b5eba9f | 1043 | // } |
Lightvalve | 50:3c630b5eba9f | 1044 | // temp_time = TMR_FREQ_5k; |
Lightvalve | 50:3c630b5eba9f | 1045 | // } |
Lightvalve | 50:3c630b5eba9f | 1046 | // TMR3_COUNT_FLOWRATE++; |
Lightvalve | 50:3c630b5eba9f | 1047 | // if (TMR3_COUNT_FLOWRATE > temp_time) { |
Lightvalve | 50:3c630b5eba9f | 1048 | // if (flag_flowrate % 2 == 0) { // (+) |
Lightvalve | 50:3c630b5eba9f | 1049 | // VALVE_VOLTAGE = 1000.0f * (float) (flag_flowrate / 2 + 1); |
Lightvalve | 50:3c630b5eba9f | 1050 | // V_out = VALVE_VOLTAGE; |
Lightvalve | 50:3c630b5eba9f | 1051 | // if (pos.sen > (pos_minus_end + check_vel_pos_init) && pos.sen < (pos_minus_end + check_vel_pos_fin)) { |
Lightvalve | 50:3c630b5eba9f | 1052 | // fl_temp_cnt++; |
Lightvalve | 50:3c630b5eba9f | 1053 | // } else if (pos.sen >= (pos_minus_end + check_vel_pos_fin) && CUR_VELOCITY == 0) { |
Lightvalve | 50:3c630b5eba9f | 1054 | // VALVE_GAIN_LPM_PER_V[flag_flowrate] = 0.95873f * 0.5757f * (float) TMR_FREQ_5k / 10000.0 * (float) check_vel_pos_interv / (float) fl_temp_cnt / VALVE_VOLTAGE; // 0.9587=6*pi/65536*10000 0.5757=0.02525*0.02*0.0095*2*60*1000 |
Lightvalve | 50:3c630b5eba9f | 1055 | // // VALVE_GAIN_LPM_PER_V[flag_flowrate] = (float) TMR_FREQ_10k * (float) check_vel_pos_interv / (float) fl_temp_cnt / VALVE_VOLTAGE; // PULSE/sec |
Lightvalve | 50:3c630b5eba9f | 1056 | // fl_temp_cnt2++; |
Lightvalve | 50:3c630b5eba9f | 1057 | // } |
Lightvalve | 50:3c630b5eba9f | 1058 | // } else if (flag_flowrate % 2 == 1) { // (-) |
Lightvalve | 50:3c630b5eba9f | 1059 | // VALVE_VOLTAGE = -1. * (float) (flag_flowrate / 2 + 1); |
Lightvalve | 50:3c630b5eba9f | 1060 | // V_out = VALVE_VOLTAGE; |
Lightvalve | 50:3c630b5eba9f | 1061 | // if (pos.sen < (pos_plus_end - check_vel_pos_init) && pos.sen > (pos_plus_end - check_vel_pos_fin)) { |
Lightvalve | 50:3c630b5eba9f | 1062 | // fl_temp_cnt++; |
Lightvalve | 50:3c630b5eba9f | 1063 | // } else if (pos.sen <= (pos_plus_end - check_vel_pos_fin) && CUR_VELOCITY == 0) { |
Lightvalve | 50:3c630b5eba9f | 1064 | // VALVE_GAIN_LPM_PER_V[flag_flowrate] = 0.95873f * 0.5757f * (float) TMR_FREQ_5k / 10000.0f * (float) check_vel_pos_interv / (float) fl_temp_cnt / (-VALVE_VOLTAGE); |
Lightvalve | 50:3c630b5eba9f | 1065 | // // VALVE_GAIN_LPM_PER_V[flag_flowrate] = (float) TMR_FREQ_10k * (float) check_vel_pos_interv / (float) fl_temp_cnt / (-VALVE_VOLTAGE); // PULSE/sec |
Lightvalve | 50:3c630b5eba9f | 1066 | // fl_temp_cnt2++; |
Lightvalve | 50:3c630b5eba9f | 1067 | // } |
Lightvalve | 50:3c630b5eba9f | 1068 | // } |
Lightvalve | 50:3c630b5eba9f | 1069 | // if (fl_temp_cnt2 == 100) { |
Lightvalve | 50:3c630b5eba9f | 1070 | // |
Lightvalve | 50:3c630b5eba9f | 1071 | // ROM_RESET_DATA(); |
Lightvalve | 50:3c630b5eba9f | 1072 | // |
Lightvalve | 50:3c630b5eba9f | 1073 | // //spi_eeprom_write(RID_VALVE_GAIN_PLUS_1 + flag_flowrate, (int16_t) (VALVE_GAIN_LPM_PER_V[flag_flowrate] * 100.0f)); |
Lightvalve | 50:3c630b5eba9f | 1074 | // cur_vel_sum = 0; |
Lightvalve | 50:3c630b5eba9f | 1075 | // fl_temp_cnt = 0; |
Lightvalve | 50:3c630b5eba9f | 1076 | // fl_temp_cnt2 = 0; |
Lightvalve | 50:3c630b5eba9f | 1077 | // flag_flowrate++; |
Lightvalve | 50:3c630b5eba9f | 1078 | // } |
Lightvalve | 50:3c630b5eba9f | 1079 | // if (flag_flowrate == 10) { |
Lightvalve | 50:3c630b5eba9f | 1080 | // V_out = 0; |
Lightvalve | 50:3c630b5eba9f | 1081 | // flag_flowrate = 0; |
Lightvalve | 50:3c630b5eba9f | 1082 | // TMR3_COUNT_FLOWRATE = 0; |
Lightvalve | 50:3c630b5eba9f | 1083 | // valve_gain_repeat_cnt++; |
Lightvalve | 50:3c630b5eba9f | 1084 | // if (valve_gain_repeat_cnt >= 1) { |
Lightvalve | 50:3c630b5eba9f | 1085 | // CONTROL_MODE = MODE_NO_ACT; |
Lightvalve | 50:3c630b5eba9f | 1086 | // valve_gain_repeat_cnt = 0; |
Lightvalve | 50:3c630b5eba9f | 1087 | // } |
Lightvalve | 50:3c630b5eba9f | 1088 | // |
Lightvalve | 50:3c630b5eba9f | 1089 | // } |
Lightvalve | 50:3c630b5eba9f | 1090 | // break; |
Lightvalve | 50:3c630b5eba9f | 1091 | // } |
Lightvalve | 50:3c630b5eba9f | 1092 | // |
Lightvalve | 50:3c630b5eba9f | 1093 | // } |
Lightvalve | 14:8e7590227d22 | 1094 | case MODE_PRESSURE_SENSOR_NULLING: { |
Lightvalve | 13:747daba9cf59 | 1095 | // DAC Voltage reference set |
Lightvalve | 14:8e7590227d22 | 1096 | if (TMR3_COUNT_PRES_NULL < TMR_FREQ_5k * 2) { |
Lightvalve | 14:8e7590227d22 | 1097 | CUR_PRES_A_sum += pres_A.sen; |
Lightvalve | 14:8e7590227d22 | 1098 | CUR_PRES_B_sum += pres_B.sen; |
Lightvalve | 14:8e7590227d22 | 1099 | |
Lightvalve | 14:8e7590227d22 | 1100 | if (TMR3_COUNT_PRES_NULL % 10 == 0) { |
Lightvalve | 30:8d561f16383b | 1101 | CUR_PRES_A_mean = CUR_PRES_A_sum / 10.0f; |
Lightvalve | 30:8d561f16383b | 1102 | CUR_PRES_B_mean = CUR_PRES_B_sum / 10.0f; |
Lightvalve | 13:747daba9cf59 | 1103 | CUR_PRES_A_sum = 0; |
Lightvalve | 13:747daba9cf59 | 1104 | CUR_PRES_B_sum = 0; |
Lightvalve | 14:8e7590227d22 | 1105 | |
Lightvalve | 38:118df027d851 | 1106 | float VREF_NullingGain = 0.0003f; |
Lightvalve | 58:2eade98630e2 | 1107 | PRES_A_VREF = PRES_A_VREF + VREF_NullingGain * CUR_PRES_A_mean; |
Lightvalve | 58:2eade98630e2 | 1108 | PRES_B_VREF = PRES_B_VREF + VREF_NullingGain * CUR_PRES_B_mean; |
Lightvalve | 14:8e7590227d22 | 1109 | |
Lightvalve | 30:8d561f16383b | 1110 | if (PRES_A_VREF > 3.3f) PRES_A_VREF = 3.3f; |
Lightvalve | 30:8d561f16383b | 1111 | if (PRES_A_VREF < 0.0f) PRES_A_VREF = 0.0f; |
Lightvalve | 30:8d561f16383b | 1112 | if (PRES_B_VREF > 3.3f) PRES_B_VREF = 3.3f; |
Lightvalve | 30:8d561f16383b | 1113 | if (PRES_B_VREF < 0.0f) PRES_B_VREF = 0.0f; |
Lightvalve | 19:23b7c1ad8683 | 1114 | |
Lightvalve | 30:8d561f16383b | 1115 | dac_1 = PRES_A_VREF / 3.3f; |
Lightvalve | 30:8d561f16383b | 1116 | dac_2 = PRES_B_VREF / 3.3f; |
Lightvalve | 13:747daba9cf59 | 1117 | } |
Lightvalve | 13:747daba9cf59 | 1118 | } else { |
Lightvalve | 57:f4819de54e7a | 1119 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 14:8e7590227d22 | 1120 | TMR3_COUNT_PRES_NULL = 0; |
Lightvalve | 13:747daba9cf59 | 1121 | CUR_PRES_A_sum = 0; |
Lightvalve | 13:747daba9cf59 | 1122 | CUR_PRES_B_sum = 0; |
Lightvalve | 13:747daba9cf59 | 1123 | CUR_PRES_A_mean = 0; |
Lightvalve | 13:747daba9cf59 | 1124 | CUR_PRES_B_mean = 0; |
Lightvalve | 14:8e7590227d22 | 1125 | |
Lightvalve | 16:903b5a4433b4 | 1126 | ROM_RESET_DATA(); |
Lightvalve | 19:23b7c1ad8683 | 1127 | |
Lightvalve | 30:8d561f16383b | 1128 | dac_1 = PRES_A_VREF / 3.3f; |
Lightvalve | 30:8d561f16383b | 1129 | dac_2 = PRES_B_VREF / 3.3f; |
Lightvalve | 17:1865016ca2e7 | 1130 | //pc.printf("nulling end"); |
Lightvalve | 13:747daba9cf59 | 1131 | } |
Lightvalve | 14:8e7590227d22 | 1132 | TMR3_COUNT_PRES_NULL++; |
Lightvalve | 13:747daba9cf59 | 1133 | break; |
Lightvalve | 13:747daba9cf59 | 1134 | } |
Lightvalve | 14:8e7590227d22 | 1135 | |
Lightvalve | 50:3c630b5eba9f | 1136 | // case MODE_PRESSURE_SENSOR_CALIB: { |
Lightvalve | 50:3c630b5eba9f | 1137 | // if (TMR3_COUNT_PRES_CALIB < 2 * TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1138 | // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1139 | // if (TMR3_COUNT_PRES_CALIB >= TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1140 | // CUR_PRES_A_sum += CUR_PRES_A; |
Lightvalve | 50:3c630b5eba9f | 1141 | // } |
Lightvalve | 50:3c630b5eba9f | 1142 | // } else if (TMR3_COUNT_PRES_CALIB < 4 * TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1143 | // V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1144 | // if (TMR3_COUNT_PRES_CALIB >= 3 * TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1145 | // CUR_PRES_B_sum += CUR_PRES_B; |
Lightvalve | 50:3c630b5eba9f | 1146 | // } |
Lightvalve | 50:3c630b5eba9f | 1147 | // } else { |
Lightvalve | 50:3c630b5eba9f | 1148 | // CONTROL_MODE = MODE_NO_ACT; |
Lightvalve | 50:3c630b5eba9f | 1149 | // TMR3_COUNT_PRES_CALIB = 0; |
Lightvalve | 50:3c630b5eba9f | 1150 | // V_out = 0; |
Lightvalve | 50:3c630b5eba9f | 1151 | // PRES_SENSOR_A_PULSE_PER_BAR = CUR_PRES_A_sum / ((float) TMR_FREQ_5k - 1.0f) - PRES_A_NULL; |
Lightvalve | 50:3c630b5eba9f | 1152 | // PRES_SENSOR_A_PULSE_PER_BAR = PRES_SENSOR_A_PULSE_PER_BAR / ((float) PRES_SUPPLY - 1.0f); |
Lightvalve | 50:3c630b5eba9f | 1153 | // PRES_SENSOR_B_PULSE_PER_BAR = CUR_PRES_B_sum / ((float) TMR_FREQ_5k - 1.0f) - PRES_B_NULL; |
Lightvalve | 50:3c630b5eba9f | 1154 | // PRES_SENSOR_B_PULSE_PER_BAR = PRES_SENSOR_B_PULSE_PER_BAR / ((float) PRES_SUPPLY - 1.0f); |
Lightvalve | 50:3c630b5eba9f | 1155 | // CUR_PRES_A_sum = 0; |
Lightvalve | 50:3c630b5eba9f | 1156 | // CUR_PRES_B_sum = 0; |
Lightvalve | 50:3c630b5eba9f | 1157 | // CUR_PRES_A_mean = 0; |
Lightvalve | 50:3c630b5eba9f | 1158 | // CUR_PRES_B_mean = 0; |
Lightvalve | 50:3c630b5eba9f | 1159 | // |
Lightvalve | 50:3c630b5eba9f | 1160 | // ROM_RESET_DATA(); |
Lightvalve | 50:3c630b5eba9f | 1161 | // |
Lightvalve | 50:3c630b5eba9f | 1162 | // //spi_eeprom_write(RID_PRES_SENSOR_A_PULSE_PER_BAR, (int16_t) (PRES_SENSOR_A_PULSE_PER_BAR * 100.0f)); |
Lightvalve | 50:3c630b5eba9f | 1163 | // //spi_eeprom_write(RID_PRES_SENSOR_B_PULSE_PER_BAR, (int16_t) (PRES_SENSOR_B_PULSE_PER_BAR * 100.0f)); |
Lightvalve | 50:3c630b5eba9f | 1164 | // } |
Lightvalve | 50:3c630b5eba9f | 1165 | // TMR3_COUNT_PRES_CALIB++; |
Lightvalve | 50:3c630b5eba9f | 1166 | // break; |
Lightvalve | 50:3c630b5eba9f | 1167 | // } |
Lightvalve | 19:23b7c1ad8683 | 1168 | |
Lightvalve | 50:3c630b5eba9f | 1169 | // case MODE_ROTARY_FRICTION_TUNING: { |
Lightvalve | 50:3c630b5eba9f | 1170 | // if (TMR3_COUNT_ROTARY_FRIC_TUNE % (5 * TMR_FREQ_5k) == 0) freq_fric_tune = 4.0f + 3.0f * sin(2 * 3.14159f * 0.5f * TMR3_COUNT_ROTARY_FRIC_TUNE * 0.0001f * 0.05f); |
Lightvalve | 50:3c630b5eba9f | 1171 | // V_out = PWM_out * sin(2 * 3.14159f * freq_fric_tune * TMR3_COUNT_ROTARY_FRIC_TUNE * 0.0001f); |
Lightvalve | 50:3c630b5eba9f | 1172 | // if (V_out > 0) V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1173 | // else V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1174 | // TMR3_COUNT_ROTARY_FRIC_TUNE++; |
Lightvalve | 50:3c630b5eba9f | 1175 | // if (TMR3_COUNT_ROTARY_FRIC_TUNE > TUNING_TIME * TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1176 | // TMR3_COUNT_ROTARY_FRIC_TUNE = 0; |
Lightvalve | 50:3c630b5eba9f | 1177 | // V_out = 0.0f; |
Lightvalve | 50:3c630b5eba9f | 1178 | // CONTROL_MODE = MODE_NO_ACT; |
Lightvalve | 50:3c630b5eba9f | 1179 | // } |
Lightvalve | 50:3c630b5eba9f | 1180 | // break; |
Lightvalve | 50:3c630b5eba9f | 1181 | // } |
Lightvalve | 14:8e7590227d22 | 1182 | |
Lightvalve | 14:8e7590227d22 | 1183 | case MODE_DDV_POS_VS_PWM_ID: { |
Lightvalve | 59:f308b1656d9c | 1184 | CONTROL_MODE = MODE_VALVE_OPEN_LOOP; |
Lightvalve | 13:747daba9cf59 | 1185 | VALVE_ID_timer = VALVE_ID_timer + 1; |
Lightvalve | 14:8e7590227d22 | 1186 | |
Lightvalve | 14:8e7590227d22 | 1187 | if(VALVE_ID_timer < TMR_FREQ_5k*1) { |
Lightvalve | 60:64181f1d3e60 | 1188 | Vout.ref = 3000.0f * sin(2.0f*3.14f*VALVE_ID_timer/TMR_FREQ_5k * 100.0f); |
Lightvalve | 14:8e7590227d22 | 1189 | } else if(VALVE_ID_timer < TMR_FREQ_5k*2) { |
Lightvalve | 59:f308b1656d9c | 1190 | Vout.ref = 1000.0f*(ID_index_array[ID_index]); |
Lightvalve | 14:8e7590227d22 | 1191 | } else if(VALVE_ID_timer == TMR_FREQ_5k*2) { |
Lightvalve | 13:747daba9cf59 | 1192 | VALVE_POS_TMP = 0; |
Lightvalve | 13:747daba9cf59 | 1193 | data_num = 0; |
Lightvalve | 14:8e7590227d22 | 1194 | } else if(VALVE_ID_timer < TMR_FREQ_5k*3) { |
Lightvalve | 13:747daba9cf59 | 1195 | data_num = data_num + 1; |
Lightvalve | 13:747daba9cf59 | 1196 | VALVE_POS_TMP = VALVE_POS_TMP + value; |
Lightvalve | 14:8e7590227d22 | 1197 | } else if(VALVE_ID_timer == TMR_FREQ_5k*3) { |
Lightvalve | 59:f308b1656d9c | 1198 | Vout.ref = 0.0f; |
Lightvalve | 59:f308b1656d9c | 1199 | } else { |
Lightvalve | 13:747daba9cf59 | 1200 | VALVE_POS_AVG[ID_index] = VALVE_POS_TMP / data_num; |
Lightvalve | 13:747daba9cf59 | 1201 | VALVE_ID_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1202 | ID_index= ID_index +1; |
Lightvalve | 13:747daba9cf59 | 1203 | } |
Lightvalve | 14:8e7590227d22 | 1204 | |
Lightvalve | 17:1865016ca2e7 | 1205 | if(ID_index>=25) { |
Lightvalve | 13:747daba9cf59 | 1206 | int i; |
Lightvalve | 13:747daba9cf59 | 1207 | VALVE_POS_AVG_OLD = VALVE_POS_AVG[0]; |
Lightvalve | 17:1865016ca2e7 | 1208 | for(i=0; i<25; i++) { |
Lightvalve | 13:747daba9cf59 | 1209 | VALVE_POS_VS_PWM[i] = (int16_t) (VALVE_POS_AVG[i]); |
Lightvalve | 14:8e7590227d22 | 1210 | if(VALVE_POS_AVG[i] > VALVE_POS_AVG_OLD) { |
Lightvalve | 13:747daba9cf59 | 1211 | VALVE_MAX_POS = VALVE_POS_AVG[i]; |
Lightvalve | 13:747daba9cf59 | 1212 | VALVE_POS_AVG_OLD = VALVE_MAX_POS; |
Lightvalve | 14:8e7590227d22 | 1213 | } else if(VALVE_POS_AVG[i] < VALVE_POS_AVG_OLD) { |
Lightvalve | 13:747daba9cf59 | 1214 | VALVE_MIN_POS = VALVE_POS_AVG[i]; |
Lightvalve | 13:747daba9cf59 | 1215 | VALVE_POS_AVG_OLD = VALVE_MIN_POS; |
Lightvalve | 13:747daba9cf59 | 1216 | } |
Lightvalve | 13:747daba9cf59 | 1217 | } |
Lightvalve | 59:f308b1656d9c | 1218 | ROM_RESET_DATA(); |
Lightvalve | 13:747daba9cf59 | 1219 | ID_index = 0; |
Lightvalve | 57:f4819de54e7a | 1220 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 13:747daba9cf59 | 1221 | } |
Lightvalve | 14:8e7590227d22 | 1222 | |
Lightvalve | 14:8e7590227d22 | 1223 | |
Lightvalve | 13:747daba9cf59 | 1224 | break; |
Lightvalve | 13:747daba9cf59 | 1225 | } |
Lightvalve | 14:8e7590227d22 | 1226 | |
Lightvalve | 14:8e7590227d22 | 1227 | case MODE_DDV_DEADZONE_AND_CENTER: { |
Lightvalve | 59:f308b1656d9c | 1228 | CONTROL_MODE = MODE_VALVE_OPEN_LOOP; |
Lightvalve | 13:747daba9cf59 | 1229 | VALVE_DZ_timer = VALVE_DZ_timer + 1; |
Lightvalve | 14:8e7590227d22 | 1230 | if(first_check == 0) { |
Lightvalve | 30:8d561f16383b | 1231 | if(VALVE_DZ_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1232 | Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 30:8d561f16383b | 1233 | } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1234 | Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 14:8e7590227d22 | 1235 | pos_plus_end = pos.sen; |
Lightvalve | 30:8d561f16383b | 1236 | } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1237 | Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 30:8d561f16383b | 1238 | } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1239 | Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 14:8e7590227d22 | 1240 | pos_minus_end = pos.sen; |
Lightvalve | 30:8d561f16383b | 1241 | } else if(VALVE_DZ_timer < (int) (3.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1242 | Vout.ref = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; |
Lightvalve | 30:8d561f16383b | 1243 | } else if(VALVE_DZ_timer < (int) (4.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1244 | Vout.ref = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; |
Lightvalve | 13:747daba9cf59 | 1245 | data_num = data_num + 1; |
Lightvalve | 13:747daba9cf59 | 1246 | VALVE_POS_TMP = VALVE_POS_TMP + value; |
Lightvalve | 30:8d561f16383b | 1247 | } else if(VALVE_DZ_timer == (int) (4.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1248 | Vout.ref = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; |
Lightvalve | 13:747daba9cf59 | 1249 | DDV_POS_AVG = VALVE_POS_TMP / data_num; |
Lightvalve | 14:8e7590227d22 | 1250 | START_POS = pos.sen; |
Lightvalve | 13:747daba9cf59 | 1251 | VALVE_POS_TMP = 0; |
Lightvalve | 13:747daba9cf59 | 1252 | data_num = 0; |
Lightvalve | 14:8e7590227d22 | 1253 | |
Lightvalve | 30:8d561f16383b | 1254 | } else if(VALVE_DZ_timer < (int) (5.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1255 | valve_pos.ref = DDV_POS_AVG; |
Lightvalve | 14:8e7590227d22 | 1256 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 14:8e7590227d22 | 1257 | |
Lightvalve | 30:8d561f16383b | 1258 | } else if(VALVE_DZ_timer < (int) (6.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1259 | valve_pos.ref = DDV_POS_AVG; |
Lightvalve | 14:8e7590227d22 | 1260 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 60:64181f1d3e60 | 1261 | |
Lightvalve | 30:8d561f16383b | 1262 | } else if(VALVE_DZ_timer == (int) (6.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1263 | valve_pos.ref = DDV_POS_AVG; |
Lightvalve | 14:8e7590227d22 | 1264 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 14:8e7590227d22 | 1265 | FINAL_POS = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1266 | |
Lightvalve | 60:64181f1d3e60 | 1267 | if((FINAL_POS - START_POS)>200) { |
Lightvalve | 13:747daba9cf59 | 1268 | DZ_case = 1; |
Lightvalve | 60:64181f1d3e60 | 1269 | } else if((FINAL_POS - START_POS)<-200) { |
Lightvalve | 13:747daba9cf59 | 1270 | DZ_case = -1; |
Lightvalve | 14:8e7590227d22 | 1271 | } else { |
Lightvalve | 13:747daba9cf59 | 1272 | DZ_case = 0; |
Lightvalve | 13:747daba9cf59 | 1273 | } |
Lightvalve | 61:bc8c8270f0ab | 1274 | |
Lightvalve | 60:64181f1d3e60 | 1275 | CAN_TX_PRES((int16_t) (DZ_case), (int16_t) (6)); |
Lightvalve | 50:3c630b5eba9f | 1276 | |
Lightvalve | 13:747daba9cf59 | 1277 | first_check = 1; |
Lightvalve | 13:747daba9cf59 | 1278 | DZ_DIRECTION = 1; |
Lightvalve | 13:747daba9cf59 | 1279 | VALVE_DZ_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1280 | Ref_Valve_Pos_Old = DDV_POS_AVG; |
Lightvalve | 13:747daba9cf59 | 1281 | DZ_NUM = 1; |
Lightvalve | 13:747daba9cf59 | 1282 | DZ_index = 1; |
Lightvalve | 14:8e7590227d22 | 1283 | |
Lightvalve | 13:747daba9cf59 | 1284 | } |
Lightvalve | 19:23b7c1ad8683 | 1285 | } else { |
Lightvalve | 14:8e7590227d22 | 1286 | if((DZ_case == -1 && DZ_NUM == 1) | (DZ_case == 1 && DZ_NUM == 1)) { |
Lightvalve | 30:8d561f16383b | 1287 | if(VALVE_DZ_timer < (int) (1.0 * (float) TMR_FREQ_5k)) { |
Lightvalve | 60:64181f1d3e60 | 1288 | Vout.ref = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; |
Lightvalve | 60:64181f1d3e60 | 1289 | //pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; |
Lightvalve | 60:64181f1d3e60 | 1290 | //CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 30:8d561f16383b | 1291 | } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1292 | START_POS = pos.sen; |
Lightvalve | 30:8d561f16383b | 1293 | } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1294 | valve_pos.ref = Ref_Valve_Pos_Old - DZ_case * DZ_DIRECTION * 64 / DZ_index; |
Lightvalve | 14:8e7590227d22 | 1295 | if(valve_pos.ref <= VALVE_MIN_POS) { |
Lightvalve | 14:8e7590227d22 | 1296 | valve_pos.ref = VALVE_MIN_POS; |
Lightvalve | 14:8e7590227d22 | 1297 | } else if(valve_pos.ref >= VALVE_MAX_POS) { |
Lightvalve | 14:8e7590227d22 | 1298 | valve_pos.ref = VALVE_MAX_POS; |
Lightvalve | 13:747daba9cf59 | 1299 | } |
Lightvalve | 14:8e7590227d22 | 1300 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 60:64181f1d3e60 | 1301 | |
Lightvalve | 30:8d561f16383b | 1302 | } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1303 | Ref_Valve_Pos_Old = valve_pos.ref; |
Lightvalve | 14:8e7590227d22 | 1304 | FINAL_POS = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1305 | |
Lightvalve | 14:8e7590227d22 | 1306 | if((FINAL_POS - START_POS)>100) { |
Lightvalve | 14:8e7590227d22 | 1307 | DZ_DIRECTION = 1 * DZ_case; |
Lightvalve | 14:8e7590227d22 | 1308 | } else if((FINAL_POS - START_POS)<-100) { |
Lightvalve | 14:8e7590227d22 | 1309 | DZ_DIRECTION = -1 * DZ_case; |
Lightvalve | 14:8e7590227d22 | 1310 | } else { |
Lightvalve | 13:747daba9cf59 | 1311 | DZ_DIRECTION = 1 * DZ_case; |
Lightvalve | 13:747daba9cf59 | 1312 | } |
Lightvalve | 14:8e7590227d22 | 1313 | |
Lightvalve | 13:747daba9cf59 | 1314 | VALVE_DZ_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1315 | DZ_index= DZ_index *2; |
Lightvalve | 14:8e7590227d22 | 1316 | if(DZ_index >= 128) { |
Lightvalve | 14:8e7590227d22 | 1317 | FIRST_DZ = valve_pos.ref; |
Lightvalve | 13:747daba9cf59 | 1318 | DZ_NUM = 2; |
Lightvalve | 13:747daba9cf59 | 1319 | Ref_Valve_Pos_Old = FIRST_DZ; |
Lightvalve | 13:747daba9cf59 | 1320 | DZ_index = 1; |
Lightvalve | 13:747daba9cf59 | 1321 | DZ_DIRECTION = 1; |
Lightvalve | 13:747daba9cf59 | 1322 | } |
Lightvalve | 13:747daba9cf59 | 1323 | } |
Lightvalve | 14:8e7590227d22 | 1324 | } else if((DZ_case == -1 && DZ_NUM == 2) | (DZ_case == 1 && DZ_NUM == 2)) { |
Lightvalve | 30:8d561f16383b | 1325 | if(VALVE_DZ_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 60:64181f1d3e60 | 1326 | Vout.ref = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; |
Lightvalve | 60:64181f1d3e60 | 1327 | //pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; |
Lightvalve | 60:64181f1d3e60 | 1328 | //CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 30:8d561f16383b | 1329 | } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1330 | START_POS = pos.sen; |
Lightvalve | 30:8d561f16383b | 1331 | } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 60:64181f1d3e60 | 1332 | valve_pos.ref = Ref_Valve_Pos_Old - DZ_case * DZ_DIRECTION * 64 / DZ_index; |
Lightvalve | 14:8e7590227d22 | 1333 | if(valve_pos.ref <= VALVE_MIN_POS) { |
Lightvalve | 14:8e7590227d22 | 1334 | valve_pos.ref = VALVE_MIN_POS; |
Lightvalve | 14:8e7590227d22 | 1335 | } else if(valve_pos.ref >= VALVE_MAX_POS) { |
Lightvalve | 14:8e7590227d22 | 1336 | valve_pos.ref = VALVE_MAX_POS; |
Lightvalve | 13:747daba9cf59 | 1337 | } |
Lightvalve | 14:8e7590227d22 | 1338 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 61:bc8c8270f0ab | 1339 | |
Lightvalve | 30:8d561f16383b | 1340 | } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1341 | Vout.ref = 0.0f; |
Lightvalve | 59:f308b1656d9c | 1342 | } else if(VALVE_DZ_timer > (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1343 | Ref_Valve_Pos_Old = valve_pos.ref; |
Lightvalve | 14:8e7590227d22 | 1344 | FINAL_POS = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1345 | |
Lightvalve | 14:8e7590227d22 | 1346 | if((FINAL_POS - START_POS)>100) { |
Lightvalve | 60:64181f1d3e60 | 1347 | DZ_DIRECTION = 1 * DZ_case; |
Lightvalve | 14:8e7590227d22 | 1348 | } else if((FINAL_POS - START_POS)<-100) { |
Lightvalve | 60:64181f1d3e60 | 1349 | DZ_DIRECTION = -1 * DZ_case; |
Lightvalve | 14:8e7590227d22 | 1350 | } else { |
Lightvalve | 60:64181f1d3e60 | 1351 | DZ_DIRECTION = -1 * DZ_case; |
Lightvalve | 13:747daba9cf59 | 1352 | } |
Lightvalve | 14:8e7590227d22 | 1353 | |
Lightvalve | 13:747daba9cf59 | 1354 | VALVE_DZ_timer = 0; |
Lightvalve | 60:64181f1d3e60 | 1355 | DZ_index= DZ_index * 2; |
Lightvalve | 14:8e7590227d22 | 1356 | if(DZ_index >= 128) { |
Lightvalve | 14:8e7590227d22 | 1357 | SECOND_DZ = valve_pos.ref; |
Lightvalve | 57:f4819de54e7a | 1358 | VALVE_CENTER = (int) (0.5f * (float) (FIRST_DZ) + 0.5f * (float) (SECOND_DZ)); |
Lightvalve | 13:747daba9cf59 | 1359 | first_check = 0; |
Lightvalve | 33:91b17819ec30 | 1360 | VALVE_DEADZONE_MINUS = (float) FIRST_DZ; |
Lightvalve | 33:91b17819ec30 | 1361 | VALVE_DEADZONE_PLUS = (float) SECOND_DZ; |
Lightvalve | 19:23b7c1ad8683 | 1362 | |
Lightvalve | 16:903b5a4433b4 | 1363 | ROM_RESET_DATA(); |
Lightvalve | 34:bb2ca2fc2a8e | 1364 | |
Lightvalve | 60:64181f1d3e60 | 1365 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 13:747daba9cf59 | 1366 | DZ_index = 1; |
Lightvalve | 13:747daba9cf59 | 1367 | } |
Lightvalve | 13:747daba9cf59 | 1368 | } |
Lightvalve | 14:8e7590227d22 | 1369 | } else if(DZ_case == 0 && DZ_NUM ==1) { |
Lightvalve | 30:8d561f16383b | 1370 | if(VALVE_DZ_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 60:64181f1d3e60 | 1371 | Vout.ref = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; |
Lightvalve | 60:64181f1d3e60 | 1372 | //pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; |
Lightvalve | 60:64181f1d3e60 | 1373 | //CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 30:8d561f16383b | 1374 | } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1375 | START_POS = pos.sen; |
Lightvalve | 30:8d561f16383b | 1376 | } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1377 | valve_pos.ref = Ref_Valve_Pos_Old - DZ_DIRECTION * 64 / DZ_index; |
Lightvalve | 14:8e7590227d22 | 1378 | if(valve_pos.ref <= VALVE_MIN_POS) { |
Lightvalve | 14:8e7590227d22 | 1379 | valve_pos.ref = VALVE_MIN_POS; |
Lightvalve | 14:8e7590227d22 | 1380 | } else if(valve_pos.ref >= VALVE_MAX_POS) { |
Lightvalve | 14:8e7590227d22 | 1381 | valve_pos.ref = VALVE_MAX_POS; |
Lightvalve | 13:747daba9cf59 | 1382 | } |
Lightvalve | 14:8e7590227d22 | 1383 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 61:bc8c8270f0ab | 1384 | |
Lightvalve | 30:8d561f16383b | 1385 | } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1386 | Ref_Valve_Pos_Old = valve_pos.ref; |
Lightvalve | 14:8e7590227d22 | 1387 | FINAL_POS = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1388 | |
Lightvalve | 14:8e7590227d22 | 1389 | if((FINAL_POS - START_POS)>100) { |
Lightvalve | 14:8e7590227d22 | 1390 | DZ_DIRECTION = 1; |
Lightvalve | 14:8e7590227d22 | 1391 | } else if((FINAL_POS - START_POS)<-100) { |
Lightvalve | 14:8e7590227d22 | 1392 | DZ_DIRECTION = -1; |
Lightvalve | 14:8e7590227d22 | 1393 | } else { |
Lightvalve | 13:747daba9cf59 | 1394 | DZ_DIRECTION = 1; |
Lightvalve | 13:747daba9cf59 | 1395 | } |
Lightvalve | 13:747daba9cf59 | 1396 | VALVE_DZ_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1397 | DZ_index= DZ_index *2; |
Lightvalve | 14:8e7590227d22 | 1398 | if(DZ_index >= 128) { |
Lightvalve | 14:8e7590227d22 | 1399 | FIRST_DZ = valve_pos.ref; |
Lightvalve | 13:747daba9cf59 | 1400 | DZ_NUM = 2; |
Lightvalve | 13:747daba9cf59 | 1401 | Ref_Valve_Pos_Old = FIRST_DZ; |
Lightvalve | 13:747daba9cf59 | 1402 | DZ_index = 1; |
Lightvalve | 13:747daba9cf59 | 1403 | DZ_DIRECTION = 1; |
Lightvalve | 13:747daba9cf59 | 1404 | } |
Lightvalve | 13:747daba9cf59 | 1405 | } |
Lightvalve | 14:8e7590227d22 | 1406 | } else { |
Lightvalve | 30:8d561f16383b | 1407 | if(VALVE_DZ_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 60:64181f1d3e60 | 1408 | Vout.ref = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; |
Lightvalve | 60:64181f1d3e60 | 1409 | //pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; |
Lightvalve | 60:64181f1d3e60 | 1410 | //CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 30:8d561f16383b | 1411 | } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1412 | START_POS = pos.sen; |
Lightvalve | 30:8d561f16383b | 1413 | } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1414 | valve_pos.ref = Ref_Valve_Pos_Old + DZ_DIRECTION * 64 / DZ_index; |
Lightvalve | 14:8e7590227d22 | 1415 | if(valve_pos.ref <= VALVE_MIN_POS) { |
Lightvalve | 14:8e7590227d22 | 1416 | valve_pos.ref = VALVE_MIN_POS; |
Lightvalve | 14:8e7590227d22 | 1417 | } else if(valve_pos.ref > VALVE_MAX_POS) { |
Lightvalve | 14:8e7590227d22 | 1418 | valve_pos.ref = VALVE_MAX_POS - 1; |
Lightvalve | 13:747daba9cf59 | 1419 | } |
Lightvalve | 14:8e7590227d22 | 1420 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 60:64181f1d3e60 | 1421 | |
Lightvalve | 30:8d561f16383b | 1422 | } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1423 | Vout.ref = 0.0f; |
Lightvalve | 59:f308b1656d9c | 1424 | } else if(VALVE_DZ_timer > (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1425 | Ref_Valve_Pos_Old = valve_pos.ref; |
Lightvalve | 14:8e7590227d22 | 1426 | FINAL_POS = pos.sen; |
Lightvalve | 61:bc8c8270f0ab | 1427 | |
Lightvalve | 60:64181f1d3e60 | 1428 | if((FINAL_POS - START_POS)>100) { |
Lightvalve | 13:747daba9cf59 | 1429 | DZ_DIRECTION = 1; |
Lightvalve | 60:64181f1d3e60 | 1430 | } else if((FINAL_POS - START_POS)<-100) { |
Lightvalve | 60:64181f1d3e60 | 1431 | DZ_DIRECTION = -1; |
Lightvalve | 60:64181f1d3e60 | 1432 | } else { |
Lightvalve | 13:747daba9cf59 | 1433 | DZ_DIRECTION = 1; |
Lightvalve | 60:64181f1d3e60 | 1434 | } |
Lightvalve | 14:8e7590227d22 | 1435 | |
Lightvalve | 13:747daba9cf59 | 1436 | VALVE_DZ_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1437 | DZ_index= DZ_index *2; |
Lightvalve | 14:8e7590227d22 | 1438 | if(DZ_index >= 128) { |
Lightvalve | 14:8e7590227d22 | 1439 | SECOND_DZ = valve_pos.ref; |
Lightvalve | 57:f4819de54e7a | 1440 | VALVE_CENTER = (int) (0.5f * (float) (FIRST_DZ) + 0.5f * (float) (SECOND_DZ)); |
Lightvalve | 13:747daba9cf59 | 1441 | first_check = 0; |
Lightvalve | 33:91b17819ec30 | 1442 | VALVE_DEADZONE_MINUS = (float) FIRST_DZ; |
Lightvalve | 33:91b17819ec30 | 1443 | VALVE_DEADZONE_PLUS = (float) SECOND_DZ; |
Lightvalve | 61:bc8c8270f0ab | 1444 | |
Lightvalve | 59:f308b1656d9c | 1445 | ROM_RESET_DATA(); |
Lightvalve | 34:bb2ca2fc2a8e | 1446 | |
Lightvalve | 57:f4819de54e7a | 1447 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 13:747daba9cf59 | 1448 | DZ_index = 1; |
Lightvalve | 13:747daba9cf59 | 1449 | } |
Lightvalve | 13:747daba9cf59 | 1450 | } |
Lightvalve | 13:747daba9cf59 | 1451 | } |
Lightvalve | 14:8e7590227d22 | 1452 | } |
Lightvalve | 13:747daba9cf59 | 1453 | break; |
Lightvalve | 13:747daba9cf59 | 1454 | } |
Lightvalve | 14:8e7590227d22 | 1455 | |
Lightvalve | 14:8e7590227d22 | 1456 | case MODE_DDV_POS_VS_FLOWRATE: { |
Lightvalve | 59:f308b1656d9c | 1457 | CONTROL_MODE = MODE_VALVE_OPEN_LOOP; |
Lightvalve | 13:747daba9cf59 | 1458 | VALVE_FR_timer = VALVE_FR_timer + 1; |
Lightvalve | 14:8e7590227d22 | 1459 | if(first_check == 0) { |
Lightvalve | 30:8d561f16383b | 1460 | if(VALVE_FR_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1461 | Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 23:59218d4a256d | 1462 | //CAN_TX_PRES((int16_t) (VALVE_FR_timer), (int16_t) (6)); |
Lightvalve | 30:8d561f16383b | 1463 | } else if(VALVE_FR_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1464 | Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 14:8e7590227d22 | 1465 | pos_plus_end = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1466 | // CAN_TX_PRES((int16_t) (V_out), (int16_t) (7)); |
Lightvalve | 30:8d561f16383b | 1467 | } else if(VALVE_FR_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1468 | Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 30:8d561f16383b | 1469 | } else if(VALVE_FR_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1470 | // CAN_TX_PRES((int16_t) (V_out), (int16_t) (8)); |
Lightvalve | 59:f308b1656d9c | 1471 | Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 14:8e7590227d22 | 1472 | pos_minus_end = pos.sen; |
Lightvalve | 13:747daba9cf59 | 1473 | first_check = 1; |
Lightvalve | 13:747daba9cf59 | 1474 | VALVE_FR_timer = 0; |
Lightvalve | 57:f4819de54e7a | 1475 | valve_pos.ref = (float) VALVE_CENTER; |
Lightvalve | 13:747daba9cf59 | 1476 | ID_index = 0; |
Lightvalve | 13:747daba9cf59 | 1477 | max_check = 0; |
Lightvalve | 13:747daba9cf59 | 1478 | min_check = 0; |
Lightvalve | 13:747daba9cf59 | 1479 | } |
Lightvalve | 14:8e7590227d22 | 1480 | } else { |
Lightvalve | 30:8d561f16383b | 1481 | if(VALVE_FR_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1482 | //V_out = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; |
Lightvalve | 59:f308b1656d9c | 1483 | pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; |
Lightvalve | 59:f308b1656d9c | 1484 | CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 30:8d561f16383b | 1485 | } else if(VALVE_FR_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 13:747daba9cf59 | 1486 | data_num = 0; |
Lightvalve | 57:f4819de54e7a | 1487 | valve_pos.ref = 10.0f*((float) ID_index_array[ID_index]) + (float) VALVE_CENTER; |
Lightvalve | 14:8e7590227d22 | 1488 | |
Lightvalve | 14:8e7590227d22 | 1489 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 14:8e7590227d22 | 1490 | START_POS = pos.sen; |
Lightvalve | 30:8d561f16383b | 1491 | } else if(VALVE_FR_timer < (int) (5.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 57:f4819de54e7a | 1492 | valve_pos.ref = 10.0f*((float) ID_index_array[ID_index]) + (float) VALVE_CENTER; |
Lightvalve | 14:8e7590227d22 | 1493 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 13:747daba9cf59 | 1494 | data_num = data_num + 1; |
Lightvalve | 30:8d561f16383b | 1495 | if(abs(0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen) > 20000.0f) { |
Lightvalve | 14:8e7590227d22 | 1496 | FINAL_POS = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1497 | one_period_end = 1; |
Lightvalve | 13:747daba9cf59 | 1498 | } |
Lightvalve | 30:8d561f16383b | 1499 | } else if(VALVE_FR_timer == (int) (5.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1500 | FINAL_POS = pos.sen; |
Lightvalve | 13:747daba9cf59 | 1501 | one_period_end = 1; |
Lightvalve | 59:f308b1656d9c | 1502 | V_out = 0.0f; |
Lightvalve | 13:747daba9cf59 | 1503 | } |
Lightvalve | 14:8e7590227d22 | 1504 | |
Lightvalve | 14:8e7590227d22 | 1505 | if(one_period_end == 1) { |
Lightvalve | 14:8e7590227d22 | 1506 | if(valve_pos.ref > VALVE_MAX_POS) { |
Lightvalve | 13:747daba9cf59 | 1507 | max_check = 1; |
Lightvalve | 14:8e7590227d22 | 1508 | } else if(valve_pos.ref < VALVE_MIN_POS) { |
Lightvalve | 13:747daba9cf59 | 1509 | min_check = 1; |
Lightvalve | 13:747daba9cf59 | 1510 | } |
Lightvalve | 13:747daba9cf59 | 1511 | JOINT_VEL[ID_index] = (FINAL_POS - START_POS) / data_num * TMR_FREQ_5k; // pulse/sec |
Lightvalve | 19:23b7c1ad8683 | 1512 | |
Lightvalve | 13:747daba9cf59 | 1513 | VALVE_FR_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1514 | one_period_end = 0; |
Lightvalve | 13:747daba9cf59 | 1515 | ID_index= ID_index +1; |
Lightvalve | 30:8d561f16383b | 1516 | V_out = 0.0f; |
Lightvalve | 13:747daba9cf59 | 1517 | } |
Lightvalve | 14:8e7590227d22 | 1518 | |
Lightvalve | 14:8e7590227d22 | 1519 | if(max_check == 1 && min_check == 1) { |
Lightvalve | 19:23b7c1ad8683 | 1520 | |
Lightvalve | 13:747daba9cf59 | 1521 | VALVE_POS_NUM = ID_index; |
Lightvalve | 59:f308b1656d9c | 1522 | ROM_RESET_DATA(); |
Lightvalve | 13:747daba9cf59 | 1523 | ID_index = 0; |
Lightvalve | 13:747daba9cf59 | 1524 | first_check = 0; |
Lightvalve | 13:747daba9cf59 | 1525 | VALVE_FR_timer = 0; |
Lightvalve | 57:f4819de54e7a | 1526 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 49:e7bcfc244d40 | 1527 | // CAN_TX_PRES((int16_t) (VALVE_FR_timer), (int16_t) (6)); |
Lightvalve | 13:747daba9cf59 | 1528 | } |
Lightvalve | 13:747daba9cf59 | 1529 | } |
Lightvalve | 13:747daba9cf59 | 1530 | break; |
Lightvalve | 13:747daba9cf59 | 1531 | } |
Lightvalve | 58:2eade98630e2 | 1532 | |
Lightvalve | 57:f4819de54e7a | 1533 | case MODE_SYSTEM_ID: { |
Lightvalve | 57:f4819de54e7a | 1534 | freq_sysid_Iref = (double) cnt_sysid * DT_TMR3 * 3.; |
Lightvalve | 57:f4819de54e7a | 1535 | valve_pos.ref = 2500.0f * sin(2.0f * 3.14159f * freq_sysid_Iref * (double) cnt_sysid * DT_TMR3); |
Lightvalve | 57:f4819de54e7a | 1536 | CONTROL_MODE = MODE_VALVE_OPEN_LOOP; |
Lightvalve | 57:f4819de54e7a | 1537 | cnt_sysid++; |
Lightvalve | 57:f4819de54e7a | 1538 | if (freq_sysid_Iref >= 300) { |
Lightvalve | 57:f4819de54e7a | 1539 | cnt_sysid = 0; |
Lightvalve | 57:f4819de54e7a | 1540 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 57:f4819de54e7a | 1541 | } |
Lightvalve | 57:f4819de54e7a | 1542 | break; |
Lightvalve | 57:f4819de54e7a | 1543 | } |
Lightvalve | 58:2eade98630e2 | 1544 | |
Lightvalve | 58:2eade98630e2 | 1545 | |
Lightvalve | 57:f4819de54e7a | 1546 | |
Lightvalve | 57:f4819de54e7a | 1547 | default: |
Lightvalve | 57:f4819de54e7a | 1548 | break; |
Lightvalve | 57:f4819de54e7a | 1549 | } |
Lightvalve | 57:f4819de54e7a | 1550 | |
Lightvalve | 57:f4819de54e7a | 1551 | // CONTROL MODE ------------------------------------------------------------ |
Lightvalve | 57:f4819de54e7a | 1552 | |
Lightvalve | 57:f4819de54e7a | 1553 | switch (CONTROL_MODE) { |
Lightvalve | 57:f4819de54e7a | 1554 | case MODE_NO_ACT: { |
Lightvalve | 57:f4819de54e7a | 1555 | V_out = 0.0f; |
Lightvalve | 57:f4819de54e7a | 1556 | break; |
Lightvalve | 57:f4819de54e7a | 1557 | } |
Lightvalve | 57:f4819de54e7a | 1558 | |
Lightvalve | 57:f4819de54e7a | 1559 | case MODE_VALVE_POSITION_CONTROL: { |
Lightvalve | 67:c2812cf26c38 | 1560 | if (OPERATING_MODE == 5) { //SW Valve |
Lightvalve | 57:f4819de54e7a | 1561 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 59:f308b1656d9c | 1562 | V_out = Vout.ref; |
Lightvalve | 67:c2812cf26c38 | 1563 | } else if (CURRENT_CONTROL_MODE == 0) { //PWM |
Lightvalve | 67:c2812cf26c38 | 1564 | V_out = valve_pos.ref; |
Lightvalve | 67:c2812cf26c38 | 1565 | } else { |
Lightvalve | 67:c2812cf26c38 | 1566 | I_REF = valve_pos.ref * 0.001f; |
Lightvalve | 57:f4819de54e7a | 1567 | } |
Lightvalve | 58:2eade98630e2 | 1568 | |
Lightvalve | 57:f4819de54e7a | 1569 | break; |
Lightvalve | 57:f4819de54e7a | 1570 | } |
Lightvalve | 57:f4819de54e7a | 1571 | |
Lightvalve | 57:f4819de54e7a | 1572 | case MODE_JOINT_CONTROL: { |
Lightvalve | 57:f4819de54e7a | 1573 | double torq_ref = 0.0f; |
Lightvalve | 57:f4819de54e7a | 1574 | pos.err = (pos.ref - pos.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm] |
Lightvalve | 67:c2812cf26c38 | 1575 | vel.err = (0.0f - vel.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm/s] |
Lightvalve | 57:f4819de54e7a | 1576 | pos.err_sum += pos.err/(float) TMR_FREQ_5k; //[mm] |
Lightvalve | 67:c2812cf26c38 | 1577 | |
Lightvalve | 67:c2812cf26c38 | 1578 | //K & D Low Pass Filter |
Lightvalve | 67:c2812cf26c38 | 1579 | float alpha_K_D = 1.0f/(1.0f + 5000.0f/(2.0f*3.14f*30.0f)); // f_cutoff : 30Hz |
Lightvalve | 67:c2812cf26c38 | 1580 | K_LPF = K_LPF*(1.0f-alpha_K_D)+K_SPRING*(alpha_K_D); |
Lightvalve | 67:c2812cf26c38 | 1581 | D_LPF = D_LPF*(1.0f-alpha_K_D)+D_DAMPER*(alpha_K_D); |
Lightvalve | 67:c2812cf26c38 | 1582 | |
Lightvalve | 67:c2812cf26c38 | 1583 | torq_ref = torq.ref + K_LPF * pos.err - D_LPF * vel.sen / ENC_PULSE_PER_POSITION; //[N] |
Lightvalve | 57:f4819de54e7a | 1584 | |
Lightvalve | 57:f4819de54e7a | 1585 | // torque feedback |
Lightvalve | 67:c2812cf26c38 | 1586 | torq.err = torq_ref - torq.sen; //[N] |
Lightvalve | 57:f4819de54e7a | 1587 | torq.err_sum += torq.err/(float) TMR_FREQ_5k; //[N] |
Lightvalve | 57:f4819de54e7a | 1588 | |
Lightvalve | 57:f4819de54e7a | 1589 | if (((OPERATING_MODE&0b110)>>1) == 0 || ((OPERATING_MODE&0b110)>>1) == 1) { |
Lightvalve | 58:2eade98630e2 | 1590 | |
Lightvalve | 57:f4819de54e7a | 1591 | double I_REF_POS = 0.0f; |
Lightvalve | 57:f4819de54e7a | 1592 | double I_REF_FORCE_FB = 0.0f; // I_REF by Force Feedback |
Lightvalve | 57:f4819de54e7a | 1593 | double I_REF_VC = 0.0f; // I_REF for velocity compensation |
Lightvalve | 57:f4819de54e7a | 1594 | |
Lightvalve | 57:f4819de54e7a | 1595 | double temp_vel_pos = 0.0f; |
Lightvalve | 57:f4819de54e7a | 1596 | double temp_vel_torq = 0.0f; |
Lightvalve | 57:f4819de54e7a | 1597 | double wn_Pos = 2.0f * PI * 5.0f; // f_cut : 5Hz Position Control |
Lightvalve | 58:2eade98630e2 | 1598 | |
Lightvalve | 69:3995ffeaa786 | 1599 | if ((OPERATING_MODE & 0x01) == 0) { // Rotary Mode |
Lightvalve | 57:f4819de54e7a | 1600 | temp_vel_pos = (0.01f * (double) P_GAIN_JOINT_POSITION * wn_Pos * pos.err + 0.01f * (double) I_GAIN_JOINT_POSITION * wn_Pos * pos.err_sum + 0.01f * (double) VELOCITY_COMP_GAIN * vel.ref / ENC_PULSE_PER_POSITION) * PI / 180.0f; // rad/s |
Lightvalve | 57:f4819de54e7a | 1601 | // L when P-gain = 100, f_cut = 10Hz L feedforward velocity |
Lightvalve | 69:3995ffeaa786 | 1602 | } else if ((OPERATING_MODE & 0x01) == 1) { |
Lightvalve | 57:f4819de54e7a | 1603 | temp_vel_pos = (0.01f * (double) P_GAIN_JOINT_POSITION * wn_Pos * pos.err + 0.01f * (double) I_GAIN_JOINT_POSITION * wn_Pos * pos.err_sum + 0.01f * (double) VELOCITY_COMP_GAIN * vel.ref / ENC_PULSE_PER_POSITION); // mm/s |
Lightvalve | 57:f4819de54e7a | 1604 | // L when P-gain = 100, f_cut = 10Hz L feedforward velocity |
Lightvalve | 57:f4819de54e7a | 1605 | } |
Lightvalve | 57:f4819de54e7a | 1606 | if (temp_vel_pos > 0.0f) I_REF_POS = temp_vel_pos * ((double) PISTON_AREA_A * 0.00006f / (K_v * sqrt(2.0f * alpha3 / (alpha3 + 1.0f)))); |
Lightvalve | 57:f4819de54e7a | 1607 | else I_REF_POS = temp_vel_pos * ((double) PISTON_AREA_B * 0.00006f / (K_v * sqrt(2.0f / (alpha3 + 1.0f)))); |
Lightvalve | 57:f4819de54e7a | 1608 | |
Lightvalve | 57:f4819de54e7a | 1609 | // velocity compensation for torque control |
Lightvalve | 69:3995ffeaa786 | 1610 | if ((OPERATING_MODE & 0x01) == 0) { // Rotary Mode |
Lightvalve | 57:f4819de54e7a | 1611 | I_REF_FORCE_FB = 0.001f * ((double) P_GAIN_JOINT_TORQUE * torq.err + (double) I_GAIN_JOINT_TORQUE * torq.err_sum); |
Lightvalve | 57:f4819de54e7a | 1612 | // temp_vel_torq = (0.01 * (double) VELOCITY_COMP_GAIN * (double) CUR_VELOCITY / (double) ENC_PULSE_PER_POSITION) * PI / 180.0; // rad/s |
Lightvalve | 57:f4819de54e7a | 1613 | temp_vel_torq = (0.01f * (double) VELOCITY_COMP_GAIN * vel.ref / (double) ENC_PULSE_PER_POSITION) * PI / 180.0f; // rad/s |
Lightvalve | 57:f4819de54e7a | 1614 | // L feedforward velocity |
Lightvalve | 69:3995ffeaa786 | 1615 | } else if ((OPERATING_MODE & 0x01) == 1) { |
Lightvalve | 57:f4819de54e7a | 1616 | I_REF_FORCE_FB = 0.001f * 0.01f*((double) P_GAIN_JOINT_TORQUE * torq.err + (double) I_GAIN_JOINT_TORQUE * torq.err_sum); // Linear Actuators are more sensitive. |
Lightvalve | 57:f4819de54e7a | 1617 | // temp_vel_torq = (0.01 * (double) VELOCITY_COMP_GAIN * (double) CUR_VELOCITY / (double) ENC_PULSE_PER_POSITION); // mm/s |
Lightvalve | 57:f4819de54e7a | 1618 | temp_vel_torq = (0.01f * (double) VELOCITY_COMP_GAIN * vel.ref / (double) ENC_PULSE_PER_POSITION); // mm/s |
Lightvalve | 57:f4819de54e7a | 1619 | // L feedforward velocity |
Lightvalve | 57:f4819de54e7a | 1620 | } |
Lightvalve | 57:f4819de54e7a | 1621 | if (temp_vel_torq > 0.0f) I_REF_VC = temp_vel_torq * ((double) PISTON_AREA_A * 0.00006f / (K_v * sqrt(2.0f * alpha3 / (alpha3 + 1.0f)))); |
Lightvalve | 57:f4819de54e7a | 1622 | else I_REF_VC = temp_vel_torq * ((double) PISTON_AREA_B * 0.00006f / (K_v * sqrt(2.0f / (alpha3 + 1.0f)))); |
Lightvalve | 57:f4819de54e7a | 1623 | // L velocity(rad/s or mm/s) >> I_ref(mA) |
Lightvalve | 57:f4819de54e7a | 1624 | // Ref_Joint_FT_dot = (Ref_Joint_FT_Nm - Ref_Joint_FT_Nm_old) / TMR_DT_5k; |
Lightvalve | 57:f4819de54e7a | 1625 | // Ref_Joint_FT_Nm_old = Ref_Joint_FT_Nm; |
Lightvalve | 57:f4819de54e7a | 1626 | |
Lightvalve | 57:f4819de54e7a | 1627 | I_REF = (1.0f - alpha_trans) * I_REF_POS + alpha_trans * (I_REF_VC + I_REF_FORCE_FB); |
Lightvalve | 67:c2812cf26c38 | 1628 | |
Lightvalve | 67:c2812cf26c38 | 1629 | // Anti-windup for FT |
Lightvalve | 67:c2812cf26c38 | 1630 | if (I_GAIN_JOINT_TORQUE != 0) { |
Lightvalve | 67:c2812cf26c38 | 1631 | double I_MAX = 10.0f; // Maximum Current : 10mV |
Lightvalve | 67:c2812cf26c38 | 1632 | double Ka = 2.0f / ((double) I_GAIN_JOINT_TORQUE * 0.001f); |
Lightvalve | 67:c2812cf26c38 | 1633 | if (I_REF > I_MAX) { |
Lightvalve | 67:c2812cf26c38 | 1634 | double I_rem = I_REF - I_MAX; |
Lightvalve | 67:c2812cf26c38 | 1635 | I_rem = Ka*I_rem; |
Lightvalve | 67:c2812cf26c38 | 1636 | I_REF = I_MAX; |
Lightvalve | 67:c2812cf26c38 | 1637 | torq.err_sum = torq.err_sum - I_rem /(float) TMR_FREQ_5k; |
Lightvalve | 67:c2812cf26c38 | 1638 | } else if (I_REF < -I_MAX) { |
Lightvalve | 67:c2812cf26c38 | 1639 | double I_rem = I_REF - (-I_MAX); |
Lightvalve | 67:c2812cf26c38 | 1640 | I_rem = Ka*I_rem; |
Lightvalve | 67:c2812cf26c38 | 1641 | I_REF = -I_MAX; |
Lightvalve | 67:c2812cf26c38 | 1642 | torq.err_sum = torq.err_sum - I_rem /(float) TMR_FREQ_5k; |
Lightvalve | 67:c2812cf26c38 | 1643 | } |
Lightvalve | 67:c2812cf26c38 | 1644 | } |
Lightvalve | 57:f4819de54e7a | 1645 | |
Lightvalve | 57:f4819de54e7a | 1646 | } else { |
Lightvalve | 57:f4819de54e7a | 1647 | float VALVE_POS_RAW_FORCE_FB = 0.0f; |
Lightvalve | 72:3436ce769b1e | 1648 | float VALVE_POS_RAW_FORCE_FF = 0.0f; |
Lightvalve | 72:3436ce769b1e | 1649 | float VALVE_POS_RAW = 0.0f; |
Lightvalve | 72:3436ce769b1e | 1650 | |
Lightvalve | 57:f4819de54e7a | 1651 | VALVE_POS_RAW_FORCE_FB = alpha_trans*(((float) P_GAIN_JOINT_TORQUE * torq.err + (float) I_GAIN_JOINT_TORQUE * torq.err_sum) * 0.01f |
Lightvalve | 57:f4819de54e7a | 1652 | + DDV_JOINT_POS_FF(vel.sen))+ (1.0f-alpha_trans) * (P_GAIN_JOINT_POSITION * 0.01f * pos.err + DDV_JOINT_POS_FF(vel.ref)); |
Lightvalve | 57:f4819de54e7a | 1653 | |
Lightvalve | 72:3436ce769b1e | 1654 | VALVE_POS_RAW_FORCE_FF = P_GAIN_JOINT_TORQUE_FF * torq_ref * 0.001f + D_GAIN_JOINT_TORQUE_FF * (torq_ref - torq_ref_past) * 0.0001f; |
Lightvalve | 72:3436ce769b1e | 1655 | |
Lightvalve | 72:3436ce769b1e | 1656 | VALVE_POS_RAW = VALVE_POS_RAW_FORCE_FB + VALVE_POS_RAW_FORCE_FF; |
Lightvalve | 72:3436ce769b1e | 1657 | |
Lightvalve | 72:3436ce769b1e | 1658 | |
Lightvalve | 72:3436ce769b1e | 1659 | if (VALVE_POS_RAW >= 0) { |
Lightvalve | 72:3436ce769b1e | 1660 | valve_pos.ref = VALVE_POS_RAW + VALVE_DEADZONE_PLUS; |
Lightvalve | 57:f4819de54e7a | 1661 | } else { |
Lightvalve | 72:3436ce769b1e | 1662 | valve_pos.ref = VALVE_POS_RAW + VALVE_DEADZONE_MINUS; |
Lightvalve | 57:f4819de54e7a | 1663 | } |
Lightvalve | 57:f4819de54e7a | 1664 | |
Lightvalve | 57:f4819de54e7a | 1665 | if(I_GAIN_JOINT_TORQUE != 0) { |
Lightvalve | 57:f4819de54e7a | 1666 | double Ka = 1.0f / (double) I_GAIN_JOINT_TORQUE * 100.0f; |
Lightvalve | 57:f4819de54e7a | 1667 | if(valve_pos.ref>VALVE_MAX_POS) { |
Lightvalve | 57:f4819de54e7a | 1668 | double valve_pos_rem = valve_pos.ref - VALVE_MAX_POS; |
Lightvalve | 57:f4819de54e7a | 1669 | valve_pos_rem = valve_pos_rem * Ka; |
Lightvalve | 57:f4819de54e7a | 1670 | valve_pos.ref = VALVE_MAX_POS; |
Lightvalve | 57:f4819de54e7a | 1671 | torq.err_sum = torq.err_sum - valve_pos_rem/(float) TMR_FREQ_5k; |
Lightvalve | 57:f4819de54e7a | 1672 | } else if(valve_pos.ref < VALVE_MIN_POS) { |
Lightvalve | 57:f4819de54e7a | 1673 | double valve_pos_rem = valve_pos.ref - VALVE_MIN_POS; |
Lightvalve | 57:f4819de54e7a | 1674 | valve_pos_rem = valve_pos_rem * Ka; |
Lightvalve | 57:f4819de54e7a | 1675 | valve_pos.ref = VALVE_MIN_POS; |
Lightvalve | 57:f4819de54e7a | 1676 | torq.err_sum = torq.err_sum - valve_pos_rem/(float) TMR_FREQ_5k; |
Lightvalve | 57:f4819de54e7a | 1677 | } |
Lightvalve | 57:f4819de54e7a | 1678 | } |
Lightvalve | 61:bc8c8270f0ab | 1679 | |
Lightvalve | 57:f4819de54e7a | 1680 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 61:bc8c8270f0ab | 1681 | |
Lightvalve | 67:c2812cf26c38 | 1682 | // Vout.ref = (float) P_GAIN_JOINT_POSITION * 0.01f * ((float) pos.err); |
Lightvalve | 60:64181f1d3e60 | 1683 | V_out = (float) Vout.ref; |
Lightvalve | 57:f4819de54e7a | 1684 | |
Lightvalve | 57:f4819de54e7a | 1685 | } |
Lightvalve | 72:3436ce769b1e | 1686 | |
Lightvalve | 72:3436ce769b1e | 1687 | torq_ref_past = torq_ref; |
Lightvalve | 58:2eade98630e2 | 1688 | |
Lightvalve | 57:f4819de54e7a | 1689 | break; |
Lightvalve | 57:f4819de54e7a | 1690 | } |
Lightvalve | 58:2eade98630e2 | 1691 | |
Lightvalve | 57:f4819de54e7a | 1692 | case MODE_VALVE_OPEN_LOOP: { |
Lightvalve | 57:f4819de54e7a | 1693 | V_out = (float) Vout.ref; |
Lightvalve | 57:f4819de54e7a | 1694 | break; |
Lightvalve | 57:f4819de54e7a | 1695 | } |
Lightvalve | 14:8e7590227d22 | 1696 | |
Lightvalve | 12:6f2531038ea4 | 1697 | default: |
Lightvalve | 12:6f2531038ea4 | 1698 | break; |
Lightvalve | 12:6f2531038ea4 | 1699 | } |
Lightvalve | 14:8e7590227d22 | 1700 | |
Lightvalve | 57:f4819de54e7a | 1701 | |
Lightvalve | 57:f4819de54e7a | 1702 | if (((OPERATING_MODE&0b110)>>1) == 0 || ((OPERATING_MODE&0b110)>>1) == 1) { //Moog Valve or KNR Valve |
Lightvalve | 58:2eade98630e2 | 1703 | |
Lightvalve | 57:f4819de54e7a | 1704 | //////////////////////////////////////////////////////////////////////////// |
Lightvalve | 57:f4819de54e7a | 1705 | //////////////////////////// CURRENT CONTROL ////////////////////////////// |
Lightvalve | 57:f4819de54e7a | 1706 | //////////////////////////////////////////////////////////////////////////// |
Lightvalve | 57:f4819de54e7a | 1707 | if (CURRENT_CONTROL_MODE) { |
Lightvalve | 67:c2812cf26c38 | 1708 | double alpha_update_Iref = 1.0f / (1.0f + 5000.0f / (2.0f * 3.14f * 300.0f)); // f_cutoff : 500Hz |
Lightvalve | 57:f4819de54e7a | 1709 | I_REF_fil = (1.0f - alpha_update_Iref) * I_REF_fil + alpha_update_Iref*I_REF; |
Lightvalve | 57:f4819de54e7a | 1710 | |
Lightvalve | 57:f4819de54e7a | 1711 | I_ERR = I_REF_fil - cur.sen; |
Lightvalve | 67:c2812cf26c38 | 1712 | I_ERR_INT = I_ERR_INT + (I_ERR) * 0.0002f; |
Lightvalve | 57:f4819de54e7a | 1713 | |
Lightvalve | 57:f4819de54e7a | 1714 | |
Lightvalve | 57:f4819de54e7a | 1715 | // Moog Valve Current Control Gain |
Lightvalve | 67:c2812cf26c38 | 1716 | double R_model = 500.0f; // ohm |
Lightvalve | 57:f4819de54e7a | 1717 | double L_model = 1.2f; |
Lightvalve | 57:f4819de54e7a | 1718 | double w0 = 2.0f * 3.14f * 150.0f; |
Lightvalve | 57:f4819de54e7a | 1719 | double KP_I = 0.1f * L_model*w0; |
Lightvalve | 57:f4819de54e7a | 1720 | double KI_I = 0.1f * R_model*w0; |
Lightvalve | 57:f4819de54e7a | 1721 | |
Lightvalve | 57:f4819de54e7a | 1722 | // KNR Valve Current Control Gain |
Lightvalve | 57:f4819de54e7a | 1723 | if (((OPERATING_MODE & 0b110)>>1) == 1) { // KNR Valve |
Lightvalve | 57:f4819de54e7a | 1724 | R_model = 163.0f; // ohm |
Lightvalve | 57:f4819de54e7a | 1725 | L_model = 1.0f; |
Lightvalve | 57:f4819de54e7a | 1726 | w0 = 2.0f * 3.14f * 80.0f; |
Lightvalve | 57:f4819de54e7a | 1727 | KP_I = 1.0f * L_model*w0; |
Lightvalve | 57:f4819de54e7a | 1728 | KI_I = 0.08f * R_model*w0; |
Lightvalve | 57:f4819de54e7a | 1729 | } |
Lightvalve | 57:f4819de54e7a | 1730 | |
Lightvalve | 57:f4819de54e7a | 1731 | double FF_gain = 1.0f; |
Lightvalve | 57:f4819de54e7a | 1732 | |
Lightvalve | 67:c2812cf26c38 | 1733 | VALVE_PWM_RAW = KP_I * 2.0f * I_ERR + KI_I * 2.0f* I_ERR_INT; |
Lightvalve | 57:f4819de54e7a | 1734 | // VALVE_PWM_RAW = VALVE_PWM_RAW + FF_gain * (R_model*I_REF); // Unit : mV |
Lightvalve | 57:f4819de54e7a | 1735 | I_REF_fil_diff = I_REF_fil - I_REF_fil_old; |
Lightvalve | 57:f4819de54e7a | 1736 | I_REF_fil_old = I_REF_fil; |
Lightvalve | 67:c2812cf26c38 | 1737 | // VALVE_PWM_RAW = VALVE_PWM_RAW + FF_gain * (R_model * I_REF_fil + L_model * I_REF_fil_diff * 5000.0f); // Unit : mV |
Lightvalve | 67:c2812cf26c38 | 1738 | VALVE_PWM_RAW = VALVE_PWM_RAW + FF_gain * (R_model * I_REF_fil); // Unit : mV |
Lightvalve | 67:c2812cf26c38 | 1739 | double V_MAX = 12000.0f; // Maximum Voltage : 12V = 12000mV |
Lightvalve | 57:f4819de54e7a | 1740 | |
Lightvalve | 57:f4819de54e7a | 1741 | double Ka = 3.0f / KP_I; |
Lightvalve | 57:f4819de54e7a | 1742 | if (VALVE_PWM_RAW > V_MAX) { |
Lightvalve | 57:f4819de54e7a | 1743 | V_rem = VALVE_PWM_RAW - V_MAX; |
Lightvalve | 57:f4819de54e7a | 1744 | V_rem = Ka*V_rem; |
Lightvalve | 57:f4819de54e7a | 1745 | VALVE_PWM_RAW = V_MAX; |
Lightvalve | 67:c2812cf26c38 | 1746 | I_ERR_INT = I_ERR_INT - V_rem * 0.0002f; |
Lightvalve | 57:f4819de54e7a | 1747 | } else if (VALVE_PWM_RAW < -V_MAX) { |
Lightvalve | 57:f4819de54e7a | 1748 | V_rem = VALVE_PWM_RAW - (-V_MAX); |
Lightvalve | 57:f4819de54e7a | 1749 | V_rem = Ka*V_rem; |
Lightvalve | 57:f4819de54e7a | 1750 | VALVE_PWM_RAW = -V_MAX; |
Lightvalve | 67:c2812cf26c38 | 1751 | I_ERR_INT = I_ERR_INT - V_rem * 0.0002f; |
Lightvalve | 57:f4819de54e7a | 1752 | } |
Lightvalve | 57:f4819de54e7a | 1753 | Cur_Valve_Open_pulse = cur.sen / mA_PER_pulse; |
Lightvalve | 57:f4819de54e7a | 1754 | } else { |
Lightvalve | 57:f4819de54e7a | 1755 | VALVE_PWM_RAW = I_REF * mV_PER_mA; |
Lightvalve | 57:f4819de54e7a | 1756 | Cur_Valve_Open_pulse = I_REF / mA_PER_pulse; |
Lightvalve | 57:f4819de54e7a | 1757 | } |
Lightvalve | 57:f4819de54e7a | 1758 | |
Lightvalve | 57:f4819de54e7a | 1759 | //////////////////////////////////////////////////////////////////////////// |
Lightvalve | 57:f4819de54e7a | 1760 | ///////////////// Dead Zone Cancellation & Linearization ////////////////// |
Lightvalve | 57:f4819de54e7a | 1761 | //////////////////////////////////////////////////////////////////////////// |
Lightvalve | 57:f4819de54e7a | 1762 | // Dead Zone Cancellation (Mechanical Valve dead-zone) |
Lightvalve | 57:f4819de54e7a | 1763 | if (FLAG_VALVE_DEADZONE) { |
Lightvalve | 57:f4819de54e7a | 1764 | if (VALVE_PWM_RAW > 0) VALVE_PWM_RAW = VALVE_PWM_RAW + VALVE_DEADZONE_PLUS * mV_PER_pulse; // unit: mV |
Lightvalve | 57:f4819de54e7a | 1765 | else if (VALVE_PWM_RAW < 0) VALVE_PWM_RAW = VALVE_PWM_RAW + VALVE_DEADZONE_MINUS * mV_PER_pulse; // unit: mV |
Lightvalve | 57:f4819de54e7a | 1766 | |
Lightvalve | 57:f4819de54e7a | 1767 | VALVE_PWM_VALVE_DZ = VALVE_PWM_RAW + (double)VALVE_CENTER * mV_PER_pulse; // unit: mV |
Lightvalve | 57:f4819de54e7a | 1768 | |
Lightvalve | 57:f4819de54e7a | 1769 | } else { |
Lightvalve | 57:f4819de54e7a | 1770 | VALVE_PWM_VALVE_DZ = VALVE_PWM_RAW; |
Lightvalve | 57:f4819de54e7a | 1771 | } |
Lightvalve | 57:f4819de54e7a | 1772 | |
Lightvalve | 57:f4819de54e7a | 1773 | // Output Voltage Linearization |
Lightvalve | 57:f4819de54e7a | 1774 | double CUR_PWM_nonlin = VALVE_PWM_VALVE_DZ; // Unit : mV |
Lightvalve | 67:c2812cf26c38 | 1775 | double CUR_PWM_lin = PWM_duty_byLT(CUR_PWM_nonlin); // -8000~8000 |
Lightvalve | 57:f4819de54e7a | 1776 | |
Lightvalve | 57:f4819de54e7a | 1777 | // Dead Zone Cancellation (Electrical dead-zone) |
Lightvalve | 67:c2812cf26c38 | 1778 | if (CUR_PWM_lin > 0) V_out = (float) (CUR_PWM_lin + 169.0f); |
Lightvalve | 67:c2812cf26c38 | 1779 | else if (CUR_PWM_lin < 0) V_out = (float) (CUR_PWM_lin - 174.0f); |
Lightvalve | 67:c2812cf26c38 | 1780 | else V_out = (float) (CUR_PWM_lin); |
Lightvalve | 57:f4819de54e7a | 1781 | } |
Lightvalve | 89:a7b45368ea0f | 1782 | else { //////////////////////////sw valve |
Lightvalve | 89:a7b45368ea0f | 1783 | // Output Voltage Linearization |
Lightvalve | 89:a7b45368ea0f | 1784 | double CUR_PWM_nonlin = V_out; // Unit : mV |
Lightvalve | 89:a7b45368ea0f | 1785 | double CUR_PWM_lin = PWM_duty_byLT(CUR_PWM_nonlin); // -8000~8000 |
Lightvalve | 89:a7b45368ea0f | 1786 | |
Lightvalve | 89:a7b45368ea0f | 1787 | // Dead Zone Cancellation (Electrical dead-zone) |
Lightvalve | 89:a7b45368ea0f | 1788 | if (CUR_PWM_lin > 0) V_out = (float) (CUR_PWM_lin + 169.0f); |
Lightvalve | 89:a7b45368ea0f | 1789 | else if (CUR_PWM_lin < 0) V_out = (float) (CUR_PWM_lin - 174.0f); |
Lightvalve | 89:a7b45368ea0f | 1790 | else V_out = (float) (CUR_PWM_lin); |
Lightvalve | 89:a7b45368ea0f | 1791 | } |
Lightvalve | 67:c2812cf26c38 | 1792 | |
Lightvalve | 67:c2812cf26c38 | 1793 | // if(V_out > 0.0f) V_out = (float) (V_out + 169.0f); |
Lightvalve | 67:c2812cf26c38 | 1794 | // else if(V_out < 0.0f) V_out = (float) (V_out - 174.0f); |
Lightvalve | 67:c2812cf26c38 | 1795 | // else V_out = V_out; |
Lightvalve | 67:c2812cf26c38 | 1796 | |
jobuuu | 7:e9086c72bb22 | 1797 | /******************************************************* |
jobuuu | 7:e9086c72bb22 | 1798 | *** PWM |
jobuuu | 7:e9086c72bb22 | 1799 | ********************************************************/ |
Lightvalve | 67:c2812cf26c38 | 1800 | if(DIR_VALVE<0){ |
Lightvalve | 67:c2812cf26c38 | 1801 | V_out = -V_out; |
Lightvalve | 67:c2812cf26c38 | 1802 | } |
Lightvalve | 67:c2812cf26c38 | 1803 | |
Lightvalve | 49:e7bcfc244d40 | 1804 | if (V_out >= VALVE_VOLTAGE_LIMIT*1000.0f) { |
Lightvalve | 49:e7bcfc244d40 | 1805 | V_out = VALVE_VOLTAGE_LIMIT*1000.0f; |
Lightvalve | 49:e7bcfc244d40 | 1806 | } else if(V_out<=-VALVE_VOLTAGE_LIMIT*1000.0f) { |
Lightvalve | 49:e7bcfc244d40 | 1807 | V_out = -VALVE_VOLTAGE_LIMIT*1000.0f; |
Lightvalve | 27:a2254a485f23 | 1808 | } |
Lightvalve | 49:e7bcfc244d40 | 1809 | PWM_out= V_out/(SUPPLY_VOLTAGE*1000.0f); // Full duty : 12000.0mV |
Lightvalve | 13:747daba9cf59 | 1810 | |
Lightvalve | 19:23b7c1ad8683 | 1811 | // Saturation of output voltage to 12.0V |
Lightvalve | 30:8d561f16383b | 1812 | if(PWM_out > 1.0f) PWM_out=1.0f; |
Lightvalve | 30:8d561f16383b | 1813 | else if (PWM_out < -1.0f) PWM_out=-1.0f; |
Lightvalve | 13:747daba9cf59 | 1814 | |
Lightvalve | 30:8d561f16383b | 1815 | if (PWM_out>0.0f) { |
Lightvalve | 30:8d561f16383b | 1816 | dtc_v=0.0f; |
jobuuu | 1:e04e563be5ce | 1817 | dtc_w=PWM_out; |
jobuuu | 1:e04e563be5ce | 1818 | } else { |
jobuuu | 2:a1c0a37df760 | 1819 | dtc_v=-PWM_out; |
Lightvalve | 30:8d561f16383b | 1820 | dtc_w=0.0f; |
jobuuu | 1:e04e563be5ce | 1821 | } |
Lightvalve | 13:747daba9cf59 | 1822 | |
jobuuu | 1:e04e563be5ce | 1823 | //pwm |
Lightvalve | 30:8d561f16383b | 1824 | TIM4->CCR2 = (PWM_ARR)*(1.0f-dtc_v); |
Lightvalve | 30:8d561f16383b | 1825 | TIM4->CCR1 = (PWM_ARR)*(1.0f-dtc_w); |
Lightvalve | 67:c2812cf26c38 | 1826 | |
Lightvalve | 61:bc8c8270f0ab | 1827 | |
Lightvalve | 57:f4819de54e7a | 1828 | if (TMR2_COUNT_CAN_TX % (int) ((int) TMR_FREQ_5k/CAN_FREQ) == 0) { |
Lightvalve | 20:806196fda269 | 1829 | |
Lightvalve | 54:647072f5307a | 1830 | // Position, Velocity, and Torque (ID:1200) |
Lightvalve | 56:6f50d9d3bfee | 1831 | if (flag_data_request[0] == HIGH) { |
Lightvalve | 57:f4819de54e7a | 1832 | if ((OPERATING_MODE & 0b01) == 0) { // Rotary Actuator |
Lightvalve | 54:647072f5307a | 1833 | if (SENSING_MODE == 0) { |
Lightvalve | 67:c2812cf26c38 | 1834 | CAN_TX_POSITION_FT((int16_t) (pos.sen), (int16_t) (vel.sen/10.0f), (int16_t) (torq.sen*10.0f)); |
Lightvalve | 54:647072f5307a | 1835 | } else if (SENSING_MODE == 1) { |
Lightvalve | 58:2eade98630e2 | 1836 | CAN_TX_POSITION_PRESSURE((int16_t) (pos.sen), (int16_t) (vel.sen/10.0f), (int16_t) ((pres_A.sen)*5.0f), (int16_t) ((pres_B.sen)*5.0f)); |
Lightvalve | 54:647072f5307a | 1837 | } |
Lightvalve | 57:f4819de54e7a | 1838 | } else if ((OPERATING_MODE & 0b01) == 1) { // Linear Actuator |
Lightvalve | 54:647072f5307a | 1839 | if (SENSING_MODE == 0) { |
Lightvalve | 67:c2812cf26c38 | 1840 | CAN_TX_POSITION_FT((int16_t) (pos.sen/10.0f), (int16_t) (vel.sen/256.0f), (int16_t) (torq.sen * 10.0f * (float)(TORQUE_SENSOR_PULSE_PER_TORQUE))); |
Lightvalve | 54:647072f5307a | 1841 | } else if (SENSING_MODE == 1) { |
Lightvalve | 67:c2812cf26c38 | 1842 | CAN_TX_POSITION_PRESSURE((int16_t) (pos.sen/10.0f), (int16_t) (vel.sen/256.0f), (int16_t) ((pres_A.sen)*5.0f), (int16_t) ((pres_B.sen)*5.0f)); |
Lightvalve | 54:647072f5307a | 1843 | } |
Lightvalve | 52:8ea76864368a | 1844 | } |
Lightvalve | 52:8ea76864368a | 1845 | } |
Lightvalve | 56:6f50d9d3bfee | 1846 | if (flag_data_request[1] == HIGH) { |
Lightvalve | 54:647072f5307a | 1847 | //valve position |
Lightvalve | 54:647072f5307a | 1848 | double t_value = 0; |
Lightvalve | 97:d71c57e3515e | 1849 | if(valve_pos.ref>=(float) VALVE_CENTER) { |
Lightvalve | 97:d71c57e3515e | 1850 | t_value = 10000.0f*((double)valve_pos.ref - (double)VALVE_CENTER)/((double)VALVE_MAX_POS - (double)VALVE_CENTER); |
Lightvalve | 97:d71c57e3515e | 1851 | } else { |
Lightvalve | 97:d71c57e3515e | 1852 | t_value = -10000.0f*((double)valve_pos.ref - (double)VALVE_CENTER)/((double)VALVE_MIN_POS - (double)VALVE_CENTER); |
Lightvalve | 97:d71c57e3515e | 1853 | } |
Lightvalve | 97:d71c57e3515e | 1854 | // if(OPERATING_MODE==5) { |
Lightvalve | 97:d71c57e3515e | 1855 | // if(valve_pos.ref>=(float) VALVE_CENTER) { |
Lightvalve | 97:d71c57e3515e | 1856 | // t_value = 10000.0f*((double)value - (double)VALVE_CENTER)/((double)VALVE_MAX_POS - (double)VALVE_CENTER); |
Lightvalve | 97:d71c57e3515e | 1857 | // } else { |
Lightvalve | 97:d71c57e3515e | 1858 | // t_value = -10000.0f*((double)value - (double)VALVE_CENTER)/((double)VALVE_MIN_POS - (double)VALVE_CENTER); |
Lightvalve | 97:d71c57e3515e | 1859 | // } |
Lightvalve | 97:d71c57e3515e | 1860 | //t_value = (double) value; |
Lightvalve | 97:d71c57e3515e | 1861 | // } else if(CURRENT_CONTROL_MODE==1) { |
Lightvalve | 97:d71c57e3515e | 1862 | // t_value = cur.sen * 1000.0f; |
Lightvalve | 89:a7b45368ea0f | 1863 | // } else { |
Lightvalve | 97:d71c57e3515e | 1864 | // t_value = V_out; |
Lightvalve | 89:a7b45368ea0f | 1865 | // } |
Lightvalve | 67:c2812cf26c38 | 1866 | CAN_TX_TORQUE((int16_t) (t_value)); //1300 |
Lightvalve | 67:c2812cf26c38 | 1867 | //CAN_TX_TORQUE((int16_t) (cur.sen * 1000.0f)); //1300 |
Lightvalve | 67:c2812cf26c38 | 1868 | //CAN_TX_TORQUE((int16_t) (I_REF * 1000.0f)); //1300 |
Lightvalve | 54:647072f5307a | 1869 | } |
Lightvalve | 58:2eade98630e2 | 1870 | |
Lightvalve | 58:2eade98630e2 | 1871 | |
Lightvalve | 98:cd1b2da4704f | 1872 | if (flag_data_request[2] == HIGH) { |
Lightvalve | 89:a7b45368ea0f | 1873 | //CAN_TX_PRES((int16_t) (pres_A.sen), (int16_t) (pres_B.sen)); // 1400 |
Lightvalve | 89:a7b45368ea0f | 1874 | double t_value = 0; |
Lightvalve | 89:a7b45368ea0f | 1875 | if(valve_pos.ref>=(float) VALVE_CENTER) { |
Lightvalve | 89:a7b45368ea0f | 1876 | t_value = 10000.0f*((double)valve_pos.ref - (double)VALVE_CENTER)/((double)VALVE_MAX_POS - (double)VALVE_CENTER); |
Lightvalve | 89:a7b45368ea0f | 1877 | } else { |
Lightvalve | 89:a7b45368ea0f | 1878 | t_value = -10000.0f*((double)valve_pos.ref - (double)VALVE_CENTER)/((double)VALVE_MIN_POS - (double)VALVE_CENTER); |
Lightvalve | 89:a7b45368ea0f | 1879 | } |
Lightvalve | 89:a7b45368ea0f | 1880 | CAN_TX_PRES((int16_t) (t_value), (int16_t) (V_out)); // 1400 |
Lightvalve | 55:b25725257569 | 1881 | } |
Lightvalve | 58:2eade98630e2 | 1882 | |
Lightvalve | 57:f4819de54e7a | 1883 | //If it doesn't rest, below can can not work. |
Lightvalve | 57:f4819de54e7a | 1884 | for (can_rest = 0; can_rest < 10000; can_rest++) { |
Lightvalve | 57:f4819de54e7a | 1885 | ; |
Lightvalve | 57:f4819de54e7a | 1886 | } |
Lightvalve | 58:2eade98630e2 | 1887 | |
Lightvalve | 56:6f50d9d3bfee | 1888 | if (flag_data_request[3] == HIGH) { |
Lightvalve | 54:647072f5307a | 1889 | //PWM |
Lightvalve | 73:f80dc3970c99 | 1890 | //CAN_TX_PWM((int16_t) value); //1500 |
Lightvalve | 73:f80dc3970c99 | 1891 | CAN_TX_PWM((int16_t) input_NN[0] * 100.0f); //1500 |
Lightvalve | 54:647072f5307a | 1892 | } |
Lightvalve | 57:f4819de54e7a | 1893 | //for (i = 0; i < 10000; i++) { |
Lightvalve | 57:f4819de54e7a | 1894 | // ; |
Lightvalve | 57:f4819de54e7a | 1895 | // } |
Lightvalve | 56:6f50d9d3bfee | 1896 | if (flag_data_request[4] == HIGH) { |
Lightvalve | 54:647072f5307a | 1897 | //valve position |
Lightvalve | 73:f80dc3970c99 | 1898 | CAN_TX_VALVE_POSITION((int16_t) (input_NN[1] * 100.0f), (int16_t) (input_NN[2]* 100.0f), (int16_t) (input_NN[3]* 100.0f), (int16_t) (input_NN[4]* 100.0f)); //1600 |
Lightvalve | 54:647072f5307a | 1899 | } |
Lightvalve | 20:806196fda269 | 1900 | |
Lightvalve | 54:647072f5307a | 1901 | // Others : Reference position, Reference FT, PWM, Current (ID:1300) |
Lightvalve | 52:8ea76864368a | 1902 | // if (flag_data_request[1] == HIGH) { |
Lightvalve | 52:8ea76864368a | 1903 | // CAN_TX_SOMETHING((int) (FORCE_VREF), (int16_t) (1), (int16_t) (2), (int16_t) (3)); |
Lightvalve | 52:8ea76864368a | 1904 | // } |
Lightvalve | 54:647072f5307a | 1905 | //if (flag_delay_test == 1){ |
Lightvalve | 58:2eade98630e2 | 1906 | //CAN_TX_PRES((int16_t) (0),(int16_t) torq_ref); |
Lightvalve | 54:647072f5307a | 1907 | //} |
Lightvalve | 52:8ea76864368a | 1908 | |
Lightvalve | 54:647072f5307a | 1909 | TMR2_COUNT_CAN_TX = 0; |
Lightvalve | 54:647072f5307a | 1910 | } |
Lightvalve | 54:647072f5307a | 1911 | TMR2_COUNT_CAN_TX++; |
Lightvalve | 52:8ea76864368a | 1912 | |
Lightvalve | 20:806196fda269 | 1913 | } |
Lightvalve | 52:8ea76864368a | 1914 | TIM3->SR = 0x0; // reset the status register |
Lightvalve | 52:8ea76864368a | 1915 | |
Lightvalve | 58:2eade98630e2 | 1916 | } |