![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Original Version of STM Board
main.cpp@73:f80dc3970c99, 2020-06-08 (annotated)
- Committer:
- Lightvalve
- Date:
- Mon Jun 08 11:00:23 2020 +0000
- Revision:
- 73:f80dc3970c99
- Parent:
- 72:3436ce769b1e
- Child:
- 74:2bd13b02ed17
200608
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Lightvalve | 73:f80dc3970c99 | 1 | //200522-1 |
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 | 65:a2d7c63419c2 | 187 | |
Lightvalve | 68:328e1be06f5d | 188 | float x_past[num_array_x_past] = {0.0f}; |
Lightvalve | 68:328e1be06f5d | 189 | float f_past[num_array_f_past] = {0.0f}; |
Lightvalve | 68:328e1be06f5d | 190 | float f_future[num_array_f_future] = {0.0f}; |
Lightvalve | 66:a8e6799dbce3 | 191 | |
Lightvalve | 73:f80dc3970c99 | 192 | float input_NN[num_input] = { 0.0f }; |
Lightvalve | 65:a2d7c63419c2 | 193 | |
Lightvalve | 66:a8e6799dbce3 | 194 | const float h1[num_input][32] = { |
Lightvalve | 73:f80dc3970c99 | 195 | {-1.5316121578216553f,1.046117901802063f,0.10087299346923828f,-0.5920249819755554f,0.006000066641718149f,-0.06292402744293213f,-0.7302544713020325f,1.2003053426742554f,-0.22492285072803497f,-1.0005651712417603f,-0.19194258749485016f,0.6088903546333313f,-0.18402203917503357f,0.22412745654582977f,-0.20103082060813904f,-0.7672873735427856f,0.6400743722915649f,0.23753002285957336f,-0.3429633677005768f,1.2256020307540894f,-0.3417735695838928f,0.1018887460231781f,-0.31691664457321167f,-0.07546886801719666f,0.6211225390434265f,0.1750296652317047f,-0.16833457350730896f,-0.7552083134651184f,0.3320983946323395f,-0.17902883887290955f,-2.2890756130218506f,0.07611003518104553f}, |
Lightvalve | 73:f80dc3970c99 | 196 | {-1.4611567258834839f,1.0853360891342163f,0.2844829857349396f,-0.9236651062965393f,0.051900915801525116f,-0.05538089573383331f,-0.17226804792881012f,0.9712872505187988f,-0.1281311810016632f,-0.7099795341491699f,-0.27849888801574707f,0.6594517230987549f,0.020206838846206665f,0.1498834639787674f,0.04370078444480896f,-0.5641506910324097f,0.3744271993637085f,0.059967368841171265f,0.2747458517551422f,1.2454235553741455f,-0.05271541327238083f,-0.11504809558391571f,-0.0905606746673584f,0.2640003263950348f,0.4686833620071411f,0.2797521650791168f,0.12084531784057617f,-0.20431983470916748f,-0.07909221202135086f,0.09343862533569336f,-1.144808292388916f,0.09386715292930603f}, |
Lightvalve | 73:f80dc3970c99 | 197 | {-0.6785809397697449f,0.8657543659210205f,-0.004022121429443359f,-0.1997077912092209f,0.011013412848114967f,-0.1420801728963852f,-0.08535565435886383f,0.5210550427436829f,0.020213676616549492f,-0.5929723978042603f,0.26537173986434937f,0.6844944357872009f,-0.031272560358047485f,0.16001033782958984f,-0.3021453320980072f,-0.3262001574039459f,0.6271952390670776f,-0.25322937965393066f,0.13424378633499146f,0.9074867367744446f,0.18754218518733978f,-0.14585837721824646f,0.1290973722934723f,-0.23490183055400848f,0.22646471858024597f,0.13848352432250977f,-0.14778463542461395f,0.04744651913642883f,-0.2646981477737427f,0.28840622305870056f,-0.05210360512137413f,-0.18625950813293457f}, |
Lightvalve | 73:f80dc3970c99 | 198 | {-0.14816814661026f,0.1484924852848053f,-0.19558930397033691f,-0.4587199091911316f,-0.4259108603000641f,-0.003024315694347024f,0.09867669641971588f,-0.2979104220867157f,0.2820493280887604f,-0.2173389047384262f,0.1107335165143013f,0.5747724771499634f,-0.11249050498008728f,0.28691187500953674f,-0.12209486961364746f,-0.00012021820293739438f,-0.0060715447179973125f,-0.22630342841148376f,-0.2441006749868393f,0.13262957334518433f,-0.26148006319999695f,-0.08376853168010712f,-0.14013314247131348f,-0.277662992477417f,-0.09883667528629303f,0.1348792016506195f,0.12745562195777893f,0.13001176714897156f,0.13773585855960846f,0.1260412633419037f,1.1402820348739624f,0.16906705498695374f}, |
Lightvalve | 73:f80dc3970c99 | 199 | {0.9182100892066956f,-0.531394898891449f,0.08011308312416077f,0.04475727304816246f,-0.45140811800956726f,-0.06544674932956696f,0.27154937386512756f,-1.203261375427246f,-0.21332035958766937f,0.8113646507263184f,-0.23975150287151337f,-0.2693038582801819f,0.20140400528907776f,0.16929718852043152f,-0.2388615608215332f,0.20772291719913483f,-0.5291081070899963f,-0.17562326788902283f,0.10829375684261322f,-0.9625781774520874f,0.1068328246474266f,0.22469106316566467f,-0.2337813377380371f,-0.07104292511940002f,-0.5743539333343506f,-0.32632216811180115f,0.038649410009384155f,0.13008525967597961f,0.02648647502064705f,-0.15546131134033203f,1.5635931491851807f,0.025572150945663452f}, |
Lightvalve | 73:f80dc3970c99 | 200 | {2.718548536300659f,-2.4721014499664307f,0.2906685173511505f,1.2711524963378906f,-0.49755430221557617f,-0.025780361145734787f,0.5067746043205261f,-2.209226608276367f,-0.3355410695075989f,2.053006172180176f,0.2649611830711365f,-2.3765242099761963f,-0.029951006174087524f,-0.005192920565605164f,0.20863232016563416f,0.25620603561401367f,-1.375850796699524f,-0.30441316962242126f,-0.3512604534626007f,-2.340895891189575f,0.10424350202083588f,-0.009217172861099243f,0.11990180611610413f,0.3152395784854889f,-1.3226662874221802f,0.19827589392662048f,-0.278697669506073f,0.9180163145065308f,-0.34610462188720703f,-0.0012509822845458984f,0.33043405413627625f,-0.053316205739974976f}, |
Lightvalve | 73:f80dc3970c99 | 201 | {0.20082953572273254f,-0.3293028473854065f,0.15515866875648499f,0.38857918977737427f,0.022376351058483124f,-0.008546920493245125f,-0.04682992026209831f,-0.06396719813346863f,-0.13507501780986786f,-0.11766078323125839f,-0.08986316621303558f,-0.3768438398838043f,0.09392929077148438f,-0.02030598558485508f,-0.17407774925231934f,-0.041438039392232895f,-0.43712759017944336f,-0.07779207825660706f,0.2857636511325836f,-0.42887356877326965f,-0.18191516399383545f,-0.16872906684875488f,-0.2501657009124756f,-0.23358337581157684f,-0.5499646067619324f,-0.14798402786254883f,-0.1072954386472702f,-0.10270185768604279f,-0.3651081621646881f,-0.033211708068847656f,-1.7639816999435425f,0.11262083053588867f}, |
Lightvalve | 73:f80dc3970c99 | 202 | {0.1810125708580017f,0.04380026459693909f,0.1585540771484375f,0.09520703554153442f,0.13614939153194427f,-0.2871411144733429f,0.027985045686364174f,0.24350906908512115f,0.24975617229938507f,0.06216800585389137f,-0.22294187545776367f,-0.5886633396148682f,0.10294389724731445f,-0.07682676613330841f,0.052227020263671875f,-0.5156266093254089f,-0.15223275125026703f,-0.272625207901001f,-0.35299432277679443f,-0.18794843554496765f,-0.0981115773320198f,0.021598905324935913f,-0.12170252203941345f,-0.027094602584838867f,-0.28403598070144653f,0.016911834478378296f,-0.32526659965515137f,-0.22122310101985931f,-0.3122880160808563f,0.00411224365234375f,-1.6618061065673828f,0.24875596165657043f}, |
Lightvalve | 73:f80dc3970c99 | 203 | {0.011248071677982807f,-0.3440488576889038f,0.1305990219116211f,0.1634446233510971f,-0.1435123234987259f,-0.22065450251102448f,-0.13434356451034546f,0.12558163702487946f,-0.036939892917871475f,-0.12558740377426147f,-0.2808530926704407f,-0.1826796531677246f,0.10954022407531738f,0.22486212849617004f,0.23004469275474548f,-0.4840049743652344f,-0.15952230989933014f,0.05736207962036133f,0.12664148211479187f,-0.15527382493019104f,-0.31599417328834534f,-0.02127060294151306f,-0.2822587490081787f,0.08045688271522522f,-0.7549505233764648f,-0.07828792929649353f,-0.08483991026878357f,-0.0207098089158535f,-0.059344928711652756f,-0.11358706653118134f,-2.75872802734375f,0.0935753881931305f}, |
Lightvalve | 73:f80dc3970c99 | 204 | {-0.1231784000992775f,-0.039662137627601624f,-0.2328716218471527f,0.41179922223091125f,0.08715936541557312f,-0.14673462510108948f,0.10638939589262009f,-0.36458462476730347f,-0.30250200629234314f,-0.15081094205379486f,-0.33652785420417786f,0.12425272911787033f,0.08001843094825745f,0.10154984146356583f,-0.2551456391811371f,1.087019443511963f,0.08366376906633377f,0.316246896982193f,0.08225584775209427f,-0.21876347064971924f,-0.21885016560554504f,0.1560649871826172f,-0.11126312613487244f,-0.30638599395751953f,-0.40880250930786133f,0.05366125702857971f,0.1294359266757965f,0.2448592334985733f,-0.0201678816229105f,0.28930428624153137f,-1.4611858129501343f,0.1775827705860138f}, |
Lightvalve | 73:f80dc3970c99 | 205 | {-0.2089596837759018f,0.06453723460435867f,-0.0634300708770752f,0.13166697323322296f,-0.36363914608955383f,-0.6308650970458984f,-0.010237024165689945f,-0.10475338250398636f,-0.28933432698249817f,-0.18470923602581024f,-0.32581478357315063f,-0.04712572693824768f,-0.17047008872032166f,0.24898871779441833f,0.016325324773788452f,0.9002126455307007f,-0.3312543034553528f,-0.23234836757183075f,0.18384136259555817f,-0.2505335211753845f,0.13443168997764587f,-0.24138674139976501f,0.2283824384212494f,0.010796308517456055f,-0.18242990970611572f,0.09781908988952637f,0.07673224806785583f,-0.0375511609017849f,0.4107106029987335f,0.02820834517478943f,0.6104573607444763f,0.17321613430976868f}, |
Lightvalve | 73:f80dc3970c99 | 206 | {-0.25129181146621704f,1.0552700757980347f,-0.29345569014549255f,-0.5351536870002747f,-0.3985939621925354f,-1.1024703979492188f,-0.2657238245010376f,0.019460858777165413f,-0.22419829666614532f,0.47431257367134094f,0.282219797372818f,-0.16405567526817322f,-0.03579244017601013f,-0.1687009334564209f,-0.28509521484375f,-0.9953089356422424f,-0.001277706935070455f,-0.17347121238708496f,-0.3031772971153259f,-0.1526116281747818f,0.24897505342960358f,0.21679124236106873f,-0.22265808284282684f,0.31252244114875793f,-0.44624584913253784f,0.2008223831653595f,0.3222421705722809f,0.43312186002731323f,0.6519185900688171f,0.14098921418190002f,4.913338661193848f,-0.04709109663963318f}, |
Lightvalve | 73:f80dc3970c99 | 207 | {0.2144526243209839f,-0.4853420853614807f,0.1837349236011505f,0.4992810785770416f,-0.049303676933050156f,-0.16164228320121765f,-0.2237636148929596f,0.06998294591903687f,-0.1106376126408577f,0.9089545607566833f,-0.13708744943141937f,-0.047490619122982025f,-0.2591227889060974f,-0.3686586320400238f,0.061814457178115845f,4.4232940673828125f,-0.5329093933105469f,0.20787635445594788f,-0.02931533008813858f,-0.3807309567928314f,-0.2677971422672272f,0.025913476943969727f,0.011856883764266968f,-0.002827882766723633f,0.24938860535621643f,0.028789907693862915f,0.3261648118495941f,-0.2596067786216736f,-0.2998162508010864f,-0.32888755202293396f,-0.5427634119987488f,0.09549155831336975f}, |
Lightvalve | 73:f80dc3970c99 | 208 | {-0.001334975939244032f,-0.11350695043802261f,0.05985936522483826f,0.34115123748779297f,-0.11124051362276077f,0.01227458007633686f,0.2972363531589508f,-0.10988402366638184f,-0.06534075736999512f,0.8434353470802307f,0.28291523456573486f,-0.10051646828651428f,0.031953901052474976f,-0.0022092361468821764f,0.1021522581577301f,3.8103036880493164f,-0.31991440057754517f,0.08450636267662048f,-0.11887738108634949f,0.10229919105768204f,-0.24059925973415375f,-0.014602094888687134f,0.11327552795410156f,-0.31571850180625916f,0.20790383219718933f,-0.14150118827819824f,0.24654820561408997f,-0.39427995681762695f,-0.1427154541015625f,0.23035290837287903f,0.5915879011154175f,0.2325780689716339f}, |
Lightvalve | 73:f80dc3970c99 | 209 | {0.12685076892375946f,-0.10873474925756454f,0.24405649304389954f,-0.17700229585170746f,-0.31883007287979126f,0.11844643205404282f,0.30884283781051636f,0.3269212245941162f,0.07765036076307297f,0.8023349046707153f,-0.03895876184105873f,-0.05754624679684639f,0.18033960461616516f,-0.34255746006965637f,0.03770804405212402f,0.6625205278396606f,0.00980472657829523f,-0.06876960396766663f,0.23091186583042145f,0.2826549708843231f,0.2729778587818146f,0.2508205473423004f,0.025177806615829468f,0.2262592613697052f,-0.24321362376213074f,0.1852022111415863f,0.18975666165351868f,-0.5789910554885864f,-0.3306794762611389f,-0.09938693046569824f,0.4308316111564636f,-0.1806284636259079f}, |
Lightvalve | 73:f80dc3970c99 | 210 | {-0.12595590949058533f,-0.0918254479765892f,-0.13136014342308044f,0.04583144560456276f,-0.34972572326660156f,0.29451239109039307f,0.028729718178510666f,0.11094336211681366f,-0.18802323937416077f,0.9224112033843994f,-0.3028465509414673f,-0.21619796752929688f,0.05990728735923767f,-0.2451106309890747f,0.26781734824180603f,-1.2170041799545288f,-0.0901833325624466f,-0.13362249732017517f,-0.2815459072589874f,-0.45441287755966187f,0.14839361608028412f,0.06692108511924744f,-0.12372803688049316f,0.041742414236068726f,-0.18964315950870514f,-0.11748671531677246f,-0.11852662265300751f,-0.1516326367855072f,-0.2872304916381836f,0.2662833034992218f,-0.03345943242311478f,0.17151817679405212f}, |
Lightvalve | 73:f80dc3970c99 | 211 | {-0.04896603897213936f,-0.06419946998357773f,0.22696831822395325f,-0.3183729946613312f,0.11373230814933777f,-0.026064174249768257f,0.3809360861778259f,-0.1035236194729805f,0.301129013299942f,0.42611297965049744f,-0.32619306445121765f,-0.36584436893463135f,0.011522531509399414f,-0.1042637750506401f,-0.03764382004737854f,-0.5529539585113525f,0.12163998186588287f,0.23899778723716736f,0.1177738681435585f,0.02314203605055809f,0.1856810450553894f,0.2893877923488617f,-0.006054013967514038f,-0.10518202185630798f,-0.25214630365371704f,-0.27516937255859375f,-0.05509433150291443f,-0.18892589211463928f,0.030877724289894104f,-0.14826560020446777f,0.527121365070343f,-0.16339246928691864f}, |
Lightvalve | 73:f80dc3970c99 | 212 | {0.08396264910697937f,-0.20068591833114624f,0.30063238739967346f,-0.6196314692497253f,-0.3211996853351593f,-0.36317241191864014f,0.13618449866771698f,0.1404253989458084f,0.059888698160648346f,-0.06191140040755272f,0.16720986366271973f,-0.4092051386833191f,0.25101223587989807f,-0.2438148409128189f,0.10770025849342346f,-0.5144917368888855f,0.19408570230007172f,0.06214180588722229f,-0.1610698401927948f,0.22373145818710327f,0.2308855652809143f,-0.2509557604789734f,0.010174989700317383f,0.07912516593933105f,-0.18170639872550964f,0.022580862045288086f,0.09753298759460449f,-0.38260406255722046f,-0.30150505900382996f,0.3270951211452484f,0.5637995004653931f,-0.027072906494140625f}, |
Lightvalve | 73:f80dc3970c99 | 213 | {0.07517534494400024f,-0.13612450659275055f,-0.01902279257774353f,-0.296744704246521f,-0.4439983367919922f,0.26509934663772583f,0.23263545334339142f,0.023093458265066147f,-0.17553813755512238f,-0.03185465559363365f,0.16469305753707886f,-0.28393617272377014f,0.15116563439369202f,0.21735073626041412f,0.112009197473526f,-1.608994722366333f,0.094059519469738f,-0.09951440989971161f,-0.3688817322254181f,0.08099498599767685f,-0.02450268343091011f,-0.22721576690673828f,-0.058719635009765625f,0.2827478349208832f,-0.5673863291740417f,-0.11849872767925262f,-0.0910792350769043f,-0.6259247660636902f,-0.17078222334384918f,0.1612793505191803f,-0.06830675899982452f,-0.3307521343231201f}, |
Lightvalve | 73:f80dc3970c99 | 214 | {-0.17645062506198883f,-0.5214343070983887f,-0.22018472850322723f,0.062068577855825424f,0.05406512692570686f,0.3154950439929962f,-0.36925244331359863f,-0.3087034225463867f,-0.16332665085792542f,-0.35030171275138855f,-0.14849798381328583f,-0.03669149428606033f,0.17184868454933167f,-0.25622454285621643f,0.17424550652503967f,-0.8091639876365662f,0.012661978602409363f,-0.14159934222698212f,0.050866249948740005f,-0.32677870988845825f,0.1718762218952179f,0.034713178873062134f,0.04339686036109924f,-0.1864316463470459f,-0.44723203778266907f,-0.08606395125389099f,0.018100887537002563f,-0.22345711290836334f,-0.028657862916588783f,0.25916776061058044f,0.025130515918135643f,0.028863340616226196f}, |
Lightvalve | 73:f80dc3970c99 | 215 | {-0.09732287377119064f,-0.2573648691177368f,-0.07112669944763184f,-0.172755628824234f,-0.014765103347599506f,0.12664653360843658f,-0.17749442160129547f,-0.1892668455839157f,-0.21697230637073517f,-0.1893903613090515f,-0.31319567561149597f,-0.31168439984321594f,-0.21931910514831543f,0.20962679386138916f,-0.15002036094665527f,-0.7523041367530823f,-0.20464317500591278f,-0.1280200481414795f,0.03756003826856613f,0.4016495645046234f,0.2273504137992859f,-0.18634438514709473f,0.16605710983276367f,0.2803939878940582f,-0.2868742346763611f,0.3151257336139679f,-0.10340547561645508f,-0.37791118025779724f,-0.00679020443931222f,-0.28105688095092773f,0.08633270114660263f,0.02959480881690979f}, |
Lightvalve | 73:f80dc3970c99 | 216 | {0.14746327698230743f,-0.40016382932662964f,-0.31935176253318787f,-0.21832075715065002f,0.1683027148246765f,0.16693559288978577f,-0.3683743178844452f,-0.1856914758682251f,0.018035337328910828f,-0.6892287731170654f,-0.2238667607307434f,-0.4736902713775635f,-0.243825763463974f,0.1641266942024231f,-0.053373098373413086f,-0.8769702911376953f,0.009612754918634892f,0.2269948422908783f,-0.19954398274421692f,0.09266676008701324f,-0.27336224913597107f,-0.039089351892471313f,-0.04909595847129822f,-0.32456254959106445f,-0.231498584151268f,0.10373988747596741f,0.19934538006782532f,-0.4083142876625061f,-0.21434897184371948f,-0.3250839114189148f,0.1145261749625206f,-0.28260526061058044f}, |
Lightvalve | 65:a2d7c63419c2 | 217 | }; |
Lightvalve | 65:a2d7c63419c2 | 218 | |
Lightvalve | 66:a8e6799dbce3 | 219 | const float h2[32][32] = { |
Lightvalve | 73:f80dc3970c99 | 220 | {-0.16326946020126343f,-0.10295046865940094f,-0.04925942420959473f,0.050971269607543945f,-0.15490937232971191f,0.1877606362104416f,3.9929428100585938f,-0.051035910844802856f,-0.30411389470100403f,-0.10008957982063293f,-0.01741175539791584f,-0.7279316186904907f,-0.11304793506860733f,2.9829652309417725f,-0.3120362460613251f,-3.5567915439605713f,0.07803884148597717f,-0.21483641862869263f,-0.1311756670475006f,0.03230968117713928f,-2.2395131587982178f,-0.6140937209129333f,-0.23983746767044067f,-0.2296801060438156f,-1.5527613162994385f,-4.519993782043457f,-2.9003138542175293f,-1.8340901136398315f,0.23828622698783875f,0.11771553754806519f,-0.24613501131534576f,-3.15969181060791f}, |
Lightvalve | 73:f80dc3970c99 | 221 | {-0.19646918773651123f,0.002147972583770752f,-0.04321768879890442f,0.2524152100086212f,0.039372533559799194f,-0.24828968942165375f,0.6935232877731323f,-0.14352136850357056f,0.24677053093910217f,0.048597872257232666f,-0.12809783220291138f,1.2671866416931152f,0.010356568731367588f,-1.5664680004119873f,-0.19318237900733948f,-0.7424448132514954f,0.056778669357299805f,-0.2737269401550293f,-0.29584428668022156f,0.24127694964408875f,-0.48102137446403503f,-0.06914578378200531f,-0.16832955181598663f,0.2706228494644165f,-0.4924691617488861f,2.0721607208251953f,-1.8100959062576294f,1.475907325744629f,-0.28620439767837524f,-0.0511949360370636f,0.19307708740234375f,1.6319316625595093f}, |
Lightvalve | 66:a8e6799dbce3 | 222 | {-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 | 73:f80dc3970c99 | 223 | {-0.14173336327075958f,-0.01806354522705078f,-0.23058539628982544f,0.059558480978012085f,-0.27190759778022766f,-0.31705471873283386f,0.07028335332870483f,-0.05271124094724655f,-0.06944303214550018f,0.09271347522735596f,-0.502864420413971f,-0.2147229164838791f,-0.25770139694213867f,0.09395993500947952f,-0.38760676980018616f,-2.2978157997131348f,0.10996055603027344f,0.24023392796516418f,-0.047878652811050415f,-0.1802535057067871f,-0.10663941502571106f,-0.4868054687976837f,-0.06394433975219727f,-0.23531532287597656f,-2.773634195327759f,-0.4456554651260376f,0.060279812663793564f,-0.08077692240476608f,-0.22396358847618103f,0.2546447217464447f,0.03394383192062378f,0.09156961739063263f}, |
Lightvalve | 73:f80dc3970c99 | 224 | {-0.18258020281791687f,0.2506926953792572f,-0.0804666131734848f,0.08235585689544678f,0.02918580174446106f,-0.327265202999115f,-0.07576625049114227f,-0.13690795004367828f,0.043158918619155884f,-0.2690317630767822f,-0.5958983898162842f,-0.47659018635749817f,-0.27281659841537476f,-0.12866327166557312f,-0.38381248712539673f,-0.2798430621623993f,-0.10307048261165619f,0.15626338124275208f,-0.19660992920398712f,0.04106660932302475f,-0.0601617805659771f,0.05024907365441322f,0.19172045588493347f,-0.2798337936401367f,-0.05941186472773552f,-0.02522856369614601f,0.3012700378894806f,0.17071844637393951f,0.2695164978504181f,-0.16498444974422455f,0.008398771286010742f,-0.13133783638477325f}, |
Lightvalve | 73:f80dc3970c99 | 225 | {-0.19158349931240082f,-0.004258692264556885f,0.032371193170547485f,-0.2693426012992859f,-0.023485273122787476f,-0.29336631298065186f,0.6338390111923218f,-0.2668501138687134f,-0.03548547625541687f,0.08825305104255676f,-0.17250679433345795f,0.1041390523314476f,-0.26444390416145325f,0.41167017817497253f,-0.3789145052433014f,-0.32638683915138245f,0.2371552288532257f,0.24713221192359924f,0.23947544395923615f,0.19400858879089355f,-0.0887998715043068f,0.18473951518535614f,-0.1307595670223236f,-0.10346674174070358f,0.3634099066257477f,-0.23307152092456818f,0.5753985047340393f,-0.17762428522109985f,0.05800282955169678f,-0.26823562383651733f,0.17187702655792236f,0.18498310446739197f}, |
Lightvalve | 73:f80dc3970c99 | 226 | {-0.21433322131633759f,-0.1279313862323761f,-0.11171227693557739f,0.27164509892463684f,-0.26441383361816406f,0.16968202590942383f,-0.22347897291183472f,-0.2772391438484192f,-0.26620519161224365f,0.17144301533699036f,-0.6824053525924683f,-0.36272379755973816f,0.2655913531780243f,-0.5736172795295715f,-0.21337908506393433f,0.058745093643665314f,-0.16153597831726074f,0.18742787837982178f,-0.2565487325191498f,0.0900397077202797f,-0.33379432559013367f,-0.14819838106632233f,-0.07988794147968292f,-0.18341456353664398f,-0.2762095332145691f,0.31096121668815613f,-0.48296481370925903f,-0.2723126709461212f,-0.11822041869163513f,0.19546762108802795f,-0.16657039523124695f,-0.22732144594192505f}, |
Lightvalve | 73:f80dc3970c99 | 227 | {0.20982852578163147f,0.11346611380577087f,0.04012581706047058f,0.025473803281784058f,0.22828009724617004f,-0.3026310205459595f,-1.6610443592071533f,-0.12493795901536942f,0.2864855229854584f,0.01006925106048584f,-1.6744041442871094f,0.28360995650291443f,-0.2593194246292114f,-0.6620850563049316f,-0.29043570160865784f,-2.2500503063201904f,-0.2721019387245178f,0.2706601917743683f,-0.16461779177188873f,-0.11082688719034195f,-0.4680328369140625f,-0.3877258002758026f,-0.07979777455329895f,0.20552334189414978f,-4.128807544708252f,-0.4893045425415039f,1.5998578071594238f,0.2545700669288635f,-0.14135785400867462f,0.07403197884559631f,0.16089555621147156f,0.3558458089828491f}, |
Lightvalve | 73:f80dc3970c99 | 228 | {0.28564146161079407f,0.2890130579471588f,-0.021617114543914795f,0.11687019467353821f,0.29321715235710144f,0.07065775990486145f,-0.2717415988445282f,-0.23997274041175842f,0.29470762610435486f,-0.06864601373672485f,0.09986010938882828f,-0.09799063950777054f,0.24146446585655212f,-0.016309112310409546f,0.26754143834114075f,0.22709563374519348f,0.046292245388031006f,0.06025278568267822f,0.056145161390304565f,0.25802502036094666f,0.21172749996185303f,0.04203718900680542f,0.28743305802345276f,-0.016932066529989243f,0.035908136516809464f,-0.16033335030078888f,-0.04660121351480484f,0.1315695196390152f,0.2501918375492096f,-0.14010676741600037f,-0.24744901061058044f,-0.2319546937942505f}, |
Lightvalve | 73:f80dc3970c99 | 229 | {0.2116049975156784f,0.08643358945846558f,-0.29237738251686096f,-0.2233119159936905f,0.15896368026733398f,-0.165767103433609f,0.5119739770889282f,-0.2520345151424408f,0.18755429983139038f,-0.07031691074371338f,0.13431191444396973f,-0.417360782623291f,-0.09766045957803726f,0.13946810364723206f,-0.3310633897781372f,1.4794741868972778f,-0.015168905258178711f,-0.2859399914741516f,-0.45929256081581116f,-0.2024649679660797f,-1.1079310178756714f,-0.24853846430778503f,-0.2307620644569397f,0.14791369438171387f,0.1841735690832138f,-0.19036804139614105f,0.2987721264362335f,-1.4277855157852173f,0.2113950550556183f,0.0796298086643219f,-0.0010054409503936768f,1.4824200868606567f}, |
Lightvalve | 73:f80dc3970c99 | 230 | {0.19981321692466736f,0.1956864297389984f,-0.033508092164993286f,-0.22838544845581055f,-0.12505969405174255f,0.026693344116210938f,0.0956813171505928f,0.14285165071487427f,-0.17670965194702148f,0.17403557896614075f,-0.1869525909423828f,0.10795225948095322f,-0.1060299277305603f,0.0025149716529995203f,-0.21540889143943787f,0.02191716432571411f,0.03990337252616882f,0.0716913640499115f,0.1463070958852768f,-0.06274133175611496f,0.2751665413379669f,0.09515849500894547f,0.07470300793647766f,0.2698332369327545f,0.06326060742139816f,0.046824950724840164f,-0.048256684094667435f,-0.25542938709259033f,0.13817378878593445f,0.17853263020515442f,-0.009185433387756348f,0.02107522264122963f}, |
Lightvalve | 73:f80dc3970c99 | 231 | {-0.28804346919059753f,-0.09556084871292114f,0.12328919768333435f,0.09608548879623413f,-0.258735328912735f,-0.004608888179063797f,0.4559241235256195f,-0.2431015968322754f,0.17735600471496582f,0.009893029928207397f,-0.1309758722782135f,0.20345696806907654f,-0.2834458649158478f,-0.7466545104980469f,-0.006244654767215252f,-2.9013426303863525f,0.009990394115447998f,0.10842388868331909f,-0.017563465982675552f,0.20695523917675018f,0.004606326576322317f,-0.5708132982254028f,0.09996896982192993f,0.04907679185271263f,-0.967893123626709f,-2.6015706062316895f,-0.2869747579097748f,0.6055577397346497f,-0.288028746843338f,-0.2434448003768921f,0.17687886953353882f,-0.3418651819229126f}, |
Lightvalve | 66:a8e6799dbce3 | 232 | {-0.08816954493522644f,0.2728963792324066f,-0.07170480489730835f,0.1482785940170288f,0.07727676630020142f,0.20119628310203552f,0.03849402070045471f,0.02873826026916504f,-0.15294449031352997f,-0.038666754961013794f,-0.1574239432811737f,0.27019134163856506f,0.1312139928340912f,-0.26498496532440186f,0.1620480716228485f,0.12264445424079895f,0.023397088050842285f,0.21900424361228943f,0.25839516520500183f,0.2068612277507782f,-0.29656288027763367f,0.045920878648757935f,-0.19714993238449097f,0.22523340582847595f,0.07844719290733337f,0.22350957989692688f,-0.04062908887863159f,-0.26378923654556274f,0.18573936820030212f,0.15478622913360596f,0.013760745525360107f,0.010002970695495605f}, |
Lightvalve | 73:f80dc3970c99 | 233 | {0.14700931310653687f,0.1833711564540863f,-0.0858893096446991f,0.07914295792579651f,-0.25116482377052307f,0.2733006179332733f,0.13753771781921387f,-0.16134384274482727f,0.000652611255645752f,-0.22920364141464233f,0.1586657017469406f,-0.12103044241666794f,0.26723334193229675f,0.18380750715732574f,0.08766046911478043f,-0.21903924643993378f,-0.07963520288467407f,0.14483880996704102f,-0.3074553608894348f,-0.17277491092681885f,-0.18974721431732178f,0.20158080756664276f,-0.2228696048259735f,0.2315138280391693f,-0.08837060630321503f,0.0395948700606823f,0.05372410640120506f,0.021460043266415596f,-0.011228948831558228f,0.26896968483924866f,-0.28556761145591736f,-0.18896770477294922f}, |
Lightvalve | 66:a8e6799dbce3 | 234 | {-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 | 73:f80dc3970c99 | 235 | {-0.17367008328437805f,0.1317739188671112f,0.03260180354118347f,-0.16839730739593506f,-0.05160003900527954f,-0.5113937854766846f,-0.306745320558548f,-0.02774585410952568f,0.05445769429206848f,0.07657262682914734f,-0.5597742795944214f,-0.48852020502090454f,-0.04732672870159149f,-0.7129117846488953f,-0.035290397703647614f,-2.4951183795928955f,-0.25386664271354675f,-0.18997573852539062f,-0.4575275480747223f,-0.23375970125198364f,-0.18809296190738678f,-0.7232235074043274f,-0.3044300675392151f,0.22805070877075195f,-1.0960323810577393f,-0.7878693342208862f,-0.03980342671275139f,-0.0448833592236042f,-0.0006675124168395996f,-0.2239055633544922f,-0.035532981157302856f,0.5779961347579956f}, |
Lightvalve | 73:f80dc3970c99 | 236 | {-0.034729670733213425f,-0.062024205923080444f,0.10704237222671509f,-0.15739846229553223f,-0.04875987768173218f,0.017226072028279305f,-0.4658409357070923f,0.1428191065788269f,-0.23304778337478638f,-0.035415440797805786f,-0.7374803423881531f,-0.015124290250241756f,0.13907593488693237f,-0.22737517952919006f,-0.1961776167154312f,0.542763888835907f,-0.027234435081481934f,0.19620582461357117f,-0.05566025525331497f,-0.23526522517204285f,0.8212165236473083f,-0.2741292417049408f,-0.19671492278575897f,-0.3127191960811615f,-1.095475196838379f,-0.37894970178604126f,0.02289975807070732f,0.34884360432624817f,-0.2531542181968689f,0.24004116654396057f,-0.21812304854393005f,-0.21182672679424286f}, |
Lightvalve | 67:c2812cf26c38 | 237 | {0.1379433274269104f,-0.16078773140907288f,0.11784148216247559f,0.2671110928058624f,0.2693568766117096f,0.19759181141853333f,0.08533552289009094f,0.17868870496749878f,0.040603965520858765f,-0.2119520902633667f,0.1136421263217926f,-0.24326792359352112f,-0.07898660004138947f,0.2795462906360626f,-0.22247430682182312f,-0.0708579272031784f,0.18204066157341003f,0.2297056019306183f,0.034212857484817505f,0.05284380912780762f,-0.15357805788516998f,-0.2940097451210022f,0.26029130816459656f,0.2647087275981903f,0.1594548225402832f,0.04613301157951355f,-0.22981436550617218f,0.10197556018829346f,-0.08671019971370697f,-0.019541800022125244f,0.30332449078559875f,0.15016543865203857f}, |
Lightvalve | 73:f80dc3970c99 | 238 | {0.09298902750015259f,0.2841971218585968f,-0.0814327746629715f,-0.004546761512756348f,-0.017610490322113037f,0.11057800054550171f,-0.25087428092956543f,0.20642486214637756f,-0.2925014793872833f,0.022429823875427246f,-0.1203533336520195f,-0.04344084486365318f,-0.2097223699092865f,-0.048255983740091324f,0.05468165874481201f,0.21256521344184875f,0.1296386420726776f,0.027322769165039062f,0.21004201471805573f,-0.0019793203100562096f,0.26259565353393555f,0.07352039963006973f,0.06231796741485596f,0.17006443440914154f,0.007411579601466656f,0.19231633841991425f,-0.0562468096613884f,-0.07408905029296875f,0.14345040917396545f,-0.11986468732357025f,-0.19420018792152405f,0.16563236713409424f}, |
Lightvalve | 73:f80dc3970c99 | 239 | {-0.19453851878643036f,0.29651907086372375f,0.02990397810935974f,-0.03183019161224365f,0.1826970875263214f,-0.4306669235229492f,-2.333421468734741f,0.14081794023513794f,-0.2325194776058197f,-0.2458522766828537f,-0.18006348609924316f,0.08647046983242035f,-0.4315612316131592f,-1.720565676689148f,-0.07477915287017822f,2.3747122287750244f,0.2577105462551117f,0.11064860224723816f,-0.37064871191978455f,0.010507180355489254f,0.40755829215049744f,-0.5243611335754395f,-0.07374785840511322f,-0.015664272010326385f,0.229752317070961f,-4.937829971313477f,1.596664309501648f,0.5336189866065979f,-0.2205982804298401f,0.28094157576560974f,-0.1669490486383438f,0.39956894516944885f}, |
Lightvalve | 73:f80dc3970c99 | 240 | {0.2703488767147064f,-0.16041381657123566f,0.12738299369812012f,-0.03611093759536743f,0.1169431209564209f,0.1861400008201599f,-0.12824495136737823f,0.28177282214164734f,0.1474648416042328f,-0.23766008019447327f,0.024293899536132812f,0.036244120448827744f,0.09594401717185974f,-0.12182024121284485f,-0.16805587708950043f,-0.058941617608070374f,-0.22846683859825134f,0.08700510859489441f,-0.3013780415058136f,0.07154610753059387f,-0.11311932653188705f,0.22832396626472473f,-0.18301571905612946f,-0.17816279828548431f,0.00895837415009737f,0.23498231172561646f,0.13736982643604279f,-0.3111035227775574f,0.08541131019592285f,0.08213254809379578f,-0.29332536458969116f,0.1327129453420639f}, |
Lightvalve | 66:a8e6799dbce3 | 241 | {-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 | 66:a8e6799dbce3 | 242 | {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 | 66:a8e6799dbce3 | 243 | {-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 | 73:f80dc3970c99 | 244 | {-0.011267274618148804f,-0.25281068682670593f,-0.10565309226512909f,-0.054374486207962036f,0.2702934443950653f,-0.11885673552751541f,-0.11116353422403336f,-0.3345920145511627f,-0.06814777851104736f,-0.24531681835651398f,-0.8990318179130554f,0.03515978157520294f,-0.0395677387714386f,-0.05453812703490257f,-0.11613164842128754f,-0.9123259782791138f,0.2015441358089447f,0.04417389631271362f,-0.02469121851027012f,0.12593363225460052f,-0.41059863567352295f,-0.23646636307239532f,-0.2520882785320282f,0.2631355822086334f,-1.072510838508606f,-3.001229763031006f,-0.08817043155431747f,0.0003416698891669512f,-0.18211489915847778f,-0.15127526223659515f,0.20075061917304993f,-0.0948491171002388f}, |
Lightvalve | 66:a8e6799dbce3 | 245 | {-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 | 66:a8e6799dbce3 | 246 | {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 | 73:f80dc3970c99 | 247 | {0.3014208972454071f,-0.11652402579784393f,0.24921879172325134f,0.21162590384483337f,-0.2817712128162384f,-0.3030143082141876f,0.22799591720104218f,-0.24836668372154236f,0.23963233828544617f,0.21321198344230652f,-1.0052136182785034f,-0.01688615418970585f,-0.16443446278572083f,0.18270723521709442f,-0.2297925353050232f,-0.926933765411377f,-0.19791248440742493f,0.2487291395664215f,-0.3273348808288574f,-0.26565316319465637f,-0.37649425864219666f,0.004399613477289677f,-0.09928475320339203f,-0.2533465027809143f,-1.0978420972824097f,0.48929762840270996f,0.7250343561172485f,0.1685045212507248f,-0.03476092219352722f,0.2736774981021881f,0.004408210515975952f,0.33553993701934814f}, |
Lightvalve | 73:f80dc3970c99 | 248 | {-0.17075178027153015f,0.009595632553100586f,0.2466227114200592f,0.07792654633522034f,-0.29828932881355286f,-0.42616724967956543f,0.11710071563720703f,-0.28695422410964966f,-0.2516406178474426f,0.012286126613616943f,0.09375717490911484f,-0.23888254165649414f,-0.1534736603498459f,-0.011724728159606457f,-0.07792103290557861f,-0.1053847149014473f,-0.24087269604206085f,-0.048499464988708496f,-0.3150923550128937f,0.04290187731385231f,-0.34083160758018494f,-0.23348352313041687f,-0.031352698802948f,0.2588866651058197f,-0.18763604760169983f,-0.5401352047920227f,0.1810045689344406f,0.2899788022041321f,-0.07090267539024353f,-0.23986908793449402f,-0.2543276250362396f,0.12683501839637756f}, |
Lightvalve | 66:a8e6799dbce3 | 249 | {-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 | 73:f80dc3970c99 | 250 | {-0.1763739138841629f,-0.17203155159950256f,0.0620841383934021f,-0.002935647964477539f,-0.07396678626537323f,-0.4493316411972046f,1.3334112167358398f,0.034098364412784576f,-0.21029016375541687f,0.2210421860218048f,-0.8007190823554993f,0.22562140226364136f,-0.1720278114080429f,0.8404245972633362f,-0.17881757020950317f,0.20031636953353882f,0.10771593451499939f,-0.29308468103408813f,-0.13625413179397583f,-0.1528603732585907f,-1.0286694765090942f,-0.8565900325775146f,-0.22302524745464325f,0.1559164971113205f,-2.811842441558838f,1.9661753177642822f,-1.6081079244613647f,0.07771549373865128f,0.17976179718971252f,-0.22928372025489807f,0.28763797879219055f,0.5705336928367615f}, |
Lightvalve | 73:f80dc3970c99 | 251 | {-0.09888127446174622f,-0.22750279307365417f,-0.22503364086151123f,-0.008032619953155518f,-0.012498408555984497f,-0.24329537153244019f,-0.07913157343864441f,0.08175003528594971f,-0.016126900911331177f,0.06972584128379822f,0.06827792525291443f,0.2120952308177948f,-0.031845152378082275f,-0.30540701746940613f,0.18349257111549377f,0.20412376523017883f,-0.09216172993183136f,0.04617339372634888f,-0.09483018517494202f,-0.06833663582801819f,-0.026390254497528076f,-0.28567367792129517f,-0.06047184765338898f,-0.28923499584198f,0.01265987753868103f,-0.2029699683189392f,0.29187360405921936f,-0.2903735339641571f,-0.16326025128364563f,0.11664235591888428f,-0.02675291895866394f,0.1267804503440857f}, |
Lightvalve | 65:a2d7c63419c2 | 252 | }; |
Lightvalve | 65:a2d7c63419c2 | 253 | |
Lightvalve | 66:a8e6799dbce3 | 254 | const float h3[32][32] = { |
Lightvalve | 73:f80dc3970c99 | 255 | {-0.2551194727420807f,-0.09101890027523041f,-0.026477575302124023f,-0.24469062685966492f,-0.10447631776332855f,0.005303284619003534f,0.23563924431800842f,0.21467849612236023f,-0.16514207422733307f,0.034586966037750244f,-0.07635081559419632f,0.28293344378471375f,0.03883872181177139f,0.1892293095588684f,-0.2476848065853119f,0.13452908396720886f,0.033751994371414185f,0.2061004936695099f,-0.022569477558135986f,-0.10083381831645966f,-0.11890523135662079f,0.024368882179260254f,-0.22618433833122253f,0.044178664684295654f,0.25882774591445923f,-0.1258748173713684f,0.2930828630924225f,-0.22120264172554016f,0.08456003665924072f,0.2922307550907135f,-0.21407078206539154f,-0.1853330433368683f}, |
Lightvalve | 66:a8e6799dbce3 | 256 | {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 | 66:a8e6799dbce3 | 257 | {-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 | 73:f80dc3970c99 | 258 | {0.2906629145145416f,0.19203472137451172f,-0.2048129439353943f,0.2633720338344574f,0.1020251214504242f,-0.058899492025375366f,-0.061309605836868286f,-0.17915479838848114f,-0.02168092131614685f,-0.044261813163757324f,-0.09506386518478394f,0.24970653653144836f,0.14959025382995605f,0.07040172815322876f,0.22106656432151794f,-0.23978039622306824f,-0.28915077447891235f,0.030949801206588745f,-0.2734605371952057f,0.1836264431476593f,0.24216356873512268f,-0.0361824631690979f,-0.16484108567237854f,-0.27595841884613037f,0.19840911030769348f,-0.11024686694145203f,-0.09994620084762573f,-0.00024366378784179688f,-0.1939506083726883f,-0.25852420926094055f,0.05653107166290283f,0.0037463903427124023f}, |
Lightvalve | 67:c2812cf26c38 | 259 | {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 | 73:f80dc3970c99 | 260 | {0.10931676626205444f,0.2396949827671051f,0.12925085425376892f,-0.01787710189819336f,-0.15513373911380768f,0.0658058449625969f,-0.061815500259399414f,0.04091137647628784f,-0.24543136358261108f,-0.15699732303619385f,-0.057651348412036896f,-0.21529507637023926f,0.020223088562488556f,-0.020992251113057137f,0.2971965968608856f,0.25175121426582336f,-0.2889891266822815f,-0.13035915791988373f,0.2068924903869629f,-0.10121818631887436f,0.01788393035531044f,-0.31652653217315674f,0.023232191801071167f,0.27409639954566956f,-0.1627592295408249f,-0.18302330374717712f,0.09057381749153137f,0.01028666365891695f,-0.27729424834251404f,-0.29547566175460815f,-0.25800079107284546f,0.24402263760566711f}, |
Lightvalve | 73:f80dc3970c99 | 261 | {-0.21155381202697754f,0.11555894464254379f,-0.3375842273235321f,-0.25899580121040344f,-0.5256489515304565f,0.3981437385082245f,-0.11560182273387909f,0.2444917857646942f,0.10230787098407745f,1.5624498128890991f,-6.0789713859558105f,-0.3797595500946045f,0.36298131942749023f,-0.5448732376098633f,0.25543639063835144f,-0.1192857176065445f,-0.18917083740234375f,0.011466026306152344f,0.6969979405403137f,2.335822820663452f,0.6063205599784851f,-0.792424201965332f,-0.23246735334396362f,-0.2255190908908844f,0.8784614205360413f,-0.48243606090545654f,-0.26130008697509766f,-0.09065218269824982f,0.06049847602844238f,-0.09532724320888519f,0.03405633941292763f,0.17983141541481018f}, |
Lightvalve | 73:f80dc3970c99 | 262 | {-0.01093912124633789f,-0.23583689332008362f,0.28153905272483826f,0.2877257764339447f,-0.003743631299585104f,-0.1620817333459854f,0.036741942167282104f,-0.0059101879596710205f,-0.3300963044166565f,-0.27182313799858093f,0.09319102764129639f,-0.08139897882938385f,0.08707339316606522f,0.06235157698392868f,0.0685860812664032f,-0.29903873801231384f,0.1317853033542633f,0.20550194382667542f,-0.22115525603294373f,-0.39193177223205566f,0.19779208302497864f,0.19676683843135834f,0.0343703031539917f,0.12564969062805176f,0.12944568693637848f,0.23886635899543762f,-0.2778390347957611f,0.034354567527770996f,0.28547611832618713f,0.17161712050437927f,-0.017215043306350708f,-0.05991865694522858f}, |
Lightvalve | 66:a8e6799dbce3 | 263 | {-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 | 66:a8e6799dbce3 | 264 | {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 | 73:f80dc3970c99 | 265 | {-0.023678362369537354f,0.2771764099597931f,0.017873521894216537f,0.022997092455625534f,0.024810129776597023f,0.2613765597343445f,0.0393199622631073f,0.196751207113266f,-0.20596253871917725f,0.17963795363903046f,0.17463752627372742f,0.04822662100195885f,-0.1946902573108673f,0.06778408586978912f,0.080221027135849f,-0.2471318244934082f,0.026521950960159302f,0.28880444169044495f,-0.2722514867782593f,-0.5069992542266846f,-0.20101700723171234f,0.21886536478996277f,0.08564630150794983f,0.2614522874355316f,0.35179924964904785f,-0.25962090492248535f,0.02772158570587635f,-0.07828899472951889f,0.8830800652503967f,-0.2912617325782776f,-0.3602991998195648f,-0.3361721932888031f}, |
Lightvalve | 73:f80dc3970c99 | 266 | {0.2680447995662689f,-0.04194077476859093f,-0.6022524237632751f,-0.19889406859874725f,-0.2952810525894165f,-0.32753682136535645f,0.17733857035636902f,-0.17794576287269592f,-2.5405471324920654f,-0.9676181674003601f,-0.44661444425582886f,0.10291211307048798f,0.5018886923789978f,2.1795859336853027f,0.23152390122413635f,-0.07731422781944275f,0.21101722121238708f,-0.15284278988838196f,0.395886093378067f,0.010456563904881477f,1.215508222579956f,-0.17075811326503754f,-0.24210311472415924f,0.12623250484466553f,-0.6041556000709534f,-0.020351901650428772f,-0.3913725018501282f,-0.03234436735510826f,-0.08792643249034882f,-0.1739533692598343f,-0.46215856075286865f,-1.2778096199035645f}, |
Lightvalve | 73:f80dc3970c99 | 267 | {0.10771462321281433f,0.1270637810230255f,-0.1647956818342209f,-0.00161704421043396f,0.10816431045532227f,0.2421230524778366f,-0.2502448558807373f,-0.05063694715499878f,-0.1897546797990799f,-0.11501708626747131f,0.24353471398353577f,0.11519002914428711f,-0.1879904866218567f,0.0605493038892746f,-0.0055807530879974365f,0.05870962142944336f,-0.0561012327671051f,-0.1419317126274109f,-0.24982497096061707f,-0.042069949209690094f,-0.21048110723495483f,-0.1540573388338089f,0.2986377775669098f,-0.2888573110103607f,-0.07723522186279297f,-0.03866580128669739f,0.09892630577087402f,0.20166337490081787f,0.1267586350440979f,0.024399906396865845f,-0.264041006565094f,-0.037910252809524536f}, |
Lightvalve | 73:f80dc3970c99 | 268 | {0.07240793108940125f,-0.07661328464746475f,-0.07069046050310135f,-0.02916223742067814f,-0.18147224187850952f,-0.40131792426109314f,0.17870497703552246f,-0.09019742906093597f,1.1034103631973267f,-3.4376988410949707f,1.2077449560165405f,-0.2114412486553192f,-0.4626493453979492f,0.1759500950574875f,0.13272255659103394f,-0.0684008002281189f,-0.13351139426231384f,0.2471931278705597f,-0.5543991327285767f,-2.591998338699341f,-0.8945927023887634f,0.15569530427455902f,-0.044914066791534424f,0.28785380721092224f,0.2168842852115631f,-0.30555644631385803f,-0.38022580742836f,-0.009755823761224747f,-0.31310585141181946f,-0.29330405592918396f,-0.22947366535663605f,-2.5290331840515137f}, |
Lightvalve | 73:f80dc3970c99 | 269 | {-0.27890223264694214f,0.08861199021339417f,0.18213510513305664f,0.20657816529273987f,-0.10968903452157974f,0.028156545013189316f,-0.2505151033401489f,-0.2674597501754761f,-0.27857667207717896f,0.11670660972595215f,0.020896315574645996f,0.04456409811973572f,-0.15096987783908844f,0.1511862874031067f,-0.02410009503364563f,0.10129088163375854f,0.22686699032783508f,-0.30486053228378296f,-0.12621688842773438f,-0.0020874792244285345f,0.08171554654836655f,0.03120262362062931f,-0.09317314624786377f,0.11354613304138184f,0.10982992500066757f,-0.025903940200805664f,-0.15464875102043152f,-0.04880758002400398f,0.20984533429145813f,0.06508117914199829f,0.02118399739265442f,-0.003070831298828125f}, |
Lightvalve | 73:f80dc3970c99 | 270 | {0.3047083914279938f,0.12143945693969727f,-0.030520766973495483f,-0.29199281334877014f,0.21142122149467468f,1.0254100561141968f,-0.09724730253219604f,-0.25786101818084717f,-5.3391313552856445f,-0.34070342779159546f,-0.7626186609268188f,0.038040339946746826f,-0.08699492365121841f,-0.2679107189178467f,0.062144935131073f,-0.28920799493789673f,0.03473195433616638f,-0.0016761720180511475f,0.03706405684351921f,0.19646742939949036f,-2.230938196182251f,1.7041254043579102f,0.27043071389198303f,-0.10900285840034485f,0.9777950644493103f,-0.031148135662078857f,-0.18866202235221863f,0.02212020568549633f,0.03568693995475769f,0.017086774110794067f,-0.15847967565059662f,-0.14411842823028564f}, |
Lightvalve | 66:a8e6799dbce3 | 271 | {-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 | 67:c2812cf26c38 | 272 | {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 | 73:f80dc3970c99 | 273 | {-0.16101892292499542f,0.06696435809135437f,0.26537272334098816f,0.13945069909095764f,-0.06945167481899261f,-0.22229918837547302f,0.1589156985282898f,-0.17396175861358643f,0.25127315521240234f,-0.11376987397670746f,0.20405784249305725f,-0.04377517104148865f,-0.08261391520500183f,-0.024246346205472946f,-0.2592318058013916f,0.1978430449962616f,0.18047624826431274f,0.2863751947879791f,-0.1514630764722824f,-0.03983204439282417f,-0.08874796330928802f,0.12356612831354141f,0.29893049597740173f,0.13123968243598938f,-0.07798498868942261f,-0.28873488306999207f,-0.013772714883089066f,0.2438080608844757f,0.1386248916387558f,0.18439257144927979f,0.17250561714172363f,0.13921788334846497f}, |
Lightvalve | 73:f80dc3970c99 | 274 | {0.261911004781723f,-0.28497835993766785f,-0.2993849217891693f,-0.023781416937708855f,0.06433887034654617f,0.06450940668582916f,-0.06670857965946198f,-0.030254334211349487f,-0.28624898195266724f,0.1197996437549591f,0.01667046546936035f,-0.2924177646636963f,0.18427419662475586f,-0.11933153122663498f,-0.20773646235466003f,-0.10781967639923096f,-0.15712574124336243f,0.16112294793128967f,0.22489622235298157f,0.19089055061340332f,0.1918894499540329f,0.13768716156482697f,-0.3001303970813751f,0.14906415343284607f,0.1627657264471054f,0.0025720298290252686f,-0.05664414167404175f,-0.22471794486045837f,0.12718677520751953f,0.21125611662864685f,-0.05751854181289673f,-0.22727590799331665f}, |
Lightvalve | 73:f80dc3970c99 | 275 | {0.14277681708335876f,-0.323458731174469f,0.08033742755651474f,-0.23404449224472046f,-0.31116944551467896f,-0.30470114946365356f,0.1624150574207306f,-0.27022814750671387f,0.05864642933011055f,-0.6934435367584229f,0.7814860343933105f,-0.02736346796154976f,0.39837557077407837f,0.14340569078922272f,-0.03100520372390747f,-0.2484396994113922f,0.06366744637489319f,-0.2764144539833069f,-0.521210253238678f,1.6719543933868408f,-0.2273610234260559f,-1.0045647621154785f,0.2572875916957855f,-0.0716068297624588f,-0.2857397198677063f,-0.3089295029640198f,0.13684715330600739f,0.2871914803981781f,-0.3550509214401245f,-0.10488687455654144f,-0.32480448484420776f,0.9415252804756165f}, |
Lightvalve | 73:f80dc3970c99 | 276 | {0.29069945216178894f,-0.23835359513759613f,0.019009560346603394f,-0.30970773100852966f,0.11984284967184067f,-0.6793195605278015f,0.045349299907684326f,-0.17138783633708954f,0.4167804419994354f,0.020233217626810074f,-0.20003964006900787f,-0.15074089169502258f,-0.05425729975104332f,-0.5104228854179382f,0.09875330328941345f,0.08164769411087036f,0.2294725477695465f,0.10683679580688477f,-0.07596248388290405f,-0.12196816504001617f,0.11493495851755142f,-0.15881620347499847f,0.16651621460914612f,-0.15362010896205902f,-0.1951005756855011f,0.023651927709579468f,-0.1729920208454132f,0.5587583780288696f,0.12823010981082916f,0.19045329093933105f,0.02994692325592041f,-0.18855193257331848f}, |
Lightvalve | 73:f80dc3970c99 | 277 | {0.1991647183895111f,0.12534403800964355f,-0.04112154245376587f,0.23123982548713684f,-0.17588619887828827f,-0.302817702293396f,-0.1610087752342224f,-0.031804412603378296f,0.10274738073348999f,-0.25018924474716187f,0.15975651144981384f,-0.057292819023132324f,0.1464652419090271f,0.08016204833984375f,0.2151305377483368f,0.2952744662761688f,-0.21319252252578735f,0.04970458149909973f,0.10210192203521729f,0.3050673305988312f,0.21167120337486267f,-0.15151944756507874f,0.13887640833854675f,0.25299301743507385f,-0.11117732524871826f,-0.07015113532543182f,-0.287551611661911f,-0.025779157876968384f,-0.07337476313114166f,-0.24420931935310364f,0.015819430351257324f,-0.10595546662807465f}, |
Lightvalve | 73:f80dc3970c99 | 278 | {0.12202468514442444f,0.10608518123626709f,-0.10034829378128052f,-0.3246283531188965f,0.20245090126991272f,0.04734083265066147f,-0.06113804876804352f,-0.11568751931190491f,0.3261568248271942f,-0.3037929832935333f,-0.06917986273765564f,-0.11160935461521149f,-0.09358227252960205f,-0.21875040233135223f,-0.06735922396183014f,0.05864924192428589f,-0.25733181834220886f,-0.17565661668777466f,0.095695361495018f,-0.07591581344604492f,-0.2171992063522339f,0.14910152554512024f,0.173453688621521f,-0.05681343376636505f,0.20495089888572693f,0.1795230209827423f,0.19069638848304749f,0.04863719269633293f,-0.19967538118362427f,0.2425754964351654f,-0.22172409296035767f,-0.009572982788085938f}, |
Lightvalve | 73:f80dc3970c99 | 279 | {-0.3055141270160675f,-0.22692157328128815f,-0.06546061486005783f,-0.22364665567874908f,-0.301609069108963f,0.3466431796550751f,0.09419310092926025f,0.21086838841438293f,-1.2103636264801025f,0.1926555335521698f,-1.2885984182357788f,-0.20249620079994202f,-0.25163519382476807f,0.04730202257633209f,-0.023131370544433594f,0.036719828844070435f,0.16260939836502075f,0.05286213755607605f,-0.2853477895259857f,0.11423645913600922f,-0.12400790303945541f,0.26420584321022034f,0.1409359872341156f,0.19191309809684753f,0.5323112607002258f,-0.02825927734375f,-0.14624470472335815f,-1.3739569187164307f,-0.12972024083137512f,0.1865309774875641f,0.14116251468658447f,-0.6218597888946533f}, |
Lightvalve | 73:f80dc3970c99 | 280 | {0.1782623827457428f,-0.015146075747907162f,-0.4011057913303375f,-0.09168504178524017f,0.035190191119909286f,-0.01224052906036377f,-0.2435605823993683f,0.1475539207458496f,2.0372250080108643f,-0.64677494764328f,0.09235234558582306f,-0.3219165503978729f,-0.6243833303451538f,-0.21862100064754486f,-0.2527656555175781f,-0.3049176335334778f,0.032145023345947266f,-0.25376296043395996f,-1.736000418663025f,-0.35007935762405396f,-1.5456494092941284f,0.08730726689100266f,0.1247415542602539f,0.05391114950180054f,-2.0970795154571533f,-0.0563075952231884f,0.13928088545799255f,4.6070876121521f,-0.5247244238853455f,0.1616479754447937f,-0.29320231080055237f,-0.930035412311554f}, |
Lightvalve | 73:f80dc3970c99 | 281 | {-0.17396044731140137f,-0.10267387330532074f,-0.38119179010391235f,-0.16983388364315033f,-0.10548646748065948f,0.9111438989639282f,-0.13985206186771393f,-0.1761629432439804f,0.3419595956802368f,-1.4837113618850708f,1.480345368385315f,-0.4204767048358917f,0.7904236912727356f,-0.2960832118988037f,-0.19851773977279663f,-0.10762731730937958f,0.14198419451713562f,0.10370296239852905f,0.23569215834140778f,-4.164161205291748f,-4.5298590660095215f,-0.9154318571090698f,0.18175193667411804f,-0.19857197999954224f,0.7777286767959595f,-0.37469691038131714f,0.09056463092565536f,-0.4552287757396698f,-0.2473701536655426f,-0.1200934648513794f,-0.15247362852096558f,-3.3762712478637695f}, |
Lightvalve | 73:f80dc3970c99 | 282 | {-0.12546227872371674f,-0.23776933550834656f,-0.4473806321620941f,0.11002571135759354f,0.011121923103928566f,-0.3694802522659302f,-0.28310835361480713f,-0.020981580018997192f,0.8688364624977112f,-0.47459572553634644f,1.7547227144241333f,-0.09219010174274445f,0.7238489389419556f,-1.6560261249542236f,-0.0649729073047638f,0.2468220293521881f,0.060016900300979614f,-0.16779978573322296f,0.883475661277771f,-0.7162744402885437f,-1.7292978763580322f,-0.8765726685523987f,-0.26878347992897034f,0.22389158606529236f,-0.28621965646743774f,-0.1761058121919632f,-0.4023822844028473f,0.6458700299263f,-0.006878874264657497f,-0.000007510185241699219f,-0.014864769764244556f,2.9540889263153076f}, |
Lightvalve | 66:a8e6799dbce3 | 283 | {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 | 72:3436ce769b1e | 284 | {0.06582912802696228f,0.2796666920185089f,-0.2556927502155304f,0.0023079216480255127f,0.2043982446193695f,0.13894453644752502f,0.06556430459022522f,0.29767414927482605f,0.24966773390769958f,-0.16670267283916473f,-0.1203770637512207f,-0.06570860743522644f,-0.015925198793411255f,0.17675906419754028f,-0.014884740114212036f,-0.05300724506378174f,0.26490333676338196f,0.15243005752563477f,-0.07319167256355286f,0.2353842556476593f,0.23596063256263733f,0.1602974534034729f,-0.04174882173538208f,-0.11559568345546722f,-0.06235519051551819f,0.21069613099098206f,-0.19532959163188934f,-0.2486409693956375f,0.032513976097106934f,-0.2712400257587433f,-0.19435247778892517f,-0.23200613260269165f}, |
Lightvalve | 67:c2812cf26c38 | 285 | {-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 | 73:f80dc3970c99 | 286 | {0.07638216018676758f,0.07996532320976257f,-0.4532916247844696f,-0.286763995885849f,-0.14361587166786194f,0.15333548188209534f,0.2795381247997284f,-0.25668495893478394f,1.5776686668395996f,-0.3557981550693512f,-4.558074474334717f,-0.0959593802690506f,-0.2420492321252823f,1.8044195175170898f,-0.029521822929382324f,-0.19500072300434113f,0.06506577134132385f,-0.011876672506332397f,0.9772398471832275f,-1.1837528944015503f,1.1952396631240845f,-0.7478441596031189f,-0.15799765288829803f,-0.17324526607990265f,0.7002406120300293f,0.017084553837776184f,-0.2846224009990692f,-0.2008575201034546f,-0.8861852288246155f,0.22636333107948303f,-0.3774070739746094f,-0.03760375455021858f}, |
Lightvalve | 66:a8e6799dbce3 | 287 | }; |
Lightvalve | 65:a2d7c63419c2 | 288 | |
Lightvalve | 73:f80dc3970c99 | 289 | const float hout[32] = { 0.3285340666770935f,0.32595810294151306f,-0.16531020402908325f,-0.1120261549949646f,-0.02814103290438652f,0.20109859108924866f,-0.0071088592521846294f,0.1081397533416748f,0.14690308272838593f,-0.04607205465435982f,0.1793166697025299f,-0.09312135726213455f,-0.2741614878177643f,0.973639726638794f,0.2356991171836853f,-0.1462659239768982f,0.09851181507110596f,-0.21499931812286377f,-0.22608381509780884f,-0.19660963118076324f,-0.13850048184394836f,0.33182141184806824f,-0.2774904668331146f,-0.175692617893219f,0.12098437547683716f,0.062369804829359055f,-0.26919692754745483f,-0.09816103428602219f,0.8765497207641602f,-0.3257754445075989f,-0.19969786703586578f,-0.5018784403800964f }; |
Lightvalve | 66:a8e6799dbce3 | 290 | |
Lightvalve | 73:f80dc3970c99 | 291 | const float b1[32] = { 0.360392302274704f,1.3258261680603027f,-1.7145336866378784f,0.11188247054815292f,1.0527279376983643f,0.5051818490028381f,-0.10494530200958252f,1.3075183629989624f,0.5332803726196289f,-1.3167273998260498f,0.5802411437034607f,2.0797219276428223f,-0.3425353467464447f,-0.8710014224052429f,-1.087764859199524f,0.34449902176856995f,0.6696957945823669f,-0.26377663016319275f,0.22221045196056366f,0.7987192273139954f,-0.3121899664402008f,-1.1118980646133423f,-1.6770726442337036f,-1.2263047695159912f,1.8851773738861084f,-2.0880801677703857f,-1.0489267110824585f,0.6635584235191345f,0.4126681685447693f,-1.0887231826782227f,0.7133725881576538f,-0.4426153898239136f }; |
Lightvalve | 65:a2d7c63419c2 | 292 | |
Lightvalve | 73:f80dc3970c99 | 293 | const float b2[32] = { -0.21426281332969666f,-0.7642630338668823f,-1.4564176797866821f,-0.4739953577518463f,-0.6939148902893066f,0.08300478756427765f,-0.4721355140209198f,-0.4483444094657898f,-1.20063054561615f,-1.912178635597229f,-0.07969088852405548f,0.6989963054656982f,-0.3409772515296936f,1.5607539415359497f,-0.1873372495174408f,0.5244904160499573f,-1.798204779624939f,-1.5844906568527222f,-0.06145767867565155f,-0.2975791394710541f,-0.05740395933389664f,0.1989542841911316f,0.09335066378116608f,-1.0665833950042725f,0.060874372720718384f,1.2573281526565552f,0.9455531239509583f,0.3112686574459076f,-0.6323830485343933f,-0.4208582937717438f,-1.178520679473877f,-0.8882189989089966f }; |
Lightvalve | 65:a2d7c63419c2 | 294 | |
Lightvalve | 73:f80dc3970c99 | 295 | const float b3[32] = { -1.963319182395935f,-0.49897506833076477f,-0.04165864363312721f,-0.24708756804466248f,-0.12295565754175186f,0.8161247372627258f,-0.490390807390213f,-0.6562485098838806f,-0.11963385343551636f,-0.35514017939567566f,-1.653018593788147f,-0.1486135721206665f,-0.8058865666389465f,-2.3385539054870605f,-1.1428403854370117f,-0.3598397970199585f,-1.3594286441802979f,-1.0192245244979858f,-0.8995988368988037f,0.8749277591705322f,0.11804358661174774f,1.180364966392517f,-1.026091456413269f,-0.8066051602363586f,0.5967051982879639f,-0.565889835357666f,-0.2720939517021179f,-0.15897169709205627f,0.0058806478045880795f,-2.3236680030822754f,-0.21091698110103607f,-2.045327663421631f }; |
Lightvalve | 66:a8e6799dbce3 | 296 | |
Lightvalve | 73:f80dc3970c99 | 297 | const float bout[1] = { -0.08369258046150208f }; |
Lightvalve | 61:bc8c8270f0ab | 298 | |
Lightvalve | 61:bc8c8270f0ab | 299 | |
GiJeongKim | 0:51c43836c1d7 | 300 | int main() |
GiJeongKim | 0:51c43836c1d7 | 301 | { |
Lightvalve | 66:a8e6799dbce3 | 302 | |
Lightvalve | 65:a2d7c63419c2 | 303 | HAL_Init(); |
Lightvalve | 65:a2d7c63419c2 | 304 | SystemClock_Config(); |
Lightvalve | 65:a2d7c63419c2 | 305 | |
jobuuu | 6:df07d3491e3a | 306 | /********************************* |
jobuuu | 1:e04e563be5ce | 307 | *** Initialization |
jobuuu | 6:df07d3491e3a | 308 | *********************************/ |
Lightvalve | 69:3995ffeaa786 | 309 | LED = 0; |
Lightvalve | 61:bc8c8270f0ab | 310 | pc.baud(9600); |
Lightvalve | 21:e5f1a43ea6f9 | 311 | |
GiJeongKim | 0:51c43836c1d7 | 312 | // i2c init |
Lightvalve | 8:5d2eebdad025 | 313 | i2c.frequency(400 * 1000); // 0.4 mHz |
Lightvalve | 8:5d2eebdad025 | 314 | wait_ms(2); // Power Up wait |
Lightvalve | 8:5d2eebdad025 | 315 | look_for_hardware_i2c(); // Hardware present |
Lightvalve | 8:5d2eebdad025 | 316 | init_as5510(i2c_slave_addr1); |
Lightvalve | 11:82d8768d7351 | 317 | make_delay(); |
jobuuu | 2:a1c0a37df760 | 318 | |
GiJeongKim | 0:51c43836c1d7 | 319 | // // spi init |
Lightvalve | 16:903b5a4433b4 | 320 | //eeprom.format(8,3); |
Lightvalve | 16:903b5a4433b4 | 321 | //eeprom.frequency(5000000); //5M |
GiJeongKim | 0:51c43836c1d7 | 322 | enc.format(8,0); |
GiJeongKim | 0:51c43836c1d7 | 323 | enc.frequency(5000000); //5M |
Lightvalve | 11:82d8768d7351 | 324 | make_delay(); |
Lightvalve | 21:e5f1a43ea6f9 | 325 | |
Lightvalve | 16:903b5a4433b4 | 326 | //rom |
Lightvalve | 19:23b7c1ad8683 | 327 | ROM_CALL_DATA(); |
Lightvalve | 16:903b5a4433b4 | 328 | make_delay(); |
Lightvalve | 13:747daba9cf59 | 329 | |
GiJeongKim | 0:51c43836c1d7 | 330 | // ADC init |
jobuuu | 5:a4319f79457b | 331 | Init_ADC(); |
Lightvalve | 11:82d8768d7351 | 332 | make_delay(); |
jobuuu | 2:a1c0a37df760 | 333 | |
GiJeongKim | 0:51c43836c1d7 | 334 | // Pwm init |
GiJeongKim | 0:51c43836c1d7 | 335 | Init_PWM(); |
GiJeongKim | 0:51c43836c1d7 | 336 | TIM4->CR1 ^= TIM_CR1_UDIS; |
Lightvalve | 11:82d8768d7351 | 337 | make_delay(); |
Lightvalve | 13:747daba9cf59 | 338 | |
Lightvalve | 11:82d8768d7351 | 339 | // TMR3 init |
Lightvalve | 11:82d8768d7351 | 340 | Init_TMR3(); |
Lightvalve | 11:82d8768d7351 | 341 | TIM3->CR1 ^= TIM_CR1_UDIS; |
Lightvalve | 11:82d8768d7351 | 342 | make_delay(); |
Lightvalve | 21:e5f1a43ea6f9 | 343 | |
Lightvalve | 50:3c630b5eba9f | 344 | // TMR2 init |
Lightvalve | 56:6f50d9d3bfee | 345 | // Init_TMR2(); |
Lightvalve | 56:6f50d9d3bfee | 346 | // TIM2->CR1 ^= TIM_CR1_UDIS; |
Lightvalve | 56:6f50d9d3bfee | 347 | // make_delay(); |
Lightvalve | 21:e5f1a43ea6f9 | 348 | |
GiJeongKim | 0:51c43836c1d7 | 349 | // CAN |
jobuuu | 2:a1c0a37df760 | 350 | can.attach(&CAN_RX_HANDLER); |
Lightvalve | 11:82d8768d7351 | 351 | CAN_ID_INIT(); |
Lightvalve | 11:82d8768d7351 | 352 | make_delay(); |
Lightvalve | 34:bb2ca2fc2a8e | 353 | |
Lightvalve | 23:59218d4a256d | 354 | //Timer priority |
Lightvalve | 23:59218d4a256d | 355 | NVIC_SetPriority(TIM3_IRQn, 2); |
Lightvalve | 57:f4819de54e7a | 356 | //NVIC_SetPriority(TIM2_IRQn, 3); |
Lightvalve | 54:647072f5307a | 357 | NVIC_SetPriority(TIM4_IRQn, 3); |
Lightvalve | 34:bb2ca2fc2a8e | 358 | |
Lightvalve | 23:59218d4a256d | 359 | //can.reset(); |
Lightvalve | 19:23b7c1ad8683 | 360 | can.filter(msg.id, 0xFFFFF000, CANStandard); |
Lightvalve | 34:bb2ca2fc2a8e | 361 | |
GiJeongKim | 0:51c43836c1d7 | 362 | // spi _ enc |
GiJeongKim | 0:51c43836c1d7 | 363 | spi_enc_set_init(); |
Lightvalve | 11:82d8768d7351 | 364 | make_delay(); |
Lightvalve | 13:747daba9cf59 | 365 | |
Lightvalve | 11:82d8768d7351 | 366 | //DAC init |
Lightvalve | 58:2eade98630e2 | 367 | if (SENSING_MODE == 0) { |
Lightvalve | 58:2eade98630e2 | 368 | dac_1 = TORQUE_VREF / 3.3f; |
Lightvalve | 58:2eade98630e2 | 369 | dac_2 = 0.0f; |
Lightvalve | 58:2eade98630e2 | 370 | } else if (SENSING_MODE == 1) { |
Lightvalve | 58:2eade98630e2 | 371 | dac_1 = PRES_A_VREF / 3.3f; |
Lightvalve | 58:2eade98630e2 | 372 | dac_2 = PRES_B_VREF / 3.3f; |
Lightvalve | 58:2eade98630e2 | 373 | } |
Lightvalve | 11:82d8768d7351 | 374 | make_delay(); |
Lightvalve | 13:747daba9cf59 | 375 | |
Lightvalve | 19:23b7c1ad8683 | 376 | for (int i=0; i<50; i++) { |
Lightvalve | 11:82d8768d7351 | 377 | if(i%2==0) |
Lightvalve | 38:118df027d851 | 378 | ID_index_array[i] = - i * 0.5f; |
Lightvalve | 11:82d8768d7351 | 379 | else |
Lightvalve | 38:118df027d851 | 380 | ID_index_array[i] = (i+1) * 0.5f; |
Lightvalve | 11:82d8768d7351 | 381 | } |
Lightvalve | 61:bc8c8270f0ab | 382 | |
Lightvalve | 61:bc8c8270f0ab | 383 | |
jobuuu | 6:df07d3491e3a | 384 | /************************************ |
jobuuu | 1:e04e563be5ce | 385 | *** Program is operating! |
jobuuu | 6:df07d3491e3a | 386 | *************************************/ |
GiJeongKim | 0:51c43836c1d7 | 387 | while(1) { |
Lightvalve | 66:a8e6799dbce3 | 388 | // if(timer_while==1000 && OPERATING_MODE==5) { |
Lightvalve | 66:a8e6799dbce3 | 389 | //if(timer_while==1000) { |
Lightvalve | 65:a2d7c63419c2 | 390 | //i2c |
Lightvalve | 66:a8e6799dbce3 | 391 | |
Lightvalve | 65:a2d7c63419c2 | 392 | read_field(i2c_slave_addr1); |
Lightvalve | 65:a2d7c63419c2 | 393 | if(DIR_VALVE_ENC < 0) value = 1023 - value; |
Lightvalve | 65:a2d7c63419c2 | 394 | // if(LED==1) { |
Lightvalve | 65:a2d7c63419c2 | 395 | // LED=0; |
Lightvalve | 65:a2d7c63419c2 | 396 | // } else |
Lightvalve | 65:a2d7c63419c2 | 397 | // LED = 1; |
Lightvalve | 65:a2d7c63419c2 | 398 | timer_while = 0; |
Lightvalve | 66:a8e6799dbce3 | 399 | //} |
Lightvalve | 66:a8e6799dbce3 | 400 | |
Lightvalve | 66:a8e6799dbce3 | 401 | timer_while ++; |
Lightvalve | 66:a8e6799dbce3 | 402 | |
Lightvalve | 73:f80dc3970c99 | 403 | if(NN_Control_Flag == 0) { |
Lightvalve | 73:f80dc3970c99 | 404 | LED = 0; |
Lightvalve | 73:f80dc3970c99 | 405 | } |
Lightvalve | 66:a8e6799dbce3 | 406 | |
Lightvalve | 73:f80dc3970c99 | 407 | else if(NN_Control_Flag == 1) { |
Lightvalve | 66:a8e6799dbce3 | 408 | float output1[32] = { 0.0f }; |
Lightvalve | 66:a8e6799dbce3 | 409 | float output2[32] = { 0.0f }; |
Lightvalve | 66:a8e6799dbce3 | 410 | float output3[32] = { 0.0f }; |
Lightvalve | 66:a8e6799dbce3 | 411 | float output = 0.0f; |
Lightvalve | 65:a2d7c63419c2 | 412 | |
Lightvalve | 66:a8e6799dbce3 | 413 | for (int index2 = 0; index2 < 32; index2++) { |
Lightvalve | 68:328e1be06f5d | 414 | for (int index1 = 0; index1 < num_input; index1++) { |
Lightvalve | 66:a8e6799dbce3 | 415 | output1[index2] = output1[index2] |
Lightvalve | 73:f80dc3970c99 | 416 | + h1[index1][index2] * input_NN[index1]; |
Lightvalve | 66:a8e6799dbce3 | 417 | } |
Lightvalve | 66:a8e6799dbce3 | 418 | output1[index2] = output1[index2] + b1[index2]; |
Lightvalve | 66:a8e6799dbce3 | 419 | if (output1[index2] < 0) { |
Lightvalve | 66:a8e6799dbce3 | 420 | output1[index2] = 0; |
Lightvalve | 66:a8e6799dbce3 | 421 | } |
Lightvalve | 66:a8e6799dbce3 | 422 | } |
Lightvalve | 65:a2d7c63419c2 | 423 | |
Lightvalve | 66:a8e6799dbce3 | 424 | for (int index2 = 0; index2 < 32; index2++) { |
Lightvalve | 66:a8e6799dbce3 | 425 | for (int index1 = 0; index1 < 32; index1++) { |
Lightvalve | 66:a8e6799dbce3 | 426 | output2[index2] = output2[index2] |
Lightvalve | 66:a8e6799dbce3 | 427 | + h2[index1][index2] * output1[index1]; |
Lightvalve | 66:a8e6799dbce3 | 428 | } |
Lightvalve | 66:a8e6799dbce3 | 429 | output2[index2] = output2[index2] + b2[index2]; |
Lightvalve | 66:a8e6799dbce3 | 430 | if (output2[index2] < 0) { |
Lightvalve | 66:a8e6799dbce3 | 431 | output2[index2] = 0; |
Lightvalve | 66:a8e6799dbce3 | 432 | } |
Lightvalve | 66:a8e6799dbce3 | 433 | } |
Lightvalve | 65:a2d7c63419c2 | 434 | |
Lightvalve | 66:a8e6799dbce3 | 435 | for (int index2 = 0; index2 < 32; index2++) { |
Lightvalve | 66:a8e6799dbce3 | 436 | for (int index1 = 0; index1 < 32; index1++) { |
Lightvalve | 66:a8e6799dbce3 | 437 | output3[index2] = output3[index2] |
Lightvalve | 66:a8e6799dbce3 | 438 | + h3[index1][index2] * output2[index1]; |
Lightvalve | 66:a8e6799dbce3 | 439 | } |
Lightvalve | 66:a8e6799dbce3 | 440 | output3[index2] = output3[index2] + b3[index2]; |
Lightvalve | 66:a8e6799dbce3 | 441 | if (output3[index2] < 0) { |
Lightvalve | 66:a8e6799dbce3 | 442 | output3[index2] = 0; |
Lightvalve | 66:a8e6799dbce3 | 443 | } |
Lightvalve | 65:a2d7c63419c2 | 444 | } |
Lightvalve | 66:a8e6799dbce3 | 445 | |
Lightvalve | 66:a8e6799dbce3 | 446 | for (int index2 = 0; index2 < 1; index2++) { |
Lightvalve | 66:a8e6799dbce3 | 447 | for (int index1 = 0; index1 < 32; index1++) { |
Lightvalve | 73:f80dc3970c99 | 448 | output = output + hout[index1] * output3[index1]; |
Lightvalve | 66:a8e6799dbce3 | 449 | } |
Lightvalve | 66:a8e6799dbce3 | 450 | output = output + bout[index2]; |
Lightvalve | 73:f80dc3970c99 | 451 | |
Lightvalve | 66:a8e6799dbce3 | 452 | } |
Lightvalve | 73:f80dc3970c99 | 453 | output = 1.0f/(1.0f+exp(-output)); |
Lightvalve | 68:328e1be06f5d | 454 | output = output * 20000.0f - 10000.0f; |
Lightvalve | 66:a8e6799dbce3 | 455 | if(output>=0) { |
Lightvalve | 66:a8e6799dbce3 | 456 | valve_pos.ref = output*0.0001f*((double)VALVE_MAX_POS - (double) VALVE_CENTER) + (double) VALVE_CENTER; |
Lightvalve | 66:a8e6799dbce3 | 457 | } else { |
Lightvalve | 66:a8e6799dbce3 | 458 | valve_pos.ref = -output*0.0001f*((double)VALVE_MIN_POS - (double) VALVE_CENTER) + (double) VALVE_CENTER; |
Lightvalve | 65:a2d7c63419c2 | 459 | } |
Lightvalve | 69:3995ffeaa786 | 460 | |
Lightvalve | 69:3995ffeaa786 | 461 | if(LED==1) { |
Lightvalve | 69:3995ffeaa786 | 462 | LED=0; |
Lightvalve | 69:3995ffeaa786 | 463 | } else |
Lightvalve | 69:3995ffeaa786 | 464 | LED = 1; |
Lightvalve | 69:3995ffeaa786 | 465 | |
Lightvalve | 65:a2d7c63419c2 | 466 | } |
Lightvalve | 62:b5452adfb2cd | 467 | |
Lightvalve | 69:3995ffeaa786 | 468 | |
Lightvalve | 66:a8e6799dbce3 | 469 | |
GiJeongKim | 0:51c43836c1d7 | 470 | } |
jobuuu | 1:e04e563be5ce | 471 | } |
jobuuu | 1:e04e563be5ce | 472 | |
Lightvalve | 33:91b17819ec30 | 473 | float DDV_JOINT_POS_FF(float REF_JOINT_VEL) |
Lightvalve | 14:8e7590227d22 | 474 | { |
Lightvalve | 14:8e7590227d22 | 475 | |
Lightvalve | 13:747daba9cf59 | 476 | int i = 0; |
Lightvalve | 48:889798ff9329 | 477 | float Ref_Valve_Pos_FF = 0.0f; |
Lightvalve | 14:8e7590227d22 | 478 | for(i=0; i<VALVE_POS_NUM; i++) { |
Lightvalve | 14:8e7590227d22 | 479 | 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 | 480 | if(i==0) { |
Lightvalve | 50:3c630b5eba9f | 481 | if(JOINT_VEL[i+1] == JOINT_VEL[i]) { |
Lightvalve | 57:f4819de54e7a | 482 | Ref_Valve_Pos_FF = (float) VALVE_CENTER; |
Lightvalve | 50:3c630b5eba9f | 483 | } else { |
Lightvalve | 57:f4819de54e7a | 484 | 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 | 485 | } |
Lightvalve | 14:8e7590227d22 | 486 | } else { |
Lightvalve | 50:3c630b5eba9f | 487 | if(JOINT_VEL[i+1] == JOINT_VEL[i-1]) { |
Lightvalve | 57:f4819de54e7a | 488 | Ref_Valve_Pos_FF = (float) VALVE_CENTER; |
Lightvalve | 50:3c630b5eba9f | 489 | } else { |
Lightvalve | 57:f4819de54e7a | 490 | 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 | 491 | } |
Lightvalve | 13:747daba9cf59 | 492 | } |
Lightvalve | 13:747daba9cf59 | 493 | break; |
Lightvalve | 13:747daba9cf59 | 494 | } |
Lightvalve | 13:747daba9cf59 | 495 | } |
Lightvalve | 14:8e7590227d22 | 496 | if(REF_JOINT_VEL > max(JOINT_VEL[VALVE_POS_NUM-1], JOINT_VEL[VALVE_POS_NUM-2])) { |
Lightvalve | 33:91b17819ec30 | 497 | Ref_Valve_Pos_FF = (float) VALVE_MAX_POS; |
Lightvalve | 14:8e7590227d22 | 498 | } else if(REF_JOINT_VEL < min(JOINT_VEL[VALVE_POS_NUM-1], JOINT_VEL[VALVE_POS_NUM-2])) { |
Lightvalve | 33:91b17819ec30 | 499 | Ref_Valve_Pos_FF = (float) VALVE_MIN_POS; |
Lightvalve | 13:747daba9cf59 | 500 | } |
Lightvalve | 36:a46e63505ed8 | 501 | |
Lightvalve | 57:f4819de54e7a | 502 | Ref_Valve_Pos_FF = (float) VELOCITY_COMP_GAIN * 0.01f * (float) (Ref_Valve_Pos_FF - (float) VALVE_CENTER); |
Lightvalve | 13:747daba9cf59 | 503 | return Ref_Valve_Pos_FF; |
Lightvalve | 50:3c630b5eba9f | 504 | |
Lightvalve | 13:747daba9cf59 | 505 | } |
jobuuu | 6:df07d3491e3a | 506 | |
jobuuu | 6:df07d3491e3a | 507 | |
Lightvalve | 30:8d561f16383b | 508 | void VALVE_POS_CONTROL(float REF_VALVE_POS) |
Lightvalve | 14:8e7590227d22 | 509 | { |
Lightvalve | 13:747daba9cf59 | 510 | int i = 0; |
Lightvalve | 13:747daba9cf59 | 511 | |
Lightvalve | 38:118df027d851 | 512 | if(REF_VALVE_POS > VALVE_MAX_POS) { |
Lightvalve | 38:118df027d851 | 513 | REF_VALVE_POS = VALVE_MAX_POS; |
Lightvalve | 38:118df027d851 | 514 | } else if(REF_VALVE_POS < VALVE_MIN_POS) { |
Lightvalve | 38:118df027d851 | 515 | REF_VALVE_POS = VALVE_MIN_POS; |
Lightvalve | 38:118df027d851 | 516 | } |
Lightvalve | 38:118df027d851 | 517 | |
Lightvalve | 13:747daba9cf59 | 518 | valve_pos_err = REF_VALVE_POS - value; |
Lightvalve | 13:747daba9cf59 | 519 | valve_pos_err_diff = valve_pos_err - valve_pos_err_old; |
Lightvalve | 13:747daba9cf59 | 520 | valve_pos_err_old = valve_pos_err; |
Lightvalve | 13:747daba9cf59 | 521 | valve_pos_err_sum += valve_pos_err; |
Lightvalve | 13:747daba9cf59 | 522 | if (valve_pos_err_sum > 1000) valve_pos_err_sum = 1000; |
Lightvalve | 13:747daba9cf59 | 523 | if (valve_pos_err_sum<-1000) valve_pos_err_sum = -1000; |
Lightvalve | 13:747daba9cf59 | 524 | |
Lightvalve | 13:747daba9cf59 | 525 | 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 | 526 | |
Lightvalve | 18:b8adf1582ea3 | 527 | for(i=0; i<24; i++) { |
Lightvalve | 14:8e7590227d22 | 528 | if(REF_VALVE_POS >= min(VALVE_POS_VS_PWM[i],VALVE_POS_VS_PWM[i+1]) && REF_VALVE_POS <= max(VALVE_POS_VS_PWM[i],VALVE_POS_VS_PWM[i+1])) { |
Lightvalve | 14:8e7590227d22 | 529 | if(i==0) { |
Lightvalve | 48:889798ff9329 | 530 | 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 | 531 | } else { |
Lightvalve | 48:889798ff9329 | 532 | 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 | 533 | } |
Lightvalve | 13:747daba9cf59 | 534 | break; |
Lightvalve | 13:747daba9cf59 | 535 | } |
Lightvalve | 13:747daba9cf59 | 536 | } |
Lightvalve | 59:f308b1656d9c | 537 | Vout.ref = VALVE_PWM_RAW_FF + VALVE_PWM_RAW_FB; |
Lightvalve | 13:747daba9cf59 | 538 | } |
Lightvalve | 13:747daba9cf59 | 539 | |
Lightvalve | 14:8e7590227d22 | 540 | #define LT_MAX_IDX 57 |
Lightvalve | 30:8d561f16383b | 541 | 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 | 542 | -19.0f, -18.0f, -17.0f, -16.0f, -15.0f, -14.0f, -13.0f, -12.0f, -11.0f, -10.0f, |
Lightvalve | 34:bb2ca2fc2a8e | 543 | -9.0f, -8.0f, -7.0f, -6.0f, -5.0f, -4.0f, -3.0f, -2.0f, -1.0f, 0.0f, |
Lightvalve | 34:bb2ca2fc2a8e | 544 | 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, |
Lightvalve | 34:bb2ca2fc2a8e | 545 | 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, |
Lightvalve | 34:bb2ca2fc2a8e | 546 | 25.0f, 30.0f, 35.0f, 40.0f, 50.0f, 60.0f, 80.0f, 100.0f |
Lightvalve | 34:bb2ca2fc2a8e | 547 | }; // duty |
Lightvalve | 67:c2812cf26c38 | 548 | 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 | 549 | -150.0f, -145.0f, -145.0f, -145.0f, -135.0f, -135.0f, -135.0f, -127.5f, -127.5f, -115.0f, |
Lightvalve | 67:c2812cf26c38 | 550 | -115.0f, -115.0F, -100.0f, -100.0f, -100.0f, -60.0f, -60.0f, -10.0f, -5.0f, 0.0f, |
Lightvalve | 67:c2812cf26c38 | 551 | 7.5f, 14.0f, 14.0f, 14.0f, 42.5f, 42.5f, 42.5f, 80.0f, 80.0f, 105.0f, |
Lightvalve | 67:c2812cf26c38 | 552 | 105.0f, 105.0f, 120.0f, 120.0f, 120.0f, 131.0f, 131.0f, 140.0f, 140.0f, 140.0f, |
Lightvalve | 67:c2812cf26c38 | 553 | 155.0f, 160.0f, 170.0f, 174.0f, 182.0f, 191.0f, 212.0f, 230.0f |
Lightvalve | 34:bb2ca2fc2a8e | 554 | }; // mV |
Lightvalve | 13:747daba9cf59 | 555 | |
Lightvalve | 30:8d561f16383b | 556 | float PWM_duty_byLT(float Ref_V) |
Lightvalve | 14:8e7590227d22 | 557 | { |
Lightvalve | 30:8d561f16383b | 558 | float PWM_duty = 0.0f; |
Lightvalve | 13:747daba9cf59 | 559 | if(Ref_V<LT_Voltage_Output[0]) { |
Lightvalve | 30:8d561f16383b | 560 | PWM_duty = (Ref_V-LT_Voltage_Output[0])/1.5f+LT_PWM_duty[0]; |
Lightvalve | 13:747daba9cf59 | 561 | } else if (Ref_V>=LT_Voltage_Output[LT_MAX_IDX-1]) { |
Lightvalve | 30:8d561f16383b | 562 | PWM_duty = (Ref_V-LT_Voltage_Output[LT_MAX_IDX-1])/1.5f+LT_PWM_duty[LT_MAX_IDX-1]; |
Lightvalve | 13:747daba9cf59 | 563 | } else { |
Lightvalve | 13:747daba9cf59 | 564 | int idx = 0; |
Lightvalve | 13:747daba9cf59 | 565 | for(idx=0; idx<LT_MAX_IDX-1; idx++) { |
Lightvalve | 30:8d561f16383b | 566 | float ini_x = LT_Voltage_Output[idx]; |
Lightvalve | 30:8d561f16383b | 567 | float fin_x = LT_Voltage_Output[idx+1]; |
Lightvalve | 30:8d561f16383b | 568 | float ini_y = LT_PWM_duty[idx]; |
Lightvalve | 30:8d561f16383b | 569 | float fin_y = LT_PWM_duty[idx+1]; |
Lightvalve | 13:747daba9cf59 | 570 | if(Ref_V>=ini_x && Ref_V<fin_x) { |
Lightvalve | 13:747daba9cf59 | 571 | PWM_duty = (fin_y-ini_y)/(fin_x-ini_x)*(Ref_V-ini_x) + ini_y; |
Lightvalve | 13:747daba9cf59 | 572 | break; |
Lightvalve | 13:747daba9cf59 | 573 | } |
Lightvalve | 13:747daba9cf59 | 574 | } |
Lightvalve | 13:747daba9cf59 | 575 | } |
Lightvalve | 14:8e7590227d22 | 576 | |
Lightvalve | 13:747daba9cf59 | 577 | return PWM_duty; |
Lightvalve | 13:747daba9cf59 | 578 | } |
jobuuu | 6:df07d3491e3a | 579 | |
Lightvalve | 57:f4819de54e7a | 580 | |
Lightvalve | 57:f4819de54e7a | 581 | |
Lightvalve | 57:f4819de54e7a | 582 | |
Lightvalve | 57:f4819de54e7a | 583 | |
jobuuu | 2:a1c0a37df760 | 584 | /******************************************************************************* |
jobuuu | 2:a1c0a37df760 | 585 | TIMER INTERRUPT |
jobuuu | 2:a1c0a37df760 | 586 | *******************************************************************************/ |
jobuuu | 2:a1c0a37df760 | 587 | |
Lightvalve | 51:b46bed7fec80 | 588 | float FREQ_TMR4 = (float)FREQ_20k; |
Lightvalve | 51:b46bed7fec80 | 589 | float DT_TMR4 = (float)DT_20k; |
Lightvalve | 57:f4819de54e7a | 590 | long CNT_TMR4 = 0; |
Lightvalve | 57:f4819de54e7a | 591 | int TMR4_FREQ_10k = (int)FREQ_10k; |
jobuuu | 1:e04e563be5ce | 592 | extern "C" void TIM4_IRQHandler(void) |
jobuuu | 1:e04e563be5ce | 593 | { |
Lightvalve | 19:23b7c1ad8683 | 594 | if (TIM4->SR & TIM_SR_UIF ) { |
Lightvalve | 21:e5f1a43ea6f9 | 595 | |
Lightvalve | 21:e5f1a43ea6f9 | 596 | /******************************************************* |
Lightvalve | 21:e5f1a43ea6f9 | 597 | *** Sensor Read & Data Handling |
Lightvalve | 21:e5f1a43ea6f9 | 598 | ********************************************************/ |
Lightvalve | 13:747daba9cf59 | 599 | |
Lightvalve | 57:f4819de54e7a | 600 | //Encoder |
Lightvalve | 57:f4819de54e7a | 601 | if (CNT_TMR4 % (int) ((int) FREQ_TMR4/TMR4_FREQ_10k) == 0) { |
Lightvalve | 57:f4819de54e7a | 602 | ENC_UPDATE(); |
Lightvalve | 57:f4819de54e7a | 603 | } |
Lightvalve | 61:bc8c8270f0ab | 604 | |
Lightvalve | 61:bc8c8270f0ab | 605 | ADC1->CR2 |= 0x40000000; |
Lightvalve | 58:2eade98630e2 | 606 | if (SENSING_MODE == 0) { |
Lightvalve | 58:2eade98630e2 | 607 | // Torque Sensing (0~210)bar ============================================= |
Lightvalve | 58:2eade98630e2 | 608 | float pres_A_new = (((float) ADC1->DR) - 2047.5f); |
Lightvalve | 58:2eade98630e2 | 609 | double alpha_update_ft = 1.0f / (1.0f + FREQ_TMR4 / (2.0f * 3.14f * 100.0f)); // f_cutoff : 200Hz |
Lightvalve | 58:2eade98630e2 | 610 | pres_A.sen = (1.0f - alpha_update_ft) * pres_A.sen + alpha_update_ft * pres_A_new; |
Lightvalve | 67:c2812cf26c38 | 611 | torq.sen = -pres_A.sen / TORQUE_SENSOR_PULSE_PER_TORQUE; |
Lightvalve | 67:c2812cf26c38 | 612 | |
Lightvalve | 67:c2812cf26c38 | 613 | |
Lightvalve | 67:c2812cf26c38 | 614 | // float alpha_update_pres_A = 1.0f/(1.0f + FREQ_TMR4/(2.0f*3.14f*100.0f)); |
Lightvalve | 67:c2812cf26c38 | 615 | //// float pres_A_new = ((float)ADC1->DR - PRES_A_NULL) / PRES_SENSOR_A_PULSE_PER_BAR; |
Lightvalve | 67:c2812cf26c38 | 616 | // float pres_A_new = ((float)ADC1->DR); |
Lightvalve | 67:c2812cf26c38 | 617 | // pres_A.sen = pres_A.sen*(1.0f-alpha_update_pres_A)+pres_A_new*(alpha_update_pres_A); |
Lightvalve | 67:c2812cf26c38 | 618 | // torq.sen = - (pres_A.sen-2048.0f); //pulse -2047~2047 |
Lightvalve | 67:c2812cf26c38 | 619 | |
Lightvalve | 17:1865016ca2e7 | 620 | |
Lightvalve | 58:2eade98630e2 | 621 | } else if (SENSING_MODE == 1) { |
Lightvalve | 58:2eade98630e2 | 622 | // Pressure Sensing (0~210)bar ============================================= |
Lightvalve | 58:2eade98630e2 | 623 | float pres_A_new = (((float)ADC1->DR) - PRES_A_NULL); |
Lightvalve | 58:2eade98630e2 | 624 | float pres_B_new = (((float)ADC2->DR) - PRES_B_NULL); |
Lightvalve | 58:2eade98630e2 | 625 | double alpha_update_pres = 1.0f / (1.0f + FREQ_TMR4 / (2.0f * 3.14f * 200.0f)); // f_cutoff : 500Hz |
Lightvalve | 58:2eade98630e2 | 626 | pres_A.sen = (1.0f - alpha_update_pres) * pres_A.sen + alpha_update_pres * pres_A_new; |
Lightvalve | 58:2eade98630e2 | 627 | pres_B.sen = (1.0f - alpha_update_pres) * pres_B.sen + alpha_update_pres * pres_B_new; |
Lightvalve | 58:2eade98630e2 | 628 | CUR_PRES_A_BAR = pres_A.sen / PRES_SENSOR_A_PULSE_PER_BAR; |
Lightvalve | 58:2eade98630e2 | 629 | CUR_PRES_B_BAR = pres_B.sen / PRES_SENSOR_B_PULSE_PER_BAR; |
Lightvalve | 50:3c630b5eba9f | 630 | |
Lightvalve | 58:2eade98630e2 | 631 | if ((OPERATING_MODE & 0x01) == 0) { // Rotary Actuator |
Lightvalve | 58:2eade98630e2 | 632 | 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 | 633 | } else if ((OPERATING_MODE & 0x01) == 1) { // Linear Actuator |
Lightvalve | 58:2eade98630e2 | 634 | 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 | 635 | } |
Lightvalve | 58:2eade98630e2 | 636 | } |
Lightvalve | 61:bc8c8270f0ab | 637 | |
Lightvalve | 58:2eade98630e2 | 638 | // //Pressure sensor A |
Lightvalve | 58:2eade98630e2 | 639 | // ADC1->CR2 |= 0x40000000; // adc _ 12bit |
Lightvalve | 58:2eade98630e2 | 640 | // //while((ADC1->SR & 0b10)); |
Lightvalve | 58:2eade98630e2 | 641 | // float alpha_update_pres_A = 1.0f/(1.0f + FREQ_TMR4/(2.0f*3.14f*100.0f)); |
Lightvalve | 58:2eade98630e2 | 642 | // float pres_A_new = ((float)ADC1->DR); |
Lightvalve | 58:2eade98630e2 | 643 | // pres_A.sen = pres_A.sen*(1.0f-alpha_update_pres_A)+pres_A_new*(alpha_update_pres_A); |
Lightvalve | 58:2eade98630e2 | 644 | // 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 | 645 | // |
Lightvalve | 58:2eade98630e2 | 646 | // |
Lightvalve | 58:2eade98630e2 | 647 | // //Pressure sensor B |
Lightvalve | 58:2eade98630e2 | 648 | // float alpha_update_pres_B = 1.0f/(1.0f + FREQ_TMR4/(2.0f*3.14f*100.0f)); |
Lightvalve | 58:2eade98630e2 | 649 | // float pres_B_new = ((float)ADC2->DR); |
Lightvalve | 58:2eade98630e2 | 650 | // pres_B.sen = pres_B.sen*(1.0f-alpha_update_pres_B)+pres_B_new*(alpha_update_pres_B); |
Lightvalve | 58:2eade98630e2 | 651 | // //torq.sen = pres_A.sen * (float) PISTON_AREA_A - pres_B.sen * (float) PISTON_AREA_B; |
Lightvalve | 17:1865016ca2e7 | 652 | |
Lightvalve | 17:1865016ca2e7 | 653 | |
Lightvalve | 21:e5f1a43ea6f9 | 654 | //Current |
Lightvalve | 21:e5f1a43ea6f9 | 655 | //ADC3->CR2 |= 0x40000000; // adc _ 12bit |
Lightvalve | 25:3e6b574cab5c | 656 | //int raw_cur = ADC3->DR; |
Lightvalve | 21:e5f1a43ea6f9 | 657 | //while((ADC3->SR & 0b10)); |
Lightvalve | 51:b46bed7fec80 | 658 | float alpha_update_cur = 1.0f/(1.0f + FREQ_TMR4/(2.0f*3.14f*500.0f)); // f_cutoff : 500Hz |
Lightvalve | 30:8d561f16383b | 659 | float cur_new = ((float)ADC3->DR-2048.0f)*20.0f/4096.0f; // unit : mA |
Lightvalve | 30:8d561f16383b | 660 | cur.sen=cur.sen*(1.0f-alpha_update_cur)+cur_new*(alpha_update_cur); |
Lightvalve | 25:3e6b574cab5c | 661 | //cur.sen = raw_cur; |
Lightvalve | 58:2eade98630e2 | 662 | |
Lightvalve | 57:f4819de54e7a | 663 | CNT_TMR4++; |
Lightvalve | 21:e5f1a43ea6f9 | 664 | } |
Lightvalve | 11:82d8768d7351 | 665 | TIM4->SR = 0x0; // reset the status register |
Lightvalve | 11:82d8768d7351 | 666 | } |
Lightvalve | 19:23b7c1ad8683 | 667 | |
Lightvalve | 19:23b7c1ad8683 | 668 | |
Lightvalve | 18:b8adf1582ea3 | 669 | int j =0; |
Lightvalve | 54:647072f5307a | 670 | float FREQ_TMR3 = (float)FREQ_5k; |
Lightvalve | 48:889798ff9329 | 671 | float DT_TMR3 = (float)DT_5k; |
Lightvalve | 45:35fa6884d0c6 | 672 | int cnt_trans = 0; |
Lightvalve | 48:889798ff9329 | 673 | double VALVE_POS_RAW_FORCE_FB_LOGGING = 0.0f; |
Lightvalve | 57:f4819de54e7a | 674 | int can_rest =0; |
Lightvalve | 48:889798ff9329 | 675 | |
Lightvalve | 11:82d8768d7351 | 676 | extern "C" void TIM3_IRQHandler(void) |
Lightvalve | 21:e5f1a43ea6f9 | 677 | { |
Lightvalve | 19:23b7c1ad8683 | 678 | if (TIM3->SR & TIM_SR_UIF ) { |
Lightvalve | 57:f4819de54e7a | 679 | |
Lightvalve | 57:f4819de54e7a | 680 | if (((OPERATING_MODE&0b110)>>1) == 0) { |
Lightvalve | 57:f4819de54e7a | 681 | K_v = 0.4f; // Moog (LPM >> mA) , 100bar |
Lightvalve | 57:f4819de54e7a | 682 | mV_PER_mA = 500.0f; // 5000mV/10mA |
Lightvalve | 57:f4819de54e7a | 683 | mV_PER_pulse = 0.5f; // 5000mV/10000pulse |
Lightvalve | 57:f4819de54e7a | 684 | mA_PER_pulse = 0.001f; // 10mA/10000pulse |
Lightvalve | 57:f4819de54e7a | 685 | } else if (((OPERATING_MODE&0b110)>>1) == 1) { |
Lightvalve | 57:f4819de54e7a | 686 | K_v = 0.5f; // KNR (LPM >> mA) , 100bar |
Lightvalve | 57:f4819de54e7a | 687 | mV_PER_mA = 166.6666f; // 5000mV/30mA |
Lightvalve | 57:f4819de54e7a | 688 | mV_PER_pulse = 0.5f; // 5000mV/10000pulse |
Lightvalve | 57:f4819de54e7a | 689 | mA_PER_pulse = 0.003f; // 30mA/10000pulse |
Lightvalve | 57:f4819de54e7a | 690 | } |
Lightvalve | 50:3c630b5eba9f | 691 | |
Lightvalve | 50:3c630b5eba9f | 692 | if(MODE_POS_FT_TRANS == 1) { |
Lightvalve | 48:889798ff9329 | 693 | alpha_trans = (float)(1.0f - cos(3.141592f * (float)cnt_trans * DT_TMR3 /3.0f))/2.0f; |
Lightvalve | 45:35fa6884d0c6 | 694 | cnt_trans++; |
Lightvalve | 46:2694daea349b | 695 | torq.err_sum = 0; |
Lightvalve | 48:889798ff9329 | 696 | if((float)cnt_trans * DT_TMR3 > 3.0f) |
Lightvalve | 45:35fa6884d0c6 | 697 | MODE_POS_FT_TRANS = 2; |
Lightvalve | 50:3c630b5eba9f | 698 | } else if(MODE_POS_FT_TRANS == 3) { |
Lightvalve | 48:889798ff9329 | 699 | alpha_trans = (float)(1.0f + cos(3.141592f * (float)cnt_trans * DT_TMR3 /3.0f))/2.0f; |
Lightvalve | 45:35fa6884d0c6 | 700 | cnt_trans++; |
Lightvalve | 46:2694daea349b | 701 | torq.err_sum = 0; |
Lightvalve | 48:889798ff9329 | 702 | if((float) cnt_trans * DT_TMR3 > 3.0f ) |
Lightvalve | 45:35fa6884d0c6 | 703 | MODE_POS_FT_TRANS = 0; |
Lightvalve | 50:3c630b5eba9f | 704 | } else if(MODE_POS_FT_TRANS == 2) { |
Lightvalve | 58:2eade98630e2 | 705 | alpha_trans = 1.0f; |
Lightvalve | 45:35fa6884d0c6 | 706 | cnt_trans = 0; |
Lightvalve | 50:3c630b5eba9f | 707 | } else { |
Lightvalve | 58:2eade98630e2 | 708 | alpha_trans = 0.0f; |
Lightvalve | 45:35fa6884d0c6 | 709 | cnt_trans = 0; |
Lightvalve | 45:35fa6884d0c6 | 710 | } |
Lightvalve | 45:35fa6884d0c6 | 711 | |
Lightvalve | 50:3c630b5eba9f | 712 | |
Lightvalve | 57:f4819de54e7a | 713 | int UTILITY_MODE = 0; |
Lightvalve | 57:f4819de54e7a | 714 | int CONTROL_MODE = 0; |
Lightvalve | 58:2eade98630e2 | 715 | |
Lightvalve | 57:f4819de54e7a | 716 | if (CONTROL_UTILITY_MODE >= 20 || CONTROL_UTILITY_MODE == 0) { |
Lightvalve | 57:f4819de54e7a | 717 | UTILITY_MODE = CONTROL_UTILITY_MODE; |
Lightvalve | 57:f4819de54e7a | 718 | CONTROL_MODE = MODE_NO_ACT; |
Lightvalve | 57:f4819de54e7a | 719 | } else { |
Lightvalve | 57:f4819de54e7a | 720 | CONTROL_MODE = CONTROL_UTILITY_MODE; |
Lightvalve | 57:f4819de54e7a | 721 | UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 57:f4819de54e7a | 722 | } |
Lightvalve | 56:6f50d9d3bfee | 723 | |
Lightvalve | 56:6f50d9d3bfee | 724 | |
Lightvalve | 56:6f50d9d3bfee | 725 | |
Lightvalve | 57:f4819de54e7a | 726 | // UTILITY MODE ------------------------------------------------------------ |
Lightvalve | 56:6f50d9d3bfee | 727 | |
Lightvalve | 57:f4819de54e7a | 728 | switch (UTILITY_MODE) { |
Lightvalve | 57:f4819de54e7a | 729 | case MODE_NO_ACT: { |
Lightvalve | 13:747daba9cf59 | 730 | break; |
Lightvalve | 13:747daba9cf59 | 731 | } |
Lightvalve | 14:8e7590227d22 | 732 | |
Lightvalve | 14:8e7590227d22 | 733 | case MODE_TORQUE_SENSOR_NULLING: { |
Lightvalve | 13:747daba9cf59 | 734 | // DAC Voltage reference set |
Lightvalve | 14:8e7590227d22 | 735 | if (TMR3_COUNT_TORQUE_NULL < TMR_FREQ_5k * 2) { |
Lightvalve | 15:bd0d12728506 | 736 | CUR_TORQUE_sum += torq.sen; |
Lightvalve | 19:23b7c1ad8683 | 737 | |
Lightvalve | 14:8e7590227d22 | 738 | if (TMR3_COUNT_TORQUE_NULL % 10 == 0) { |
Lightvalve | 30:8d561f16383b | 739 | CUR_TORQUE_mean = CUR_TORQUE_sum / 10.0f; |
Lightvalve | 13:747daba9cf59 | 740 | CUR_TORQUE_sum = 0; |
Lightvalve | 14:8e7590227d22 | 741 | |
Lightvalve | 59:f308b1656d9c | 742 | TORQUE_VREF += 0.0003f * (0.0f - CUR_TORQUE_mean); |
Lightvalve | 19:23b7c1ad8683 | 743 | |
Lightvalve | 30:8d561f16383b | 744 | if (TORQUE_VREF > 3.3f) TORQUE_VREF = 3.3f; |
Lightvalve | 59:f308b1656d9c | 745 | if (TORQUE_VREF < 0.0f) TORQUE_VREF = 0.0f; |
Lightvalve | 50:3c630b5eba9f | 746 | |
Lightvalve | 16:903b5a4433b4 | 747 | //spi_eeprom_write(RID_TORQUE_SENSOR_VREF, (int16_t) (TORQUE_VREF * 1000.0)); |
Lightvalve | 30:8d561f16383b | 748 | dac_1 = TORQUE_VREF / 3.3f; |
Lightvalve | 13:747daba9cf59 | 749 | } |
Lightvalve | 13:747daba9cf59 | 750 | } else { |
Lightvalve | 58:2eade98630e2 | 751 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 14:8e7590227d22 | 752 | TMR3_COUNT_TORQUE_NULL = 0; |
Lightvalve | 13:747daba9cf59 | 753 | CUR_TORQUE_sum = 0; |
Lightvalve | 13:747daba9cf59 | 754 | CUR_TORQUE_mean = 0; |
Lightvalve | 19:23b7c1ad8683 | 755 | |
Lightvalve | 16:903b5a4433b4 | 756 | ROM_RESET_DATA(); |
Lightvalve | 19:23b7c1ad8683 | 757 | |
Lightvalve | 30:8d561f16383b | 758 | dac_1 = TORQUE_VREF / 3.3f; |
Lightvalve | 14:8e7590227d22 | 759 | |
Lightvalve | 13:747daba9cf59 | 760 | } |
Lightvalve | 14:8e7590227d22 | 761 | TMR3_COUNT_TORQUE_NULL++; |
Lightvalve | 13:747daba9cf59 | 762 | break; |
Lightvalve | 19:23b7c1ad8683 | 763 | } |
Lightvalve | 14:8e7590227d22 | 764 | |
Lightvalve | 50:3c630b5eba9f | 765 | // case MODE_VALVE_NULLING_AND_DEADZONE_SETTING: { |
Lightvalve | 50:3c630b5eba9f | 766 | // if (TMR3_COUNT_DEADZONE == 0) { |
Lightvalve | 50:3c630b5eba9f | 767 | // if (pos_plus_end == pos_minus_end) need_enc_init = true; |
Lightvalve | 50:3c630b5eba9f | 768 | // else temp_time = 0; |
Lightvalve | 50:3c630b5eba9f | 769 | // } |
Lightvalve | 50:3c630b5eba9f | 770 | // if (need_enc_init) { |
Lightvalve | 50:3c630b5eba9f | 771 | // if (TMR3_COUNT_DEADZONE < (int) (0.5f * (float) TMR_FREQ_5k)) { |
Lightvalve | 50:3c630b5eba9f | 772 | // V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 773 | // pos_plus_end = pos.sen; |
Lightvalve | 50:3c630b5eba9f | 774 | // } else if (TMR3_COUNT_DEADZONE < TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 775 | // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 776 | // pos_minus_end = pos.sen; |
Lightvalve | 50:3c630b5eba9f | 777 | // } else if (TMR3_COUNT_DEADZONE == TMR_FREQ_5k) need_enc_init = false; |
Lightvalve | 50:3c630b5eba9f | 778 | // temp_time = TMR_FREQ_5k; |
Lightvalve | 50:3c630b5eba9f | 779 | // } |
Lightvalve | 50:3c630b5eba9f | 780 | // |
Lightvalve | 50:3c630b5eba9f | 781 | // if (temp_time <= TMR3_COUNT_DEADZONE && TMR3_COUNT_DEADZONE < (temp_time + TMR_FREQ_5k)) { |
Lightvalve | 50:3c630b5eba9f | 782 | // 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 | 783 | // VALVE_CENTER = VALVE_DEADZONE_PLUS = VALVE_DEADZONE_MINUS = 0; |
Lightvalve | 50:3c630b5eba9f | 784 | // |
Lightvalve | 50:3c630b5eba9f | 785 | // } else if (temp_time <= TMR3_COUNT_DEADZONE && TMR3_COUNT_DEADZONE < (temp_time + (int) (1.9f * (float) TMR_FREQ_5k))) { |
Lightvalve | 50:3c630b5eba9f | 786 | // V_out = 0; |
Lightvalve | 50:3c630b5eba9f | 787 | // CUR_VELOCITY_sum += CUR_VELOCITY; |
Lightvalve | 50:3c630b5eba9f | 788 | // } else if (TMR3_COUNT_DEADZONE == (temp_time + 2 * TMR_FREQ_5k)) { |
Lightvalve | 50:3c630b5eba9f | 789 | // if (CUR_VELOCITY_sum == 0) DZ_dir = 1; |
Lightvalve | 50:3c630b5eba9f | 790 | // else if (CUR_VELOCITY_sum > 0) DZ_dir = 1; |
Lightvalve | 50:3c630b5eba9f | 791 | // else if (CUR_VELOCITY_sum < 0) DZ_dir = -1; |
Lightvalve | 50:3c630b5eba9f | 792 | // else DZ_temp_cnt2 = DZ_end; |
Lightvalve | 50:3c630b5eba9f | 793 | // CUR_VELOCITY_sum = 0; |
Lightvalve | 50:3c630b5eba9f | 794 | // } else if (TMR3_COUNT_DEADZONE > (temp_time + 2 * TMR_FREQ_5k)) { |
Lightvalve | 50:3c630b5eba9f | 795 | // if (TMR3_COUNT_DEADZONE > (temp_time + 10 * TMR_FREQ_5k)) DZ_temp_cnt2 = DZ_end; |
Lightvalve | 50:3c630b5eba9f | 796 | // |
Lightvalve | 50:3c630b5eba9f | 797 | // // Position of Dead Zone |
Lightvalve | 50:3c630b5eba9f | 798 | // // (CUR_VELOCITY < 0) (CUR_VELOCITY == 0) (CUR_VELOCITY > 0) |
Lightvalve | 50:3c630b5eba9f | 799 | // // | / | / |/ |
Lightvalve | 50:3c630b5eba9f | 800 | // // | ______/ ___|___/ ______/| |
Lightvalve | 50:3c630b5eba9f | 801 | // // |/ / | / | |
Lightvalve | 50:3c630b5eba9f | 802 | // // /| / | / | |
Lightvalve | 50:3c630b5eba9f | 803 | // // 0V 0V 0V |
Lightvalve | 50:3c630b5eba9f | 804 | // |
Lightvalve | 50:3c630b5eba9f | 805 | // if (DZ_temp_cnt2 < DZ_end) { |
Lightvalve | 50:3c630b5eba9f | 806 | // if (TMR3_COUNT_DEADZONE % 20 != 0) { |
Lightvalve | 50:3c630b5eba9f | 807 | // CUR_VELOCITY_sum += CUR_VELOCITY; |
Lightvalve | 50:3c630b5eba9f | 808 | // } else { |
Lightvalve | 50:3c630b5eba9f | 809 | // V_out -= DZ_dir; |
Lightvalve | 50:3c630b5eba9f | 810 | // if (CUR_VELOCITY_sum * DZ_dir < 0) DZ_temp_cnt++; |
Lightvalve | 50:3c630b5eba9f | 811 | // CUR_VELOCITY_sum = 0; |
Lightvalve | 50:3c630b5eba9f | 812 | // } |
Lightvalve | 50:3c630b5eba9f | 813 | // if (DZ_temp_cnt == 5) { |
Lightvalve | 50:3c630b5eba9f | 814 | // if (DZ_dir >= 0) VALVE_DEADZONE_MINUS = (int16_t) V_out; |
Lightvalve | 50:3c630b5eba9f | 815 | // else VALVE_DEADZONE_PLUS = (int16_t) V_out; |
Lightvalve | 50:3c630b5eba9f | 816 | // DZ_dir = -DZ_dir; |
Lightvalve | 50:3c630b5eba9f | 817 | // DZ_temp_cnt = 0; |
Lightvalve | 50:3c630b5eba9f | 818 | // DZ_temp_cnt2++; |
Lightvalve | 50:3c630b5eba9f | 819 | // } |
Lightvalve | 50:3c630b5eba9f | 820 | // } else { |
Lightvalve | 50:3c630b5eba9f | 821 | // TMR3_COUNT_DEADZONE = -1; |
Lightvalve | 50:3c630b5eba9f | 822 | // VALVE_CENTER = VALVE_DEADZONE_PLUS / 2 + VALVE_DEADZONE_MINUS / 2; |
Lightvalve | 50:3c630b5eba9f | 823 | // if (VALVE_DEADZONE_PLUS < VALVE_DEADZONE_MINUS) { |
Lightvalve | 50:3c630b5eba9f | 824 | // VALVE_DEADZONE_PLUS = VALVE_CENTER; |
Lightvalve | 50:3c630b5eba9f | 825 | // VALVE_DEADZONE_MINUS = VALVE_CENTER; |
Lightvalve | 50:3c630b5eba9f | 826 | // } |
Lightvalve | 50:3c630b5eba9f | 827 | // V_out = 0; |
Lightvalve | 50:3c630b5eba9f | 828 | // |
Lightvalve | 50:3c630b5eba9f | 829 | // ROM_RESET_DATA(); |
Lightvalve | 50:3c630b5eba9f | 830 | // |
Lightvalve | 50:3c630b5eba9f | 831 | // //spi_eeprom_write(RID_VALVE_DEADZONE_PLUS, VALVE_DEADZONE_PLUS); |
Lightvalve | 50:3c630b5eba9f | 832 | // //spi_eeprom_write(RID_VALVE_DEADZONE_MINUS, VALVE_DEADZONE_MINUS); |
Lightvalve | 50:3c630b5eba9f | 833 | // |
Lightvalve | 50:3c630b5eba9f | 834 | // CONTROL_MODE = MODE_NO_ACT; |
Lightvalve | 50:3c630b5eba9f | 835 | // DZ_temp_cnt2 = 0; |
Lightvalve | 50:3c630b5eba9f | 836 | // } |
Lightvalve | 50:3c630b5eba9f | 837 | // } |
Lightvalve | 50:3c630b5eba9f | 838 | // TMR3_COUNT_DEADZONE++; |
Lightvalve | 50:3c630b5eba9f | 839 | // break; |
Lightvalve | 50:3c630b5eba9f | 840 | // } |
Lightvalve | 14:8e7590227d22 | 841 | |
Lightvalve | 14:8e7590227d22 | 842 | case MODE_FIND_HOME: { |
Lightvalve | 29:69f3f5445d6d | 843 | if (FINDHOME_STAGE == FINDHOME_INIT) { |
Lightvalve | 14:8e7590227d22 | 844 | cnt_findhome = 0; |
Lightvalve | 14:8e7590227d22 | 845 | cnt_vel_findhome = 0; |
Lightvalve | 14:8e7590227d22 | 846 | //REFERENCE_MODE = MODE_REF_NO_ACT; // Stop taking reference data from PODO |
Lightvalve | 59:f308b1656d9c | 847 | pos.ref = pos.sen; |
Lightvalve | 59:f308b1656d9c | 848 | vel.ref = 0.0f; |
Lightvalve | 29:69f3f5445d6d | 849 | FINDHOME_STAGE = FINDHOME_GOTOLIMIT; |
Lightvalve | 29:69f3f5445d6d | 850 | } else if (FINDHOME_STAGE == FINDHOME_GOTOLIMIT) { |
Lightvalve | 67:c2812cf26c38 | 851 | int cnt_check_enc = (TMR_FREQ_5k/20); |
Lightvalve | 29:69f3f5445d6d | 852 | if(cnt_findhome%cnt_check_enc == 0) { |
Lightvalve | 29:69f3f5445d6d | 853 | FINDHOME_POSITION = pos.sen; |
Lightvalve | 29:69f3f5445d6d | 854 | FINDHOME_VELOCITY = FINDHOME_POSITION - FINDHOME_POSITION_OLD; |
Lightvalve | 29:69f3f5445d6d | 855 | FINDHOME_POSITION_OLD = FINDHOME_POSITION; |
Lightvalve | 29:69f3f5445d6d | 856 | } |
Lightvalve | 29:69f3f5445d6d | 857 | cnt_findhome++; |
Lightvalve | 14:8e7590227d22 | 858 | |
Lightvalve | 29:69f3f5445d6d | 859 | if (abs(FINDHOME_VELOCITY) <= 1) { |
Lightvalve | 29:69f3f5445d6d | 860 | cnt_vel_findhome = cnt_vel_findhome + 1; |
Lightvalve | 29:69f3f5445d6d | 861 | } else { |
Lightvalve | 29:69f3f5445d6d | 862 | cnt_vel_findhome = 0; |
Lightvalve | 29:69f3f5445d6d | 863 | } |
Lightvalve | 19:23b7c1ad8683 | 864 | |
Lightvalve | 57:f4819de54e7a | 865 | if ((cnt_vel_findhome < 3*TMR_FREQ_5k) && cnt_findhome < 10*TMR_FREQ_5k) { // wait for 3sec |
Lightvalve | 29:69f3f5445d6d | 866 | //REFERENCE_MODE = MODE_REF_NO_ACT; |
Lightvalve | 67:c2812cf26c38 | 867 | if (HOMEPOS_OFFSET > 0) pos.ref = pos.ref + 12.0f; |
Lightvalve | 67:c2812cf26c38 | 868 | else pos.ref = pos.ref - 12.0f; |
Lightvalve | 61:bc8c8270f0ab | 869 | |
Lightvalve | 59:f308b1656d9c | 870 | // pos.err = pos.ref_home_pos - pos.sen; |
Lightvalve | 59:f308b1656d9c | 871 | // float VALVE_POS_RAW_POS_FB = 0.0f; |
Lightvalve | 59:f308b1656d9c | 872 | // VALVE_POS_RAW_POS_FB = (float) P_GAIN_JOINT_POSITION * pos.err/(float) ENC_PULSE_PER_POSITION * 0.01f; |
Lightvalve | 59:f308b1656d9c | 873 | // valve_pos.ref = VALVE_POS_RAW_POS_FB + (float) VALVE_CENTER; |
Lightvalve | 59:f308b1656d9c | 874 | // VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 61:bc8c8270f0ab | 875 | |
Lightvalve | 59:f308b1656d9c | 876 | CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 59:f308b1656d9c | 877 | alpha_trans = 0.0f; |
Lightvalve | 61:bc8c8270f0ab | 878 | |
Lightvalve | 34:bb2ca2fc2a8e | 879 | |
Lightvalve | 29:69f3f5445d6d | 880 | } else { |
Lightvalve | 29:69f3f5445d6d | 881 | ENC_SET(HOMEPOS_OFFSET); |
Lightvalve | 67:c2812cf26c38 | 882 | // ENC_SET_ZERO(); |
Lightvalve | 29:69f3f5445d6d | 883 | INIT_REF_POS = HOMEPOS_OFFSET; |
Lightvalve | 29:69f3f5445d6d | 884 | REF_POSITION = 0; |
Lightvalve | 29:69f3f5445d6d | 885 | REF_VELOCITY = 0; |
Lightvalve | 29:69f3f5445d6d | 886 | FINDHOME_POSITION = 0; |
Lightvalve | 29:69f3f5445d6d | 887 | FINDHOME_POSITION_OLD = 0; |
Lightvalve | 29:69f3f5445d6d | 888 | FINDHOME_VELOCITY = 0; |
Lightvalve | 29:69f3f5445d6d | 889 | cnt_findhome = 0; |
Lightvalve | 29:69f3f5445d6d | 890 | cnt_vel_findhome = 0; |
Lightvalve | 29:69f3f5445d6d | 891 | FINDHOME_STAGE = FINDHOME_ZEROPOSE; |
Lightvalve | 67:c2812cf26c38 | 892 | |
Lightvalve | 67:c2812cf26c38 | 893 | |
Lightvalve | 67:c2812cf26c38 | 894 | cnt_findhome = 0; |
Lightvalve | 67:c2812cf26c38 | 895 | pos.ref = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 896 | vel.ref = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 897 | pos.ref_home_pos = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 898 | vel.ref_home_pos = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 899 | //FINDHOME_STAGE = FINDHOME_INIT; |
Lightvalve | 67:c2812cf26c38 | 900 | //CONTROL_UTILITY_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 67:c2812cf26c38 | 901 | |
Lightvalve | 67:c2812cf26c38 | 902 | |
Lightvalve | 29:69f3f5445d6d | 903 | } |
Lightvalve | 29:69f3f5445d6d | 904 | } else if (FINDHOME_STAGE == FINDHOME_ZEROPOSE) { |
Lightvalve | 29:69f3f5445d6d | 905 | int T_move = 2*TMR_FREQ_5k; |
Lightvalve | 59:f308b1656d9c | 906 | 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 | 907 | //pos.ref = 0.0f; |
Lightvalve | 59:f308b1656d9c | 908 | vel.ref = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 909 | |
Lightvalve | 29:69f3f5445d6d | 910 | // input for position control |
Lightvalve | 67:c2812cf26c38 | 911 | |
Lightvalve | 67:c2812cf26c38 | 912 | // CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 67:c2812cf26c38 | 913 | alpha_trans = 0.0f; |
Lightvalve | 61:bc8c8270f0ab | 914 | |
Lightvalve | 67:c2812cf26c38 | 915 | double torq_ref = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 916 | pos.err = (pos.ref - pos.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm] |
Lightvalve | 67:c2812cf26c38 | 917 | vel.err = (0.0f - vel.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm/s] |
Lightvalve | 67:c2812cf26c38 | 918 | pos.err_sum += pos.err/(float) TMR_FREQ_5k; //[mm] |
Lightvalve | 67:c2812cf26c38 | 919 | |
Lightvalve | 67:c2812cf26c38 | 920 | if (((OPERATING_MODE&0b110)>>1) == 0 || ((OPERATING_MODE&0b110)>>1) == 1) { |
Lightvalve | 67:c2812cf26c38 | 921 | |
Lightvalve | 67:c2812cf26c38 | 922 | double I_REF_POS = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 923 | double I_REF_FORCE_FB = 0.0f; // I_REF by Force Feedback |
Lightvalve | 67:c2812cf26c38 | 924 | double I_REF_VC = 0.0f; // I_REF for velocity compensation |
Lightvalve | 67:c2812cf26c38 | 925 | |
Lightvalve | 67:c2812cf26c38 | 926 | double temp_vel_pos = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 927 | double temp_vel_torq = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 928 | double wn_Pos = 2.0f * PI * 5.0f; // f_cut : 5Hz Position Control |
Lightvalve | 67:c2812cf26c38 | 929 | |
Lightvalve | 69:3995ffeaa786 | 930 | if ((OPERATING_MODE & 0x01) == 0) { // Rotary Mode |
Lightvalve | 67:c2812cf26c38 | 931 | 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 | 932 | // L when P-gain = 100, f_cut = 10Hz L feedforward velocity |
Lightvalve | 69:3995ffeaa786 | 933 | } else if ((OPERATING_MODE & 0x01) == 1) { |
Lightvalve | 67:c2812cf26c38 | 934 | 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 | 935 | // L when P-gain = 100, f_cut = 10Hz L feedforward velocity |
Lightvalve | 67:c2812cf26c38 | 936 | } |
Lightvalve | 67:c2812cf26c38 | 937 | 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 | 938 | else I_REF_POS = temp_vel_pos * ((double) PISTON_AREA_B * 0.00006f / (K_v * sqrt(2.0f / (alpha3 + 1.0f)))); |
Lightvalve | 67:c2812cf26c38 | 939 | |
Lightvalve | 67:c2812cf26c38 | 940 | I_REF = I_REF_POS; |
Lightvalve | 67:c2812cf26c38 | 941 | |
Lightvalve | 67:c2812cf26c38 | 942 | |
Lightvalve | 67:c2812cf26c38 | 943 | |
Lightvalve | 67:c2812cf26c38 | 944 | } else { |
Lightvalve | 67:c2812cf26c38 | 945 | float VALVE_POS_RAW_FORCE_FB = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 946 | 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 | 947 | |
Lightvalve | 67:c2812cf26c38 | 948 | if (VALVE_POS_RAW_FORCE_FB >= 0) { |
Lightvalve | 67:c2812cf26c38 | 949 | valve_pos.ref = VALVE_POS_RAW_FORCE_FB + VALVE_DEADZONE_PLUS; |
Lightvalve | 67:c2812cf26c38 | 950 | } else { |
Lightvalve | 67:c2812cf26c38 | 951 | valve_pos.ref = VALVE_POS_RAW_FORCE_FB + VALVE_DEADZONE_MINUS; |
Lightvalve | 67:c2812cf26c38 | 952 | } |
Lightvalve | 67:c2812cf26c38 | 953 | |
Lightvalve | 67:c2812cf26c38 | 954 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 67:c2812cf26c38 | 955 | |
Lightvalve | 67:c2812cf26c38 | 956 | V_out = (float) Vout.ref; |
Lightvalve | 67:c2812cf26c38 | 957 | |
Lightvalve | 67:c2812cf26c38 | 958 | } |
Lightvalve | 67:c2812cf26c38 | 959 | |
Lightvalve | 67:c2812cf26c38 | 960 | |
Lightvalve | 67:c2812cf26c38 | 961 | |
Lightvalve | 67:c2812cf26c38 | 962 | |
Lightvalve | 59:f308b1656d9c | 963 | // pos.err = pos.ref - (float)pos.sen; |
Lightvalve | 59:f308b1656d9c | 964 | // float VALVE_POS_RAW_POS_FB = 0.0f; |
Lightvalve | 59:f308b1656d9c | 965 | // VALVE_POS_RAW_POS_FB = (float) P_GAIN_JOINT_POSITION * 0.01f * pos.err/(float) ENC_PULSE_PER_POSITION; |
Lightvalve | 59:f308b1656d9c | 966 | // valve_pos.ref = VALVE_POS_RAW_POS_FB + (float) VALVE_CENTER; |
Lightvalve | 59:f308b1656d9c | 967 | // VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 29:69f3f5445d6d | 968 | |
Lightvalve | 29:69f3f5445d6d | 969 | cnt_findhome++; |
Lightvalve | 29:69f3f5445d6d | 970 | if (cnt_findhome >= T_move) { |
Lightvalve | 29:69f3f5445d6d | 971 | //REFERENCE_MODE = MODE_REF_DIRECT; |
Lightvalve | 29:69f3f5445d6d | 972 | cnt_findhome = 0; |
Lightvalve | 30:8d561f16383b | 973 | pos.ref = 0.0f; |
Lightvalve | 30:8d561f16383b | 974 | vel.ref = 0.0f; |
Lightvalve | 30:8d561f16383b | 975 | pos.ref_home_pos = 0.0f; |
Lightvalve | 30:8d561f16383b | 976 | vel.ref_home_pos = 0.0f; |
Lightvalve | 29:69f3f5445d6d | 977 | FINDHOME_STAGE = FINDHOME_INIT; |
Lightvalve | 57:f4819de54e7a | 978 | CONTROL_UTILITY_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 29:69f3f5445d6d | 979 | } |
Lightvalve | 13:747daba9cf59 | 980 | } |
Lightvalve | 19:23b7c1ad8683 | 981 | |
Lightvalve | 13:747daba9cf59 | 982 | break; |
Lightvalve | 13:747daba9cf59 | 983 | } |
Lightvalve | 14:8e7590227d22 | 984 | |
Lightvalve | 50:3c630b5eba9f | 985 | // case MODE_VALVE_GAIN_SETTING: { |
Lightvalve | 50:3c630b5eba9f | 986 | // if (TMR3_COUNT_FLOWRATE == 0) { |
Lightvalve | 50:3c630b5eba9f | 987 | // if (pos_plus_end == pos_minus_end) need_enc_init = true; |
Lightvalve | 50:3c630b5eba9f | 988 | // else { |
Lightvalve | 50:3c630b5eba9f | 989 | // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 990 | // temp_time = (int) (0.5f * (float) TMR_FREQ_5k); |
Lightvalve | 50:3c630b5eba9f | 991 | // } |
Lightvalve | 50:3c630b5eba9f | 992 | // } |
Lightvalve | 50:3c630b5eba9f | 993 | // if (need_enc_init) { |
Lightvalve | 50:3c630b5eba9f | 994 | // if (TMR3_COUNT_FLOWRATE < (int) (0.5f * (float) TMR_FREQ_5k)) { |
Lightvalve | 50:3c630b5eba9f | 995 | // V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 996 | // pos_plus_end = pos.sen; |
Lightvalve | 50:3c630b5eba9f | 997 | // } else if (TMR3_COUNT_FLOWRATE < TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 998 | // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 999 | // pos_minus_end = pos.sen; |
Lightvalve | 50:3c630b5eba9f | 1000 | // } else if (TMR3_COUNT_FLOWRATE == TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1001 | // need_enc_init = false; |
Lightvalve | 50:3c630b5eba9f | 1002 | // check_vel_pos_init = (int) (0.9f * (float) (pos_plus_end - pos_minus_end)); |
Lightvalve | 50:3c630b5eba9f | 1003 | // check_vel_pos_fin = (int) (0.95f * (float) (pos_plus_end - pos_minus_end)); |
Lightvalve | 50:3c630b5eba9f | 1004 | // check_vel_pos_interv = check_vel_pos_fin - check_vel_pos_init; |
Lightvalve | 50:3c630b5eba9f | 1005 | // } |
Lightvalve | 50:3c630b5eba9f | 1006 | // temp_time = TMR_FREQ_5k; |
Lightvalve | 50:3c630b5eba9f | 1007 | // } |
Lightvalve | 50:3c630b5eba9f | 1008 | // TMR3_COUNT_FLOWRATE++; |
Lightvalve | 50:3c630b5eba9f | 1009 | // if (TMR3_COUNT_FLOWRATE > temp_time) { |
Lightvalve | 50:3c630b5eba9f | 1010 | // if (flag_flowrate % 2 == 0) { // (+) |
Lightvalve | 50:3c630b5eba9f | 1011 | // VALVE_VOLTAGE = 1000.0f * (float) (flag_flowrate / 2 + 1); |
Lightvalve | 50:3c630b5eba9f | 1012 | // V_out = VALVE_VOLTAGE; |
Lightvalve | 50:3c630b5eba9f | 1013 | // if (pos.sen > (pos_minus_end + check_vel_pos_init) && pos.sen < (pos_minus_end + check_vel_pos_fin)) { |
Lightvalve | 50:3c630b5eba9f | 1014 | // fl_temp_cnt++; |
Lightvalve | 50:3c630b5eba9f | 1015 | // } else if (pos.sen >= (pos_minus_end + check_vel_pos_fin) && CUR_VELOCITY == 0) { |
Lightvalve | 50:3c630b5eba9f | 1016 | // 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 | 1017 | // // 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 | 1018 | // fl_temp_cnt2++; |
Lightvalve | 50:3c630b5eba9f | 1019 | // } |
Lightvalve | 50:3c630b5eba9f | 1020 | // } else if (flag_flowrate % 2 == 1) { // (-) |
Lightvalve | 50:3c630b5eba9f | 1021 | // VALVE_VOLTAGE = -1. * (float) (flag_flowrate / 2 + 1); |
Lightvalve | 50:3c630b5eba9f | 1022 | // V_out = VALVE_VOLTAGE; |
Lightvalve | 50:3c630b5eba9f | 1023 | // if (pos.sen < (pos_plus_end - check_vel_pos_init) && pos.sen > (pos_plus_end - check_vel_pos_fin)) { |
Lightvalve | 50:3c630b5eba9f | 1024 | // fl_temp_cnt++; |
Lightvalve | 50:3c630b5eba9f | 1025 | // } else if (pos.sen <= (pos_plus_end - check_vel_pos_fin) && CUR_VELOCITY == 0) { |
Lightvalve | 50:3c630b5eba9f | 1026 | // 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 | 1027 | // // 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 | 1028 | // fl_temp_cnt2++; |
Lightvalve | 50:3c630b5eba9f | 1029 | // } |
Lightvalve | 50:3c630b5eba9f | 1030 | // } |
Lightvalve | 50:3c630b5eba9f | 1031 | // if (fl_temp_cnt2 == 100) { |
Lightvalve | 50:3c630b5eba9f | 1032 | // |
Lightvalve | 50:3c630b5eba9f | 1033 | // ROM_RESET_DATA(); |
Lightvalve | 50:3c630b5eba9f | 1034 | // |
Lightvalve | 50:3c630b5eba9f | 1035 | // //spi_eeprom_write(RID_VALVE_GAIN_PLUS_1 + flag_flowrate, (int16_t) (VALVE_GAIN_LPM_PER_V[flag_flowrate] * 100.0f)); |
Lightvalve | 50:3c630b5eba9f | 1036 | // cur_vel_sum = 0; |
Lightvalve | 50:3c630b5eba9f | 1037 | // fl_temp_cnt = 0; |
Lightvalve | 50:3c630b5eba9f | 1038 | // fl_temp_cnt2 = 0; |
Lightvalve | 50:3c630b5eba9f | 1039 | // flag_flowrate++; |
Lightvalve | 50:3c630b5eba9f | 1040 | // } |
Lightvalve | 50:3c630b5eba9f | 1041 | // if (flag_flowrate == 10) { |
Lightvalve | 50:3c630b5eba9f | 1042 | // V_out = 0; |
Lightvalve | 50:3c630b5eba9f | 1043 | // flag_flowrate = 0; |
Lightvalve | 50:3c630b5eba9f | 1044 | // TMR3_COUNT_FLOWRATE = 0; |
Lightvalve | 50:3c630b5eba9f | 1045 | // valve_gain_repeat_cnt++; |
Lightvalve | 50:3c630b5eba9f | 1046 | // if (valve_gain_repeat_cnt >= 1) { |
Lightvalve | 50:3c630b5eba9f | 1047 | // CONTROL_MODE = MODE_NO_ACT; |
Lightvalve | 50:3c630b5eba9f | 1048 | // valve_gain_repeat_cnt = 0; |
Lightvalve | 50:3c630b5eba9f | 1049 | // } |
Lightvalve | 50:3c630b5eba9f | 1050 | // |
Lightvalve | 50:3c630b5eba9f | 1051 | // } |
Lightvalve | 50:3c630b5eba9f | 1052 | // break; |
Lightvalve | 50:3c630b5eba9f | 1053 | // } |
Lightvalve | 50:3c630b5eba9f | 1054 | // |
Lightvalve | 50:3c630b5eba9f | 1055 | // } |
Lightvalve | 14:8e7590227d22 | 1056 | case MODE_PRESSURE_SENSOR_NULLING: { |
Lightvalve | 13:747daba9cf59 | 1057 | // DAC Voltage reference set |
Lightvalve | 14:8e7590227d22 | 1058 | if (TMR3_COUNT_PRES_NULL < TMR_FREQ_5k * 2) { |
Lightvalve | 14:8e7590227d22 | 1059 | CUR_PRES_A_sum += pres_A.sen; |
Lightvalve | 14:8e7590227d22 | 1060 | CUR_PRES_B_sum += pres_B.sen; |
Lightvalve | 14:8e7590227d22 | 1061 | |
Lightvalve | 14:8e7590227d22 | 1062 | if (TMR3_COUNT_PRES_NULL % 10 == 0) { |
Lightvalve | 30:8d561f16383b | 1063 | CUR_PRES_A_mean = CUR_PRES_A_sum / 10.0f; |
Lightvalve | 30:8d561f16383b | 1064 | CUR_PRES_B_mean = CUR_PRES_B_sum / 10.0f; |
Lightvalve | 13:747daba9cf59 | 1065 | CUR_PRES_A_sum = 0; |
Lightvalve | 13:747daba9cf59 | 1066 | CUR_PRES_B_sum = 0; |
Lightvalve | 14:8e7590227d22 | 1067 | |
Lightvalve | 38:118df027d851 | 1068 | float VREF_NullingGain = 0.0003f; |
Lightvalve | 58:2eade98630e2 | 1069 | PRES_A_VREF = PRES_A_VREF + VREF_NullingGain * CUR_PRES_A_mean; |
Lightvalve | 58:2eade98630e2 | 1070 | PRES_B_VREF = PRES_B_VREF + VREF_NullingGain * CUR_PRES_B_mean; |
Lightvalve | 14:8e7590227d22 | 1071 | |
Lightvalve | 30:8d561f16383b | 1072 | if (PRES_A_VREF > 3.3f) PRES_A_VREF = 3.3f; |
Lightvalve | 30:8d561f16383b | 1073 | if (PRES_A_VREF < 0.0f) PRES_A_VREF = 0.0f; |
Lightvalve | 30:8d561f16383b | 1074 | if (PRES_B_VREF > 3.3f) PRES_B_VREF = 3.3f; |
Lightvalve | 30:8d561f16383b | 1075 | if (PRES_B_VREF < 0.0f) PRES_B_VREF = 0.0f; |
Lightvalve | 19:23b7c1ad8683 | 1076 | |
Lightvalve | 30:8d561f16383b | 1077 | dac_1 = PRES_A_VREF / 3.3f; |
Lightvalve | 30:8d561f16383b | 1078 | dac_2 = PRES_B_VREF / 3.3f; |
Lightvalve | 13:747daba9cf59 | 1079 | } |
Lightvalve | 13:747daba9cf59 | 1080 | } else { |
Lightvalve | 57:f4819de54e7a | 1081 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 14:8e7590227d22 | 1082 | TMR3_COUNT_PRES_NULL = 0; |
Lightvalve | 13:747daba9cf59 | 1083 | CUR_PRES_A_sum = 0; |
Lightvalve | 13:747daba9cf59 | 1084 | CUR_PRES_B_sum = 0; |
Lightvalve | 13:747daba9cf59 | 1085 | CUR_PRES_A_mean = 0; |
Lightvalve | 13:747daba9cf59 | 1086 | CUR_PRES_B_mean = 0; |
Lightvalve | 14:8e7590227d22 | 1087 | |
Lightvalve | 16:903b5a4433b4 | 1088 | ROM_RESET_DATA(); |
Lightvalve | 19:23b7c1ad8683 | 1089 | |
Lightvalve | 30:8d561f16383b | 1090 | dac_1 = PRES_A_VREF / 3.3f; |
Lightvalve | 30:8d561f16383b | 1091 | dac_2 = PRES_B_VREF / 3.3f; |
Lightvalve | 17:1865016ca2e7 | 1092 | //pc.printf("nulling end"); |
Lightvalve | 13:747daba9cf59 | 1093 | } |
Lightvalve | 14:8e7590227d22 | 1094 | TMR3_COUNT_PRES_NULL++; |
Lightvalve | 13:747daba9cf59 | 1095 | break; |
Lightvalve | 13:747daba9cf59 | 1096 | } |
Lightvalve | 14:8e7590227d22 | 1097 | |
Lightvalve | 50:3c630b5eba9f | 1098 | // case MODE_PRESSURE_SENSOR_CALIB: { |
Lightvalve | 50:3c630b5eba9f | 1099 | // if (TMR3_COUNT_PRES_CALIB < 2 * TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1100 | // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1101 | // if (TMR3_COUNT_PRES_CALIB >= TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1102 | // CUR_PRES_A_sum += CUR_PRES_A; |
Lightvalve | 50:3c630b5eba9f | 1103 | // } |
Lightvalve | 50:3c630b5eba9f | 1104 | // } else if (TMR3_COUNT_PRES_CALIB < 4 * TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1105 | // V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1106 | // if (TMR3_COUNT_PRES_CALIB >= 3 * TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1107 | // CUR_PRES_B_sum += CUR_PRES_B; |
Lightvalve | 50:3c630b5eba9f | 1108 | // } |
Lightvalve | 50:3c630b5eba9f | 1109 | // } else { |
Lightvalve | 50:3c630b5eba9f | 1110 | // CONTROL_MODE = MODE_NO_ACT; |
Lightvalve | 50:3c630b5eba9f | 1111 | // TMR3_COUNT_PRES_CALIB = 0; |
Lightvalve | 50:3c630b5eba9f | 1112 | // V_out = 0; |
Lightvalve | 50:3c630b5eba9f | 1113 | // PRES_SENSOR_A_PULSE_PER_BAR = CUR_PRES_A_sum / ((float) TMR_FREQ_5k - 1.0f) - PRES_A_NULL; |
Lightvalve | 50:3c630b5eba9f | 1114 | // PRES_SENSOR_A_PULSE_PER_BAR = PRES_SENSOR_A_PULSE_PER_BAR / ((float) PRES_SUPPLY - 1.0f); |
Lightvalve | 50:3c630b5eba9f | 1115 | // PRES_SENSOR_B_PULSE_PER_BAR = CUR_PRES_B_sum / ((float) TMR_FREQ_5k - 1.0f) - PRES_B_NULL; |
Lightvalve | 50:3c630b5eba9f | 1116 | // PRES_SENSOR_B_PULSE_PER_BAR = PRES_SENSOR_B_PULSE_PER_BAR / ((float) PRES_SUPPLY - 1.0f); |
Lightvalve | 50:3c630b5eba9f | 1117 | // CUR_PRES_A_sum = 0; |
Lightvalve | 50:3c630b5eba9f | 1118 | // CUR_PRES_B_sum = 0; |
Lightvalve | 50:3c630b5eba9f | 1119 | // CUR_PRES_A_mean = 0; |
Lightvalve | 50:3c630b5eba9f | 1120 | // CUR_PRES_B_mean = 0; |
Lightvalve | 50:3c630b5eba9f | 1121 | // |
Lightvalve | 50:3c630b5eba9f | 1122 | // ROM_RESET_DATA(); |
Lightvalve | 50:3c630b5eba9f | 1123 | // |
Lightvalve | 50:3c630b5eba9f | 1124 | // //spi_eeprom_write(RID_PRES_SENSOR_A_PULSE_PER_BAR, (int16_t) (PRES_SENSOR_A_PULSE_PER_BAR * 100.0f)); |
Lightvalve | 50:3c630b5eba9f | 1125 | // //spi_eeprom_write(RID_PRES_SENSOR_B_PULSE_PER_BAR, (int16_t) (PRES_SENSOR_B_PULSE_PER_BAR * 100.0f)); |
Lightvalve | 50:3c630b5eba9f | 1126 | // } |
Lightvalve | 50:3c630b5eba9f | 1127 | // TMR3_COUNT_PRES_CALIB++; |
Lightvalve | 50:3c630b5eba9f | 1128 | // break; |
Lightvalve | 50:3c630b5eba9f | 1129 | // } |
Lightvalve | 19:23b7c1ad8683 | 1130 | |
Lightvalve | 50:3c630b5eba9f | 1131 | // case MODE_ROTARY_FRICTION_TUNING: { |
Lightvalve | 50:3c630b5eba9f | 1132 | // 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 | 1133 | // V_out = PWM_out * sin(2 * 3.14159f * freq_fric_tune * TMR3_COUNT_ROTARY_FRIC_TUNE * 0.0001f); |
Lightvalve | 50:3c630b5eba9f | 1134 | // if (V_out > 0) V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1135 | // else V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1136 | // TMR3_COUNT_ROTARY_FRIC_TUNE++; |
Lightvalve | 50:3c630b5eba9f | 1137 | // if (TMR3_COUNT_ROTARY_FRIC_TUNE > TUNING_TIME * TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1138 | // TMR3_COUNT_ROTARY_FRIC_TUNE = 0; |
Lightvalve | 50:3c630b5eba9f | 1139 | // V_out = 0.0f; |
Lightvalve | 50:3c630b5eba9f | 1140 | // CONTROL_MODE = MODE_NO_ACT; |
Lightvalve | 50:3c630b5eba9f | 1141 | // } |
Lightvalve | 50:3c630b5eba9f | 1142 | // break; |
Lightvalve | 50:3c630b5eba9f | 1143 | // } |
Lightvalve | 14:8e7590227d22 | 1144 | |
Lightvalve | 14:8e7590227d22 | 1145 | case MODE_DDV_POS_VS_PWM_ID: { |
Lightvalve | 59:f308b1656d9c | 1146 | CONTROL_MODE = MODE_VALVE_OPEN_LOOP; |
Lightvalve | 13:747daba9cf59 | 1147 | VALVE_ID_timer = VALVE_ID_timer + 1; |
Lightvalve | 14:8e7590227d22 | 1148 | |
Lightvalve | 14:8e7590227d22 | 1149 | if(VALVE_ID_timer < TMR_FREQ_5k*1) { |
Lightvalve | 60:64181f1d3e60 | 1150 | Vout.ref = 3000.0f * sin(2.0f*3.14f*VALVE_ID_timer/TMR_FREQ_5k * 100.0f); |
Lightvalve | 14:8e7590227d22 | 1151 | } else if(VALVE_ID_timer < TMR_FREQ_5k*2) { |
Lightvalve | 59:f308b1656d9c | 1152 | Vout.ref = 1000.0f*(ID_index_array[ID_index]); |
Lightvalve | 14:8e7590227d22 | 1153 | } else if(VALVE_ID_timer == TMR_FREQ_5k*2) { |
Lightvalve | 13:747daba9cf59 | 1154 | VALVE_POS_TMP = 0; |
Lightvalve | 13:747daba9cf59 | 1155 | data_num = 0; |
Lightvalve | 14:8e7590227d22 | 1156 | } else if(VALVE_ID_timer < TMR_FREQ_5k*3) { |
Lightvalve | 13:747daba9cf59 | 1157 | data_num = data_num + 1; |
Lightvalve | 13:747daba9cf59 | 1158 | VALVE_POS_TMP = VALVE_POS_TMP + value; |
Lightvalve | 14:8e7590227d22 | 1159 | } else if(VALVE_ID_timer == TMR_FREQ_5k*3) { |
Lightvalve | 59:f308b1656d9c | 1160 | Vout.ref = 0.0f; |
Lightvalve | 59:f308b1656d9c | 1161 | } else { |
Lightvalve | 13:747daba9cf59 | 1162 | VALVE_POS_AVG[ID_index] = VALVE_POS_TMP / data_num; |
Lightvalve | 13:747daba9cf59 | 1163 | VALVE_ID_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1164 | ID_index= ID_index +1; |
Lightvalve | 13:747daba9cf59 | 1165 | } |
Lightvalve | 14:8e7590227d22 | 1166 | |
Lightvalve | 17:1865016ca2e7 | 1167 | if(ID_index>=25) { |
Lightvalve | 13:747daba9cf59 | 1168 | int i; |
Lightvalve | 13:747daba9cf59 | 1169 | VALVE_POS_AVG_OLD = VALVE_POS_AVG[0]; |
Lightvalve | 17:1865016ca2e7 | 1170 | for(i=0; i<25; i++) { |
Lightvalve | 13:747daba9cf59 | 1171 | VALVE_POS_VS_PWM[i] = (int16_t) (VALVE_POS_AVG[i]); |
Lightvalve | 14:8e7590227d22 | 1172 | if(VALVE_POS_AVG[i] > VALVE_POS_AVG_OLD) { |
Lightvalve | 13:747daba9cf59 | 1173 | VALVE_MAX_POS = VALVE_POS_AVG[i]; |
Lightvalve | 13:747daba9cf59 | 1174 | VALVE_POS_AVG_OLD = VALVE_MAX_POS; |
Lightvalve | 14:8e7590227d22 | 1175 | } else if(VALVE_POS_AVG[i] < VALVE_POS_AVG_OLD) { |
Lightvalve | 13:747daba9cf59 | 1176 | VALVE_MIN_POS = VALVE_POS_AVG[i]; |
Lightvalve | 13:747daba9cf59 | 1177 | VALVE_POS_AVG_OLD = VALVE_MIN_POS; |
Lightvalve | 13:747daba9cf59 | 1178 | } |
Lightvalve | 13:747daba9cf59 | 1179 | } |
Lightvalve | 59:f308b1656d9c | 1180 | ROM_RESET_DATA(); |
Lightvalve | 13:747daba9cf59 | 1181 | ID_index = 0; |
Lightvalve | 57:f4819de54e7a | 1182 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 13:747daba9cf59 | 1183 | } |
Lightvalve | 14:8e7590227d22 | 1184 | |
Lightvalve | 14:8e7590227d22 | 1185 | |
Lightvalve | 13:747daba9cf59 | 1186 | break; |
Lightvalve | 13:747daba9cf59 | 1187 | } |
Lightvalve | 14:8e7590227d22 | 1188 | |
Lightvalve | 14:8e7590227d22 | 1189 | case MODE_DDV_DEADZONE_AND_CENTER: { |
Lightvalve | 59:f308b1656d9c | 1190 | CONTROL_MODE = MODE_VALVE_OPEN_LOOP; |
Lightvalve | 13:747daba9cf59 | 1191 | VALVE_DZ_timer = VALVE_DZ_timer + 1; |
Lightvalve | 14:8e7590227d22 | 1192 | if(first_check == 0) { |
Lightvalve | 30:8d561f16383b | 1193 | if(VALVE_DZ_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1194 | Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 30:8d561f16383b | 1195 | } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1196 | Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 14:8e7590227d22 | 1197 | pos_plus_end = pos.sen; |
Lightvalve | 30:8d561f16383b | 1198 | } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1199 | Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 30:8d561f16383b | 1200 | } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1201 | Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 14:8e7590227d22 | 1202 | pos_minus_end = pos.sen; |
Lightvalve | 30:8d561f16383b | 1203 | } else if(VALVE_DZ_timer < (int) (3.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1204 | 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 | 1205 | } else if(VALVE_DZ_timer < (int) (4.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1206 | 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 | 1207 | data_num = data_num + 1; |
Lightvalve | 13:747daba9cf59 | 1208 | VALVE_POS_TMP = VALVE_POS_TMP + value; |
Lightvalve | 30:8d561f16383b | 1209 | } else if(VALVE_DZ_timer == (int) (4.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1210 | 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 | 1211 | DDV_POS_AVG = VALVE_POS_TMP / data_num; |
Lightvalve | 14:8e7590227d22 | 1212 | START_POS = pos.sen; |
Lightvalve | 13:747daba9cf59 | 1213 | VALVE_POS_TMP = 0; |
Lightvalve | 13:747daba9cf59 | 1214 | data_num = 0; |
Lightvalve | 14:8e7590227d22 | 1215 | |
Lightvalve | 30:8d561f16383b | 1216 | } else if(VALVE_DZ_timer < (int) (5.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1217 | valve_pos.ref = DDV_POS_AVG; |
Lightvalve | 14:8e7590227d22 | 1218 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 14:8e7590227d22 | 1219 | |
Lightvalve | 30:8d561f16383b | 1220 | } else if(VALVE_DZ_timer < (int) (6.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1221 | valve_pos.ref = DDV_POS_AVG; |
Lightvalve | 14:8e7590227d22 | 1222 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 60:64181f1d3e60 | 1223 | |
Lightvalve | 30:8d561f16383b | 1224 | } else if(VALVE_DZ_timer == (int) (6.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1225 | valve_pos.ref = DDV_POS_AVG; |
Lightvalve | 14:8e7590227d22 | 1226 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 14:8e7590227d22 | 1227 | FINAL_POS = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1228 | |
Lightvalve | 60:64181f1d3e60 | 1229 | if((FINAL_POS - START_POS)>200) { |
Lightvalve | 13:747daba9cf59 | 1230 | DZ_case = 1; |
Lightvalve | 60:64181f1d3e60 | 1231 | } else if((FINAL_POS - START_POS)<-200) { |
Lightvalve | 13:747daba9cf59 | 1232 | DZ_case = -1; |
Lightvalve | 14:8e7590227d22 | 1233 | } else { |
Lightvalve | 13:747daba9cf59 | 1234 | DZ_case = 0; |
Lightvalve | 13:747daba9cf59 | 1235 | } |
Lightvalve | 61:bc8c8270f0ab | 1236 | |
Lightvalve | 60:64181f1d3e60 | 1237 | CAN_TX_PRES((int16_t) (DZ_case), (int16_t) (6)); |
Lightvalve | 50:3c630b5eba9f | 1238 | |
Lightvalve | 13:747daba9cf59 | 1239 | first_check = 1; |
Lightvalve | 13:747daba9cf59 | 1240 | DZ_DIRECTION = 1; |
Lightvalve | 13:747daba9cf59 | 1241 | VALVE_DZ_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1242 | Ref_Valve_Pos_Old = DDV_POS_AVG; |
Lightvalve | 13:747daba9cf59 | 1243 | DZ_NUM = 1; |
Lightvalve | 13:747daba9cf59 | 1244 | DZ_index = 1; |
Lightvalve | 14:8e7590227d22 | 1245 | |
Lightvalve | 13:747daba9cf59 | 1246 | } |
Lightvalve | 19:23b7c1ad8683 | 1247 | } else { |
Lightvalve | 14:8e7590227d22 | 1248 | if((DZ_case == -1 && DZ_NUM == 1) | (DZ_case == 1 && DZ_NUM == 1)) { |
Lightvalve | 30:8d561f16383b | 1249 | if(VALVE_DZ_timer < (int) (1.0 * (float) TMR_FREQ_5k)) { |
Lightvalve | 60:64181f1d3e60 | 1250 | 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 | 1251 | //pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; |
Lightvalve | 60:64181f1d3e60 | 1252 | //CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 30:8d561f16383b | 1253 | } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1254 | START_POS = pos.sen; |
Lightvalve | 30:8d561f16383b | 1255 | } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1256 | valve_pos.ref = Ref_Valve_Pos_Old - DZ_case * DZ_DIRECTION * 64 / DZ_index; |
Lightvalve | 14:8e7590227d22 | 1257 | if(valve_pos.ref <= VALVE_MIN_POS) { |
Lightvalve | 14:8e7590227d22 | 1258 | valve_pos.ref = VALVE_MIN_POS; |
Lightvalve | 14:8e7590227d22 | 1259 | } else if(valve_pos.ref >= VALVE_MAX_POS) { |
Lightvalve | 14:8e7590227d22 | 1260 | valve_pos.ref = VALVE_MAX_POS; |
Lightvalve | 13:747daba9cf59 | 1261 | } |
Lightvalve | 14:8e7590227d22 | 1262 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 60:64181f1d3e60 | 1263 | |
Lightvalve | 30:8d561f16383b | 1264 | } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1265 | Ref_Valve_Pos_Old = valve_pos.ref; |
Lightvalve | 14:8e7590227d22 | 1266 | FINAL_POS = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1267 | |
Lightvalve | 14:8e7590227d22 | 1268 | if((FINAL_POS - START_POS)>100) { |
Lightvalve | 14:8e7590227d22 | 1269 | DZ_DIRECTION = 1 * DZ_case; |
Lightvalve | 14:8e7590227d22 | 1270 | } else if((FINAL_POS - START_POS)<-100) { |
Lightvalve | 14:8e7590227d22 | 1271 | DZ_DIRECTION = -1 * DZ_case; |
Lightvalve | 14:8e7590227d22 | 1272 | } else { |
Lightvalve | 13:747daba9cf59 | 1273 | DZ_DIRECTION = 1 * DZ_case; |
Lightvalve | 13:747daba9cf59 | 1274 | } |
Lightvalve | 14:8e7590227d22 | 1275 | |
Lightvalve | 13:747daba9cf59 | 1276 | VALVE_DZ_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1277 | DZ_index= DZ_index *2; |
Lightvalve | 14:8e7590227d22 | 1278 | if(DZ_index >= 128) { |
Lightvalve | 14:8e7590227d22 | 1279 | FIRST_DZ = valve_pos.ref; |
Lightvalve | 13:747daba9cf59 | 1280 | DZ_NUM = 2; |
Lightvalve | 13:747daba9cf59 | 1281 | Ref_Valve_Pos_Old = FIRST_DZ; |
Lightvalve | 13:747daba9cf59 | 1282 | DZ_index = 1; |
Lightvalve | 13:747daba9cf59 | 1283 | DZ_DIRECTION = 1; |
Lightvalve | 13:747daba9cf59 | 1284 | } |
Lightvalve | 13:747daba9cf59 | 1285 | } |
Lightvalve | 14:8e7590227d22 | 1286 | } else if((DZ_case == -1 && DZ_NUM == 2) | (DZ_case == 1 && DZ_NUM == 2)) { |
Lightvalve | 30:8d561f16383b | 1287 | if(VALVE_DZ_timer < (int) (1.0f * (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 | 60:64181f1d3e60 | 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 | 61:bc8c8270f0ab | 1301 | |
Lightvalve | 30:8d561f16383b | 1302 | } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1303 | Vout.ref = 0.0f; |
Lightvalve | 59:f308b1656d9c | 1304 | } else if(VALVE_DZ_timer > (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1305 | Ref_Valve_Pos_Old = valve_pos.ref; |
Lightvalve | 14:8e7590227d22 | 1306 | FINAL_POS = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1307 | |
Lightvalve | 14:8e7590227d22 | 1308 | if((FINAL_POS - START_POS)>100) { |
Lightvalve | 60:64181f1d3e60 | 1309 | DZ_DIRECTION = 1 * DZ_case; |
Lightvalve | 14:8e7590227d22 | 1310 | } else if((FINAL_POS - START_POS)<-100) { |
Lightvalve | 60:64181f1d3e60 | 1311 | DZ_DIRECTION = -1 * DZ_case; |
Lightvalve | 14:8e7590227d22 | 1312 | } else { |
Lightvalve | 60:64181f1d3e60 | 1313 | DZ_DIRECTION = -1 * DZ_case; |
Lightvalve | 13:747daba9cf59 | 1314 | } |
Lightvalve | 14:8e7590227d22 | 1315 | |
Lightvalve | 13:747daba9cf59 | 1316 | VALVE_DZ_timer = 0; |
Lightvalve | 60:64181f1d3e60 | 1317 | DZ_index= DZ_index * 2; |
Lightvalve | 14:8e7590227d22 | 1318 | if(DZ_index >= 128) { |
Lightvalve | 14:8e7590227d22 | 1319 | SECOND_DZ = valve_pos.ref; |
Lightvalve | 57:f4819de54e7a | 1320 | VALVE_CENTER = (int) (0.5f * (float) (FIRST_DZ) + 0.5f * (float) (SECOND_DZ)); |
Lightvalve | 13:747daba9cf59 | 1321 | first_check = 0; |
Lightvalve | 33:91b17819ec30 | 1322 | VALVE_DEADZONE_MINUS = (float) FIRST_DZ; |
Lightvalve | 33:91b17819ec30 | 1323 | VALVE_DEADZONE_PLUS = (float) SECOND_DZ; |
Lightvalve | 19:23b7c1ad8683 | 1324 | |
Lightvalve | 16:903b5a4433b4 | 1325 | ROM_RESET_DATA(); |
Lightvalve | 34:bb2ca2fc2a8e | 1326 | |
Lightvalve | 60:64181f1d3e60 | 1327 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 13:747daba9cf59 | 1328 | DZ_index = 1; |
Lightvalve | 13:747daba9cf59 | 1329 | } |
Lightvalve | 13:747daba9cf59 | 1330 | } |
Lightvalve | 14:8e7590227d22 | 1331 | } else if(DZ_case == 0 && DZ_NUM ==1) { |
Lightvalve | 30:8d561f16383b | 1332 | if(VALVE_DZ_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 60:64181f1d3e60 | 1333 | 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 | 1334 | //pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; |
Lightvalve | 60:64181f1d3e60 | 1335 | //CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 30:8d561f16383b | 1336 | } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1337 | START_POS = pos.sen; |
Lightvalve | 30:8d561f16383b | 1338 | } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1339 | valve_pos.ref = Ref_Valve_Pos_Old - DZ_DIRECTION * 64 / DZ_index; |
Lightvalve | 14:8e7590227d22 | 1340 | if(valve_pos.ref <= VALVE_MIN_POS) { |
Lightvalve | 14:8e7590227d22 | 1341 | valve_pos.ref = VALVE_MIN_POS; |
Lightvalve | 14:8e7590227d22 | 1342 | } else if(valve_pos.ref >= VALVE_MAX_POS) { |
Lightvalve | 14:8e7590227d22 | 1343 | valve_pos.ref = VALVE_MAX_POS; |
Lightvalve | 13:747daba9cf59 | 1344 | } |
Lightvalve | 14:8e7590227d22 | 1345 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 61:bc8c8270f0ab | 1346 | |
Lightvalve | 30:8d561f16383b | 1347 | } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1348 | Ref_Valve_Pos_Old = valve_pos.ref; |
Lightvalve | 14:8e7590227d22 | 1349 | FINAL_POS = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1350 | |
Lightvalve | 14:8e7590227d22 | 1351 | if((FINAL_POS - START_POS)>100) { |
Lightvalve | 14:8e7590227d22 | 1352 | DZ_DIRECTION = 1; |
Lightvalve | 14:8e7590227d22 | 1353 | } else if((FINAL_POS - START_POS)<-100) { |
Lightvalve | 14:8e7590227d22 | 1354 | DZ_DIRECTION = -1; |
Lightvalve | 14:8e7590227d22 | 1355 | } else { |
Lightvalve | 13:747daba9cf59 | 1356 | DZ_DIRECTION = 1; |
Lightvalve | 13:747daba9cf59 | 1357 | } |
Lightvalve | 13:747daba9cf59 | 1358 | VALVE_DZ_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1359 | DZ_index= DZ_index *2; |
Lightvalve | 14:8e7590227d22 | 1360 | if(DZ_index >= 128) { |
Lightvalve | 14:8e7590227d22 | 1361 | FIRST_DZ = valve_pos.ref; |
Lightvalve | 13:747daba9cf59 | 1362 | DZ_NUM = 2; |
Lightvalve | 13:747daba9cf59 | 1363 | Ref_Valve_Pos_Old = FIRST_DZ; |
Lightvalve | 13:747daba9cf59 | 1364 | DZ_index = 1; |
Lightvalve | 13:747daba9cf59 | 1365 | DZ_DIRECTION = 1; |
Lightvalve | 13:747daba9cf59 | 1366 | } |
Lightvalve | 13:747daba9cf59 | 1367 | } |
Lightvalve | 14:8e7590227d22 | 1368 | } else { |
Lightvalve | 30:8d561f16383b | 1369 | if(VALVE_DZ_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 60:64181f1d3e60 | 1370 | 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 | 1371 | //pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; |
Lightvalve | 60:64181f1d3e60 | 1372 | //CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 30:8d561f16383b | 1373 | } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1374 | START_POS = pos.sen; |
Lightvalve | 30:8d561f16383b | 1375 | } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1376 | valve_pos.ref = Ref_Valve_Pos_Old + DZ_DIRECTION * 64 / DZ_index; |
Lightvalve | 14:8e7590227d22 | 1377 | if(valve_pos.ref <= VALVE_MIN_POS) { |
Lightvalve | 14:8e7590227d22 | 1378 | valve_pos.ref = VALVE_MIN_POS; |
Lightvalve | 14:8e7590227d22 | 1379 | } else if(valve_pos.ref > VALVE_MAX_POS) { |
Lightvalve | 14:8e7590227d22 | 1380 | valve_pos.ref = VALVE_MAX_POS - 1; |
Lightvalve | 13:747daba9cf59 | 1381 | } |
Lightvalve | 14:8e7590227d22 | 1382 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 60:64181f1d3e60 | 1383 | |
Lightvalve | 30:8d561f16383b | 1384 | } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1385 | Vout.ref = 0.0f; |
Lightvalve | 59:f308b1656d9c | 1386 | } else if(VALVE_DZ_timer > (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1387 | Ref_Valve_Pos_Old = valve_pos.ref; |
Lightvalve | 14:8e7590227d22 | 1388 | FINAL_POS = pos.sen; |
Lightvalve | 61:bc8c8270f0ab | 1389 | |
Lightvalve | 60:64181f1d3e60 | 1390 | if((FINAL_POS - START_POS)>100) { |
Lightvalve | 13:747daba9cf59 | 1391 | DZ_DIRECTION = 1; |
Lightvalve | 60:64181f1d3e60 | 1392 | } else if((FINAL_POS - START_POS)<-100) { |
Lightvalve | 60:64181f1d3e60 | 1393 | DZ_DIRECTION = -1; |
Lightvalve | 60:64181f1d3e60 | 1394 | } else { |
Lightvalve | 13:747daba9cf59 | 1395 | DZ_DIRECTION = 1; |
Lightvalve | 60:64181f1d3e60 | 1396 | } |
Lightvalve | 14:8e7590227d22 | 1397 | |
Lightvalve | 13:747daba9cf59 | 1398 | VALVE_DZ_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1399 | DZ_index= DZ_index *2; |
Lightvalve | 14:8e7590227d22 | 1400 | if(DZ_index >= 128) { |
Lightvalve | 14:8e7590227d22 | 1401 | SECOND_DZ = valve_pos.ref; |
Lightvalve | 57:f4819de54e7a | 1402 | VALVE_CENTER = (int) (0.5f * (float) (FIRST_DZ) + 0.5f * (float) (SECOND_DZ)); |
Lightvalve | 13:747daba9cf59 | 1403 | first_check = 0; |
Lightvalve | 33:91b17819ec30 | 1404 | VALVE_DEADZONE_MINUS = (float) FIRST_DZ; |
Lightvalve | 33:91b17819ec30 | 1405 | VALVE_DEADZONE_PLUS = (float) SECOND_DZ; |
Lightvalve | 61:bc8c8270f0ab | 1406 | |
Lightvalve | 59:f308b1656d9c | 1407 | ROM_RESET_DATA(); |
Lightvalve | 34:bb2ca2fc2a8e | 1408 | |
Lightvalve | 57:f4819de54e7a | 1409 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 13:747daba9cf59 | 1410 | DZ_index = 1; |
Lightvalve | 13:747daba9cf59 | 1411 | } |
Lightvalve | 13:747daba9cf59 | 1412 | } |
Lightvalve | 13:747daba9cf59 | 1413 | } |
Lightvalve | 14:8e7590227d22 | 1414 | } |
Lightvalve | 13:747daba9cf59 | 1415 | break; |
Lightvalve | 13:747daba9cf59 | 1416 | } |
Lightvalve | 14:8e7590227d22 | 1417 | |
Lightvalve | 14:8e7590227d22 | 1418 | case MODE_DDV_POS_VS_FLOWRATE: { |
Lightvalve | 59:f308b1656d9c | 1419 | CONTROL_MODE = MODE_VALVE_OPEN_LOOP; |
Lightvalve | 13:747daba9cf59 | 1420 | VALVE_FR_timer = VALVE_FR_timer + 1; |
Lightvalve | 14:8e7590227d22 | 1421 | if(first_check == 0) { |
Lightvalve | 30:8d561f16383b | 1422 | if(VALVE_FR_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1423 | Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 23:59218d4a256d | 1424 | //CAN_TX_PRES((int16_t) (VALVE_FR_timer), (int16_t) (6)); |
Lightvalve | 30:8d561f16383b | 1425 | } else if(VALVE_FR_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1426 | Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 14:8e7590227d22 | 1427 | pos_plus_end = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1428 | // CAN_TX_PRES((int16_t) (V_out), (int16_t) (7)); |
Lightvalve | 30:8d561f16383b | 1429 | } else if(VALVE_FR_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1430 | Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 30:8d561f16383b | 1431 | } else if(VALVE_FR_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1432 | // CAN_TX_PRES((int16_t) (V_out), (int16_t) (8)); |
Lightvalve | 59:f308b1656d9c | 1433 | Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 14:8e7590227d22 | 1434 | pos_minus_end = pos.sen; |
Lightvalve | 13:747daba9cf59 | 1435 | first_check = 1; |
Lightvalve | 13:747daba9cf59 | 1436 | VALVE_FR_timer = 0; |
Lightvalve | 57:f4819de54e7a | 1437 | valve_pos.ref = (float) VALVE_CENTER; |
Lightvalve | 13:747daba9cf59 | 1438 | ID_index = 0; |
Lightvalve | 13:747daba9cf59 | 1439 | max_check = 0; |
Lightvalve | 13:747daba9cf59 | 1440 | min_check = 0; |
Lightvalve | 13:747daba9cf59 | 1441 | } |
Lightvalve | 14:8e7590227d22 | 1442 | } else { |
Lightvalve | 30:8d561f16383b | 1443 | if(VALVE_FR_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1444 | //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 | 1445 | pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; |
Lightvalve | 59:f308b1656d9c | 1446 | CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 30:8d561f16383b | 1447 | } else if(VALVE_FR_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 13:747daba9cf59 | 1448 | data_num = 0; |
Lightvalve | 57:f4819de54e7a | 1449 | valve_pos.ref = 10.0f*((float) ID_index_array[ID_index]) + (float) VALVE_CENTER; |
Lightvalve | 14:8e7590227d22 | 1450 | |
Lightvalve | 14:8e7590227d22 | 1451 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 14:8e7590227d22 | 1452 | START_POS = pos.sen; |
Lightvalve | 30:8d561f16383b | 1453 | } else if(VALVE_FR_timer < (int) (5.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 57:f4819de54e7a | 1454 | valve_pos.ref = 10.0f*((float) ID_index_array[ID_index]) + (float) VALVE_CENTER; |
Lightvalve | 14:8e7590227d22 | 1455 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 13:747daba9cf59 | 1456 | data_num = data_num + 1; |
Lightvalve | 30:8d561f16383b | 1457 | if(abs(0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen) > 20000.0f) { |
Lightvalve | 14:8e7590227d22 | 1458 | FINAL_POS = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1459 | one_period_end = 1; |
Lightvalve | 13:747daba9cf59 | 1460 | } |
Lightvalve | 30:8d561f16383b | 1461 | } else if(VALVE_FR_timer == (int) (5.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1462 | FINAL_POS = pos.sen; |
Lightvalve | 13:747daba9cf59 | 1463 | one_period_end = 1; |
Lightvalve | 59:f308b1656d9c | 1464 | V_out = 0.0f; |
Lightvalve | 13:747daba9cf59 | 1465 | } |
Lightvalve | 14:8e7590227d22 | 1466 | |
Lightvalve | 14:8e7590227d22 | 1467 | if(one_period_end == 1) { |
Lightvalve | 14:8e7590227d22 | 1468 | if(valve_pos.ref > VALVE_MAX_POS) { |
Lightvalve | 13:747daba9cf59 | 1469 | max_check = 1; |
Lightvalve | 14:8e7590227d22 | 1470 | } else if(valve_pos.ref < VALVE_MIN_POS) { |
Lightvalve | 13:747daba9cf59 | 1471 | min_check = 1; |
Lightvalve | 13:747daba9cf59 | 1472 | } |
Lightvalve | 13:747daba9cf59 | 1473 | JOINT_VEL[ID_index] = (FINAL_POS - START_POS) / data_num * TMR_FREQ_5k; // pulse/sec |
Lightvalve | 19:23b7c1ad8683 | 1474 | |
Lightvalve | 13:747daba9cf59 | 1475 | VALVE_FR_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1476 | one_period_end = 0; |
Lightvalve | 13:747daba9cf59 | 1477 | ID_index= ID_index +1; |
Lightvalve | 30:8d561f16383b | 1478 | V_out = 0.0f; |
Lightvalve | 13:747daba9cf59 | 1479 | } |
Lightvalve | 14:8e7590227d22 | 1480 | |
Lightvalve | 14:8e7590227d22 | 1481 | if(max_check == 1 && min_check == 1) { |
Lightvalve | 19:23b7c1ad8683 | 1482 | |
Lightvalve | 13:747daba9cf59 | 1483 | VALVE_POS_NUM = ID_index; |
Lightvalve | 59:f308b1656d9c | 1484 | ROM_RESET_DATA(); |
Lightvalve | 13:747daba9cf59 | 1485 | ID_index = 0; |
Lightvalve | 13:747daba9cf59 | 1486 | first_check = 0; |
Lightvalve | 13:747daba9cf59 | 1487 | VALVE_FR_timer = 0; |
Lightvalve | 57:f4819de54e7a | 1488 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 49:e7bcfc244d40 | 1489 | // CAN_TX_PRES((int16_t) (VALVE_FR_timer), (int16_t) (6)); |
Lightvalve | 13:747daba9cf59 | 1490 | } |
Lightvalve | 13:747daba9cf59 | 1491 | } |
Lightvalve | 13:747daba9cf59 | 1492 | break; |
Lightvalve | 13:747daba9cf59 | 1493 | } |
Lightvalve | 58:2eade98630e2 | 1494 | |
Lightvalve | 57:f4819de54e7a | 1495 | case MODE_SYSTEM_ID: { |
Lightvalve | 57:f4819de54e7a | 1496 | freq_sysid_Iref = (double) cnt_sysid * DT_TMR3 * 3.; |
Lightvalve | 57:f4819de54e7a | 1497 | valve_pos.ref = 2500.0f * sin(2.0f * 3.14159f * freq_sysid_Iref * (double) cnt_sysid * DT_TMR3); |
Lightvalve | 57:f4819de54e7a | 1498 | CONTROL_MODE = MODE_VALVE_OPEN_LOOP; |
Lightvalve | 57:f4819de54e7a | 1499 | cnt_sysid++; |
Lightvalve | 57:f4819de54e7a | 1500 | if (freq_sysid_Iref >= 300) { |
Lightvalve | 57:f4819de54e7a | 1501 | cnt_sysid = 0; |
Lightvalve | 57:f4819de54e7a | 1502 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 57:f4819de54e7a | 1503 | } |
Lightvalve | 57:f4819de54e7a | 1504 | break; |
Lightvalve | 57:f4819de54e7a | 1505 | } |
Lightvalve | 58:2eade98630e2 | 1506 | |
Lightvalve | 58:2eade98630e2 | 1507 | |
Lightvalve | 57:f4819de54e7a | 1508 | |
Lightvalve | 57:f4819de54e7a | 1509 | default: |
Lightvalve | 57:f4819de54e7a | 1510 | break; |
Lightvalve | 57:f4819de54e7a | 1511 | } |
Lightvalve | 57:f4819de54e7a | 1512 | |
Lightvalve | 57:f4819de54e7a | 1513 | // CONTROL MODE ------------------------------------------------------------ |
Lightvalve | 57:f4819de54e7a | 1514 | |
Lightvalve | 57:f4819de54e7a | 1515 | switch (CONTROL_MODE) { |
Lightvalve | 57:f4819de54e7a | 1516 | case MODE_NO_ACT: { |
Lightvalve | 57:f4819de54e7a | 1517 | V_out = 0.0f; |
Lightvalve | 57:f4819de54e7a | 1518 | break; |
Lightvalve | 57:f4819de54e7a | 1519 | } |
Lightvalve | 57:f4819de54e7a | 1520 | |
Lightvalve | 57:f4819de54e7a | 1521 | case MODE_VALVE_POSITION_CONTROL: { |
Lightvalve | 67:c2812cf26c38 | 1522 | if (OPERATING_MODE == 5) { //SW Valve |
Lightvalve | 57:f4819de54e7a | 1523 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 59:f308b1656d9c | 1524 | V_out = Vout.ref; |
Lightvalve | 67:c2812cf26c38 | 1525 | } else if (CURRENT_CONTROL_MODE == 0) { //PWM |
Lightvalve | 67:c2812cf26c38 | 1526 | V_out = valve_pos.ref; |
Lightvalve | 67:c2812cf26c38 | 1527 | } else { |
Lightvalve | 67:c2812cf26c38 | 1528 | I_REF = valve_pos.ref * 0.001f; |
Lightvalve | 57:f4819de54e7a | 1529 | } |
Lightvalve | 58:2eade98630e2 | 1530 | |
Lightvalve | 57:f4819de54e7a | 1531 | break; |
Lightvalve | 57:f4819de54e7a | 1532 | } |
Lightvalve | 57:f4819de54e7a | 1533 | |
Lightvalve | 57:f4819de54e7a | 1534 | case MODE_JOINT_CONTROL: { |
Lightvalve | 57:f4819de54e7a | 1535 | double torq_ref = 0.0f; |
Lightvalve | 57:f4819de54e7a | 1536 | pos.err = (pos.ref - pos.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm] |
Lightvalve | 67:c2812cf26c38 | 1537 | vel.err = (0.0f - vel.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm/s] |
Lightvalve | 57:f4819de54e7a | 1538 | pos.err_sum += pos.err/(float) TMR_FREQ_5k; //[mm] |
Lightvalve | 67:c2812cf26c38 | 1539 | |
Lightvalve | 67:c2812cf26c38 | 1540 | //K & D Low Pass Filter |
Lightvalve | 67:c2812cf26c38 | 1541 | float alpha_K_D = 1.0f/(1.0f + 5000.0f/(2.0f*3.14f*30.0f)); // f_cutoff : 30Hz |
Lightvalve | 67:c2812cf26c38 | 1542 | K_LPF = K_LPF*(1.0f-alpha_K_D)+K_SPRING*(alpha_K_D); |
Lightvalve | 67:c2812cf26c38 | 1543 | D_LPF = D_LPF*(1.0f-alpha_K_D)+D_DAMPER*(alpha_K_D); |
Lightvalve | 67:c2812cf26c38 | 1544 | |
Lightvalve | 67:c2812cf26c38 | 1545 | torq_ref = torq.ref + K_LPF * pos.err - D_LPF * vel.sen / ENC_PULSE_PER_POSITION; //[N] |
Lightvalve | 57:f4819de54e7a | 1546 | |
Lightvalve | 57:f4819de54e7a | 1547 | // torque feedback |
Lightvalve | 67:c2812cf26c38 | 1548 | torq.err = torq_ref - torq.sen; //[N] |
Lightvalve | 57:f4819de54e7a | 1549 | torq.err_sum += torq.err/(float) TMR_FREQ_5k; //[N] |
Lightvalve | 57:f4819de54e7a | 1550 | |
Lightvalve | 57:f4819de54e7a | 1551 | if (((OPERATING_MODE&0b110)>>1) == 0 || ((OPERATING_MODE&0b110)>>1) == 1) { |
Lightvalve | 58:2eade98630e2 | 1552 | |
Lightvalve | 57:f4819de54e7a | 1553 | double I_REF_POS = 0.0f; |
Lightvalve | 57:f4819de54e7a | 1554 | double I_REF_FORCE_FB = 0.0f; // I_REF by Force Feedback |
Lightvalve | 57:f4819de54e7a | 1555 | double I_REF_VC = 0.0f; // I_REF for velocity compensation |
Lightvalve | 57:f4819de54e7a | 1556 | |
Lightvalve | 57:f4819de54e7a | 1557 | double temp_vel_pos = 0.0f; |
Lightvalve | 57:f4819de54e7a | 1558 | double temp_vel_torq = 0.0f; |
Lightvalve | 57:f4819de54e7a | 1559 | double wn_Pos = 2.0f * PI * 5.0f; // f_cut : 5Hz Position Control |
Lightvalve | 58:2eade98630e2 | 1560 | |
Lightvalve | 69:3995ffeaa786 | 1561 | if ((OPERATING_MODE & 0x01) == 0) { // Rotary Mode |
Lightvalve | 57:f4819de54e7a | 1562 | 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 | 1563 | // L when P-gain = 100, f_cut = 10Hz L feedforward velocity |
Lightvalve | 69:3995ffeaa786 | 1564 | } else if ((OPERATING_MODE & 0x01) == 1) { |
Lightvalve | 57:f4819de54e7a | 1565 | 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 | 1566 | // L when P-gain = 100, f_cut = 10Hz L feedforward velocity |
Lightvalve | 57:f4819de54e7a | 1567 | } |
Lightvalve | 57:f4819de54e7a | 1568 | 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 | 1569 | else I_REF_POS = temp_vel_pos * ((double) PISTON_AREA_B * 0.00006f / (K_v * sqrt(2.0f / (alpha3 + 1.0f)))); |
Lightvalve | 57:f4819de54e7a | 1570 | |
Lightvalve | 57:f4819de54e7a | 1571 | // velocity compensation for torque control |
Lightvalve | 69:3995ffeaa786 | 1572 | if ((OPERATING_MODE & 0x01) == 0) { // Rotary Mode |
Lightvalve | 57:f4819de54e7a | 1573 | I_REF_FORCE_FB = 0.001f * ((double) P_GAIN_JOINT_TORQUE * torq.err + (double) I_GAIN_JOINT_TORQUE * torq.err_sum); |
Lightvalve | 57:f4819de54e7a | 1574 | // 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 | 1575 | temp_vel_torq = (0.01f * (double) VELOCITY_COMP_GAIN * vel.ref / (double) ENC_PULSE_PER_POSITION) * PI / 180.0f; // rad/s |
Lightvalve | 57:f4819de54e7a | 1576 | // L feedforward velocity |
Lightvalve | 69:3995ffeaa786 | 1577 | } else if ((OPERATING_MODE & 0x01) == 1) { |
Lightvalve | 57:f4819de54e7a | 1578 | 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 | 1579 | // temp_vel_torq = (0.01 * (double) VELOCITY_COMP_GAIN * (double) CUR_VELOCITY / (double) ENC_PULSE_PER_POSITION); // mm/s |
Lightvalve | 57:f4819de54e7a | 1580 | temp_vel_torq = (0.01f * (double) VELOCITY_COMP_GAIN * vel.ref / (double) ENC_PULSE_PER_POSITION); // mm/s |
Lightvalve | 57:f4819de54e7a | 1581 | // L feedforward velocity |
Lightvalve | 57:f4819de54e7a | 1582 | } |
Lightvalve | 57:f4819de54e7a | 1583 | 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 | 1584 | else I_REF_VC = temp_vel_torq * ((double) PISTON_AREA_B * 0.00006f / (K_v * sqrt(2.0f / (alpha3 + 1.0f)))); |
Lightvalve | 57:f4819de54e7a | 1585 | // L velocity(rad/s or mm/s) >> I_ref(mA) |
Lightvalve | 57:f4819de54e7a | 1586 | // Ref_Joint_FT_dot = (Ref_Joint_FT_Nm - Ref_Joint_FT_Nm_old) / TMR_DT_5k; |
Lightvalve | 57:f4819de54e7a | 1587 | // Ref_Joint_FT_Nm_old = Ref_Joint_FT_Nm; |
Lightvalve | 57:f4819de54e7a | 1588 | |
Lightvalve | 57:f4819de54e7a | 1589 | I_REF = (1.0f - alpha_trans) * I_REF_POS + alpha_trans * (I_REF_VC + I_REF_FORCE_FB); |
Lightvalve | 67:c2812cf26c38 | 1590 | |
Lightvalve | 67:c2812cf26c38 | 1591 | // Anti-windup for FT |
Lightvalve | 67:c2812cf26c38 | 1592 | if (I_GAIN_JOINT_TORQUE != 0) { |
Lightvalve | 67:c2812cf26c38 | 1593 | double I_MAX = 10.0f; // Maximum Current : 10mV |
Lightvalve | 67:c2812cf26c38 | 1594 | double Ka = 2.0f / ((double) I_GAIN_JOINT_TORQUE * 0.001f); |
Lightvalve | 67:c2812cf26c38 | 1595 | if (I_REF > I_MAX) { |
Lightvalve | 67:c2812cf26c38 | 1596 | double I_rem = I_REF - I_MAX; |
Lightvalve | 67:c2812cf26c38 | 1597 | I_rem = Ka*I_rem; |
Lightvalve | 67:c2812cf26c38 | 1598 | I_REF = I_MAX; |
Lightvalve | 67:c2812cf26c38 | 1599 | torq.err_sum = torq.err_sum - I_rem /(float) TMR_FREQ_5k; |
Lightvalve | 67:c2812cf26c38 | 1600 | } else if (I_REF < -I_MAX) { |
Lightvalve | 67:c2812cf26c38 | 1601 | double I_rem = I_REF - (-I_MAX); |
Lightvalve | 67:c2812cf26c38 | 1602 | I_rem = Ka*I_rem; |
Lightvalve | 67:c2812cf26c38 | 1603 | I_REF = -I_MAX; |
Lightvalve | 67:c2812cf26c38 | 1604 | torq.err_sum = torq.err_sum - I_rem /(float) TMR_FREQ_5k; |
Lightvalve | 67:c2812cf26c38 | 1605 | } |
Lightvalve | 67:c2812cf26c38 | 1606 | } |
Lightvalve | 57:f4819de54e7a | 1607 | |
Lightvalve | 57:f4819de54e7a | 1608 | } else { |
Lightvalve | 57:f4819de54e7a | 1609 | float VALVE_POS_RAW_FORCE_FB = 0.0f; |
Lightvalve | 72:3436ce769b1e | 1610 | float VALVE_POS_RAW_FORCE_FF = 0.0f; |
Lightvalve | 72:3436ce769b1e | 1611 | float VALVE_POS_RAW = 0.0f; |
Lightvalve | 72:3436ce769b1e | 1612 | |
Lightvalve | 57:f4819de54e7a | 1613 | 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 | 1614 | + 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 | 1615 | |
Lightvalve | 72:3436ce769b1e | 1616 | 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 | 1617 | |
Lightvalve | 72:3436ce769b1e | 1618 | VALVE_POS_RAW = VALVE_POS_RAW_FORCE_FB + VALVE_POS_RAW_FORCE_FF; |
Lightvalve | 72:3436ce769b1e | 1619 | |
Lightvalve | 72:3436ce769b1e | 1620 | |
Lightvalve | 72:3436ce769b1e | 1621 | if (VALVE_POS_RAW >= 0) { |
Lightvalve | 72:3436ce769b1e | 1622 | valve_pos.ref = VALVE_POS_RAW + VALVE_DEADZONE_PLUS; |
Lightvalve | 57:f4819de54e7a | 1623 | } else { |
Lightvalve | 72:3436ce769b1e | 1624 | valve_pos.ref = VALVE_POS_RAW + VALVE_DEADZONE_MINUS; |
Lightvalve | 57:f4819de54e7a | 1625 | } |
Lightvalve | 57:f4819de54e7a | 1626 | |
Lightvalve | 57:f4819de54e7a | 1627 | if(I_GAIN_JOINT_TORQUE != 0) { |
Lightvalve | 57:f4819de54e7a | 1628 | double Ka = 1.0f / (double) I_GAIN_JOINT_TORQUE * 100.0f; |
Lightvalve | 57:f4819de54e7a | 1629 | if(valve_pos.ref>VALVE_MAX_POS) { |
Lightvalve | 57:f4819de54e7a | 1630 | double valve_pos_rem = valve_pos.ref - VALVE_MAX_POS; |
Lightvalve | 57:f4819de54e7a | 1631 | valve_pos_rem = valve_pos_rem * Ka; |
Lightvalve | 57:f4819de54e7a | 1632 | valve_pos.ref = VALVE_MAX_POS; |
Lightvalve | 57:f4819de54e7a | 1633 | torq.err_sum = torq.err_sum - valve_pos_rem/(float) TMR_FREQ_5k; |
Lightvalve | 57:f4819de54e7a | 1634 | } else if(valve_pos.ref < VALVE_MIN_POS) { |
Lightvalve | 57:f4819de54e7a | 1635 | double valve_pos_rem = valve_pos.ref - VALVE_MIN_POS; |
Lightvalve | 57:f4819de54e7a | 1636 | valve_pos_rem = valve_pos_rem * Ka; |
Lightvalve | 57:f4819de54e7a | 1637 | valve_pos.ref = VALVE_MIN_POS; |
Lightvalve | 57:f4819de54e7a | 1638 | torq.err_sum = torq.err_sum - valve_pos_rem/(float) TMR_FREQ_5k; |
Lightvalve | 57:f4819de54e7a | 1639 | } |
Lightvalve | 57:f4819de54e7a | 1640 | } |
Lightvalve | 61:bc8c8270f0ab | 1641 | |
Lightvalve | 57:f4819de54e7a | 1642 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 61:bc8c8270f0ab | 1643 | |
Lightvalve | 67:c2812cf26c38 | 1644 | // Vout.ref = (float) P_GAIN_JOINT_POSITION * 0.01f * ((float) pos.err); |
Lightvalve | 60:64181f1d3e60 | 1645 | V_out = (float) Vout.ref; |
Lightvalve | 57:f4819de54e7a | 1646 | |
Lightvalve | 57:f4819de54e7a | 1647 | } |
Lightvalve | 72:3436ce769b1e | 1648 | |
Lightvalve | 72:3436ce769b1e | 1649 | torq_ref_past = torq_ref; |
Lightvalve | 58:2eade98630e2 | 1650 | |
Lightvalve | 57:f4819de54e7a | 1651 | break; |
Lightvalve | 57:f4819de54e7a | 1652 | } |
Lightvalve | 58:2eade98630e2 | 1653 | |
Lightvalve | 57:f4819de54e7a | 1654 | case MODE_VALVE_OPEN_LOOP: { |
Lightvalve | 57:f4819de54e7a | 1655 | V_out = (float) Vout.ref; |
Lightvalve | 57:f4819de54e7a | 1656 | break; |
Lightvalve | 57:f4819de54e7a | 1657 | } |
Lightvalve | 14:8e7590227d22 | 1658 | |
Lightvalve | 12:6f2531038ea4 | 1659 | default: |
Lightvalve | 12:6f2531038ea4 | 1660 | break; |
Lightvalve | 12:6f2531038ea4 | 1661 | } |
Lightvalve | 14:8e7590227d22 | 1662 | |
Lightvalve | 57:f4819de54e7a | 1663 | |
Lightvalve | 57:f4819de54e7a | 1664 | if (((OPERATING_MODE&0b110)>>1) == 0 || ((OPERATING_MODE&0b110)>>1) == 1) { //Moog Valve or KNR Valve |
Lightvalve | 58:2eade98630e2 | 1665 | |
Lightvalve | 57:f4819de54e7a | 1666 | //////////////////////////////////////////////////////////////////////////// |
Lightvalve | 57:f4819de54e7a | 1667 | //////////////////////////// CURRENT CONTROL ////////////////////////////// |
Lightvalve | 57:f4819de54e7a | 1668 | //////////////////////////////////////////////////////////////////////////// |
Lightvalve | 57:f4819de54e7a | 1669 | if (CURRENT_CONTROL_MODE) { |
Lightvalve | 67:c2812cf26c38 | 1670 | double alpha_update_Iref = 1.0f / (1.0f + 5000.0f / (2.0f * 3.14f * 300.0f)); // f_cutoff : 500Hz |
Lightvalve | 57:f4819de54e7a | 1671 | I_REF_fil = (1.0f - alpha_update_Iref) * I_REF_fil + alpha_update_Iref*I_REF; |
Lightvalve | 57:f4819de54e7a | 1672 | |
Lightvalve | 57:f4819de54e7a | 1673 | I_ERR = I_REF_fil - cur.sen; |
Lightvalve | 67:c2812cf26c38 | 1674 | I_ERR_INT = I_ERR_INT + (I_ERR) * 0.0002f; |
Lightvalve | 57:f4819de54e7a | 1675 | |
Lightvalve | 57:f4819de54e7a | 1676 | |
Lightvalve | 57:f4819de54e7a | 1677 | // Moog Valve Current Control Gain |
Lightvalve | 67:c2812cf26c38 | 1678 | double R_model = 500.0f; // ohm |
Lightvalve | 57:f4819de54e7a | 1679 | double L_model = 1.2f; |
Lightvalve | 57:f4819de54e7a | 1680 | double w0 = 2.0f * 3.14f * 150.0f; |
Lightvalve | 57:f4819de54e7a | 1681 | double KP_I = 0.1f * L_model*w0; |
Lightvalve | 57:f4819de54e7a | 1682 | double KI_I = 0.1f * R_model*w0; |
Lightvalve | 57:f4819de54e7a | 1683 | |
Lightvalve | 57:f4819de54e7a | 1684 | // KNR Valve Current Control Gain |
Lightvalve | 57:f4819de54e7a | 1685 | if (((OPERATING_MODE & 0b110)>>1) == 1) { // KNR Valve |
Lightvalve | 57:f4819de54e7a | 1686 | R_model = 163.0f; // ohm |
Lightvalve | 57:f4819de54e7a | 1687 | L_model = 1.0f; |
Lightvalve | 57:f4819de54e7a | 1688 | w0 = 2.0f * 3.14f * 80.0f; |
Lightvalve | 57:f4819de54e7a | 1689 | KP_I = 1.0f * L_model*w0; |
Lightvalve | 57:f4819de54e7a | 1690 | KI_I = 0.08f * R_model*w0; |
Lightvalve | 57:f4819de54e7a | 1691 | } |
Lightvalve | 57:f4819de54e7a | 1692 | |
Lightvalve | 57:f4819de54e7a | 1693 | double FF_gain = 1.0f; |
Lightvalve | 57:f4819de54e7a | 1694 | |
Lightvalve | 67:c2812cf26c38 | 1695 | VALVE_PWM_RAW = KP_I * 2.0f * I_ERR + KI_I * 2.0f* I_ERR_INT; |
Lightvalve | 57:f4819de54e7a | 1696 | // VALVE_PWM_RAW = VALVE_PWM_RAW + FF_gain * (R_model*I_REF); // Unit : mV |
Lightvalve | 57:f4819de54e7a | 1697 | I_REF_fil_diff = I_REF_fil - I_REF_fil_old; |
Lightvalve | 57:f4819de54e7a | 1698 | I_REF_fil_old = I_REF_fil; |
Lightvalve | 67:c2812cf26c38 | 1699 | // 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 | 1700 | VALVE_PWM_RAW = VALVE_PWM_RAW + FF_gain * (R_model * I_REF_fil); // Unit : mV |
Lightvalve | 67:c2812cf26c38 | 1701 | double V_MAX = 12000.0f; // Maximum Voltage : 12V = 12000mV |
Lightvalve | 57:f4819de54e7a | 1702 | |
Lightvalve | 57:f4819de54e7a | 1703 | double Ka = 3.0f / KP_I; |
Lightvalve | 57:f4819de54e7a | 1704 | if (VALVE_PWM_RAW > V_MAX) { |
Lightvalve | 57:f4819de54e7a | 1705 | V_rem = VALVE_PWM_RAW - V_MAX; |
Lightvalve | 57:f4819de54e7a | 1706 | V_rem = Ka*V_rem; |
Lightvalve | 57:f4819de54e7a | 1707 | VALVE_PWM_RAW = V_MAX; |
Lightvalve | 67:c2812cf26c38 | 1708 | I_ERR_INT = I_ERR_INT - V_rem * 0.0002f; |
Lightvalve | 57:f4819de54e7a | 1709 | } else if (VALVE_PWM_RAW < -V_MAX) { |
Lightvalve | 57:f4819de54e7a | 1710 | V_rem = VALVE_PWM_RAW - (-V_MAX); |
Lightvalve | 57:f4819de54e7a | 1711 | V_rem = Ka*V_rem; |
Lightvalve | 57:f4819de54e7a | 1712 | VALVE_PWM_RAW = -V_MAX; |
Lightvalve | 67:c2812cf26c38 | 1713 | I_ERR_INT = I_ERR_INT - V_rem * 0.0002f; |
Lightvalve | 57:f4819de54e7a | 1714 | } |
Lightvalve | 57:f4819de54e7a | 1715 | Cur_Valve_Open_pulse = cur.sen / mA_PER_pulse; |
Lightvalve | 57:f4819de54e7a | 1716 | } else { |
Lightvalve | 57:f4819de54e7a | 1717 | VALVE_PWM_RAW = I_REF * mV_PER_mA; |
Lightvalve | 57:f4819de54e7a | 1718 | Cur_Valve_Open_pulse = I_REF / mA_PER_pulse; |
Lightvalve | 57:f4819de54e7a | 1719 | } |
Lightvalve | 57:f4819de54e7a | 1720 | |
Lightvalve | 57:f4819de54e7a | 1721 | //////////////////////////////////////////////////////////////////////////// |
Lightvalve | 57:f4819de54e7a | 1722 | ///////////////// Dead Zone Cancellation & Linearization ////////////////// |
Lightvalve | 57:f4819de54e7a | 1723 | //////////////////////////////////////////////////////////////////////////// |
Lightvalve | 57:f4819de54e7a | 1724 | // Dead Zone Cancellation (Mechanical Valve dead-zone) |
Lightvalve | 57:f4819de54e7a | 1725 | if (FLAG_VALVE_DEADZONE) { |
Lightvalve | 57:f4819de54e7a | 1726 | if (VALVE_PWM_RAW > 0) VALVE_PWM_RAW = VALVE_PWM_RAW + VALVE_DEADZONE_PLUS * mV_PER_pulse; // unit: mV |
Lightvalve | 57:f4819de54e7a | 1727 | else if (VALVE_PWM_RAW < 0) VALVE_PWM_RAW = VALVE_PWM_RAW + VALVE_DEADZONE_MINUS * mV_PER_pulse; // unit: mV |
Lightvalve | 57:f4819de54e7a | 1728 | |
Lightvalve | 57:f4819de54e7a | 1729 | VALVE_PWM_VALVE_DZ = VALVE_PWM_RAW + (double)VALVE_CENTER * mV_PER_pulse; // unit: mV |
Lightvalve | 57:f4819de54e7a | 1730 | |
Lightvalve | 57:f4819de54e7a | 1731 | } else { |
Lightvalve | 57:f4819de54e7a | 1732 | VALVE_PWM_VALVE_DZ = VALVE_PWM_RAW; |
Lightvalve | 57:f4819de54e7a | 1733 | } |
Lightvalve | 57:f4819de54e7a | 1734 | |
Lightvalve | 57:f4819de54e7a | 1735 | // Output Voltage Linearization |
Lightvalve | 57:f4819de54e7a | 1736 | double CUR_PWM_nonlin = VALVE_PWM_VALVE_DZ; // Unit : mV |
Lightvalve | 67:c2812cf26c38 | 1737 | double CUR_PWM_lin = PWM_duty_byLT(CUR_PWM_nonlin); // -8000~8000 |
Lightvalve | 57:f4819de54e7a | 1738 | |
Lightvalve | 57:f4819de54e7a | 1739 | // Dead Zone Cancellation (Electrical dead-zone) |
Lightvalve | 67:c2812cf26c38 | 1740 | if (CUR_PWM_lin > 0) V_out = (float) (CUR_PWM_lin + 169.0f); |
Lightvalve | 67:c2812cf26c38 | 1741 | else if (CUR_PWM_lin < 0) V_out = (float) (CUR_PWM_lin - 174.0f); |
Lightvalve | 67:c2812cf26c38 | 1742 | else V_out = (float) (CUR_PWM_lin); |
Lightvalve | 57:f4819de54e7a | 1743 | } |
Lightvalve | 67:c2812cf26c38 | 1744 | |
Lightvalve | 67:c2812cf26c38 | 1745 | // if(V_out > 0.0f) V_out = (float) (V_out + 169.0f); |
Lightvalve | 67:c2812cf26c38 | 1746 | // else if(V_out < 0.0f) V_out = (float) (V_out - 174.0f); |
Lightvalve | 67:c2812cf26c38 | 1747 | // else V_out = V_out; |
Lightvalve | 67:c2812cf26c38 | 1748 | |
jobuuu | 7:e9086c72bb22 | 1749 | /******************************************************* |
jobuuu | 7:e9086c72bb22 | 1750 | *** PWM |
jobuuu | 7:e9086c72bb22 | 1751 | ********************************************************/ |
Lightvalve | 67:c2812cf26c38 | 1752 | if(DIR_VALVE<0){ |
Lightvalve | 67:c2812cf26c38 | 1753 | V_out = -V_out; |
Lightvalve | 67:c2812cf26c38 | 1754 | } |
Lightvalve | 67:c2812cf26c38 | 1755 | |
Lightvalve | 49:e7bcfc244d40 | 1756 | if (V_out >= VALVE_VOLTAGE_LIMIT*1000.0f) { |
Lightvalve | 49:e7bcfc244d40 | 1757 | V_out = VALVE_VOLTAGE_LIMIT*1000.0f; |
Lightvalve | 49:e7bcfc244d40 | 1758 | } else if(V_out<=-VALVE_VOLTAGE_LIMIT*1000.0f) { |
Lightvalve | 49:e7bcfc244d40 | 1759 | V_out = -VALVE_VOLTAGE_LIMIT*1000.0f; |
Lightvalve | 27:a2254a485f23 | 1760 | } |
Lightvalve | 49:e7bcfc244d40 | 1761 | PWM_out= V_out/(SUPPLY_VOLTAGE*1000.0f); // Full duty : 12000.0mV |
Lightvalve | 13:747daba9cf59 | 1762 | |
Lightvalve | 19:23b7c1ad8683 | 1763 | // Saturation of output voltage to 12.0V |
Lightvalve | 30:8d561f16383b | 1764 | if(PWM_out > 1.0f) PWM_out=1.0f; |
Lightvalve | 30:8d561f16383b | 1765 | else if (PWM_out < -1.0f) PWM_out=-1.0f; |
Lightvalve | 13:747daba9cf59 | 1766 | |
Lightvalve | 30:8d561f16383b | 1767 | if (PWM_out>0.0f) { |
Lightvalve | 30:8d561f16383b | 1768 | dtc_v=0.0f; |
jobuuu | 1:e04e563be5ce | 1769 | dtc_w=PWM_out; |
jobuuu | 1:e04e563be5ce | 1770 | } else { |
jobuuu | 2:a1c0a37df760 | 1771 | dtc_v=-PWM_out; |
Lightvalve | 30:8d561f16383b | 1772 | dtc_w=0.0f; |
jobuuu | 1:e04e563be5ce | 1773 | } |
Lightvalve | 13:747daba9cf59 | 1774 | |
jobuuu | 1:e04e563be5ce | 1775 | //pwm |
Lightvalve | 30:8d561f16383b | 1776 | TIM4->CCR2 = (PWM_ARR)*(1.0f-dtc_v); |
Lightvalve | 30:8d561f16383b | 1777 | TIM4->CCR1 = (PWM_ARR)*(1.0f-dtc_w); |
Lightvalve | 67:c2812cf26c38 | 1778 | |
Lightvalve | 61:bc8c8270f0ab | 1779 | |
Lightvalve | 57:f4819de54e7a | 1780 | if (TMR2_COUNT_CAN_TX % (int) ((int) TMR_FREQ_5k/CAN_FREQ) == 0) { |
Lightvalve | 20:806196fda269 | 1781 | |
Lightvalve | 54:647072f5307a | 1782 | // Position, Velocity, and Torque (ID:1200) |
Lightvalve | 56:6f50d9d3bfee | 1783 | if (flag_data_request[0] == HIGH) { |
Lightvalve | 57:f4819de54e7a | 1784 | if ((OPERATING_MODE & 0b01) == 0) { // Rotary Actuator |
Lightvalve | 54:647072f5307a | 1785 | if (SENSING_MODE == 0) { |
Lightvalve | 67:c2812cf26c38 | 1786 | CAN_TX_POSITION_FT((int16_t) (pos.sen), (int16_t) (vel.sen/10.0f), (int16_t) (torq.sen*10.0f)); |
Lightvalve | 54:647072f5307a | 1787 | } else if (SENSING_MODE == 1) { |
Lightvalve | 58:2eade98630e2 | 1788 | 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 | 1789 | } |
Lightvalve | 57:f4819de54e7a | 1790 | } else if ((OPERATING_MODE & 0b01) == 1) { // Linear Actuator |
Lightvalve | 54:647072f5307a | 1791 | if (SENSING_MODE == 0) { |
Lightvalve | 67:c2812cf26c38 | 1792 | 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 | 1793 | } else if (SENSING_MODE == 1) { |
Lightvalve | 67:c2812cf26c38 | 1794 | 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 | 1795 | } |
Lightvalve | 52:8ea76864368a | 1796 | } |
Lightvalve | 52:8ea76864368a | 1797 | } |
Lightvalve | 56:6f50d9d3bfee | 1798 | if (flag_data_request[1] == HIGH) { |
Lightvalve | 54:647072f5307a | 1799 | //valve position |
Lightvalve | 54:647072f5307a | 1800 | double t_value = 0; |
Lightvalve | 67:c2812cf26c38 | 1801 | if(valve_pos.ref>=(float) VALVE_CENTER) { |
Lightvalve | 67:c2812cf26c38 | 1802 | t_value = 10000.0f*((double)valve_pos.ref - (double)VALVE_CENTER)/((double)VALVE_MAX_POS - (double)VALVE_CENTER); |
Lightvalve | 67:c2812cf26c38 | 1803 | } else { |
Lightvalve | 67:c2812cf26c38 | 1804 | t_value = -10000.0f*((double)valve_pos.ref - (double)VALVE_CENTER)/((double)VALVE_MIN_POS - (double)VALVE_CENTER); |
Lightvalve | 67:c2812cf26c38 | 1805 | } |
Lightvalve | 67:c2812cf26c38 | 1806 | // if(OPERATING_MODE==5) { |
Lightvalve | 67:c2812cf26c38 | 1807 | // t_value = (double) value; |
Lightvalve | 67:c2812cf26c38 | 1808 | // } else if(CURRENT_CONTROL_MODE==1) { |
Lightvalve | 67:c2812cf26c38 | 1809 | // t_value = cur.sen; |
Lightvalve | 57:f4819de54e7a | 1810 | // } else { |
Lightvalve | 67:c2812cf26c38 | 1811 | // t_value = V_out; |
Lightvalve | 67:c2812cf26c38 | 1812 | // } |
Lightvalve | 67:c2812cf26c38 | 1813 | CAN_TX_TORQUE((int16_t) (t_value)); //1300 |
Lightvalve | 67:c2812cf26c38 | 1814 | //CAN_TX_TORQUE((int16_t) (cur.sen * 1000.0f)); //1300 |
Lightvalve | 67:c2812cf26c38 | 1815 | //CAN_TX_TORQUE((int16_t) (I_REF * 1000.0f)); //1300 |
Lightvalve | 54:647072f5307a | 1816 | } |
Lightvalve | 58:2eade98630e2 | 1817 | |
Lightvalve | 58:2eade98630e2 | 1818 | |
Lightvalve | 56:6f50d9d3bfee | 1819 | if (flag_data_request[2] == HIGH) { |
Lightvalve | 56:6f50d9d3bfee | 1820 | //pressure A and B |
Lightvalve | 57:f4819de54e7a | 1821 | CAN_TX_PRES((int16_t) (pres_A.sen), (int16_t) (pres_B.sen)); // CUR_PRES_X : 0(0bar)~4096(210bar) //1400 |
Lightvalve | 55:b25725257569 | 1822 | } |
Lightvalve | 58:2eade98630e2 | 1823 | |
Lightvalve | 57:f4819de54e7a | 1824 | //If it doesn't rest, below can can not work. |
Lightvalve | 57:f4819de54e7a | 1825 | for (can_rest = 0; can_rest < 10000; can_rest++) { |
Lightvalve | 57:f4819de54e7a | 1826 | ; |
Lightvalve | 57:f4819de54e7a | 1827 | } |
Lightvalve | 58:2eade98630e2 | 1828 | |
Lightvalve | 56:6f50d9d3bfee | 1829 | if (flag_data_request[3] == HIGH) { |
Lightvalve | 54:647072f5307a | 1830 | //PWM |
Lightvalve | 73:f80dc3970c99 | 1831 | //CAN_TX_PWM((int16_t) value); //1500 |
Lightvalve | 73:f80dc3970c99 | 1832 | CAN_TX_PWM((int16_t) input_NN[0] * 100.0f); //1500 |
Lightvalve | 54:647072f5307a | 1833 | } |
Lightvalve | 57:f4819de54e7a | 1834 | //for (i = 0; i < 10000; i++) { |
Lightvalve | 57:f4819de54e7a | 1835 | // ; |
Lightvalve | 57:f4819de54e7a | 1836 | // } |
Lightvalve | 56:6f50d9d3bfee | 1837 | if (flag_data_request[4] == HIGH) { |
Lightvalve | 54:647072f5307a | 1838 | //valve position |
Lightvalve | 73:f80dc3970c99 | 1839 | 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 | 1840 | } |
Lightvalve | 20:806196fda269 | 1841 | |
Lightvalve | 54:647072f5307a | 1842 | // Others : Reference position, Reference FT, PWM, Current (ID:1300) |
Lightvalve | 52:8ea76864368a | 1843 | // if (flag_data_request[1] == HIGH) { |
Lightvalve | 52:8ea76864368a | 1844 | // CAN_TX_SOMETHING((int) (FORCE_VREF), (int16_t) (1), (int16_t) (2), (int16_t) (3)); |
Lightvalve | 52:8ea76864368a | 1845 | // } |
Lightvalve | 54:647072f5307a | 1846 | //if (flag_delay_test == 1){ |
Lightvalve | 58:2eade98630e2 | 1847 | //CAN_TX_PRES((int16_t) (0),(int16_t) torq_ref); |
Lightvalve | 54:647072f5307a | 1848 | //} |
Lightvalve | 52:8ea76864368a | 1849 | |
Lightvalve | 54:647072f5307a | 1850 | TMR2_COUNT_CAN_TX = 0; |
Lightvalve | 54:647072f5307a | 1851 | } |
Lightvalve | 54:647072f5307a | 1852 | TMR2_COUNT_CAN_TX++; |
Lightvalve | 52:8ea76864368a | 1853 | |
Lightvalve | 20:806196fda269 | 1854 | } |
Lightvalve | 52:8ea76864368a | 1855 | TIM3->SR = 0x0; // reset the status register |
Lightvalve | 52:8ea76864368a | 1856 | |
Lightvalve | 58:2eade98630e2 | 1857 | } |