Sungwoo Kim
/
HydraulicControlBoard_PostLIGHT_210420
LIGHT2
main.cpp@85:a3b46118b5cd, 2020-07-12 (annotated)
- Committer:
- Lightvalve
- Date:
- Sun Jul 12 06:25:51 2020 +0000
- Revision:
- 85:a3b46118b5cd
- Parent:
- 84:c355d3e52bf1
- Child:
- 86:b8ed7abddeb2
200712-1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Lightvalve | 85:a3b46118b5cd | 1 | //200712-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 | 85:a3b46118b5cd | 189 | float x_future[num_array_x_future] = {0.0f}; |
Lightvalve | 68:328e1be06f5d | 190 | float f_past[num_array_f_past] = {0.0f}; |
Lightvalve | 68:328e1be06f5d | 191 | float f_future[num_array_f_future] = {0.0f}; |
Lightvalve | 66:a8e6799dbce3 | 192 | |
Lightvalve | 73:f80dc3970c99 | 193 | float input_NN[num_input] = { 0.0f }; |
Lightvalve | 65:a2d7c63419c2 | 194 | |
Lightvalve | 66:a8e6799dbce3 | 195 | const float h1[num_input][32] = { |
Lightvalve | 85:a3b46118b5cd | 196 | {-2.606285810470581f,0.059674035757780075f,0.09650412201881409f,-0.16771353781223297f,0.35774460434913635f,-0.17859646677970886f,-0.14054878056049347f,-0.03556078299880028f,1.742306113243103f,-0.2271585762500763f,-0.16813033819198608f,-1.809462070465088f,-0.17605189979076385f,0.8709392547607422f,-0.19232401251792908f,-0.8437867760658264f,1.763037919998169f,0.22724241018295288f,-0.3323306441307068f,2.6034350395202637f,-0.30507606267929077f,0.09747585654258728f,-0.3031907379627228f,-0.0722002387046814f,-0.38343721628189087f,0.1674489974975586f,-0.16104386746883392f,-2.0170392990112305f,0.5571560263633728f,-0.17127496004104614f,-1.3317700624465942f,0.046951837837696075f}, |
Lightvalve | 85:a3b46118b5cd | 197 | {-2.0537681579589844f,0.12198971956968307f,0.2721617817878723f,-0.6057005524635315f,0.3086271286010742f,-0.1713162511587143f,0.20504719018936157f,0.0018860780401155353f,1.2464624643325806f,0.02156742475926876f,-0.2509200870990753f,-1.2319421768188477f,0.019331663846969604f,0.7041570544242859f,0.04180806875228882f,-0.6982311606407166f,1.6102606058120728f,0.057370126247406006f,0.2586321234703064f,2.2700934410095215f,-0.028223484754562378f,-0.1100652664899826f,-0.0866384208202362f,0.25256627798080444f,-0.5788185000419617f,0.26763588190078735f,0.11561140418052673f,-1.0474236011505127f,0.15555915236473083f,0.08939173817634583f,-1.2039589881896973f,0.06393972784280777f}, |
Lightvalve | 85:a3b46118b5cd | 198 | {-1.2255301475524902f,0.07634484767913818f,-0.0038479268550872803f,-0.08924344182014465f,0.2990475296974182f,-0.26944491267204285f,0.08716651052236557f,-0.0785437747836113f,1.0324466228485107f,0.020098716020584106f,0.2694155275821686f,-0.7900299429893494f,-0.029918134212493896f,0.6244687438011169f,-0.28905919194221497f,-0.6178285479545593f,1.9580823183059692f,-0.2422618269920349f,0.1242297887802124f,1.9476813077926636f,0.20194900035858154f,-0.1395411342382431f,0.12350606918334961f,-0.2247280478477478f,-0.6263898015022278f,0.13248568773269653f,-0.14138396084308624f,-0.690809428691864f,0.0029704421758651733f,0.27591514587402344f,-1.1270263195037842f,-0.20405474305152893f}, |
Lightvalve | 85:a3b46118b5cd | 199 | {-1.57460618019104f,-0.1511542946100235f,-0.18711818754673004f,-0.6064276099205017f,0.13043983280658722f,-0.1427042931318283f,0.03553284704685211f,-0.31533196568489075f,1.4818233251571655f,-0.01312423124909401f,0.12149564921855927f,-0.7878521084785461f,-0.10761845111846924f,0.6611183881759644f,-0.11680684983730316f,-0.46171122789382935f,1.406282901763916f,-0.21650204062461853f,-0.2377132773399353f,1.8837519884109497f,-0.22730450332164764f,-0.08014044165611267f,-0.13406386971473694f,-0.26563718914985657f,-0.14237552881240845f,0.12903746962547302f,0.12193542718887329f,-1.2571884393692017f,0.44940391182899475f,0.12058231234550476f,-0.7141066193580627f,0.13588182628154755f}, |
Lightvalve | 85:a3b46118b5cd | 200 | {-1.9089444875717163f,0.11516723781824112f,0.07664334774017334f,-0.5144784450531006f,0.37083154916763306f,-0.2133917361497879f,-0.06349990516901016f,-0.3730049431324005f,1.3145959377288818f,0.19743141531944275f,-0.21378687024116516f,-1.2395061254501343f,0.19268107414245605f,0.4547744691371918f,-0.22851628065109253f,-0.26560476422309875f,1.0595104694366455f,-0.16801688075065613f,0.09942813962697983f,1.8475277423858643f,0.1253645122051239f,0.2149595022201538f,-0.2236560881137848f,-0.06796601414680481f,0.4368893802165985f,-0.31218889355659485f,0.036975473165512085f,-2.0773279666900635f,0.41609761118888855f,-0.1487281620502472f,-0.4677320718765259f,-0.0013993316097185016f}, |
Lightvalve | 85:a3b46118b5cd | 201 | {-1.1187310218811035f,-0.03296545147895813f,0.27807939052581787f,0.037997107952833176f,0.2848196029663086f,-0.24626736342906952f,-0.16129355132579803f,-0.0512847937643528f,0.6225370168685913f,0.022184599190950394f,0.2690766155719757f,-1.4052207469940186f,-0.02865380048751831f,0.16751302778720856f,0.19959628582000732f,-0.4913268983364105f,0.8711474537849426f,-0.2912288010120392f,-0.340214341878891f,1.3274726867675781f,0.12322095036506653f,-0.008817970752716064f,0.1147087812423706f,0.3015863299369812f,0.17111442983150482f,0.18968838453292847f,-0.2666270434856415f,-1.0979872941970825f,0.13614840805530548f,-0.0011968016624450684f,-0.5869313478469849f,-0.07687170803546906f}, |
Lightvalve | 85:a3b46118b5cd | 202 | {-0.21734002232551575f,-0.26061415672302246f,0.14843863248825073f,0.04624738171696663f,0.10405876487493515f,-0.12059111893177032f,-0.18885411322116852f,0.06436038017272949f,-0.31536397337913513f,-0.0630384311079979f,-0.07302352786064148f,-0.6148138642311096f,0.08986115455627441f,0.04687202349305153f,-0.1665383130311966f,-0.26419785618782043f,1.2558611631393433f,-0.07442285120487213f,0.27002108097076416f,0.13596417009830475f,-0.1478499323129654f,-0.1614212840795517f,-0.23933082818984985f,-0.223466694355011f,-0.43228527903556824f,-0.14157472550868988f,-0.10264839231967926f,-0.21441195905208588f,-0.3483427166938782f,-0.031773269176483154f,-0.525026798248291f,0.08187884092330933f}, |
Lightvalve | 85:a3b46118b5cd | 203 | {0.6996273398399353f,-0.12204266339540482f,0.15168696641921997f,0.04846210032701492f,-0.0915396437048912f,-0.33597511053085327f,0.022557925432920456f,0.1338680386543274f,-0.5659708380699158f,0.1707867532968521f,-0.2003910094499588f,-0.43440377712249756f,0.0984853208065033f,-0.12081801891326904f,0.0499650239944458f,0.3431171774864197f,1.4376808404922485f,-0.26081758737564087f,-0.34114938974380493f,-0.6444607973098755f,-0.06771403551101685f,0.020663440227508545f,-0.11643148958683014f,-0.025921106338500977f,-0.4191009998321533f,0.01617935299873352f,-0.3111790418624878f,0.5159480571746826f,-0.39768901467323303f,0.003934144973754883f,-0.5454002022743225f,0.21211828291416168f}, |
Lightvalve | 85:a3b46118b5cd | 204 | {0.852343738079071f,-0.23038165271282196f,0.12494269013404846f,0.10629913210868835f,-0.4543680250644684f,-0.378856360912323f,-0.03972348943352699f,-0.06537827104330063f,-1.0841889381408691f,0.16502787172794342f,-0.25580206513404846f,0.23635244369506836f,0.10479596257209778f,0.08205756545066833f,0.22008126974105835f,0.3622739911079407f,1.3246990442276f,0.05487769842147827f,0.11769430339336395f,-1.1328505277633667f,-0.2761211693286896f,-0.020349353551864624f,-0.27003389596939087f,0.07697224617004395f,-0.8492781519889832f,-0.07489721477031708f,-0.08116541802883148f,1.0350816249847412f,-0.02137860469520092f,-0.1086675226688385f,-0.6284488439559937f,0.06365922093391418f}, |
Lightvalve | 85:a3b46118b5cd | 205 | {0.8225578665733337f,0.012310948222875595f,-0.22278577089309692f,0.2668815851211548f,-0.2661985754966736f,-0.23692767322063446f,0.19639447331428528f,-0.3118877708911896f,-1.4684014320373535f,0.12021926045417786f,-0.3089894652366638f,0.21858231723308563f,0.07655277848243713f,-0.10884463042020798f,-0.2440950870513916f,0.009248172864317894f,1.5609081983566284f,0.3025500178337097f,0.07529143244028091f,-1.4489120244979858f,-0.1831793338060379f,0.14930570125579834f,-0.10644422471523285f,-0.29311618208885193f,-0.642412543296814f,0.05133715271949768f,0.12382996082305908f,1.2269887924194336f,-0.09648581594228745f,0.2767742872238159f,-0.2516782581806183f,0.14402815699577332f}, |
Lightvalve | 85:a3b46118b5cd | 206 | {1.0476603507995605f,-0.28225624561309814f,-0.060682862997055054f,0.2517375349998474f,-0.7828313708305359f,-0.29988330602645874f,0.10732702165842056f,-0.05892409756779671f,-1.5249955654144287f,-0.13980087637901306f,-0.2986769378185272f,-0.19855903089046478f,-0.1630868911743164f,-0.03027329221367836f,0.01561826467514038f,0.5916606187820435f,0.9730422496795654f,-0.2222851812839508f,0.17245279252529144f,-1.7458704710006714f,0.15468448400497437f,-0.2309320867061615f,0.21849101781845093f,0.010328710079193115f,-0.556439220905304f,0.09358248114585876f,0.07340890169143677f,0.8089216947555542f,-0.14890289306640625f,0.02698659896850586f,-0.2565232217311859f,0.13985052704811096f}, |
Lightvalve | 85:a3b46118b5cd | 207 | {1.429358959197998f,0.14012667536735535f,-0.28074589371681213f,-0.00331100239418447f,-0.8435359597206116f,-0.49092042446136475f,-0.10904670506715775f,-0.07100982218980789f,-1.4690783023834229f,0.34399181604385376f,0.282975435256958f,-0.043425723910331726f,-0.03424224257469177f,-0.48426684737205505f,-0.2727475166320801f,0.6252321600914001f,1.0018049478530884f,-0.16595804691314697f,-0.2935643494129181f,-1.8126251697540283f,0.2643057703971863f,0.2074018120765686f,-0.21301458775997162f,0.29898685216903687f,-0.7996794581413269f,0.192124605178833f,0.308285653591156f,1.213356852531433f,-0.0945635586977005f,0.1348828673362732f,-0.07833566516637802f,-0.07091513276100159f}, |
Lightvalve | 85:a3b46118b5cd | 208 | {1.3329243659973145f,-0.4135081470012665f,0.17577719688415527f,0.2295958399772644f,-0.3790275454521179f,-0.18207433819770813f,-0.22016242146492004f,0.10680419206619263f,-1.2859280109405518f,0.3271210789680481f,-0.11820977926254272f,0.1946081817150116f,-0.24789996445178986f,-0.7205119729042053f,0.05913722515106201f,0.31610456109046936f,0.4705457389354706f,0.1988731026649475f,-0.03146616369485855f,-1.8467857837677002f,-0.22939208149909973f,0.02479115128517151f,0.011343330144882202f,-0.002705395221710205f,-0.13276472687721252f,0.02754300832748413f,0.3120383620262146f,1.0483598709106445f,-0.3036125898361206f,-0.31464317440986633f,-0.433398962020874f,0.06549221277236938f}, |
Lightvalve | 85:a3b46118b5cd | 209 | {0.8713327646255493f,-0.0774955302476883f,0.057266801595687866f,0.19841492176055908f,-0.34292829036712646f,-0.11250768601894379f,0.2264646738767624f,-0.10537882149219513f,-1.1634140014648438f,0.26441001892089844f,0.28365254402160645f,-0.2835421562194824f,0.03056994080543518f,-0.41713228821754456f,0.09772798418998718f,0.3050430715084076f,0.3216426968574524f,0.08084630966186523f,-0.11706972122192383f,-1.3646152019500732f,-0.20303234457969666f,-0.01396968960762024f,0.10836946964263916f,-0.30204448103904724f,-0.0337844081223011f,-0.13537266850471497f,0.23587000370025635f,0.6967245936393738f,-0.14066362380981445f,0.2203761339187622f,-0.36501774191856384f,0.19664137065410614f}, |
Lightvalve | 85:a3b46118b5cd | 210 | {0.8321783542633057f,-0.15298187732696533f,0.23348617553710938f,0.06929957121610641f,-0.3915230333805084f,-0.020342102274298668f,0.11905863881111145f,0.07463814318180084f,-0.8405796885490417f,-0.0007171871257014573f,-0.024258151650428772f,-0.45050644874572754f,0.1725289225578308f,-0.7802938222885132f,0.03607487678527832f,0.5823708176612854f,0.2477506399154663f,-0.06579115986824036f,0.21758104860782623f,-1.0475490093231201f,0.288152277469635f,0.23995733261108398f,0.024087339639663696f,0.2164597511291504f,0.12120835483074188f,0.1771809458732605f,0.18153810501098633f,0.044886842370033264f,-0.45804738998413086f,-0.09508240222930908f,-0.3922502398490906f,-0.1986687332391739f}, |
Lightvalve | 85:a3b46118b5cd | 211 | {-0.22140617668628693f,0.11039567738771439f,-0.12567082047462463f,0.14158423244953156f,-0.1939433217048645f,0.05963689088821411f,-0.24695870280265808f,0.0951455757021904f,-0.6664013266563416f,0.022931326180696487f,-0.2767846882343292f,-0.760556697845459f,0.05731263756752014f,-0.7110890746116638f,0.25621795654296875f,-0.056063972413539886f,0.048747699707746506f,-0.1278351992368698f,-0.2727428376674652f,-1.0854625701904297f,0.16882538795471191f,0.06402266025543213f,-0.11836928129196167f,0.039934515953063965f,1.003145456314087f,-0.11239828169345856f,-0.1133931428194046f,-0.3252381384372711f,-0.3182383179664612f,0.2547503709793091f,-0.1375647485256195f,0.1382262408733368f}, |
Lightvalve | 85:a3b46118b5cd | 212 | {0.7424431443214417f,-0.16360057890415192f,0.2171381115913391f,-0.16690026223659515f,0.07404414564371109f,-0.14423607289791107f,0.2765461504459381f,-0.30260738730430603f,1.6236447095870972f,0.10254877805709839f,-0.3003540635108948f,2.1228983402252197f,0.011023491621017456f,-0.12462414056062698f,-0.03601345419883728f,-0.09932885318994522f,-2.2200329303741455f,0.22864657640457153f,0.10862921923398972f,0.297675758600235f,0.20457005500793457f,0.27685415744781494f,-0.005791813135147095f,-0.10062649846076965f,0.045922599732875824f,-0.26325157284736633f,-0.05270814895629883f,0.7354073524475098f,0.031461846083402634f,-0.14184410870075226f,0.9825209975242615f,-0.18200480937957764f}, |
Lightvalve | 85:a3b46118b5cd | 213 | {3.43557071685791f,-0.37699493765830994f,0.28761178255081177f,-0.39612287282943726f,-1.149980068206787f,-0.24277469515800476f,0.150278702378273f,-0.13081876933574677f,-1.2281982898712158f,0.1744758039712906f,0.17159739136695862f,3.070831775665283f,0.24014073610305786f,-0.39453327655792236f,0.10303568840026855f,0.2651329040527344f,-2.787836790084839f,0.0594504177570343f,-0.15806250274181366f,-0.8892703652381897f,0.24788546562194824f,-0.2400866597890854f,0.009734302759170532f,0.07569819688796997f,-0.398231565952301f,0.021602869033813477f,0.09330874681472778f,2.4840033054351807f,-0.5836443901062012f,0.31292837858200073f,3.499506711959839f,-0.05150891840457916f}, |
Lightvalve | 85:a3b46118b5cd | 214 | {3.073215961456299f,0.04465167596936226f,-0.018198877573013306f,-0.13033048808574677f,-1.478877305984497f,0.229939803481102f,0.21951307356357574f,0.035041652619838715f,-1.610356092453003f,0.3388233184814453f,0.16918893158435822f,2.66919207572937f,0.14461854100227356f,-0.009949876926839352f,0.10715800523757935f,-0.014581815339624882f,-0.5364759564399719f,-0.09520435333251953f,-0.35689690709114075f,-1.1133244037628174f,0.003564387559890747f,-0.21737487614154816f,-0.056176453828811646f,0.2705017924308777f,-1.1481003761291504f,-0.11336645483970642f,-0.08713452517986298f,2.2573490142822266f,-0.48686596751213074f,0.1542942225933075f,3.3134500980377197f,-0.34200945496559143f}, |
Lightvalve | 85:a3b46118b5cd | 215 | {1.4852768182754517f,-0.39954492449760437f,-0.21064835786819458f,0.2203398048877716f,-0.5335493683815002f,0.2496090978384018f,-0.2910284698009491f,-0.3198430836200714f,-0.28080636262893677f,-0.11860388517379761f,-0.13035798072814941f,1.6375261545181274f,0.16440579295158386f,-0.4228263795375824f,0.16669881343841553f,0.14986597001552582f,-0.24249979853630066f,-0.1354665607213974f,0.04468502849340439f,-1.1441909074783325f,0.19135773181915283f,0.03320974111557007f,0.04151731729507446f,-0.17835715413093567f,-0.2396876960992813f,-0.0823364406824112f,0.01731693744659424f,1.4326388835906982f,-0.13844795525074005f,0.2479429841041565f,2.298494577407837f,0.0020472321193665266f}, |
Lightvalve | 85:a3b46118b5cd | 216 | {1.0220134258270264f,-0.32163339853286743f,-0.06804615259170532f,0.03646112605929375f,-0.5027016401290894f,0.06246945634484291f,-0.010077573359012604f,-0.2098536342382431f,0.3460806608200073f,0.18953894078731537f,-0.28787288069725037f,0.8882648944854736f,-0.2098202258348465f,0.09721869230270386f,-0.14352285861968994f,-0.4829506278038025f,-0.36567428708076477f,-0.12247540056705475f,0.03196468576788902f,-0.4261271059513092f,0.2445054054260254f,-0.17827366292476654f,0.1588650643825531f,0.2682499289512634f,-0.16950875520706177f,0.3014773726463318f,-0.09892690181732178f,1.1544232368469238f,-0.04598469287157059f,-0.2688840925693512f,1.2846530675888062f,0.0027509161736816168f}, |
Lightvalve | 85:a3b46118b5cd | 217 | {0.579922080039978f,-0.30411940813064575f,-0.3055203855037689f,-0.07766459882259369f,-0.1570633500814438f,-0.011666776612401009f,-0.16813640296459198f,-0.042732805013656616f,0.8997067213058472f,-0.1784154176712036f,-0.20238585770130157f,1.034441590309143f,-0.2332654744386673f,0.1968480348587036f,-0.0510614812374115f,0.12909819185733795f,-0.24880455434322357f,0.21716350317001343f,-0.19486063718795776f,0.01803022250533104f,-0.23450759053230286f,-0.037396371364593506f,-0.04696956276893616f,-0.3105055093765259f,-0.3451623320579529f,0.09924682974815369f,0.19071155786514282f,0.9054200053215027f,-0.14185519516468048f,-0.31100425124168396f,0.9050654768943787f,-0.29593273997306824f}, |
Lightvalve | 85:a3b46118b5cd | 218 | {-0.08677421510219574f,-0.03783690556883812f,-0.13955603539943695f,-0.06409101188182831f,-0.11201370507478714f,-0.3602372407913208f,-0.3186802268028259f,0.24745288491249084f,1.0538026094436646f,-0.2323320209980011f,-0.02506977692246437f,0.9638646841049194f,0.15656322240829468f,0.1632177233695984f,-0.2357269823551178f,-0.28166407346725464f,-0.8165067434310913f,0.06937721371650696f,-0.16676990687847137f,0.18075904250144958f,0.09017103910446167f,-0.22036904096603394f,0.14483293890953064f,-0.23648568987846375f,-0.6787664294242859f,0.08651471138000488f,-0.10241064429283142f,0.6022611260414124f,-0.14437633752822876f,-0.19917014241218567f,0.18188685178756714f,-0.23450633883476257f}, |
Lightvalve | 85:a3b46118b5cd | 219 | {-0.5766992568969727f,0.1184464767575264f,0.14412927627563477f,-0.15042896568775177f,0.1467805951833725f,-0.04327445477247238f,-0.030855635181069374f,-0.34645146131515503f,0.6894040107727051f,-0.005314269568771124f,-0.2811681628227234f,0.45902219414711f,-0.13026931881904602f,-0.010465151630342007f,-0.26593083143234253f,-0.37996169924736023f,-2.5209763050079346f,0.2377535104751587f,-0.3135165572166443f,0.5914992690086365f,-0.13781827688217163f,0.21268349885940552f,-0.08894717693328857f,-0.049122005701065063f,-0.4082443416118622f,0.2244570255279541f,0.07713767886161804f,-0.2689043879508972f,0.14912289381027222f,0.0996716320514679f,-0.5415741205215454f,0.2097400575876236f}, |
Lightvalve | 85:a3b46118b5cd | 220 | {-0.9949038624763489f,-0.4173136055469513f,-0.11498735845088959f,0.008756956085562706f,-0.08926361054182053f,-0.09582825750112534f,-0.06310929358005524f,-0.14144068956375122f,0.5721414089202881f,-0.11046501994132996f,-0.07811713963747025f,-0.21047434210777283f,0.03739750385284424f,0.1041150689125061f,-0.1758022904396057f,0.030765360221266747f,-3.6499509811401367f,0.013404697179794312f,-0.09151140600442886f,0.052862122654914856f,-0.06274017691612244f,-0.04495009779930115f,0.16096624732017517f,-0.2661283612251282f,-0.028636706992983818f,-0.26236870884895325f,0.2998650074005127f,-0.6705052852630615f,-0.20814122259616852f,0.0021838247776031494f,-1.331779956817627f,-0.2629702091217041f}, |
Lightvalve | 85:a3b46118b5cd | 221 | {-1.0482234954833984f,-0.2966521382331848f,0.22676491737365723f,-0.25471359491348267f,-0.37185031175613403f,-0.3696459233760834f,-0.0729946717619896f,-0.11789866536855698f,-0.3728426396846771f,-0.31439051032066345f,-0.22465655207633972f,0.05072358250617981f,0.24344396591186523f,0.4350084364414215f,0.10714438557624817f,-0.4546082019805908f,-4.952857494354248f,0.10376802086830139f,0.2242542952299118f,-0.4671648144721985f,-0.2054605484008789f,-0.1163475513458252f,0.2862720489501953f,-0.2529933452606201f,-0.24990373849868774f,0.2395622730255127f,-0.025946974754333496f,-0.39632874727249146f,-0.0030404594726860523f,0.1531447172164917f,-1.5278600454330444f,-0.3365791141986847f}, |
Lightvalve | 85:a3b46118b5cd | 222 | {-1.6903513669967651f,0.10733281075954437f,0.06572896242141724f,-0.1304227113723755f,-0.1115754023194313f,-0.43486207723617554f,0.29972702264785767f,-0.340988427400589f,-0.8391082286834717f,-0.0539608858525753f,0.14386940002441406f,-0.6060321927070618f,-0.28356313705444336f,0.3066166341304779f,0.2870509624481201f,-0.55873042345047f,-4.915887355804443f,0.019099920988082886f,0.14596521854400635f,-0.48744550347328186f,-0.2803005874156952f,0.2523300051689148f,0.2562907934188843f,-0.2754032015800476f,-0.07243770360946655f,-0.22490140795707703f,-0.3025656044483185f,-1.9818894863128662f,0.11724169552326202f,-0.012988030910491943f,-2.2147622108459473f,-0.10904830694198608f}, |
Lightvalve | 65:a2d7c63419c2 | 223 | }; |
Lightvalve | 65:a2d7c63419c2 | 224 | |
Lightvalve | 66:a8e6799dbce3 | 225 | const float h2[32][32] = { |
Lightvalve | 85:a3b46118b5cd | 226 | {-0.27667078375816345f,-0.23811225593090057f,-0.2068375200033188f,-0.0879012867808342f,-0.22460763156414032f,-0.07725942879915237f,-0.8246331810951233f,-0.1880926489830017f,-0.30411389470100403f,-0.10008957982063293f,-0.0884118303656578f,-0.4653884768486023f,-0.2210158258676529f,-1.6733050346374512f,-0.35370728373527527f,-0.722766101360321f,-0.0709063932299614f,-0.21483641862869263f,-0.3125793933868408f,-0.11871208995580673f,1.1690597534179688f,-0.39566323161125183f,-1.2163290977478027f,-0.36493924260139465f,-1.227667212486267f,-1.0807034969329834f,-0.24977105855941772f,-1.427618145942688f,0.1597512662410736f,0.04159419983625412f,-0.36485931277275085f,-0.37028968334198f}, |
Lightvalve | 85:a3b46118b5cd | 227 | {-0.16083313524723053f,0.002147972583770752f,-0.04321768879890442f,0.2524152100086212f,0.039372533559799194f,0.008302271366119385f,-0.1208314597606659f,-0.05986310541629791f,0.24677053093910217f,0.048597872257232666f,0.20835980772972107f,0.18927007913589478f,0.2550097405910492f,-0.34532517194747925f,0.06118088960647583f,0.019440770149230957f,0.056778669357299805f,-0.2737269401550293f,-0.24258790910243988f,0.24201518297195435f,0.06179745867848396f,0.15619775652885437f,-0.16832955181598663f,0.29149511456489563f,0.20149093866348267f,0.17517772316932678f,0.04504341632127762f,0.27575191855430603f,-0.28620439767837524f,-0.0511949360370636f,0.19307708740234375f,0.04502454772591591f}, |
Lightvalve | 66:a8e6799dbce3 | 228 | {-0.1579037755727768f,0.28447648882865906f,-0.1789936125278473f,0.20799604058265686f,0.025723248720169067f,0.17740526795387268f,-0.1666354387998581f,-0.06060470640659332f,-0.017253071069717407f,-0.2790656089782715f,-0.16800916194915771f,-0.2990717589855194f,0.07126197218894958f,-0.08032660186290741f,-0.1799015998840332f,-0.1891922950744629f,0.2556300461292267f,0.2080206573009491f,-0.24888339638710022f,0.27691522240638733f,-0.21319638192653656f,-0.14012537896633148f,-0.30466505885124207f,-0.013728171586990356f,-0.1629670113325119f,0.2530798614025116f,0.0633285641670227f,0.0011726915836334229f,-0.14820529520511627f,0.2823629677295685f,0.10884168744087219f,-0.2637729346752167f}, |
Lightvalve | 85:a3b46118b5cd | 229 | {-0.22340479493141174f,-0.14320111274719238f,-0.23058539628982544f,0.059558480978012085f,-0.27190759778022766f,-0.18698109686374664f,0.052317000925540924f,-0.017705194652080536f,-0.06944303214550018f,0.09271347522735596f,-0.08192534744739532f,-0.15819904208183289f,-0.306356817483902f,-0.18329206109046936f,-0.2806533873081207f,-0.3607129156589508f,0.10996055603027344f,0.24023392796516418f,0.18937888741493225f,-0.17948074638843536f,0.19022536277770996f,-0.3802829086780548f,-0.06394433975219727f,-0.21236775815486908f,0.17009137570858002f,-0.308042049407959f,0.3282419443130493f,-0.18204741179943085f,-0.22396358847618103f,0.18157242238521576f,0.03394383192062378f,0.09717517346143723f}, |
Lightvalve | 85:a3b46118b5cd | 230 | {-0.3102381229400635f,0.1328449547290802f,-0.0804666131734848f,0.004887737799435854f,0.02918580174446106f,-0.3023947775363922f,0.15342280268669128f,-0.2515855133533478f,0.043158918619155884f,-0.2690317630767822f,-0.07780981063842773f,-0.6515375375747681f,-0.4152904152870178f,-0.22334013879299164f,-0.4286702573299408f,-0.3818913698196411f,-0.10307048261165619f,0.15626338124275208f,-0.2876724302768707f,-0.10561763495206833f,-0.0003245422849431634f,-0.13073286414146423f,0.0641208216547966f,-0.25683170557022095f,0.6004334092140198f,-0.4072219431400299f,0.20106177031993866f,0.17939238250255585f,0.1945810168981552f,-0.24423693120479584f,0.008398771286010742f,-0.19926288723945618f}, |
Lightvalve | 85:a3b46118b5cd | 231 | {-0.35962358117103577f,-0.10369791835546494f,0.032371193170547485f,-0.2693426012992859f,-0.023485273122787476f,-0.20030589401721954f,0.11459477245807648f,-0.23795722424983978f,-0.03548547625541687f,0.08825305104255676f,-0.23303963243961334f,0.2878020107746124f,-0.40069082379341125f,0.14208975434303284f,-0.46872687339782715f,-0.25773805379867554f,0.2371552288532257f,0.24713221192359924f,0.22080418467521667f,0.19416317343711853f,0.04020584002137184f,0.15577682852745056f,-0.1307595670223236f,-0.08340707421302795f,0.20974642038345337f,-0.5711827278137207f,0.2458461970090866f,-0.039409637451171875f,0.05800282955169678f,-0.3217167854309082f,0.17187702655792236f,0.15027888119220734f}, |
Lightvalve | 85:a3b46118b5cd | 232 | {-0.21433322131633759f,-0.1279313862323761f,-0.11171227693557739f,0.27164509892463684f,-0.26441383361816406f,0.2845393121242523f,0.059883393347263336f,-0.20844537019729614f,-0.26620519161224365f,0.17144301533699036f,-0.09376060962677002f,-0.1572292447090149f,0.29584869742393494f,-0.058311186730861664f,-0.11244286596775055f,0.0967603325843811f,-0.16153597831726074f,0.18742787837982178f,-0.15168866515159607f,0.12337173521518707f,0.006761712022125721f,0.02421507239341736f,-0.07988794147968292f,-0.15143592655658722f,-0.2089247703552246f,0.15867114067077637f,0.18644478917121887f,-0.14779987931251526f,-0.11822041869163513f,0.19546762108802795f,-0.16657039523124695f,-0.08388599753379822f}, |
Lightvalve | 85:a3b46118b5cd | 233 | {0.29264822602272034f,0.11346611380577087f,0.04012581706047058f,0.025473803281784058f,0.22828009724617004f,-0.05009126663208008f,0.021829109638929367f,0.004197537899017334f,0.2864855229854584f,0.01006925106048584f,-0.04534134268760681f,0.06762572377920151f,-0.09209762513637543f,-0.25739482045173645f,-0.08468866348266602f,-0.25332483649253845f,-0.2721019387245178f,0.2706601917743683f,0.04719046875834465f,-0.11177165806293488f,0.23973645269870758f,0.06910467147827148f,-0.07979777455329895f,0.2198345959186554f,-0.24870845675468445f,-0.04599680006504059f,0.261798232793808f,-0.11211597174406052f,-0.14135785400867462f,0.07403197884559631f,0.16089555621147156f,0.0746181309223175f}, |
Lightvalve | 85:a3b46118b5cd | 234 | {-0.046173661947250366f,0.2067040354013443f,-0.17369569838047028f,0.020620670169591904f,0.20520558953285217f,-0.2334207445383072f,0.5509499311447144f,-0.3163010776042938f,0.29470762610435486f,-0.06864601373672485f,-0.5593370199203491f,-1.5564181804656982f,0.0968346893787384f,-1.6689549684524536f,-0.075385682284832f,-0.5072345733642578f,-0.10491269081830978f,0.06025278568267822f,-0.314052551984787f,0.10852571576833725f,-1.7864117622375488f,-0.2905685007572174f,0.20933787524700165f,-0.14714831113815308f,-0.6482618451118469f,-1.3220139741897583f,-0.19700168073177338f,0.4083876609802246f,0.17195050418376923f,-0.059212855994701385f,-0.3444784879684448f,-0.3934835195541382f}, |
Lightvalve | 85:a3b46118b5cd | 235 | {0.1889706403017044f,-0.0401761569082737f,-0.29237738251686096f,-0.2233119159936905f,0.15896368026733398f,-0.1797974854707718f,-0.2296128273010254f,-0.26513350009918213f,0.18755429983139038f,-0.07031691074371338f,-0.045559514313936234f,-0.09827352315187454f,-0.020898953080177307f,-0.38141727447509766f,-0.22772273421287537f,0.1208859235048294f,-0.015168905258178711f,-0.2859399914741516f,-0.29410815238952637f,-0.20170047879219055f,-0.07285713404417038f,-0.10289540886878967f,-0.2307620644569397f,0.1717528998851776f,-0.14798638224601746f,0.15564283728599548f,0.6784325242042542f,-0.20741957426071167f,0.2113950550556183f,0.0054363710805773735f,-0.0010054409503936768f,-0.31446996331214905f}, |
Lightvalve | 85:a3b46118b5cd | 236 | {0.19981321692466736f,0.1956864297389984f,-0.033508092164993286f,-0.22838544845581055f,-0.12505969405174255f,0.026693344116210938f,0.11359591037034988f,0.14285165071487427f,-0.17670965194702148f,0.17403557896614075f,-0.16720308363437653f,0.10220219939947128f,-0.1060299277305603f,0.003477066056802869f,-0.21540889143943787f,0.02191716432571411f,0.03990337252616882f,0.0716913640499115f,0.14514072239398956f,-0.06428739428520203f,0.28084802627563477f,0.1245347261428833f,0.07470300793647766f,0.27806827425956726f,0.07208987325429916f,0.038795921951532364f,0.026812395080924034f,-0.2607133686542511f,0.13817378878593445f,0.17853263020515442f,-0.009185433387756348f,0.02538907527923584f}, |
Lightvalve | 85:a3b46118b5cd | 237 | {-0.4442670941352844f,-0.1860445737838745f,-0.034642115235328674f,0.09608548879623413f,-0.258735328912735f,-0.13653548061847687f,-1.2089402675628662f,-0.3410877585411072f,0.17735600471496582f,0.009893029928207397f,-0.07874592393636703f,-0.2842765152454376f,-0.24438704550266266f,-1.9543540477752686f,0.010354598984122276f,-0.41466227173805237f,-0.1441226452589035f,0.10842388868331909f,-0.13093329966068268f,0.052122436463832855f,0.45565345883369446f,-0.24256029725074768f,-0.710641086101532f,-0.08674553036689758f,-1.907486081123352f,-0.37084174156188965f,0.6043446063995361f,-0.7357847690582275f,-0.5343249440193176f,-0.24354082345962524f,0.0631515383720398f,0.10293833911418915f}, |
Lightvalve | 66:a8e6799dbce3 | 238 | {-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 | 85:a3b46118b5cd | 239 | {0.0671820119023323f,0.060091227293014526f,-0.0858893096446991f,0.07914295792579651f,-0.25116482377052307f,0.15326258540153503f,-0.08713096380233765f,-0.2506338953971863f,0.000652611255645752f,-0.22920364141464233f,-0.04401589184999466f,-0.3016808331012726f,-0.03543950244784355f,0.05881982669234276f,-0.12223215401172638f,-0.22121477127075195f,-0.07963520288467407f,0.14483880996704102f,-0.31877025961875916f,-0.134050190448761f,-0.8467172980308533f,0.013909898698329926f,-0.2228696048259735f,0.25642916560173035f,-0.6417788863182068f,0.5535252094268799f,0.2769230008125305f,0.38449135422706604f,-0.011228948831558228f,0.19325007498264313f,-0.28556761145591736f,-0.1528882533311844f}, |
Lightvalve | 66:a8e6799dbce3 | 240 | {-0.23982827365398407f,0.03880670666694641f,-0.013682037591934204f,-0.11685100197792053f,-0.020662933588027954f,0.30190005898475647f,-0.14934301376342773f,-0.15993990004062653f,0.1152651309967041f,-0.11991468071937561f,-0.15497799217700958f,0.11116543412208557f,-0.2045515924692154f,0.2403949797153473f,-0.21275603771209717f,0.05732181668281555f,-0.2770107090473175f,0.088544100522995f,0.19012078642845154f,-0.07119561731815338f,-0.18914666771888733f,-0.10413256287574768f,-0.16050675511360168f,0.11598068475723267f,-0.03151249885559082f,-0.1937510371208191f,0.18474078178405762f,0.19502457976341248f,0.22045472264289856f,-0.29474368691444397f,0.09864541888237f,0.06054645776748657f}, |
Lightvalve | 85:a3b46118b5cd | 241 | {-0.27167096734046936f,0.011714187450706959f,0.03260180354118347f,-0.28680741786956787f,-0.05160003900527954f,-0.6577866077423096f,-0.10676338523626328f,-0.14501291513442993f,0.05445769429206848f,0.07657262682914734f,-0.3954622447490692f,-0.24194227159023285f,-0.07815150916576385f,-1.0453819036483765f,0.04841199144721031f,-0.7130303978919983f,-0.25386664271354675f,-0.18997573852539062f,-0.3865494728088379f,-0.2331775426864624f,0.03797753155231476f,-0.322394996881485f,-0.3663414716720581f,0.2513379752635956f,0.15967398881912231f,-0.23637755215168f,-0.24946653842926025f,-0.13272057473659515f,-0.05630142614245415f,-0.29794901609420776f,-0.035532981157302856f,0.24180591106414795f}, |
Lightvalve | 85:a3b46118b5cd | 242 | {-0.14231154322624207f,-0.15926708281040192f,0.10704237222671509f,-0.15739846229553223f,-0.15424516797065735f,0.029879294335842133f,-1.5818952322006226f,0.025422094389796257f,-0.23304778337478638f,-0.035415440797805786f,-0.08818405866622925f,0.07317487895488739f,-0.13159534335136414f,-2.304041862487793f,-0.0956379622220993f,-0.9746494293212891f,-0.027234435081481934f,0.19620582461357117f,0.031559910625219345f,-0.23665417730808258f,0.2825831174850464f,-0.23727405071258545f,-0.33594009280204773f,-0.30205652117729187f,0.4954940676689148f,-0.8056759834289551f,-0.3472602069377899f,0.7867006659507751f,-0.28215155005455017f,0.012936839833855629f,-0.21812304854393005f,-0.1726924479007721f}, |
Lightvalve | 67:c2812cf26c38 | 243 | {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 | 85:a3b46118b5cd | 244 | {0.09298902750015259f,0.2841971218585968f,-0.0814327746629715f,-0.004546761512756348f,-0.017610490322113037f,0.11057800054550171f,-0.2513483464717865f,0.20642486214637756f,-0.2925014793872833f,0.022429823875427246f,-0.12208538502454758f,-0.04182456433773041f,-0.2097223699092865f,-0.04657880216836929f,0.05468165874481201f,0.21256521344184875f,0.1296386420726776f,0.027322769165039062f,0.21169254183769226f,-0.0020682415924966335f,0.26059314608573914f,0.094583660364151f,0.06231796741485596f,0.14984634518623352f,0.005743067245930433f,0.19345685839653015f,-0.05729139968752861f,-0.07238814234733582f,0.14345040917396545f,-0.11986468732357025f,-0.19420018792152405f,0.163921520113945f}, |
Lightvalve | 85:a3b46118b5cd | 245 | {-0.3235664367675781f,0.1897745281457901f,0.02990397810935974f,-0.1192702129483223f,0.09478475898504257f,-0.5875452160835266f,-0.10678595304489136f,0.2053612917661667f,-0.2325194776058197f,-0.2458522766828537f,-0.25150302052497864f,-1.0412211418151855f,-0.431474506855011f,-2.1408212184906006f,-0.06486815959215164f,-0.4271238148212433f,0.1140141561627388f,0.11064860224723816f,-0.2641930878162384f,-0.13593877851963043f,-3.4147567749023438f,-0.5392265319824219f,-0.18391597270965576f,-0.1409711390733719f,1.2104154825210571f,-0.2507343888282776f,-0.3430251479148865f,3.450707197189331f,-0.29718831181526184f,0.2887052297592163f,-0.18571819365024567f,-0.020702049136161804f}, |
Lightvalve | 74:2bd13b02ed17 | 246 | {0.2703488767147064f,-0.16041381657123566f,0.12738299369812012f,-0.03611093759536743f,0.1169431209564209f,0.1861400008201599f,-0.1765512377023697f,0.28177282214164734f,0.1474648416042328f,-0.23766008019447327f,-0.005803406238555908f,0.08728843927383423f,0.09594401717185974f,-0.17028304934501648f,-0.16805587708950043f,-0.058941617608070374f,-0.22846683859825134f,0.08700510859489441f,-0.2656046748161316f,0.07154610753059387f,-0.1559111475944519f,0.22832396626472473f,-0.18301571905612946f,-0.17816279828548431f,-0.04200500249862671f,0.2835671007633209f,0.1830621361732483f,-0.26011598110198975f,0.08541131019592285f,0.08213254809379578f,-0.29332536458969116f,0.08477649092674255f}, |
Lightvalve | 66:a8e6799dbce3 | 247 | {-0.06283275783061981f,-0.26753589510917664f,-0.10381917655467987f,-0.13344663381576538f,0.2644997537136078f,0.2204643189907074f,0.2924788296222687f,-0.17931663990020752f,-0.09078609943389893f,-0.17306232452392578f,0.02247890830039978f,-0.26996222138404846f,0.22075030207633972f,-0.3029964864253998f,0.21873190999031067f,-0.0030784308910369873f,0.18228653073310852f,0.09971508383750916f,-0.242676243185997f,-0.1424383968114853f,0.19031599164009094f,0.3004438579082489f,-0.23650792241096497f,-0.2683113217353821f,0.29957786202430725f,0.08561205863952637f,-0.1366746425628662f,-0.15950153768062592f,-0.07675467431545258f,-0.2218506634235382f,-0.2795913517475128f,0.1869203746318817f}, |
Lightvalve | 66:a8e6799dbce3 | 248 | {0.2003176510334015f,-0.27792131900787354f,0.055196613073349f,-0.27959588170051575f,0.18430876731872559f,-0.05316638946533203f,0.16156336665153503f,-0.18850930035114288f,0.09482413530349731f,0.021483391523361206f,0.009039878845214844f,0.1586727499961853f,0.11457142233848572f,0.2876913249492645f,-0.24802550673484802f,0.14089101552963257f,-0.06842575967311859f,-0.10107968747615814f,0.06239110231399536f,-0.2528536915779114f,-0.27538973093032837f,0.15457189083099365f,-0.15549622476100922f,0.20245882868766785f,0.08544808626174927f,0.22650876641273499f,-0.05268847942352295f,0.20387354493141174f,0.24724552035331726f,0.21444126963615417f,0.05186706781387329f,-0.11084021627902985f}, |
Lightvalve | 66:a8e6799dbce3 | 249 | {-0.19810965657234192f,0.2745245397090912f,0.1767616868019104f,0.19752147793769836f,0.0650932788848877f,0.29138168692588806f,-0.29061684012413025f,0.010446667671203613f,0.025284886360168457f,-0.10202452540397644f,-0.10358673334121704f,0.14746251702308655f,0.15136101841926575f,0.04500553011894226f,-0.2497977316379547f,-0.29277902841567993f,0.02556520700454712f,-0.09509801864624023f,0.16731274127960205f,-0.25266408920288086f,-0.3004688322544098f,-0.19769597053527832f,-0.14847496151924133f,0.3053832948207855f,0.07563886046409607f,-0.10258816182613373f,-0.060128673911094666f,0.0016401112079620361f,-0.29647189378738403f,-0.18869297206401825f,0.05497395992279053f,0.16092956066131592f}, |
Lightvalve | 85:a3b46118b5cd | 250 | {-0.23316675424575806f,-0.34703072905540466f,-0.26251813769340515f,-0.17987364530563354f,0.17773596942424774f,-0.36324021220207214f,3.2900445461273193f,-0.2968785762786865f,-0.06814777851104736f,-0.24531681835651398f,-0.4146662950515747f,-2.0547890663146973f,-0.17220929265022278f,-4.949320316314697f,-0.14551500976085663f,-0.30991068482398987f,0.04916536808013916f,0.04417389631271362f,-0.17469187080860138f,-0.02684543840587139f,0.6412792205810547f,-0.30275508761405945f,-1.3109110593795776f,0.12922808527946472f,0.8519241809844971f,-2.4303390979766846f,-3.4127962589263916f,2.906496286392212f,-0.26897016167640686f,-0.27723777294158936f,0.08090485632419586f,0.12159651517868042f}, |
Lightvalve | 66:a8e6799dbce3 | 251 | {-0.10580866038799286f,-0.17215237021446228f,-0.01352420449256897f,-0.13443149626255035f,-0.10265451669692993f,-0.2169143706560135f,0.30098411440849304f,-0.2986297905445099f,0.07908004522323608f,-0.30061498284339905f,0.10424068570137024f,-0.018799901008605957f,-0.18665757775306702f,0.005998075008392334f,-0.2969498336315155f,0.18525955080986023f,0.2379322350025177f,0.15184926986694336f,0.215760737657547f,-0.19088758528232574f,0.08620095252990723f,0.019999295473098755f,-0.0752219706773758f,0.11181813478469849f,0.1881926953792572f,0.2210972011089325f,0.13236162066459656f,-0.06690356135368347f,-0.18345263600349426f,-0.14861416816711426f,0.08577704429626465f,-0.09683996438980103f}, |
Lightvalve | 66:a8e6799dbce3 | 252 | {0.03951254487037659f,0.23604217171669006f,0.012746036052703857f,-0.12561996281147003f,-0.1283164620399475f,0.25823846459388733f,0.10610169172286987f,0.22718152403831482f,0.1749366819858551f,0.007794857025146484f,0.11289489269256592f,0.2725127637386322f,-0.13616766035556793f,-0.03546282649040222f,-0.1685536652803421f,-0.24492129683494568f,0.15760570764541626f,0.017505377531051636f,-0.273531436920166f,-0.005667984485626221f,0.18370777368545532f,-0.023328542709350586f,0.2379932701587677f,-0.048420339822769165f,0.10376441478729248f,-0.295401930809021f,-0.20498433709144592f,0.22346952557563782f,-0.26649031043052673f,-0.08466874063014984f,0.23347875475883484f,-0.03380200266838074f}, |
Lightvalve | 85:a3b46118b5cd | 253 | {0.040690790861845016f,-0.23573431372642517f,0.09161179512739182f,0.07033146917819977f,-0.2817712128162384f,-0.6276457905769348f,-0.37714698910713196f,-0.33156290650367737f,0.23963233828544617f,0.21321198344230652f,-0.24425387382507324f,-0.3424640893936157f,-0.32626232504844666f,-2.4378278255462646f,-0.24740485846996307f,-0.9169236421585083f,-0.3423613905906677f,0.2487291395664215f,-0.514508843421936f,-0.418739378452301f,0.28486350178718567f,-0.21440523862838745f,-0.05746378377079964f,-0.3821214437484741f,-0.7211941480636597f,-0.9245252013206482f,-0.059503331780433655f,-1.0836530923843384f,-0.12973465025424957f,0.24282275140285492f,-0.11351406574249268f,-0.22536014020442963f}, |
Lightvalve | 85:a3b46118b5cd | 254 | {-0.27666908502578735f,-0.11293958872556686f,0.2466227114200592f,0.07792654633522034f,-0.29828932881355286f,-0.39517462253570557f,-0.08378418534994125f,-0.25900280475616455f,-0.2516406178474426f,0.012286126613616943f,0.16366124153137207f,-0.24976401031017303f,-0.24393905699253082f,-0.14810976386070251f,-0.08683206886053085f,0.04108639806509018f,-0.24087269604206085f,-0.048499464988708496f,-0.31050628423690796f,0.04387558251619339f,-0.15366223454475403f,-0.4223913848400116f,-0.031352698802948f,0.2817048728466034f,0.022134708240628242f,0.028483198955655098f,-0.15902377665042877f,0.09091032296419144f,-0.07090267539024353f,-0.3208990693092346f,-0.2543276250362396f,-0.027558956295251846f}, |
Lightvalve | 66:a8e6799dbce3 | 255 | {-0.01348048448562622f,0.08233943581581116f,0.18838337063789368f,0.21852442622184753f,-0.04740855097770691f,0.19177213311195374f,-0.0060100555419921875f,0.20933791995048523f,0.06356173753738403f,0.063028484582901f,0.09440034627914429f,0.29559019207954407f,-0.2545689642429352f,-0.09652335941791534f,-0.2841038703918457f,-0.03553757071495056f,0.02329021692276001f,-0.08720272779464722f,-0.0750999003648758f,-0.10468094050884247f,-0.03761094808578491f,-0.030853450298309326f,0.2112145721912384f,0.2599640190601349f,-0.2969062626361847f,-0.13667742908000946f,0.24173608422279358f,0.09566575288772583f,0.021116197109222412f,-0.005982398986816406f,-0.26417285203933716f,0.1879688799381256f}, |
Lightvalve | 85:a3b46118b5cd | 256 | {-0.4157778024673462f,-0.2768164575099945f,-0.09589093178510666f,-0.14509503543376923f,-0.17625996470451355f,-0.8082829117774963f,0.11251474916934967f,-0.08049019426107407f,-0.21029016375541687f,0.2210421860218048f,-0.5324726700782776f,-0.31869950890541077f,-0.2522881329059601f,-1.6379762887954712f,-0.5326108336448669f,-0.5548344850540161f,-0.047237642109394073f,-0.29308468103408813f,-0.2703635096549988f,-0.3068823218345642f,-0.511782169342041f,-0.35366109013557434f,-0.9957090616226196f,0.0199049711227417f,-2.2476844787597656f,-1.209467887878418f,-2.9938364028930664f,0.00481326412409544f,0.10213620215654373f,-0.40729013085365295f,0.1731317639350891f,-0.06308870762586594f}, |
Lightvalve | 85:a3b46118b5cd | 257 | {-0.09888127446174622f,-0.22750279307365417f,-0.22503364086151123f,-0.008032619953155518f,-0.012498408555984497f,-0.24329537153244019f,-0.07285532355308533f,0.08175003528594971f,-0.016126900911331177f,0.06972584128379822f,0.04723711311817169f,0.20952002704143524f,-0.031845152378082275f,-0.2927907407283783f,0.18349257111549377f,0.20412376523017883f,-0.09216172993183136f,0.04617339372634888f,-0.09483018517494202f,-0.06833663582801819f,-0.04525856301188469f,-0.28567367792129517f,-0.06047184765338898f,-0.28923499584198f,-0.001504910527728498f,-0.1947428286075592f,0.2807030975818634f,-0.27029848098754883f,-0.16326025128364563f,0.11664235591888428f,-0.02675291895866394f,0.10761681944131851f}, |
Lightvalve | 65:a2d7c63419c2 | 258 | }; |
Lightvalve | 65:a2d7c63419c2 | 259 | |
Lightvalve | 66:a8e6799dbce3 | 260 | const float h3[32][32] = { |
Lightvalve | 85:a3b46118b5cd | 261 | {-0.2551194727420807f,-0.09101890027523041f,-0.026477575302124023f,-0.05514620989561081f,-0.10447631776332855f,0.06744374334812164f,0.23563924431800842f,0.21467849612236023f,-0.18423226475715637f,0.034586966037750244f,-0.08393588662147522f,0.28293344378471375f,0.045914679765701294f,0.25820791721343994f,-0.2476848065853119f,0.13452908396720886f,0.033751994371414185f,0.2061004936695099f,-0.022569477558135986f,-0.11508268862962723f,-0.14949974417686462f,0.08748143166303635f,-0.22618433833122253f,0.044178664684295654f,0.321938693523407f,-0.1258748173713684f,0.2930828630924225f,-0.2595084309577942f,-0.11374835669994354f,0.2922307550907135f,-0.2780901789665222f,-0.21998201310634613f}, |
Lightvalve | 85:a3b46118b5cd | 262 | {0.05588451027870178f,0.19731858372688293f,-0.055143773555755615f,-0.09839404374361038f,-0.13887283205986023f,0.03336816281080246f,-0.2855546772480011f,0.011247634887695312f,-0.06353434175252914f,0.021339505910873413f,0.17599248886108398f,0.24069470167160034f,-0.05771490931510925f,0.02564643882215023f,-0.21469902992248535f,0.03876742720603943f,-0.21865856647491455f,-0.12651903927326202f,0.22753819823265076f,-0.40737229585647583f,-0.32043901085853577f,0.2408931702375412f,0.14157342910766602f,0.049514561891555786f,0.045854296535253525f,-0.25851932168006897f,0.0932874083518982f,0.11975095421075821f,0.11012043058872223f,0.050485759973526f,-0.07176513224840164f,-0.16893690824508667f}, |
Lightvalve | 85:a3b46118b5cd | 263 | {-0.2800689935684204f,-0.038760632276535034f,0.13974270224571228f,0.01585569977760315f,0.11945047974586487f,-0.19458696246147156f,0.11322265863418579f,0.25643888115882874f,-0.061097174882888794f,-0.07816044986248016f,-0.07445238530635834f,-0.22145158052444458f,-0.1081896424293518f,-0.09452249109745026f,0.16234496235847473f,0.1413259506225586f,-0.2648085951805115f,-0.054869145154953f,-0.05491623282432556f,0.17325228452682495f,0.23639705777168274f,0.0748760998249054f,-0.1324603259563446f,0.15828460454940796f,-0.2246721237897873f,-0.027338534593582153f,-0.06307074427604675f,0.13438841700553894f,0.14327026903629303f,0.1633671224117279f,0.25184446573257446f,-0.21565306186676025f}, |
Lightvalve | 85:a3b46118b5cd | 264 | {0.2906629145145416f,0.19203472137451172f,-0.2048129439353943f,0.2633720338344574f,0.1020251214504242f,-0.10037626326084137f,-0.061309605836868286f,-0.17915479838848114f,-0.02168092131614685f,-0.044261813163757324f,-0.09506386518478394f,0.24970653653144836f,0.14959025382995605f,0.042513735592365265f,0.22106656432151794f,-0.23978039622306824f,-0.28915077447891235f,0.030949801206588745f,-0.2734605371952057f,0.20261280238628387f,0.24216356873512268f,-0.06363512575626373f,-0.16484108567237854f,-0.27595841884613037f,0.15143372118473053f,-0.11024686694145203f,-0.09994620084762573f,-0.00024366378784179688f,-0.1939506083726883f,-0.25852420926094055f,0.10422986000776291f,0.0037463903427124023f}, |
Lightvalve | 85:a3b46118b5cd | 265 | {0.07563930749893188f,-0.0864691436290741f,-0.2677825689315796f,0.2715696394443512f,-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.05276976153254509f,-0.09959287941455841f,0.05316261947154999f,0.007399916648864746f}, |
Lightvalve | 85:a3b46118b5cd | 266 | {0.10931676626205444f,0.2396949827671051f,0.12925085425376892f,-0.08252257108688354f,-0.10811276733875275f,0.06756330281496048f,-0.061815500259399414f,0.04091137647628784f,-0.1621098518371582f,-0.15699732303619385f,0.08972057700157166f,-0.18881937861442566f,-0.003787398338317871f,-0.11700853705406189f,0.2971965968608856f,0.25175121426582336f,-0.2889891266822815f,-0.13035915791988373f,0.16576141119003296f,-0.05668075755238533f,0.06469068676233292f,-0.14416936039924622f,0.023232191801071167f,0.27409639954566956f,-0.034767039120197296f,-0.18302330374717712f,0.09057381749153137f,0.10786959528923035f,-0.548835813999176f,-0.29547566175460815f,-0.35850775241851807f,0.38859620690345764f}, |
Lightvalve | 85:a3b46118b5cd | 267 | {-0.21155381202697754f,0.07671676576137543f,-0.365216463804245f,-0.047789331525564194f,-0.10707491636276245f,-1.3750492334365845f,-0.4912494719028473f,0.08929090201854706f,-1.369384765625f,-1.248399019241333f,-0.9033269286155701f,-0.9735842943191528f,-0.2293381690979004f,-8.505420684814453f,0.09689150750637054f,-1.0314340591430664f,-0.18917083740234375f,0.011466026306152344f,-0.2092767059803009f,-0.40805622935295105f,-1.1721888780593872f,-3.5798773765563965f,-0.38582879304885864f,-0.39523354172706604f,-0.30228129029273987f,-0.2910519242286682f,-0.6309252977371216f,-1.629555583000183f,-0.44594696164131165f,-0.09532724320888519f,0.5858601331710815f,-1.0788432359695435f}, |
Lightvalve | 85:a3b46118b5cd | 268 | {-0.01093912124633789f,-0.23583689332008362f,0.28153905272483826f,0.34915414452552795f,0.14173488318920135f,-0.3328573405742645f,0.036741942167282104f,-0.0059101879596710205f,-0.16143393516540527f,-0.27182313799858093f,0.09319102764129639f,-0.07236140221357346f,0.08821836113929749f,-0.06543922424316406f,0.0685860812664032f,-0.29903873801231384f,0.1317853033542633f,0.20550194382667542f,-0.1227773055434227f,-0.2141684591770172f,0.2980828881263733f,0.06528259813785553f,0.0343703031539917f,0.12564969062805176f,-0.012211651541292667f,0.23886635899543762f,-0.2778390347957611f,0.2378171980381012f,0.28547611832618713f,0.17161712050437927f,0.06681416928768158f,0.03436092659831047f}, |
Lightvalve | 66:a8e6799dbce3 | 269 | {-0.20420776307582855f,0.1970202624797821f,0.23591408133506775f,-0.282694011926651f,0.09019026160240173f,0.20012763142585754f,0.028453975915908813f,0.23323127627372742f,0.15246456861495972f,-0.1270071268081665f,0.20025727152824402f,0.13077861070632935f,-0.2238168716430664f,-0.20709244906902313f,-0.0045506954193115234f,-0.16448761522769928f,0.28163614869117737f,0.1971360743045807f,0.30405697226524353f,-0.28959211707115173f,-0.2255709171295166f,0.15360668301582336f,0.24163606762886047f,0.19554737210273743f,-0.1804599016904831f,0.07604315876960754f,-0.1459394246339798f,-0.14081311225891113f,-0.29656586050987244f,0.19529584050178528f,-0.05168652534484863f,-0.03415781259536743f}, |
Lightvalve | 66:a8e6799dbce3 | 270 | {0.27550336718559265f,-0.14170598983764648f,-0.21542268991470337f,-0.2159879207611084f,0.06500789523124695f,-0.21155211329460144f,-0.01575431227684021f,0.0617731511592865f,0.13126209378242493f,-0.04922589659690857f,-0.23877641558647156f,-0.06292802095413208f,0.01433342695236206f,0.14592674374580383f,-0.23886999487876892f,0.08878573775291443f,0.1853090226650238f,-0.05102238059043884f,-0.13667166233062744f,-0.24401302635669708f,0.25155118107795715f,-0.20339438319206238f,0.03535670042037964f,0.048473477363586426f,-0.13871997594833374f,-0.15382859110832214f,-0.13837768137454987f,0.26085415482521057f,0.2491457164287567f,0.157204270362854f,0.14108964800834656f,0.12518465518951416f}, |
Lightvalve | 85:a3b46118b5cd | 271 | {-0.023678362369537354f,0.23636776208877563f,-0.11535780876874924f,-0.022540466859936714f,0.13657836616039276f,0.1195158138871193f,0.0393199622631073f,0.196751207113266f,-0.045937731862068176f,0.2409590780735016f,-0.0033504606690257788f,-0.06168833374977112f,-0.17429311573505402f,-0.07835593074560165f,0.080221027135849f,-0.2471318244934082f,0.026521950960159302f,0.28880444169044495f,0.19228774309158325f,-0.2018059492111206f,-0.030197033658623695f,0.06118291988968849f,0.08564630150794983f,0.2614522874355316f,0.023392729461193085f,-0.25962090492248535f,0.004192052874714136f,0.11273465305566788f,0.029061896726489067f,-0.2912617325782776f,-0.09352731704711914f,-0.3636726438999176f}, |
Lightvalve | 85:a3b46118b5cd | 272 | {0.2680447995662689f,0.06987415254116058f,-0.07723036408424377f,-1.1521879434585571f,-0.17997273802757263f,-0.07585451751947403f,0.1327475905418396f,-0.17794576287269592f,-0.2750938832759857f,-0.5723249912261963f,-1.7340177297592163f,-0.04393726959824562f,0.10793473571538925f,0.23477916419506073f,0.23152390122413635f,-0.07731422781944275f,0.21101722121238708f,-0.15284278988838196f,-0.020817279815673828f,-0.24710041284561157f,-0.23627397418022156f,0.4080229699611664f,-0.24210311472415924f,0.12623250484466553f,-0.10129186511039734f,0.18312275409698486f,-0.3820236921310425f,-0.33574652671813965f,0.8565282225608826f,-0.1739533692598343f,-0.40139415860176086f,-0.49397340416908264f}, |
Lightvalve | 85:a3b46118b5cd | 273 | {0.10771462321281433f,0.1270637810230255f,-0.1647956818342209f,-0.00161704421043396f,0.10816431045532227f,0.12214487791061401f,-0.2502448558807373f,-0.05063694715499878f,-0.1339682787656784f,-0.11501708626747131f,0.24353471398353577f,0.11519002914428711f,-0.1879904866218567f,0.014138120226562023f,-0.0055807530879974365f,0.05870962142944336f,-0.0561012327671051f,-0.1419317126274109f,-0.24982497096061707f,0.09593365341424942f,-0.0570058599114418f,-0.3279927372932434f,0.2986377775669098f,-0.2888573110103607f,-0.20504257082939148f,-0.03866580128669739f,0.09892630577087402f,0.26863425970077515f,-0.03514225035905838f,0.024399906396865845f,-0.10868262499570847f,0.11775122582912445f}, |
Lightvalve | 85:a3b46118b5cd | 274 | {0.07240793108940125f,0.04041182994842529f,0.11702513694763184f,0.5787858963012695f,-0.03083758056163788f,-0.24005953967571259f,0.16982512176036835f,-0.09019742906093597f,-0.08812267333269119f,0.17671909928321838f,0.270390123128891f,0.33242034912109375f,-0.2594541907310486f,-0.6346546411514282f,0.13272255659103394f,-0.0684008002281189f,-0.13351139426231384f,0.2471931278705597f,-0.00980430282652378f,-0.007512300740927458f,-0.6472665667533875f,-1.6416341066360474f,-0.044914066791534424f,0.28785380721092224f,3.691645622253418f,-0.1976800560951233f,-0.33554908633232117f,-0.058328717947006226f,-1.6910686492919922f,-0.29330405592918396f,0.2700785994529724f,-0.4942809045314789f}, |
Lightvalve | 85:a3b46118b5cd | 275 | {-0.27890223264694214f,0.08861199021339417f,0.18213510513305664f,0.13934633135795593f,-0.06993072479963303f,-0.19435341656208038f,-0.2505151033401489f,-0.2674597501754761f,-0.2874044179916382f,0.11670660972595215f,0.020896315574645996f,0.035015769302845f,0.07699105143547058f,-0.0011294950963929296f,-0.02410009503364563f,0.10129088163375854f,0.22686699032783508f,-0.30486053228378296f,0.09699136018753052f,0.1608044058084488f,0.11395001411437988f,-0.18098939955234528f,-0.09317314624786377f,0.11354613304138184f,-0.12409790605306625f,-0.025903940200805664f,-0.15464875102043152f,0.14187094569206238f,0.3003353476524353f,0.06508117914199829f,0.025254305452108383f,-0.11861296743154526f}, |
Lightvalve | 85:a3b46118b5cd | 276 | {0.3047083914279938f,0.12143945693969727f,-0.003977321553975344f,0.2376824915409088f,0.2578274607658386f,-0.09596908092498779f,-0.09724730253219604f,-0.25786101818084717f,-0.18161152303218842f,0.12881293892860413f,-0.2581462860107422f,-0.11245428025722504f,0.007539393380284309f,0.03671972081065178f,0.062144935131073f,-0.28920799493789673f,0.03473195433616638f,-0.0016761720180511475f,0.04677792638540268f,-0.4039270281791687f,-0.022867320105433464f,-0.050418294966220856f,0.27043071389198303f,-0.10900285840034485f,-0.46224501729011536f,-0.031148135662078857f,-0.18866202235221863f,-0.19289328157901764f,-0.6301232576370239f,0.017086774110794067f,0.03748638182878494f,-0.046868402510881424f}, |
Lightvalve | 85:a3b46118b5cd | 277 | {-0.06136500835418701f,-0.11579577624797821f,-0.23311558365821838f,-0.020844489336013794f,0.161813884973526f,0.22929790616035461f,0.11958792805671692f,-0.0384809672832489f,-0.10647237300872803f,-0.09010881185531616f,0.22322741150856018f,-0.1071339100599289f,0.05349445343017578f,-0.23458370566368103f,0.040097206830978394f,0.08616101741790771f,-0.15468145906925201f,-0.21275553107261658f,-0.21210846304893494f,-0.23840199410915375f,0.12352427840232849f,0.282552570104599f,0.14114680886268616f,0.09007054567337036f,-0.05948364734649658f,0.12031787633895874f,-0.184563547372818f,0.07786750793457031f,-0.26778778433799744f,-0.24735762178897858f,0.030290991067886353f,-0.11765947937965393f}, |
Lightvalve | 67:c2812cf26c38 | 278 | {0.1169951856136322f,0.06741076707839966f,0.014288008213043213f,-0.1894388198852539f,0.2306886613368988f,0.08970087766647339f,0.29362860321998596f,0.2666439712047577f,-0.1488228738307953f,0.22382596135139465f,-0.1313140094280243f,0.02602824568748474f,0.029441386461257935f,-0.1546926349401474f,0.10762849450111389f,0.06951633095741272f,0.0639207661151886f,0.27696695923805237f,-0.2749756872653961f,0.2684275209903717f,-0.240950807929039f,-0.08405844867229462f,0.26762983202934265f,0.09600964188575745f,-0.20394444465637207f,0.012219250202178955f,-0.09225042164325714f,-0.12637756764888763f,-0.21354423463344574f,-0.29393887519836426f,-0.056166648864746094f,0.002250969409942627f}, |
Lightvalve | 85:a3b46118b5cd | 279 | {-0.16101892292499542f,0.06696435809135437f,0.26537272334098816f,0.14242389798164368f,-0.06941846013069153f,-0.08939408510923386f,0.1589156985282898f,-0.17396175861358643f,0.2520415782928467f,-0.11376987397670746f,0.1600557565689087f,0.14661520719528198f,-0.09920920431613922f,0.11937369406223297f,-0.2592318058013916f,0.1978430449962616f,0.18047624826431274f,0.2863751947879791f,-0.15008151531219482f,-0.17706477642059326f,0.04137323424220085f,0.2641109228134155f,0.29893049597740173f,0.13123968243598938f,0.13080033659934998f,-0.28873488306999207f,-0.024474656209349632f,0.2619846761226654f,0.13840989768505096f,0.18439257144927979f,-0.06977742910385132f,0.1805502325296402f}, |
Lightvalve | 85:a3b46118b5cd | 280 | {0.261911004781723f,-0.28497835993766785f,-0.2993849217891693f,0.018002374097704887f,0.06657280772924423f,0.06222769618034363f,-0.06670857965946198f,-0.030254334211349487f,-0.2840169668197632f,0.1197996437549591f,0.01667046546936035f,-0.2924177646636963f,0.18650740385055542f,-0.12163694202899933f,-0.20773646235466003f,-0.10781967639923096f,-0.15712574124336243f,0.16112294793128967f,0.2270473837852478f,0.19313202798366547f,0.194093719124794f,0.135379821062088f,-0.3001303970813751f,0.14906415343284607f,0.16047455370426178f,0.0025720298290252686f,-0.05664414167404175f,-0.22247231006622314f,0.10167145729064941f,0.21125611662864685f,-0.029378168284893036f,-0.22727590799331665f}, |
Lightvalve | 85:a3b46118b5cd | 281 | {0.14277681708335876f,-0.3088180124759674f,-0.07111090421676636f,-1.2715349197387695f,-0.2525586187839508f,-1.2801485061645508f,-0.029207449406385422f,-0.4071364402770996f,-1.5380983352661133f,-1.382262110710144f,-0.9818264842033386f,-1.0009515285491943f,-0.03993672877550125f,-0.38989388942718506f,-0.18908967077732086f,0.39706918597221375f,0.06366744637489319f,-0.2764144539833069f,0.04149489477276802f,-0.33456262946128845f,-3.2393929958343506f,-1.0775730609893799f,0.09886767715215683f,-0.5438085198402405f,-0.7274033427238464f,-0.19159743189811707f,-0.006920442450791597f,-0.8261724710464478f,-1.352381706237793f,-0.10488687455654144f,-0.3111574947834015f,-1.1973711252212524f}, |
Lightvalve | 85:a3b46118b5cd | 282 | {0.29069945216178894f,-0.23835359513759613f,0.019009560346603394f,-0.28911280632019043f,0.14278793334960938f,-0.06867027282714844f,0.045349299907684326f,-0.17138783633708954f,-0.2704833149909973f,0.028545528650283813f,-0.16238126158714294f,-0.15074089169502258f,-0.0936775803565979f,-0.1178935170173645f,0.09875330328941345f,0.08164769411087036f,0.2294725477695465f,0.10683679580688477f,-0.23758554458618164f,-0.24961189925670624f,0.06968030333518982f,0.363527774810791f,0.16651621460914612f,-0.15362010896205902f,0.420186311006546f,0.023651927709579468f,-0.1729920208454132f,0.08877382427453995f,0.09805427491664886f,0.19045329093933105f,-0.1284513771533966f,-0.18943598866462708f}, |
Lightvalve | 85:a3b46118b5cd | 283 | {0.1991647183895111f,0.12534403800964355f,-0.04112154245376587f,-0.5893926620483398f,-0.17588619887828827f,-0.2645309567451477f,-0.1610087752342224f,-0.031804412603378296f,0.10274738073348999f,-0.25018924474716187f,0.15975651144981384f,-0.057292819023132324f,0.1464652419090271f,-0.1994783729314804f,0.2151305377483368f,0.2952744662761688f,-0.21319252252578735f,0.04970458149909973f,0.10210192203521729f,0.3051425516605377f,0.6842249035835266f,-0.9156296253204346f,0.13887640833854675f,0.25299301743507385f,0.4143226742744446f,-0.07015113532543182f,-0.287551611661911f,-0.11227443814277649f,-0.5306638479232788f,-0.24420931935310364f,0.5920869708061218f,-0.19415420293807983f}, |
Lightvalve | 85:a3b46118b5cd | 284 | {0.12202468514442444f,0.10608518123626709f,-0.10034829378128052f,-0.2956502139568329f,0.16320201754570007f,0.0862378180027008f,-0.06113804876804352f,-0.11568751931190491f,0.2868335545063019f,-0.3037929832935333f,-0.06917986273765564f,-0.11160935461521149f,-0.13285431265830994f,-0.17888973653316498f,-0.06735922396183014f,0.05864924192428589f,-0.25733181834220886f,-0.17565661668777466f,0.05582946538925171f,-0.1147834062576294f,-0.2570425271987915f,0.18900752067565918f,0.173453688621521f,-0.05681343376636505f,0.24433693289756775f,0.1795230209827423f,0.19069638848304749f,0.010025888681411743f,-0.2541712522506714f,0.2425754964351654f,-0.11579340696334839f,-0.009572982788085938f}, |
Lightvalve | 85:a3b46118b5cd | 285 | {-0.3055141270160675f,-0.3851349949836731f,-0.39758896827697754f,1.7202949523925781f,-0.2741934061050415f,-0.5617624521255493f,-0.12023571133613586f,0.05654950439929962f,-0.5676174759864807f,-0.36180180311203003f,-1.0556901693344116f,0.07073506712913513f,0.013348586857318878f,-4.939380645751953f,-0.18081167340278625f,-1.2455143928527832f,0.009005595929920673f,0.05286213755607605f,-0.5208131670951843f,-0.9368453025817871f,0.7971709370613098f,-0.21460092067718506f,0.1409359872341156f,0.057757120579481125f,1.9464781284332275f,-0.02825927734375f,-0.22573700547218323f,-1.9265499114990234f,-0.724542498588562f,0.1865309774875641f,0.09031400084495544f,-0.5980502367019653f}, |
Lightvalve | 85:a3b46118b5cd | 286 | {0.1782623827457428f,0.10266919434070587f,-0.3353572487831116f,0.23696476221084595f,0.07118476182222366f,0.5731724500656128f,-0.31857603788375854f,0.1475539207458496f,-0.11237376928329468f,0.373404860496521f,0.29898756742477417f,-0.6590624451637268f,-0.07626544684171677f,0.22064208984375f,-0.2527656555175781f,-0.3049176335334778f,0.032145023345947266f,-0.25376296043395996f,-0.03357543423771858f,-0.43860819935798645f,-1.2057366371154785f,0.7661312222480774f,0.1247415542602539f,0.05391114950180054f,0.7792649269104004f,0.10029953718185425f,0.05537182092666626f,-0.4309832453727722f,-0.5579723715782166f,0.1616479754447937f,-0.365967333316803f,-0.29087284207344055f}, |
Lightvalve | 85:a3b46118b5cd | 287 | {-0.17396044731140137f,-0.14001525938510895f,-0.1695951521396637f,1.5665149688720703f,-0.11802119761705399f,0.9005776047706604f,-0.21196839213371277f,-0.1761629432439804f,-0.002899362938478589f,-0.30667877197265625f,0.09939976036548615f,-0.20871970057487488f,0.17592547833919525f,0.24817490577697754f,-0.19851773977279663f,-0.17112360894680023f,0.14198419451713562f,0.10370296239852905f,-0.04347978159785271f,-0.7956013083457947f,1.5257806777954102f,-0.3484574556350708f,0.18175193667411804f,-0.06225347891449928f,3.148869276046753f,-0.2665709853172302f,0.08956825733184814f,-0.011365842074155807f,1.8825180530548096f,-0.1200934648513794f,-1.0590929985046387f,-0.10910904407501221f}, |
Lightvalve | 85:a3b46118b5cd | 288 | {-0.12546227872371674f,-0.25381147861480713f,-0.41361913084983826f,0.1966758817434311f,-0.05479537695646286f,-0.9609546661376953f,-0.11697011440992355f,-0.1760558784008026f,-0.5391033887863159f,-0.4849804937839508f,-0.3961711823940277f,-0.9747102856636047f,-0.04747000336647034f,-1.7257399559020996f,-0.22329537570476532f,0.14263403415679932f,-0.09554100781679153f,-0.16779978573322296f,-0.2137051671743393f,-0.12179039418697357f,-2.800898551940918f,-1.9134587049484253f,-0.26878347992897034f,-0.009471745230257511f,-1.958404779434204f,0.020356476306915283f,-0.3687167167663574f,-5.788242816925049f,0.17349965870380402f,-0.000007510185241699219f,0.2805892825126648f,-0.6033777594566345f}, |
Lightvalve | 85:a3b46118b5cd | 289 | {0.07555973529815674f,-0.0029259920120239258f,0.05441734567284584f,0.17795933783054352f,-0.11083845794200897f,0.2753245532512665f,-0.14982634782791138f,0.12075316905975342f,-0.2766430675983429f,0.013024389743804932f,0.18159812688827515f,-0.20200279355049133f,0.2637675702571869f,-0.020423894748091698f,0.2882818281650543f,0.05304515361785889f,-0.15297894179821014f,0.07341468334197998f,0.05268138647079468f,-0.05901036038994789f,-0.2661813795566559f,-0.03531910479068756f,0.1843600869178772f,0.2517976462841034f,0.09153199940919876f,-0.051110416650772095f,-0.23432010412216187f,0.16746872663497925f,-0.004589451011270285f,-0.017525076866149902f,0.044131215661764145f,-0.2141496241092682f}, |
Lightvalve | 85:a3b46118b5cd | 290 | {0.06582912802696228f,0.2796666920185089f,-0.2556927502155304f,0.4213337004184723f,0.25870010256767273f,0.29053765535354614f,0.06556430459022522f,0.29767414927482605f,0.43026992678642273f,-0.2889440357685089f,-0.1203770637512207f,-0.06570860743522644f,-0.015925198793411255f,-0.0780004933476448f,-0.014884740114212036f,-0.05300724506378174f,0.26490333676338196f,0.15243005752563477f,-0.07319167256355286f,0.41437527537345886f,0.17535027861595154f,-0.15328161418437958f,-0.04174882173538208f,-0.11559568345546722f,-0.47339776158332825f,0.21069613099098206f,-0.19532959163188934f,-0.014412187971174717f,0.16428492963314056f,-0.2712400257587433f,0.19330570101737976f,-0.04990653693675995f}, |
Lightvalve | 85:a3b46118b5cd | 291 | {-0.1299392580986023f,-0.06208275258541107f,-0.18067686259746552f,0.062329649925231934f,-0.22588664293289185f,-0.06877543032169342f,-0.19175797700881958f,0.02903696894645691f,-0.2614779472351074f,0.016345679759979248f,-0.24767392873764038f,0.2033931314945221f,-0.30105409026145935f,0.08271035552024841f,0.13206014037132263f,0.15829482674598694f,-0.21012049913406372f,0.2088232934474945f,0.07014858722686768f,-0.19175665080547333f,0.28649166226387024f,0.05041047930717468f,-0.27260470390319824f,-0.025072306394577026f,0.10618430376052856f,-0.007939159870147705f,-0.22979341447353363f,0.11936154961585999f,-0.023631373420357704f,0.18135693669319153f,0.14457125961780548f,0.15906798839569092f}, |
Lightvalve | 85:a3b46118b5cd | 292 | {0.07638216018676758f,0.07996532320976257f,-0.30373215675354004f,-0.28068432211875916f,0.12841704487800598f,0.016976704820990562f,0.2795381247997284f,-0.25668495893478394f,-0.08276357501745224f,0.1293344497680664f,-0.05191630870103836f,0.02524423599243164f,0.10861700028181076f,0.2590629756450653f,-0.029521822929382324f,-0.19500072300434113f,0.06506577134132385f,-0.011876672506332397f,0.12026964873075485f,0.27703770995140076f,0.1338760256767273f,0.001670554280281067f,-0.15799765288829803f,-0.17324526607990265f,0.20246674120426178f,0.1901901364326477f,-0.17624419927597046f,-0.06433966010808945f,-0.13379955291748047f,0.22636333107948303f,-0.18080484867095947f,0.26258352398872375f}, |
Lightvalve | 66:a8e6799dbce3 | 293 | }; |
Lightvalve | 65:a2d7c63419c2 | 294 | |
Lightvalve | 85:a3b46118b5cd | 295 | const float hout[32] = { 0.3285340666770935f,0.2529861629009247f,-0.02794448845088482f,-0.11024416238069534f,-0.014000286348164082f,0.5794768929481506f,-0.16548395156860352f,-0.02517510950565338f,0.8701211810112f,-0.1466466784477234f,1.4857077598571777f,0.11510539799928665f,-0.08165325224399567f,1.1056994199752808f,0.11580539494752884f,0.13693712651729584f,0.004584930371493101f,-0.21499931812286377f,-0.10640942305326462f,-0.12329035252332687f,-0.6041821241378784f,-0.5037342309951782f,-0.13192011415958405f,0.07643738389015198f,0.30652591586112976f,0.2520971894264221f,-0.14245828986167908f,0.4719190001487732f,0.017724622040987015f,-0.3257754445075989f,-0.215330570936203f,1.0069118738174438f }; |
Lightvalve | 66:a8e6799dbce3 | 296 | |
Lightvalve | 85:a3b46118b5cd | 297 | const float b1[32] = { 0.4471018612384796f,0.8732520341873169f,-1.7145336866378784f,0.11060962080955505f,1.837284803390503f,1.007750391960144f,-0.06491786241531372f,0.8956719636917114f,2.6451375484466553f,-1.2619271278381348f,0.5940906405448914f,2.6766932010650635f,-0.3425353467464447f,-0.98967444896698f,-1.087764859199524f,0.33063894510269165f,-5.126280784606934f,-0.26377663016319275f,0.21976712346076965f,1.9539169073104858f,-0.284685879945755f,-1.1118980646133423f,-1.6770726442337036f,-1.2263047695159912f,6.089069843292236f,-2.0880801677703857f,-1.0489267110824585f,-0.5635794401168823f,0.5242202281951904f,-1.0887231826782227f,5.702357769012451f,-0.46849215030670166f }; |
Lightvalve | 65:a2d7c63419c2 | 298 | |
Lightvalve | 85:a3b46118b5cd | 299 | const float b2[32] = { -0.37478387355804443f,-0.8822373747825623f,-1.610761046409607f,-0.5953555107116699f,-0.7830360531806946f,-0.23389804363250732f,1.5533720254898071f,-0.565883457660675f,-1.20063054561615f,-1.912178635597229f,-0.08753211051225662f,0.132071852684021f,-0.38167816400527954f,0.24978798627853394f,-0.21596388518810272f,-0.02125457674264908f,-1.9359937906265259f,-1.5844906568527222f,-0.12828677892684937f,-0.4470262825489044f,1.2603751420974731f,-0.08529075235128403f,-0.30154427886009216f,-1.1930168867111206f,1.6427350044250488f,-0.014808067120611668f,2.628875494003296f,-0.6658599376678467f,-0.6933333873748779f,-0.38596004247665405f,-1.3031682968139648f,-1.5120806694030762f }; |
Lightvalve | 65:a2d7c63419c2 | 300 | |
Lightvalve | 85:a3b46118b5cd | 301 | const float b3[32] = { -1.963319182395935f,-0.524648904800415f,-0.11971238255500793f,-2.6649246215820312f,-0.13388246297836304f,2.9242334365844727f,-0.6314579844474792f,-0.8082239031791687f,-0.21274924278259277f,-0.04028291255235672f,-0.5043213963508606f,-0.35809093713760376f,-0.8338872790336609f,1.2783610820770264f,-1.3000545501708984f,0.9831259846687317f,-1.493859052658081f,-1.0192245244979858f,-0.5513612031936646f,-0.1602744311094284f,0.28453513979911804f,1.1440303325653076f,-1.1831269264221191f,-1.1371890306472778f,-0.025017697364091873f,-0.36519983410835266f,-0.5132201910018921f,2.1017091274261475f,0.1228194534778595f,-2.3236680030822754f,-0.27946344017982483f,-0.06861314922571182f }; |
Lightvalve | 66:a8e6799dbce3 | 302 | |
Lightvalve | 85:a3b46118b5cd | 303 | const float bout[1] = { 0.33465152978897095f }; |
Lightvalve | 61:bc8c8270f0ab | 304 | |
Lightvalve | 61:bc8c8270f0ab | 305 | |
GiJeongKim | 0:51c43836c1d7 | 306 | int main() |
GiJeongKim | 0:51c43836c1d7 | 307 | { |
Lightvalve | 66:a8e6799dbce3 | 308 | |
Lightvalve | 65:a2d7c63419c2 | 309 | HAL_Init(); |
Lightvalve | 65:a2d7c63419c2 | 310 | SystemClock_Config(); |
Lightvalve | 65:a2d7c63419c2 | 311 | |
jobuuu | 6:df07d3491e3a | 312 | /********************************* |
jobuuu | 1:e04e563be5ce | 313 | *** Initialization |
jobuuu | 6:df07d3491e3a | 314 | *********************************/ |
Lightvalve | 69:3995ffeaa786 | 315 | LED = 0; |
Lightvalve | 61:bc8c8270f0ab | 316 | pc.baud(9600); |
Lightvalve | 21:e5f1a43ea6f9 | 317 | |
GiJeongKim | 0:51c43836c1d7 | 318 | // i2c init |
Lightvalve | 8:5d2eebdad025 | 319 | i2c.frequency(400 * 1000); // 0.4 mHz |
Lightvalve | 8:5d2eebdad025 | 320 | wait_ms(2); // Power Up wait |
Lightvalve | 8:5d2eebdad025 | 321 | look_for_hardware_i2c(); // Hardware present |
Lightvalve | 8:5d2eebdad025 | 322 | init_as5510(i2c_slave_addr1); |
Lightvalve | 11:82d8768d7351 | 323 | make_delay(); |
jobuuu | 2:a1c0a37df760 | 324 | |
GiJeongKim | 0:51c43836c1d7 | 325 | // // spi init |
Lightvalve | 16:903b5a4433b4 | 326 | //eeprom.format(8,3); |
Lightvalve | 16:903b5a4433b4 | 327 | //eeprom.frequency(5000000); //5M |
GiJeongKim | 0:51c43836c1d7 | 328 | enc.format(8,0); |
GiJeongKim | 0:51c43836c1d7 | 329 | enc.frequency(5000000); //5M |
Lightvalve | 11:82d8768d7351 | 330 | make_delay(); |
Lightvalve | 21:e5f1a43ea6f9 | 331 | |
Lightvalve | 16:903b5a4433b4 | 332 | //rom |
Lightvalve | 19:23b7c1ad8683 | 333 | ROM_CALL_DATA(); |
Lightvalve | 16:903b5a4433b4 | 334 | make_delay(); |
Lightvalve | 13:747daba9cf59 | 335 | |
GiJeongKim | 0:51c43836c1d7 | 336 | // ADC init |
jobuuu | 5:a4319f79457b | 337 | Init_ADC(); |
Lightvalve | 11:82d8768d7351 | 338 | make_delay(); |
jobuuu | 2:a1c0a37df760 | 339 | |
GiJeongKim | 0:51c43836c1d7 | 340 | // Pwm init |
GiJeongKim | 0:51c43836c1d7 | 341 | Init_PWM(); |
GiJeongKim | 0:51c43836c1d7 | 342 | TIM4->CR1 ^= TIM_CR1_UDIS; |
Lightvalve | 11:82d8768d7351 | 343 | make_delay(); |
Lightvalve | 13:747daba9cf59 | 344 | |
Lightvalve | 11:82d8768d7351 | 345 | // TMR3 init |
Lightvalve | 11:82d8768d7351 | 346 | Init_TMR3(); |
Lightvalve | 11:82d8768d7351 | 347 | TIM3->CR1 ^= TIM_CR1_UDIS; |
Lightvalve | 11:82d8768d7351 | 348 | make_delay(); |
Lightvalve | 21:e5f1a43ea6f9 | 349 | |
Lightvalve | 50:3c630b5eba9f | 350 | // TMR2 init |
Lightvalve | 56:6f50d9d3bfee | 351 | // Init_TMR2(); |
Lightvalve | 56:6f50d9d3bfee | 352 | // TIM2->CR1 ^= TIM_CR1_UDIS; |
Lightvalve | 56:6f50d9d3bfee | 353 | // make_delay(); |
Lightvalve | 21:e5f1a43ea6f9 | 354 | |
GiJeongKim | 0:51c43836c1d7 | 355 | // CAN |
jobuuu | 2:a1c0a37df760 | 356 | can.attach(&CAN_RX_HANDLER); |
Lightvalve | 11:82d8768d7351 | 357 | CAN_ID_INIT(); |
Lightvalve | 11:82d8768d7351 | 358 | make_delay(); |
Lightvalve | 34:bb2ca2fc2a8e | 359 | |
Lightvalve | 23:59218d4a256d | 360 | //Timer priority |
Lightvalve | 23:59218d4a256d | 361 | NVIC_SetPriority(TIM3_IRQn, 2); |
Lightvalve | 57:f4819de54e7a | 362 | //NVIC_SetPriority(TIM2_IRQn, 3); |
Lightvalve | 54:647072f5307a | 363 | NVIC_SetPriority(TIM4_IRQn, 3); |
Lightvalve | 34:bb2ca2fc2a8e | 364 | |
Lightvalve | 23:59218d4a256d | 365 | //can.reset(); |
Lightvalve | 19:23b7c1ad8683 | 366 | can.filter(msg.id, 0xFFFFF000, CANStandard); |
Lightvalve | 34:bb2ca2fc2a8e | 367 | |
GiJeongKim | 0:51c43836c1d7 | 368 | // spi _ enc |
GiJeongKim | 0:51c43836c1d7 | 369 | spi_enc_set_init(); |
Lightvalve | 11:82d8768d7351 | 370 | make_delay(); |
Lightvalve | 13:747daba9cf59 | 371 | |
Lightvalve | 11:82d8768d7351 | 372 | //DAC init |
Lightvalve | 58:2eade98630e2 | 373 | if (SENSING_MODE == 0) { |
Lightvalve | 58:2eade98630e2 | 374 | dac_1 = TORQUE_VREF / 3.3f; |
Lightvalve | 58:2eade98630e2 | 375 | dac_2 = 0.0f; |
Lightvalve | 58:2eade98630e2 | 376 | } else if (SENSING_MODE == 1) { |
Lightvalve | 58:2eade98630e2 | 377 | dac_1 = PRES_A_VREF / 3.3f; |
Lightvalve | 58:2eade98630e2 | 378 | dac_2 = PRES_B_VREF / 3.3f; |
Lightvalve | 58:2eade98630e2 | 379 | } |
Lightvalve | 11:82d8768d7351 | 380 | make_delay(); |
Lightvalve | 13:747daba9cf59 | 381 | |
Lightvalve | 19:23b7c1ad8683 | 382 | for (int i=0; i<50; i++) { |
Lightvalve | 11:82d8768d7351 | 383 | if(i%2==0) |
Lightvalve | 38:118df027d851 | 384 | ID_index_array[i] = - i * 0.5f; |
Lightvalve | 11:82d8768d7351 | 385 | else |
Lightvalve | 38:118df027d851 | 386 | ID_index_array[i] = (i+1) * 0.5f; |
Lightvalve | 11:82d8768d7351 | 387 | } |
Lightvalve | 61:bc8c8270f0ab | 388 | |
Lightvalve | 61:bc8c8270f0ab | 389 | |
jobuuu | 6:df07d3491e3a | 390 | /************************************ |
jobuuu | 1:e04e563be5ce | 391 | *** Program is operating! |
jobuuu | 6:df07d3491e3a | 392 | *************************************/ |
GiJeongKim | 0:51c43836c1d7 | 393 | while(1) { |
Lightvalve | 66:a8e6799dbce3 | 394 | // if(timer_while==1000 && OPERATING_MODE==5) { |
Lightvalve | 66:a8e6799dbce3 | 395 | //if(timer_while==1000) { |
Lightvalve | 65:a2d7c63419c2 | 396 | //i2c |
Lightvalve | 66:a8e6799dbce3 | 397 | |
Lightvalve | 65:a2d7c63419c2 | 398 | read_field(i2c_slave_addr1); |
Lightvalve | 65:a2d7c63419c2 | 399 | if(DIR_VALVE_ENC < 0) value = 1023 - value; |
Lightvalve | 65:a2d7c63419c2 | 400 | // if(LED==1) { |
Lightvalve | 65:a2d7c63419c2 | 401 | // LED=0; |
Lightvalve | 65:a2d7c63419c2 | 402 | // } else |
Lightvalve | 65:a2d7c63419c2 | 403 | // LED = 1; |
Lightvalve | 65:a2d7c63419c2 | 404 | timer_while = 0; |
Lightvalve | 66:a8e6799dbce3 | 405 | //} |
Lightvalve | 66:a8e6799dbce3 | 406 | |
Lightvalve | 66:a8e6799dbce3 | 407 | timer_while ++; |
Lightvalve | 66:a8e6799dbce3 | 408 | |
Lightvalve | 73:f80dc3970c99 | 409 | if(NN_Control_Flag == 0) { |
Lightvalve | 73:f80dc3970c99 | 410 | LED = 0; |
Lightvalve | 73:f80dc3970c99 | 411 | } |
Lightvalve | 66:a8e6799dbce3 | 412 | |
Lightvalve | 73:f80dc3970c99 | 413 | else if(NN_Control_Flag == 1) { |
Lightvalve | 66:a8e6799dbce3 | 414 | float output1[32] = { 0.0f }; |
Lightvalve | 66:a8e6799dbce3 | 415 | float output2[32] = { 0.0f }; |
Lightvalve | 66:a8e6799dbce3 | 416 | float output3[32] = { 0.0f }; |
Lightvalve | 66:a8e6799dbce3 | 417 | float output = 0.0f; |
Lightvalve | 65:a2d7c63419c2 | 418 | |
Lightvalve | 66:a8e6799dbce3 | 419 | for (int index2 = 0; index2 < 32; index2++) { |
Lightvalve | 68:328e1be06f5d | 420 | for (int index1 = 0; index1 < num_input; index1++) { |
Lightvalve | 66:a8e6799dbce3 | 421 | output1[index2] = output1[index2] |
Lightvalve | 73:f80dc3970c99 | 422 | + h1[index1][index2] * input_NN[index1]; |
Lightvalve | 66:a8e6799dbce3 | 423 | } |
Lightvalve | 66:a8e6799dbce3 | 424 | output1[index2] = output1[index2] + b1[index2]; |
Lightvalve | 66:a8e6799dbce3 | 425 | if (output1[index2] < 0) { |
Lightvalve | 66:a8e6799dbce3 | 426 | output1[index2] = 0; |
Lightvalve | 66:a8e6799dbce3 | 427 | } |
Lightvalve | 66:a8e6799dbce3 | 428 | } |
Lightvalve | 65:a2d7c63419c2 | 429 | |
Lightvalve | 66:a8e6799dbce3 | 430 | for (int index2 = 0; index2 < 32; index2++) { |
Lightvalve | 66:a8e6799dbce3 | 431 | for (int index1 = 0; index1 < 32; index1++) { |
Lightvalve | 66:a8e6799dbce3 | 432 | output2[index2] = output2[index2] |
Lightvalve | 66:a8e6799dbce3 | 433 | + h2[index1][index2] * output1[index1]; |
Lightvalve | 66:a8e6799dbce3 | 434 | } |
Lightvalve | 66:a8e6799dbce3 | 435 | output2[index2] = output2[index2] + b2[index2]; |
Lightvalve | 66:a8e6799dbce3 | 436 | if (output2[index2] < 0) { |
Lightvalve | 66:a8e6799dbce3 | 437 | output2[index2] = 0; |
Lightvalve | 66:a8e6799dbce3 | 438 | } |
Lightvalve | 66:a8e6799dbce3 | 439 | } |
Lightvalve | 65:a2d7c63419c2 | 440 | |
Lightvalve | 66:a8e6799dbce3 | 441 | for (int index2 = 0; index2 < 32; index2++) { |
Lightvalve | 66:a8e6799dbce3 | 442 | for (int index1 = 0; index1 < 32; index1++) { |
Lightvalve | 66:a8e6799dbce3 | 443 | output3[index2] = output3[index2] |
Lightvalve | 66:a8e6799dbce3 | 444 | + h3[index1][index2] * output2[index1]; |
Lightvalve | 66:a8e6799dbce3 | 445 | } |
Lightvalve | 66:a8e6799dbce3 | 446 | output3[index2] = output3[index2] + b3[index2]; |
Lightvalve | 66:a8e6799dbce3 | 447 | if (output3[index2] < 0) { |
Lightvalve | 66:a8e6799dbce3 | 448 | output3[index2] = 0; |
Lightvalve | 66:a8e6799dbce3 | 449 | } |
Lightvalve | 65:a2d7c63419c2 | 450 | } |
Lightvalve | 66:a8e6799dbce3 | 451 | |
Lightvalve | 66:a8e6799dbce3 | 452 | for (int index2 = 0; index2 < 1; index2++) { |
Lightvalve | 66:a8e6799dbce3 | 453 | for (int index1 = 0; index1 < 32; index1++) { |
Lightvalve | 73:f80dc3970c99 | 454 | output = output + hout[index1] * output3[index1]; |
Lightvalve | 66:a8e6799dbce3 | 455 | } |
Lightvalve | 66:a8e6799dbce3 | 456 | output = output + bout[index2]; |
Lightvalve | 73:f80dc3970c99 | 457 | |
Lightvalve | 66:a8e6799dbce3 | 458 | } |
Lightvalve | 73:f80dc3970c99 | 459 | output = 1.0f/(1.0f+exp(-output)); |
Lightvalve | 68:328e1be06f5d | 460 | output = output * 20000.0f - 10000.0f; |
Lightvalve | 66:a8e6799dbce3 | 461 | if(output>=0) { |
Lightvalve | 66:a8e6799dbce3 | 462 | valve_pos.ref = output*0.0001f*((double)VALVE_MAX_POS - (double) VALVE_CENTER) + (double) VALVE_CENTER; |
Lightvalve | 66:a8e6799dbce3 | 463 | } else { |
Lightvalve | 66:a8e6799dbce3 | 464 | valve_pos.ref = -output*0.0001f*((double)VALVE_MIN_POS - (double) VALVE_CENTER) + (double) VALVE_CENTER; |
Lightvalve | 65:a2d7c63419c2 | 465 | } |
Lightvalve | 69:3995ffeaa786 | 466 | |
Lightvalve | 69:3995ffeaa786 | 467 | if(LED==1) { |
Lightvalve | 69:3995ffeaa786 | 468 | LED=0; |
Lightvalve | 69:3995ffeaa786 | 469 | } else |
Lightvalve | 69:3995ffeaa786 | 470 | LED = 1; |
Lightvalve | 69:3995ffeaa786 | 471 | |
Lightvalve | 65:a2d7c63419c2 | 472 | } |
Lightvalve | 62:b5452adfb2cd | 473 | |
Lightvalve | 69:3995ffeaa786 | 474 | |
Lightvalve | 66:a8e6799dbce3 | 475 | |
GiJeongKim | 0:51c43836c1d7 | 476 | } |
jobuuu | 1:e04e563be5ce | 477 | } |
jobuuu | 1:e04e563be5ce | 478 | |
Lightvalve | 33:91b17819ec30 | 479 | float DDV_JOINT_POS_FF(float REF_JOINT_VEL) |
Lightvalve | 14:8e7590227d22 | 480 | { |
Lightvalve | 14:8e7590227d22 | 481 | |
Lightvalve | 13:747daba9cf59 | 482 | int i = 0; |
Lightvalve | 48:889798ff9329 | 483 | float Ref_Valve_Pos_FF = 0.0f; |
Lightvalve | 14:8e7590227d22 | 484 | for(i=0; i<VALVE_POS_NUM; i++) { |
Lightvalve | 14:8e7590227d22 | 485 | 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 | 486 | if(i==0) { |
Lightvalve | 50:3c630b5eba9f | 487 | if(JOINT_VEL[i+1] == JOINT_VEL[i]) { |
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/(JOINT_VEL[i+1] - JOINT_VEL[i]) * (REF_JOINT_VEL - JOINT_VEL[i])) + (float) VALVE_CENTER; |
Lightvalve | 38:118df027d851 | 491 | } |
Lightvalve | 14:8e7590227d22 | 492 | } else { |
Lightvalve | 50:3c630b5eba9f | 493 | if(JOINT_VEL[i+1] == JOINT_VEL[i-1]) { |
Lightvalve | 57:f4819de54e7a | 494 | Ref_Valve_Pos_FF = (float) VALVE_CENTER; |
Lightvalve | 50:3c630b5eba9f | 495 | } else { |
Lightvalve | 57:f4819de54e7a | 496 | 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 | 497 | } |
Lightvalve | 13:747daba9cf59 | 498 | } |
Lightvalve | 13:747daba9cf59 | 499 | break; |
Lightvalve | 13:747daba9cf59 | 500 | } |
Lightvalve | 13:747daba9cf59 | 501 | } |
Lightvalve | 14:8e7590227d22 | 502 | if(REF_JOINT_VEL > max(JOINT_VEL[VALVE_POS_NUM-1], JOINT_VEL[VALVE_POS_NUM-2])) { |
Lightvalve | 33:91b17819ec30 | 503 | Ref_Valve_Pos_FF = (float) VALVE_MAX_POS; |
Lightvalve | 14:8e7590227d22 | 504 | } else if(REF_JOINT_VEL < min(JOINT_VEL[VALVE_POS_NUM-1], JOINT_VEL[VALVE_POS_NUM-2])) { |
Lightvalve | 33:91b17819ec30 | 505 | Ref_Valve_Pos_FF = (float) VALVE_MIN_POS; |
Lightvalve | 13:747daba9cf59 | 506 | } |
Lightvalve | 36:a46e63505ed8 | 507 | |
Lightvalve | 57:f4819de54e7a | 508 | Ref_Valve_Pos_FF = (float) VELOCITY_COMP_GAIN * 0.01f * (float) (Ref_Valve_Pos_FF - (float) VALVE_CENTER); |
Lightvalve | 13:747daba9cf59 | 509 | return Ref_Valve_Pos_FF; |
Lightvalve | 50:3c630b5eba9f | 510 | |
Lightvalve | 13:747daba9cf59 | 511 | } |
jobuuu | 6:df07d3491e3a | 512 | |
jobuuu | 6:df07d3491e3a | 513 | |
Lightvalve | 30:8d561f16383b | 514 | void VALVE_POS_CONTROL(float REF_VALVE_POS) |
Lightvalve | 14:8e7590227d22 | 515 | { |
Lightvalve | 13:747daba9cf59 | 516 | int i = 0; |
Lightvalve | 13:747daba9cf59 | 517 | |
Lightvalve | 38:118df027d851 | 518 | if(REF_VALVE_POS > VALVE_MAX_POS) { |
Lightvalve | 38:118df027d851 | 519 | REF_VALVE_POS = VALVE_MAX_POS; |
Lightvalve | 38:118df027d851 | 520 | } else if(REF_VALVE_POS < VALVE_MIN_POS) { |
Lightvalve | 38:118df027d851 | 521 | REF_VALVE_POS = VALVE_MIN_POS; |
Lightvalve | 38:118df027d851 | 522 | } |
Lightvalve | 38:118df027d851 | 523 | |
Lightvalve | 13:747daba9cf59 | 524 | valve_pos_err = REF_VALVE_POS - value; |
Lightvalve | 13:747daba9cf59 | 525 | valve_pos_err_diff = valve_pos_err - valve_pos_err_old; |
Lightvalve | 13:747daba9cf59 | 526 | valve_pos_err_old = valve_pos_err; |
Lightvalve | 13:747daba9cf59 | 527 | valve_pos_err_sum += valve_pos_err; |
Lightvalve | 13:747daba9cf59 | 528 | if (valve_pos_err_sum > 1000) valve_pos_err_sum = 1000; |
Lightvalve | 13:747daba9cf59 | 529 | if (valve_pos_err_sum<-1000) valve_pos_err_sum = -1000; |
Lightvalve | 13:747daba9cf59 | 530 | |
Lightvalve | 13:747daba9cf59 | 531 | 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 | 532 | |
Lightvalve | 18:b8adf1582ea3 | 533 | for(i=0; i<24; i++) { |
Lightvalve | 14:8e7590227d22 | 534 | 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 | 535 | if(i==0) { |
Lightvalve | 48:889798ff9329 | 536 | 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 | 537 | } else { |
Lightvalve | 48:889798ff9329 | 538 | 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 | 539 | } |
Lightvalve | 13:747daba9cf59 | 540 | break; |
Lightvalve | 13:747daba9cf59 | 541 | } |
Lightvalve | 13:747daba9cf59 | 542 | } |
Lightvalve | 59:f308b1656d9c | 543 | Vout.ref = VALVE_PWM_RAW_FF + VALVE_PWM_RAW_FB; |
Lightvalve | 13:747daba9cf59 | 544 | } |
Lightvalve | 13:747daba9cf59 | 545 | |
Lightvalve | 14:8e7590227d22 | 546 | #define LT_MAX_IDX 57 |
Lightvalve | 30:8d561f16383b | 547 | 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 | 548 | -19.0f, -18.0f, -17.0f, -16.0f, -15.0f, -14.0f, -13.0f, -12.0f, -11.0f, -10.0f, |
Lightvalve | 34:bb2ca2fc2a8e | 549 | -9.0f, -8.0f, -7.0f, -6.0f, -5.0f, -4.0f, -3.0f, -2.0f, -1.0f, 0.0f, |
Lightvalve | 34:bb2ca2fc2a8e | 550 | 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, |
Lightvalve | 34:bb2ca2fc2a8e | 551 | 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, |
Lightvalve | 34:bb2ca2fc2a8e | 552 | 25.0f, 30.0f, 35.0f, 40.0f, 50.0f, 60.0f, 80.0f, 100.0f |
Lightvalve | 34:bb2ca2fc2a8e | 553 | }; // duty |
Lightvalve | 67:c2812cf26c38 | 554 | 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 | 555 | -150.0f, -145.0f, -145.0f, -145.0f, -135.0f, -135.0f, -135.0f, -127.5f, -127.5f, -115.0f, |
Lightvalve | 67:c2812cf26c38 | 556 | -115.0f, -115.0F, -100.0f, -100.0f, -100.0f, -60.0f, -60.0f, -10.0f, -5.0f, 0.0f, |
Lightvalve | 67:c2812cf26c38 | 557 | 7.5f, 14.0f, 14.0f, 14.0f, 42.5f, 42.5f, 42.5f, 80.0f, 80.0f, 105.0f, |
Lightvalve | 67:c2812cf26c38 | 558 | 105.0f, 105.0f, 120.0f, 120.0f, 120.0f, 131.0f, 131.0f, 140.0f, 140.0f, 140.0f, |
Lightvalve | 67:c2812cf26c38 | 559 | 155.0f, 160.0f, 170.0f, 174.0f, 182.0f, 191.0f, 212.0f, 230.0f |
Lightvalve | 34:bb2ca2fc2a8e | 560 | }; // mV |
Lightvalve | 13:747daba9cf59 | 561 | |
Lightvalve | 30:8d561f16383b | 562 | float PWM_duty_byLT(float Ref_V) |
Lightvalve | 14:8e7590227d22 | 563 | { |
Lightvalve | 30:8d561f16383b | 564 | float PWM_duty = 0.0f; |
Lightvalve | 13:747daba9cf59 | 565 | if(Ref_V<LT_Voltage_Output[0]) { |
Lightvalve | 30:8d561f16383b | 566 | PWM_duty = (Ref_V-LT_Voltage_Output[0])/1.5f+LT_PWM_duty[0]; |
Lightvalve | 13:747daba9cf59 | 567 | } else if (Ref_V>=LT_Voltage_Output[LT_MAX_IDX-1]) { |
Lightvalve | 30:8d561f16383b | 568 | PWM_duty = (Ref_V-LT_Voltage_Output[LT_MAX_IDX-1])/1.5f+LT_PWM_duty[LT_MAX_IDX-1]; |
Lightvalve | 13:747daba9cf59 | 569 | } else { |
Lightvalve | 13:747daba9cf59 | 570 | int idx = 0; |
Lightvalve | 13:747daba9cf59 | 571 | for(idx=0; idx<LT_MAX_IDX-1; idx++) { |
Lightvalve | 30:8d561f16383b | 572 | float ini_x = LT_Voltage_Output[idx]; |
Lightvalve | 30:8d561f16383b | 573 | float fin_x = LT_Voltage_Output[idx+1]; |
Lightvalve | 30:8d561f16383b | 574 | float ini_y = LT_PWM_duty[idx]; |
Lightvalve | 30:8d561f16383b | 575 | float fin_y = LT_PWM_duty[idx+1]; |
Lightvalve | 13:747daba9cf59 | 576 | if(Ref_V>=ini_x && Ref_V<fin_x) { |
Lightvalve | 13:747daba9cf59 | 577 | PWM_duty = (fin_y-ini_y)/(fin_x-ini_x)*(Ref_V-ini_x) + ini_y; |
Lightvalve | 13:747daba9cf59 | 578 | break; |
Lightvalve | 13:747daba9cf59 | 579 | } |
Lightvalve | 13:747daba9cf59 | 580 | } |
Lightvalve | 13:747daba9cf59 | 581 | } |
Lightvalve | 14:8e7590227d22 | 582 | |
Lightvalve | 13:747daba9cf59 | 583 | return PWM_duty; |
Lightvalve | 13:747daba9cf59 | 584 | } |
jobuuu | 6:df07d3491e3a | 585 | |
Lightvalve | 57:f4819de54e7a | 586 | |
Lightvalve | 57:f4819de54e7a | 587 | |
Lightvalve | 57:f4819de54e7a | 588 | |
Lightvalve | 57:f4819de54e7a | 589 | |
jobuuu | 2:a1c0a37df760 | 590 | /******************************************************************************* |
jobuuu | 2:a1c0a37df760 | 591 | TIMER INTERRUPT |
jobuuu | 2:a1c0a37df760 | 592 | *******************************************************************************/ |
jobuuu | 2:a1c0a37df760 | 593 | |
Lightvalve | 51:b46bed7fec80 | 594 | float FREQ_TMR4 = (float)FREQ_20k; |
Lightvalve | 51:b46bed7fec80 | 595 | float DT_TMR4 = (float)DT_20k; |
Lightvalve | 57:f4819de54e7a | 596 | long CNT_TMR4 = 0; |
Lightvalve | 57:f4819de54e7a | 597 | int TMR4_FREQ_10k = (int)FREQ_10k; |
jobuuu | 1:e04e563be5ce | 598 | extern "C" void TIM4_IRQHandler(void) |
jobuuu | 1:e04e563be5ce | 599 | { |
Lightvalve | 19:23b7c1ad8683 | 600 | if (TIM4->SR & TIM_SR_UIF ) { |
Lightvalve | 21:e5f1a43ea6f9 | 601 | |
Lightvalve | 21:e5f1a43ea6f9 | 602 | /******************************************************* |
Lightvalve | 21:e5f1a43ea6f9 | 603 | *** Sensor Read & Data Handling |
Lightvalve | 21:e5f1a43ea6f9 | 604 | ********************************************************/ |
Lightvalve | 13:747daba9cf59 | 605 | |
Lightvalve | 57:f4819de54e7a | 606 | //Encoder |
Lightvalve | 57:f4819de54e7a | 607 | if (CNT_TMR4 % (int) ((int) FREQ_TMR4/TMR4_FREQ_10k) == 0) { |
Lightvalve | 57:f4819de54e7a | 608 | ENC_UPDATE(); |
Lightvalve | 57:f4819de54e7a | 609 | } |
Lightvalve | 61:bc8c8270f0ab | 610 | |
Lightvalve | 61:bc8c8270f0ab | 611 | ADC1->CR2 |= 0x40000000; |
Lightvalve | 58:2eade98630e2 | 612 | if (SENSING_MODE == 0) { |
Lightvalve | 58:2eade98630e2 | 613 | // Torque Sensing (0~210)bar ============================================= |
Lightvalve | 58:2eade98630e2 | 614 | float pres_A_new = (((float) ADC1->DR) - 2047.5f); |
Lightvalve | 58:2eade98630e2 | 615 | double alpha_update_ft = 1.0f / (1.0f + FREQ_TMR4 / (2.0f * 3.14f * 100.0f)); // f_cutoff : 200Hz |
Lightvalve | 58:2eade98630e2 | 616 | pres_A.sen = (1.0f - alpha_update_ft) * pres_A.sen + alpha_update_ft * pres_A_new; |
Lightvalve | 67:c2812cf26c38 | 617 | torq.sen = -pres_A.sen / TORQUE_SENSOR_PULSE_PER_TORQUE; |
Lightvalve | 67:c2812cf26c38 | 618 | |
Lightvalve | 67:c2812cf26c38 | 619 | |
Lightvalve | 67:c2812cf26c38 | 620 | // float alpha_update_pres_A = 1.0f/(1.0f + FREQ_TMR4/(2.0f*3.14f*100.0f)); |
Lightvalve | 67:c2812cf26c38 | 621 | //// float pres_A_new = ((float)ADC1->DR - PRES_A_NULL) / PRES_SENSOR_A_PULSE_PER_BAR; |
Lightvalve | 67:c2812cf26c38 | 622 | // float pres_A_new = ((float)ADC1->DR); |
Lightvalve | 67:c2812cf26c38 | 623 | // pres_A.sen = pres_A.sen*(1.0f-alpha_update_pres_A)+pres_A_new*(alpha_update_pres_A); |
Lightvalve | 67:c2812cf26c38 | 624 | // torq.sen = - (pres_A.sen-2048.0f); //pulse -2047~2047 |
Lightvalve | 67:c2812cf26c38 | 625 | |
Lightvalve | 17:1865016ca2e7 | 626 | |
Lightvalve | 58:2eade98630e2 | 627 | } else if (SENSING_MODE == 1) { |
Lightvalve | 58:2eade98630e2 | 628 | // Pressure Sensing (0~210)bar ============================================= |
Lightvalve | 58:2eade98630e2 | 629 | float pres_A_new = (((float)ADC1->DR) - PRES_A_NULL); |
Lightvalve | 58:2eade98630e2 | 630 | float pres_B_new = (((float)ADC2->DR) - PRES_B_NULL); |
Lightvalve | 58:2eade98630e2 | 631 | double alpha_update_pres = 1.0f / (1.0f + FREQ_TMR4 / (2.0f * 3.14f * 200.0f)); // f_cutoff : 500Hz |
Lightvalve | 58:2eade98630e2 | 632 | pres_A.sen = (1.0f - alpha_update_pres) * pres_A.sen + alpha_update_pres * pres_A_new; |
Lightvalve | 58:2eade98630e2 | 633 | pres_B.sen = (1.0f - alpha_update_pres) * pres_B.sen + alpha_update_pres * pres_B_new; |
Lightvalve | 58:2eade98630e2 | 634 | CUR_PRES_A_BAR = pres_A.sen / PRES_SENSOR_A_PULSE_PER_BAR; |
Lightvalve | 58:2eade98630e2 | 635 | CUR_PRES_B_BAR = pres_B.sen / PRES_SENSOR_B_PULSE_PER_BAR; |
Lightvalve | 50:3c630b5eba9f | 636 | |
Lightvalve | 58:2eade98630e2 | 637 | if ((OPERATING_MODE & 0x01) == 0) { // Rotary Actuator |
Lightvalve | 58:2eade98630e2 | 638 | 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 | 639 | } else if ((OPERATING_MODE & 0x01) == 1) { // Linear Actuator |
Lightvalve | 58:2eade98630e2 | 640 | 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 | 641 | } |
Lightvalve | 58:2eade98630e2 | 642 | } |
Lightvalve | 61:bc8c8270f0ab | 643 | |
Lightvalve | 58:2eade98630e2 | 644 | // //Pressure sensor A |
Lightvalve | 58:2eade98630e2 | 645 | // ADC1->CR2 |= 0x40000000; // adc _ 12bit |
Lightvalve | 58:2eade98630e2 | 646 | // //while((ADC1->SR & 0b10)); |
Lightvalve | 58:2eade98630e2 | 647 | // float alpha_update_pres_A = 1.0f/(1.0f + FREQ_TMR4/(2.0f*3.14f*100.0f)); |
Lightvalve | 58:2eade98630e2 | 648 | // float pres_A_new = ((float)ADC1->DR); |
Lightvalve | 58:2eade98630e2 | 649 | // pres_A.sen = pres_A.sen*(1.0f-alpha_update_pres_A)+pres_A_new*(alpha_update_pres_A); |
Lightvalve | 58:2eade98630e2 | 650 | // 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 | 651 | // |
Lightvalve | 58:2eade98630e2 | 652 | // |
Lightvalve | 58:2eade98630e2 | 653 | // //Pressure sensor B |
Lightvalve | 58:2eade98630e2 | 654 | // float alpha_update_pres_B = 1.0f/(1.0f + FREQ_TMR4/(2.0f*3.14f*100.0f)); |
Lightvalve | 58:2eade98630e2 | 655 | // float pres_B_new = ((float)ADC2->DR); |
Lightvalve | 58:2eade98630e2 | 656 | // pres_B.sen = pres_B.sen*(1.0f-alpha_update_pres_B)+pres_B_new*(alpha_update_pres_B); |
Lightvalve | 58:2eade98630e2 | 657 | // //torq.sen = pres_A.sen * (float) PISTON_AREA_A - pres_B.sen * (float) PISTON_AREA_B; |
Lightvalve | 17:1865016ca2e7 | 658 | |
Lightvalve | 17:1865016ca2e7 | 659 | |
Lightvalve | 21:e5f1a43ea6f9 | 660 | //Current |
Lightvalve | 21:e5f1a43ea6f9 | 661 | //ADC3->CR2 |= 0x40000000; // adc _ 12bit |
Lightvalve | 25:3e6b574cab5c | 662 | //int raw_cur = ADC3->DR; |
Lightvalve | 21:e5f1a43ea6f9 | 663 | //while((ADC3->SR & 0b10)); |
Lightvalve | 51:b46bed7fec80 | 664 | float alpha_update_cur = 1.0f/(1.0f + FREQ_TMR4/(2.0f*3.14f*500.0f)); // f_cutoff : 500Hz |
Lightvalve | 30:8d561f16383b | 665 | float cur_new = ((float)ADC3->DR-2048.0f)*20.0f/4096.0f; // unit : mA |
Lightvalve | 30:8d561f16383b | 666 | cur.sen=cur.sen*(1.0f-alpha_update_cur)+cur_new*(alpha_update_cur); |
Lightvalve | 25:3e6b574cab5c | 667 | //cur.sen = raw_cur; |
Lightvalve | 58:2eade98630e2 | 668 | |
Lightvalve | 57:f4819de54e7a | 669 | CNT_TMR4++; |
Lightvalve | 21:e5f1a43ea6f9 | 670 | } |
Lightvalve | 11:82d8768d7351 | 671 | TIM4->SR = 0x0; // reset the status register |
Lightvalve | 11:82d8768d7351 | 672 | } |
Lightvalve | 19:23b7c1ad8683 | 673 | |
Lightvalve | 19:23b7c1ad8683 | 674 | |
Lightvalve | 18:b8adf1582ea3 | 675 | int j =0; |
Lightvalve | 54:647072f5307a | 676 | float FREQ_TMR3 = (float)FREQ_5k; |
Lightvalve | 48:889798ff9329 | 677 | float DT_TMR3 = (float)DT_5k; |
Lightvalve | 45:35fa6884d0c6 | 678 | int cnt_trans = 0; |
Lightvalve | 48:889798ff9329 | 679 | double VALVE_POS_RAW_FORCE_FB_LOGGING = 0.0f; |
Lightvalve | 57:f4819de54e7a | 680 | int can_rest =0; |
Lightvalve | 48:889798ff9329 | 681 | |
Lightvalve | 11:82d8768d7351 | 682 | extern "C" void TIM3_IRQHandler(void) |
Lightvalve | 21:e5f1a43ea6f9 | 683 | { |
Lightvalve | 19:23b7c1ad8683 | 684 | if (TIM3->SR & TIM_SR_UIF ) { |
Lightvalve | 57:f4819de54e7a | 685 | |
Lightvalve | 57:f4819de54e7a | 686 | if (((OPERATING_MODE&0b110)>>1) == 0) { |
Lightvalve | 57:f4819de54e7a | 687 | K_v = 0.4f; // Moog (LPM >> mA) , 100bar |
Lightvalve | 57:f4819de54e7a | 688 | mV_PER_mA = 500.0f; // 5000mV/10mA |
Lightvalve | 57:f4819de54e7a | 689 | mV_PER_pulse = 0.5f; // 5000mV/10000pulse |
Lightvalve | 57:f4819de54e7a | 690 | mA_PER_pulse = 0.001f; // 10mA/10000pulse |
Lightvalve | 57:f4819de54e7a | 691 | } else if (((OPERATING_MODE&0b110)>>1) == 1) { |
Lightvalve | 57:f4819de54e7a | 692 | K_v = 0.5f; // KNR (LPM >> mA) , 100bar |
Lightvalve | 57:f4819de54e7a | 693 | mV_PER_mA = 166.6666f; // 5000mV/30mA |
Lightvalve | 57:f4819de54e7a | 694 | mV_PER_pulse = 0.5f; // 5000mV/10000pulse |
Lightvalve | 57:f4819de54e7a | 695 | mA_PER_pulse = 0.003f; // 30mA/10000pulse |
Lightvalve | 57:f4819de54e7a | 696 | } |
Lightvalve | 50:3c630b5eba9f | 697 | |
Lightvalve | 50:3c630b5eba9f | 698 | if(MODE_POS_FT_TRANS == 1) { |
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 = 2; |
Lightvalve | 50:3c630b5eba9f | 704 | } else if(MODE_POS_FT_TRANS == 3) { |
Lightvalve | 48:889798ff9329 | 705 | alpha_trans = (float)(1.0f + cos(3.141592f * (float)cnt_trans * DT_TMR3 /3.0f))/2.0f; |
Lightvalve | 45:35fa6884d0c6 | 706 | cnt_trans++; |
Lightvalve | 46:2694daea349b | 707 | torq.err_sum = 0; |
Lightvalve | 48:889798ff9329 | 708 | if((float) cnt_trans * DT_TMR3 > 3.0f ) |
Lightvalve | 45:35fa6884d0c6 | 709 | MODE_POS_FT_TRANS = 0; |
Lightvalve | 50:3c630b5eba9f | 710 | } else if(MODE_POS_FT_TRANS == 2) { |
Lightvalve | 58:2eade98630e2 | 711 | alpha_trans = 1.0f; |
Lightvalve | 45:35fa6884d0c6 | 712 | cnt_trans = 0; |
Lightvalve | 50:3c630b5eba9f | 713 | } else { |
Lightvalve | 58:2eade98630e2 | 714 | alpha_trans = 0.0f; |
Lightvalve | 45:35fa6884d0c6 | 715 | cnt_trans = 0; |
Lightvalve | 45:35fa6884d0c6 | 716 | } |
Lightvalve | 45:35fa6884d0c6 | 717 | |
Lightvalve | 50:3c630b5eba9f | 718 | |
Lightvalve | 57:f4819de54e7a | 719 | int UTILITY_MODE = 0; |
Lightvalve | 57:f4819de54e7a | 720 | int CONTROL_MODE = 0; |
Lightvalve | 58:2eade98630e2 | 721 | |
Lightvalve | 57:f4819de54e7a | 722 | if (CONTROL_UTILITY_MODE >= 20 || CONTROL_UTILITY_MODE == 0) { |
Lightvalve | 57:f4819de54e7a | 723 | UTILITY_MODE = CONTROL_UTILITY_MODE; |
Lightvalve | 57:f4819de54e7a | 724 | CONTROL_MODE = MODE_NO_ACT; |
Lightvalve | 57:f4819de54e7a | 725 | } else { |
Lightvalve | 57:f4819de54e7a | 726 | CONTROL_MODE = CONTROL_UTILITY_MODE; |
Lightvalve | 57:f4819de54e7a | 727 | UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 57:f4819de54e7a | 728 | } |
Lightvalve | 56:6f50d9d3bfee | 729 | |
Lightvalve | 56:6f50d9d3bfee | 730 | |
Lightvalve | 56:6f50d9d3bfee | 731 | |
Lightvalve | 57:f4819de54e7a | 732 | // UTILITY MODE ------------------------------------------------------------ |
Lightvalve | 56:6f50d9d3bfee | 733 | |
Lightvalve | 57:f4819de54e7a | 734 | switch (UTILITY_MODE) { |
Lightvalve | 57:f4819de54e7a | 735 | case MODE_NO_ACT: { |
Lightvalve | 13:747daba9cf59 | 736 | break; |
Lightvalve | 13:747daba9cf59 | 737 | } |
Lightvalve | 14:8e7590227d22 | 738 | |
Lightvalve | 14:8e7590227d22 | 739 | case MODE_TORQUE_SENSOR_NULLING: { |
Lightvalve | 13:747daba9cf59 | 740 | // DAC Voltage reference set |
Lightvalve | 14:8e7590227d22 | 741 | if (TMR3_COUNT_TORQUE_NULL < TMR_FREQ_5k * 2) { |
Lightvalve | 15:bd0d12728506 | 742 | CUR_TORQUE_sum += torq.sen; |
Lightvalve | 19:23b7c1ad8683 | 743 | |
Lightvalve | 14:8e7590227d22 | 744 | if (TMR3_COUNT_TORQUE_NULL % 10 == 0) { |
Lightvalve | 30:8d561f16383b | 745 | CUR_TORQUE_mean = CUR_TORQUE_sum / 10.0f; |
Lightvalve | 13:747daba9cf59 | 746 | CUR_TORQUE_sum = 0; |
Lightvalve | 14:8e7590227d22 | 747 | |
Lightvalve | 84:c355d3e52bf1 | 748 | TORQUE_VREF += 0.000003f * (0.0f - CUR_TORQUE_mean); |
Lightvalve | 19:23b7c1ad8683 | 749 | |
Lightvalve | 30:8d561f16383b | 750 | if (TORQUE_VREF > 3.3f) TORQUE_VREF = 3.3f; |
Lightvalve | 59:f308b1656d9c | 751 | if (TORQUE_VREF < 0.0f) TORQUE_VREF = 0.0f; |
Lightvalve | 50:3c630b5eba9f | 752 | |
Lightvalve | 16:903b5a4433b4 | 753 | //spi_eeprom_write(RID_TORQUE_SENSOR_VREF, (int16_t) (TORQUE_VREF * 1000.0)); |
Lightvalve | 30:8d561f16383b | 754 | dac_1 = TORQUE_VREF / 3.3f; |
Lightvalve | 13:747daba9cf59 | 755 | } |
Lightvalve | 13:747daba9cf59 | 756 | } else { |
Lightvalve | 58:2eade98630e2 | 757 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 14:8e7590227d22 | 758 | TMR3_COUNT_TORQUE_NULL = 0; |
Lightvalve | 13:747daba9cf59 | 759 | CUR_TORQUE_sum = 0; |
Lightvalve | 13:747daba9cf59 | 760 | CUR_TORQUE_mean = 0; |
Lightvalve | 19:23b7c1ad8683 | 761 | |
Lightvalve | 16:903b5a4433b4 | 762 | ROM_RESET_DATA(); |
Lightvalve | 19:23b7c1ad8683 | 763 | |
Lightvalve | 30:8d561f16383b | 764 | dac_1 = TORQUE_VREF / 3.3f; |
Lightvalve | 14:8e7590227d22 | 765 | |
Lightvalve | 13:747daba9cf59 | 766 | } |
Lightvalve | 14:8e7590227d22 | 767 | TMR3_COUNT_TORQUE_NULL++; |
Lightvalve | 13:747daba9cf59 | 768 | break; |
Lightvalve | 19:23b7c1ad8683 | 769 | } |
Lightvalve | 14:8e7590227d22 | 770 | |
Lightvalve | 50:3c630b5eba9f | 771 | // case MODE_VALVE_NULLING_AND_DEADZONE_SETTING: { |
Lightvalve | 50:3c630b5eba9f | 772 | // if (TMR3_COUNT_DEADZONE == 0) { |
Lightvalve | 50:3c630b5eba9f | 773 | // if (pos_plus_end == pos_minus_end) need_enc_init = true; |
Lightvalve | 50:3c630b5eba9f | 774 | // else temp_time = 0; |
Lightvalve | 50:3c630b5eba9f | 775 | // } |
Lightvalve | 50:3c630b5eba9f | 776 | // if (need_enc_init) { |
Lightvalve | 50:3c630b5eba9f | 777 | // if (TMR3_COUNT_DEADZONE < (int) (0.5f * (float) TMR_FREQ_5k)) { |
Lightvalve | 50:3c630b5eba9f | 778 | // V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 779 | // pos_plus_end = pos.sen; |
Lightvalve | 50:3c630b5eba9f | 780 | // } else if (TMR3_COUNT_DEADZONE < TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 781 | // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 782 | // pos_minus_end = pos.sen; |
Lightvalve | 50:3c630b5eba9f | 783 | // } else if (TMR3_COUNT_DEADZONE == TMR_FREQ_5k) need_enc_init = false; |
Lightvalve | 50:3c630b5eba9f | 784 | // temp_time = TMR_FREQ_5k; |
Lightvalve | 50:3c630b5eba9f | 785 | // } |
Lightvalve | 50:3c630b5eba9f | 786 | // |
Lightvalve | 50:3c630b5eba9f | 787 | // if (temp_time <= TMR3_COUNT_DEADZONE && TMR3_COUNT_DEADZONE < (temp_time + TMR_FREQ_5k)) { |
Lightvalve | 50:3c630b5eba9f | 788 | // 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 | 789 | // VALVE_CENTER = VALVE_DEADZONE_PLUS = VALVE_DEADZONE_MINUS = 0; |
Lightvalve | 50:3c630b5eba9f | 790 | // |
Lightvalve | 50:3c630b5eba9f | 791 | // } else if (temp_time <= TMR3_COUNT_DEADZONE && TMR3_COUNT_DEADZONE < (temp_time + (int) (1.9f * (float) TMR_FREQ_5k))) { |
Lightvalve | 50:3c630b5eba9f | 792 | // V_out = 0; |
Lightvalve | 50:3c630b5eba9f | 793 | // CUR_VELOCITY_sum += CUR_VELOCITY; |
Lightvalve | 50:3c630b5eba9f | 794 | // } else if (TMR3_COUNT_DEADZONE == (temp_time + 2 * TMR_FREQ_5k)) { |
Lightvalve | 50:3c630b5eba9f | 795 | // if (CUR_VELOCITY_sum == 0) DZ_dir = 1; |
Lightvalve | 50:3c630b5eba9f | 796 | // else if (CUR_VELOCITY_sum > 0) DZ_dir = 1; |
Lightvalve | 50:3c630b5eba9f | 797 | // else if (CUR_VELOCITY_sum < 0) DZ_dir = -1; |
Lightvalve | 50:3c630b5eba9f | 798 | // else DZ_temp_cnt2 = DZ_end; |
Lightvalve | 50:3c630b5eba9f | 799 | // CUR_VELOCITY_sum = 0; |
Lightvalve | 50:3c630b5eba9f | 800 | // } else if (TMR3_COUNT_DEADZONE > (temp_time + 2 * TMR_FREQ_5k)) { |
Lightvalve | 50:3c630b5eba9f | 801 | // if (TMR3_COUNT_DEADZONE > (temp_time + 10 * TMR_FREQ_5k)) DZ_temp_cnt2 = DZ_end; |
Lightvalve | 50:3c630b5eba9f | 802 | // |
Lightvalve | 50:3c630b5eba9f | 803 | // // Position of Dead Zone |
Lightvalve | 50:3c630b5eba9f | 804 | // // (CUR_VELOCITY < 0) (CUR_VELOCITY == 0) (CUR_VELOCITY > 0) |
Lightvalve | 50:3c630b5eba9f | 805 | // // | / | / |/ |
Lightvalve | 50:3c630b5eba9f | 806 | // // | ______/ ___|___/ ______/| |
Lightvalve | 50:3c630b5eba9f | 807 | // // |/ / | / | |
Lightvalve | 50:3c630b5eba9f | 808 | // // /| / | / | |
Lightvalve | 50:3c630b5eba9f | 809 | // // 0V 0V 0V |
Lightvalve | 50:3c630b5eba9f | 810 | // |
Lightvalve | 50:3c630b5eba9f | 811 | // if (DZ_temp_cnt2 < DZ_end) { |
Lightvalve | 50:3c630b5eba9f | 812 | // if (TMR3_COUNT_DEADZONE % 20 != 0) { |
Lightvalve | 50:3c630b5eba9f | 813 | // CUR_VELOCITY_sum += CUR_VELOCITY; |
Lightvalve | 50:3c630b5eba9f | 814 | // } else { |
Lightvalve | 50:3c630b5eba9f | 815 | // V_out -= DZ_dir; |
Lightvalve | 50:3c630b5eba9f | 816 | // if (CUR_VELOCITY_sum * DZ_dir < 0) DZ_temp_cnt++; |
Lightvalve | 50:3c630b5eba9f | 817 | // CUR_VELOCITY_sum = 0; |
Lightvalve | 50:3c630b5eba9f | 818 | // } |
Lightvalve | 50:3c630b5eba9f | 819 | // if (DZ_temp_cnt == 5) { |
Lightvalve | 50:3c630b5eba9f | 820 | // if (DZ_dir >= 0) VALVE_DEADZONE_MINUS = (int16_t) V_out; |
Lightvalve | 50:3c630b5eba9f | 821 | // else VALVE_DEADZONE_PLUS = (int16_t) V_out; |
Lightvalve | 50:3c630b5eba9f | 822 | // DZ_dir = -DZ_dir; |
Lightvalve | 50:3c630b5eba9f | 823 | // DZ_temp_cnt = 0; |
Lightvalve | 50:3c630b5eba9f | 824 | // DZ_temp_cnt2++; |
Lightvalve | 50:3c630b5eba9f | 825 | // } |
Lightvalve | 50:3c630b5eba9f | 826 | // } else { |
Lightvalve | 50:3c630b5eba9f | 827 | // TMR3_COUNT_DEADZONE = -1; |
Lightvalve | 50:3c630b5eba9f | 828 | // VALVE_CENTER = VALVE_DEADZONE_PLUS / 2 + VALVE_DEADZONE_MINUS / 2; |
Lightvalve | 50:3c630b5eba9f | 829 | // if (VALVE_DEADZONE_PLUS < VALVE_DEADZONE_MINUS) { |
Lightvalve | 50:3c630b5eba9f | 830 | // VALVE_DEADZONE_PLUS = VALVE_CENTER; |
Lightvalve | 50:3c630b5eba9f | 831 | // VALVE_DEADZONE_MINUS = VALVE_CENTER; |
Lightvalve | 50:3c630b5eba9f | 832 | // } |
Lightvalve | 50:3c630b5eba9f | 833 | // V_out = 0; |
Lightvalve | 50:3c630b5eba9f | 834 | // |
Lightvalve | 50:3c630b5eba9f | 835 | // ROM_RESET_DATA(); |
Lightvalve | 50:3c630b5eba9f | 836 | // |
Lightvalve | 50:3c630b5eba9f | 837 | // //spi_eeprom_write(RID_VALVE_DEADZONE_PLUS, VALVE_DEADZONE_PLUS); |
Lightvalve | 50:3c630b5eba9f | 838 | // //spi_eeprom_write(RID_VALVE_DEADZONE_MINUS, VALVE_DEADZONE_MINUS); |
Lightvalve | 50:3c630b5eba9f | 839 | // |
Lightvalve | 50:3c630b5eba9f | 840 | // CONTROL_MODE = MODE_NO_ACT; |
Lightvalve | 50:3c630b5eba9f | 841 | // DZ_temp_cnt2 = 0; |
Lightvalve | 50:3c630b5eba9f | 842 | // } |
Lightvalve | 50:3c630b5eba9f | 843 | // } |
Lightvalve | 50:3c630b5eba9f | 844 | // TMR3_COUNT_DEADZONE++; |
Lightvalve | 50:3c630b5eba9f | 845 | // break; |
Lightvalve | 50:3c630b5eba9f | 846 | // } |
Lightvalve | 14:8e7590227d22 | 847 | |
Lightvalve | 14:8e7590227d22 | 848 | case MODE_FIND_HOME: { |
Lightvalve | 29:69f3f5445d6d | 849 | if (FINDHOME_STAGE == FINDHOME_INIT) { |
Lightvalve | 14:8e7590227d22 | 850 | cnt_findhome = 0; |
Lightvalve | 14:8e7590227d22 | 851 | cnt_vel_findhome = 0; |
Lightvalve | 14:8e7590227d22 | 852 | //REFERENCE_MODE = MODE_REF_NO_ACT; // Stop taking reference data from PODO |
Lightvalve | 59:f308b1656d9c | 853 | pos.ref = pos.sen; |
Lightvalve | 59:f308b1656d9c | 854 | vel.ref = 0.0f; |
Lightvalve | 29:69f3f5445d6d | 855 | FINDHOME_STAGE = FINDHOME_GOTOLIMIT; |
Lightvalve | 29:69f3f5445d6d | 856 | } else if (FINDHOME_STAGE == FINDHOME_GOTOLIMIT) { |
Lightvalve | 67:c2812cf26c38 | 857 | int cnt_check_enc = (TMR_FREQ_5k/20); |
Lightvalve | 29:69f3f5445d6d | 858 | if(cnt_findhome%cnt_check_enc == 0) { |
Lightvalve | 29:69f3f5445d6d | 859 | FINDHOME_POSITION = pos.sen; |
Lightvalve | 29:69f3f5445d6d | 860 | FINDHOME_VELOCITY = FINDHOME_POSITION - FINDHOME_POSITION_OLD; |
Lightvalve | 29:69f3f5445d6d | 861 | FINDHOME_POSITION_OLD = FINDHOME_POSITION; |
Lightvalve | 29:69f3f5445d6d | 862 | } |
Lightvalve | 29:69f3f5445d6d | 863 | cnt_findhome++; |
Lightvalve | 14:8e7590227d22 | 864 | |
Lightvalve | 29:69f3f5445d6d | 865 | if (abs(FINDHOME_VELOCITY) <= 1) { |
Lightvalve | 29:69f3f5445d6d | 866 | cnt_vel_findhome = cnt_vel_findhome + 1; |
Lightvalve | 29:69f3f5445d6d | 867 | } else { |
Lightvalve | 29:69f3f5445d6d | 868 | cnt_vel_findhome = 0; |
Lightvalve | 29:69f3f5445d6d | 869 | } |
Lightvalve | 19:23b7c1ad8683 | 870 | |
Lightvalve | 57:f4819de54e7a | 871 | if ((cnt_vel_findhome < 3*TMR_FREQ_5k) && cnt_findhome < 10*TMR_FREQ_5k) { // wait for 3sec |
Lightvalve | 29:69f3f5445d6d | 872 | //REFERENCE_MODE = MODE_REF_NO_ACT; |
Lightvalve | 67:c2812cf26c38 | 873 | if (HOMEPOS_OFFSET > 0) pos.ref = pos.ref + 12.0f; |
Lightvalve | 67:c2812cf26c38 | 874 | else pos.ref = pos.ref - 12.0f; |
Lightvalve | 61:bc8c8270f0ab | 875 | |
Lightvalve | 59:f308b1656d9c | 876 | // pos.err = pos.ref_home_pos - pos.sen; |
Lightvalve | 59:f308b1656d9c | 877 | // float VALVE_POS_RAW_POS_FB = 0.0f; |
Lightvalve | 59:f308b1656d9c | 878 | // VALVE_POS_RAW_POS_FB = (float) P_GAIN_JOINT_POSITION * pos.err/(float) ENC_PULSE_PER_POSITION * 0.01f; |
Lightvalve | 59:f308b1656d9c | 879 | // valve_pos.ref = VALVE_POS_RAW_POS_FB + (float) VALVE_CENTER; |
Lightvalve | 59:f308b1656d9c | 880 | // VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 61:bc8c8270f0ab | 881 | |
Lightvalve | 59:f308b1656d9c | 882 | CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 59:f308b1656d9c | 883 | alpha_trans = 0.0f; |
Lightvalve | 61:bc8c8270f0ab | 884 | |
Lightvalve | 34:bb2ca2fc2a8e | 885 | |
Lightvalve | 29:69f3f5445d6d | 886 | } else { |
Lightvalve | 29:69f3f5445d6d | 887 | ENC_SET(HOMEPOS_OFFSET); |
Lightvalve | 67:c2812cf26c38 | 888 | // ENC_SET_ZERO(); |
Lightvalve | 29:69f3f5445d6d | 889 | INIT_REF_POS = HOMEPOS_OFFSET; |
Lightvalve | 29:69f3f5445d6d | 890 | REF_POSITION = 0; |
Lightvalve | 29:69f3f5445d6d | 891 | REF_VELOCITY = 0; |
Lightvalve | 29:69f3f5445d6d | 892 | FINDHOME_POSITION = 0; |
Lightvalve | 29:69f3f5445d6d | 893 | FINDHOME_POSITION_OLD = 0; |
Lightvalve | 29:69f3f5445d6d | 894 | FINDHOME_VELOCITY = 0; |
Lightvalve | 29:69f3f5445d6d | 895 | cnt_findhome = 0; |
Lightvalve | 29:69f3f5445d6d | 896 | cnt_vel_findhome = 0; |
Lightvalve | 29:69f3f5445d6d | 897 | FINDHOME_STAGE = FINDHOME_ZEROPOSE; |
Lightvalve | 67:c2812cf26c38 | 898 | |
Lightvalve | 67:c2812cf26c38 | 899 | |
Lightvalve | 67:c2812cf26c38 | 900 | cnt_findhome = 0; |
Lightvalve | 67:c2812cf26c38 | 901 | pos.ref = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 902 | vel.ref = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 903 | pos.ref_home_pos = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 904 | vel.ref_home_pos = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 905 | //FINDHOME_STAGE = FINDHOME_INIT; |
Lightvalve | 67:c2812cf26c38 | 906 | //CONTROL_UTILITY_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 67:c2812cf26c38 | 907 | |
Lightvalve | 67:c2812cf26c38 | 908 | |
Lightvalve | 29:69f3f5445d6d | 909 | } |
Lightvalve | 29:69f3f5445d6d | 910 | } else if (FINDHOME_STAGE == FINDHOME_ZEROPOSE) { |
Lightvalve | 29:69f3f5445d6d | 911 | int T_move = 2*TMR_FREQ_5k; |
Lightvalve | 59:f308b1656d9c | 912 | 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 | 913 | //pos.ref = 0.0f; |
Lightvalve | 59:f308b1656d9c | 914 | vel.ref = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 915 | |
Lightvalve | 29:69f3f5445d6d | 916 | // input for position control |
Lightvalve | 67:c2812cf26c38 | 917 | |
Lightvalve | 67:c2812cf26c38 | 918 | // CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 67:c2812cf26c38 | 919 | alpha_trans = 0.0f; |
Lightvalve | 61:bc8c8270f0ab | 920 | |
Lightvalve | 67:c2812cf26c38 | 921 | double torq_ref = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 922 | pos.err = (pos.ref - pos.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm] |
Lightvalve | 67:c2812cf26c38 | 923 | vel.err = (0.0f - vel.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm/s] |
Lightvalve | 67:c2812cf26c38 | 924 | pos.err_sum += pos.err/(float) TMR_FREQ_5k; //[mm] |
Lightvalve | 67:c2812cf26c38 | 925 | |
Lightvalve | 67:c2812cf26c38 | 926 | if (((OPERATING_MODE&0b110)>>1) == 0 || ((OPERATING_MODE&0b110)>>1) == 1) { |
Lightvalve | 67:c2812cf26c38 | 927 | |
Lightvalve | 67:c2812cf26c38 | 928 | double I_REF_POS = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 929 | double I_REF_FORCE_FB = 0.0f; // I_REF by Force Feedback |
Lightvalve | 67:c2812cf26c38 | 930 | double I_REF_VC = 0.0f; // I_REF for velocity compensation |
Lightvalve | 67:c2812cf26c38 | 931 | |
Lightvalve | 67:c2812cf26c38 | 932 | double temp_vel_pos = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 933 | double temp_vel_torq = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 934 | double wn_Pos = 2.0f * PI * 5.0f; // f_cut : 5Hz Position Control |
Lightvalve | 67:c2812cf26c38 | 935 | |
Lightvalve | 69:3995ffeaa786 | 936 | if ((OPERATING_MODE & 0x01) == 0) { // Rotary Mode |
Lightvalve | 67:c2812cf26c38 | 937 | 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 | 938 | // L when P-gain = 100, f_cut = 10Hz L feedforward velocity |
Lightvalve | 69:3995ffeaa786 | 939 | } else if ((OPERATING_MODE & 0x01) == 1) { |
Lightvalve | 67:c2812cf26c38 | 940 | 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 | 941 | // L when P-gain = 100, f_cut = 10Hz L feedforward velocity |
Lightvalve | 67:c2812cf26c38 | 942 | } |
Lightvalve | 67:c2812cf26c38 | 943 | 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 | 944 | else I_REF_POS = temp_vel_pos * ((double) PISTON_AREA_B * 0.00006f / (K_v * sqrt(2.0f / (alpha3 + 1.0f)))); |
Lightvalve | 67:c2812cf26c38 | 945 | |
Lightvalve | 67:c2812cf26c38 | 946 | I_REF = I_REF_POS; |
Lightvalve | 67:c2812cf26c38 | 947 | |
Lightvalve | 67:c2812cf26c38 | 948 | |
Lightvalve | 67:c2812cf26c38 | 949 | |
Lightvalve | 67:c2812cf26c38 | 950 | } else { |
Lightvalve | 67:c2812cf26c38 | 951 | float VALVE_POS_RAW_FORCE_FB = 0.0f; |
Lightvalve | 67:c2812cf26c38 | 952 | 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 | 953 | |
Lightvalve | 67:c2812cf26c38 | 954 | if (VALVE_POS_RAW_FORCE_FB >= 0) { |
Lightvalve | 67:c2812cf26c38 | 955 | valve_pos.ref = VALVE_POS_RAW_FORCE_FB + VALVE_DEADZONE_PLUS; |
Lightvalve | 67:c2812cf26c38 | 956 | } else { |
Lightvalve | 67:c2812cf26c38 | 957 | valve_pos.ref = VALVE_POS_RAW_FORCE_FB + VALVE_DEADZONE_MINUS; |
Lightvalve | 67:c2812cf26c38 | 958 | } |
Lightvalve | 67:c2812cf26c38 | 959 | |
Lightvalve | 67:c2812cf26c38 | 960 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 67:c2812cf26c38 | 961 | |
Lightvalve | 67:c2812cf26c38 | 962 | V_out = (float) Vout.ref; |
Lightvalve | 67:c2812cf26c38 | 963 | |
Lightvalve | 67:c2812cf26c38 | 964 | } |
Lightvalve | 67:c2812cf26c38 | 965 | |
Lightvalve | 67:c2812cf26c38 | 966 | |
Lightvalve | 67:c2812cf26c38 | 967 | |
Lightvalve | 67:c2812cf26c38 | 968 | |
Lightvalve | 59:f308b1656d9c | 969 | // pos.err = pos.ref - (float)pos.sen; |
Lightvalve | 59:f308b1656d9c | 970 | // float VALVE_POS_RAW_POS_FB = 0.0f; |
Lightvalve | 59:f308b1656d9c | 971 | // VALVE_POS_RAW_POS_FB = (float) P_GAIN_JOINT_POSITION * 0.01f * pos.err/(float) ENC_PULSE_PER_POSITION; |
Lightvalve | 59:f308b1656d9c | 972 | // valve_pos.ref = VALVE_POS_RAW_POS_FB + (float) VALVE_CENTER; |
Lightvalve | 59:f308b1656d9c | 973 | // VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 29:69f3f5445d6d | 974 | |
Lightvalve | 29:69f3f5445d6d | 975 | cnt_findhome++; |
Lightvalve | 29:69f3f5445d6d | 976 | if (cnt_findhome >= T_move) { |
Lightvalve | 29:69f3f5445d6d | 977 | //REFERENCE_MODE = MODE_REF_DIRECT; |
Lightvalve | 29:69f3f5445d6d | 978 | cnt_findhome = 0; |
Lightvalve | 30:8d561f16383b | 979 | pos.ref = 0.0f; |
Lightvalve | 30:8d561f16383b | 980 | vel.ref = 0.0f; |
Lightvalve | 30:8d561f16383b | 981 | pos.ref_home_pos = 0.0f; |
Lightvalve | 30:8d561f16383b | 982 | vel.ref_home_pos = 0.0f; |
Lightvalve | 29:69f3f5445d6d | 983 | FINDHOME_STAGE = FINDHOME_INIT; |
Lightvalve | 57:f4819de54e7a | 984 | CONTROL_UTILITY_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 29:69f3f5445d6d | 985 | } |
Lightvalve | 13:747daba9cf59 | 986 | } |
Lightvalve | 19:23b7c1ad8683 | 987 | |
Lightvalve | 13:747daba9cf59 | 988 | break; |
Lightvalve | 13:747daba9cf59 | 989 | } |
Lightvalve | 14:8e7590227d22 | 990 | |
Lightvalve | 50:3c630b5eba9f | 991 | // case MODE_VALVE_GAIN_SETTING: { |
Lightvalve | 50:3c630b5eba9f | 992 | // if (TMR3_COUNT_FLOWRATE == 0) { |
Lightvalve | 50:3c630b5eba9f | 993 | // if (pos_plus_end == pos_minus_end) need_enc_init = true; |
Lightvalve | 50:3c630b5eba9f | 994 | // else { |
Lightvalve | 50:3c630b5eba9f | 995 | // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 996 | // temp_time = (int) (0.5f * (float) TMR_FREQ_5k); |
Lightvalve | 50:3c630b5eba9f | 997 | // } |
Lightvalve | 50:3c630b5eba9f | 998 | // } |
Lightvalve | 50:3c630b5eba9f | 999 | // if (need_enc_init) { |
Lightvalve | 50:3c630b5eba9f | 1000 | // if (TMR3_COUNT_FLOWRATE < (int) (0.5f * (float) TMR_FREQ_5k)) { |
Lightvalve | 50:3c630b5eba9f | 1001 | // V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1002 | // pos_plus_end = pos.sen; |
Lightvalve | 50:3c630b5eba9f | 1003 | // } else if (TMR3_COUNT_FLOWRATE < TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1004 | // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1005 | // pos_minus_end = pos.sen; |
Lightvalve | 50:3c630b5eba9f | 1006 | // } else if (TMR3_COUNT_FLOWRATE == TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1007 | // need_enc_init = false; |
Lightvalve | 50:3c630b5eba9f | 1008 | // check_vel_pos_init = (int) (0.9f * (float) (pos_plus_end - pos_minus_end)); |
Lightvalve | 50:3c630b5eba9f | 1009 | // check_vel_pos_fin = (int) (0.95f * (float) (pos_plus_end - pos_minus_end)); |
Lightvalve | 50:3c630b5eba9f | 1010 | // check_vel_pos_interv = check_vel_pos_fin - check_vel_pos_init; |
Lightvalve | 50:3c630b5eba9f | 1011 | // } |
Lightvalve | 50:3c630b5eba9f | 1012 | // temp_time = TMR_FREQ_5k; |
Lightvalve | 50:3c630b5eba9f | 1013 | // } |
Lightvalve | 50:3c630b5eba9f | 1014 | // TMR3_COUNT_FLOWRATE++; |
Lightvalve | 50:3c630b5eba9f | 1015 | // if (TMR3_COUNT_FLOWRATE > temp_time) { |
Lightvalve | 50:3c630b5eba9f | 1016 | // if (flag_flowrate % 2 == 0) { // (+) |
Lightvalve | 50:3c630b5eba9f | 1017 | // VALVE_VOLTAGE = 1000.0f * (float) (flag_flowrate / 2 + 1); |
Lightvalve | 50:3c630b5eba9f | 1018 | // V_out = VALVE_VOLTAGE; |
Lightvalve | 50:3c630b5eba9f | 1019 | // if (pos.sen > (pos_minus_end + check_vel_pos_init) && pos.sen < (pos_minus_end + check_vel_pos_fin)) { |
Lightvalve | 50:3c630b5eba9f | 1020 | // fl_temp_cnt++; |
Lightvalve | 50:3c630b5eba9f | 1021 | // } else if (pos.sen >= (pos_minus_end + check_vel_pos_fin) && CUR_VELOCITY == 0) { |
Lightvalve | 50:3c630b5eba9f | 1022 | // 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 | 1023 | // // 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 | 1024 | // fl_temp_cnt2++; |
Lightvalve | 50:3c630b5eba9f | 1025 | // } |
Lightvalve | 50:3c630b5eba9f | 1026 | // } else if (flag_flowrate % 2 == 1) { // (-) |
Lightvalve | 50:3c630b5eba9f | 1027 | // VALVE_VOLTAGE = -1. * (float) (flag_flowrate / 2 + 1); |
Lightvalve | 50:3c630b5eba9f | 1028 | // V_out = VALVE_VOLTAGE; |
Lightvalve | 50:3c630b5eba9f | 1029 | // if (pos.sen < (pos_plus_end - check_vel_pos_init) && pos.sen > (pos_plus_end - check_vel_pos_fin)) { |
Lightvalve | 50:3c630b5eba9f | 1030 | // fl_temp_cnt++; |
Lightvalve | 50:3c630b5eba9f | 1031 | // } else if (pos.sen <= (pos_plus_end - check_vel_pos_fin) && CUR_VELOCITY == 0) { |
Lightvalve | 50:3c630b5eba9f | 1032 | // 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 | 1033 | // // 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 | 1034 | // fl_temp_cnt2++; |
Lightvalve | 50:3c630b5eba9f | 1035 | // } |
Lightvalve | 50:3c630b5eba9f | 1036 | // } |
Lightvalve | 50:3c630b5eba9f | 1037 | // if (fl_temp_cnt2 == 100) { |
Lightvalve | 50:3c630b5eba9f | 1038 | // |
Lightvalve | 50:3c630b5eba9f | 1039 | // ROM_RESET_DATA(); |
Lightvalve | 50:3c630b5eba9f | 1040 | // |
Lightvalve | 50:3c630b5eba9f | 1041 | // //spi_eeprom_write(RID_VALVE_GAIN_PLUS_1 + flag_flowrate, (int16_t) (VALVE_GAIN_LPM_PER_V[flag_flowrate] * 100.0f)); |
Lightvalve | 50:3c630b5eba9f | 1042 | // cur_vel_sum = 0; |
Lightvalve | 50:3c630b5eba9f | 1043 | // fl_temp_cnt = 0; |
Lightvalve | 50:3c630b5eba9f | 1044 | // fl_temp_cnt2 = 0; |
Lightvalve | 50:3c630b5eba9f | 1045 | // flag_flowrate++; |
Lightvalve | 50:3c630b5eba9f | 1046 | // } |
Lightvalve | 50:3c630b5eba9f | 1047 | // if (flag_flowrate == 10) { |
Lightvalve | 50:3c630b5eba9f | 1048 | // V_out = 0; |
Lightvalve | 50:3c630b5eba9f | 1049 | // flag_flowrate = 0; |
Lightvalve | 50:3c630b5eba9f | 1050 | // TMR3_COUNT_FLOWRATE = 0; |
Lightvalve | 50:3c630b5eba9f | 1051 | // valve_gain_repeat_cnt++; |
Lightvalve | 50:3c630b5eba9f | 1052 | // if (valve_gain_repeat_cnt >= 1) { |
Lightvalve | 50:3c630b5eba9f | 1053 | // CONTROL_MODE = MODE_NO_ACT; |
Lightvalve | 50:3c630b5eba9f | 1054 | // valve_gain_repeat_cnt = 0; |
Lightvalve | 50:3c630b5eba9f | 1055 | // } |
Lightvalve | 50:3c630b5eba9f | 1056 | // |
Lightvalve | 50:3c630b5eba9f | 1057 | // } |
Lightvalve | 50:3c630b5eba9f | 1058 | // break; |
Lightvalve | 50:3c630b5eba9f | 1059 | // } |
Lightvalve | 50:3c630b5eba9f | 1060 | // |
Lightvalve | 50:3c630b5eba9f | 1061 | // } |
Lightvalve | 14:8e7590227d22 | 1062 | case MODE_PRESSURE_SENSOR_NULLING: { |
Lightvalve | 13:747daba9cf59 | 1063 | // DAC Voltage reference set |
Lightvalve | 14:8e7590227d22 | 1064 | if (TMR3_COUNT_PRES_NULL < TMR_FREQ_5k * 2) { |
Lightvalve | 14:8e7590227d22 | 1065 | CUR_PRES_A_sum += pres_A.sen; |
Lightvalve | 14:8e7590227d22 | 1066 | CUR_PRES_B_sum += pres_B.sen; |
Lightvalve | 14:8e7590227d22 | 1067 | |
Lightvalve | 14:8e7590227d22 | 1068 | if (TMR3_COUNT_PRES_NULL % 10 == 0) { |
Lightvalve | 30:8d561f16383b | 1069 | CUR_PRES_A_mean = CUR_PRES_A_sum / 10.0f; |
Lightvalve | 30:8d561f16383b | 1070 | CUR_PRES_B_mean = CUR_PRES_B_sum / 10.0f; |
Lightvalve | 13:747daba9cf59 | 1071 | CUR_PRES_A_sum = 0; |
Lightvalve | 13:747daba9cf59 | 1072 | CUR_PRES_B_sum = 0; |
Lightvalve | 14:8e7590227d22 | 1073 | |
Lightvalve | 38:118df027d851 | 1074 | float VREF_NullingGain = 0.0003f; |
Lightvalve | 58:2eade98630e2 | 1075 | PRES_A_VREF = PRES_A_VREF + VREF_NullingGain * CUR_PRES_A_mean; |
Lightvalve | 58:2eade98630e2 | 1076 | PRES_B_VREF = PRES_B_VREF + VREF_NullingGain * CUR_PRES_B_mean; |
Lightvalve | 14:8e7590227d22 | 1077 | |
Lightvalve | 30:8d561f16383b | 1078 | if (PRES_A_VREF > 3.3f) PRES_A_VREF = 3.3f; |
Lightvalve | 30:8d561f16383b | 1079 | if (PRES_A_VREF < 0.0f) PRES_A_VREF = 0.0f; |
Lightvalve | 30:8d561f16383b | 1080 | if (PRES_B_VREF > 3.3f) PRES_B_VREF = 3.3f; |
Lightvalve | 30:8d561f16383b | 1081 | if (PRES_B_VREF < 0.0f) PRES_B_VREF = 0.0f; |
Lightvalve | 19:23b7c1ad8683 | 1082 | |
Lightvalve | 30:8d561f16383b | 1083 | dac_1 = PRES_A_VREF / 3.3f; |
Lightvalve | 30:8d561f16383b | 1084 | dac_2 = PRES_B_VREF / 3.3f; |
Lightvalve | 13:747daba9cf59 | 1085 | } |
Lightvalve | 13:747daba9cf59 | 1086 | } else { |
Lightvalve | 57:f4819de54e7a | 1087 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 14:8e7590227d22 | 1088 | TMR3_COUNT_PRES_NULL = 0; |
Lightvalve | 13:747daba9cf59 | 1089 | CUR_PRES_A_sum = 0; |
Lightvalve | 13:747daba9cf59 | 1090 | CUR_PRES_B_sum = 0; |
Lightvalve | 13:747daba9cf59 | 1091 | CUR_PRES_A_mean = 0; |
Lightvalve | 13:747daba9cf59 | 1092 | CUR_PRES_B_mean = 0; |
Lightvalve | 14:8e7590227d22 | 1093 | |
Lightvalve | 16:903b5a4433b4 | 1094 | ROM_RESET_DATA(); |
Lightvalve | 19:23b7c1ad8683 | 1095 | |
Lightvalve | 30:8d561f16383b | 1096 | dac_1 = PRES_A_VREF / 3.3f; |
Lightvalve | 30:8d561f16383b | 1097 | dac_2 = PRES_B_VREF / 3.3f; |
Lightvalve | 17:1865016ca2e7 | 1098 | //pc.printf("nulling end"); |
Lightvalve | 13:747daba9cf59 | 1099 | } |
Lightvalve | 14:8e7590227d22 | 1100 | TMR3_COUNT_PRES_NULL++; |
Lightvalve | 13:747daba9cf59 | 1101 | break; |
Lightvalve | 13:747daba9cf59 | 1102 | } |
Lightvalve | 14:8e7590227d22 | 1103 | |
Lightvalve | 50:3c630b5eba9f | 1104 | // case MODE_PRESSURE_SENSOR_CALIB: { |
Lightvalve | 50:3c630b5eba9f | 1105 | // if (TMR3_COUNT_PRES_CALIB < 2 * TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1106 | // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1107 | // if (TMR3_COUNT_PRES_CALIB >= TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1108 | // CUR_PRES_A_sum += CUR_PRES_A; |
Lightvalve | 50:3c630b5eba9f | 1109 | // } |
Lightvalve | 50:3c630b5eba9f | 1110 | // } else if (TMR3_COUNT_PRES_CALIB < 4 * TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1111 | // V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1112 | // if (TMR3_COUNT_PRES_CALIB >= 3 * TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1113 | // CUR_PRES_B_sum += CUR_PRES_B; |
Lightvalve | 50:3c630b5eba9f | 1114 | // } |
Lightvalve | 50:3c630b5eba9f | 1115 | // } else { |
Lightvalve | 50:3c630b5eba9f | 1116 | // CONTROL_MODE = MODE_NO_ACT; |
Lightvalve | 50:3c630b5eba9f | 1117 | // TMR3_COUNT_PRES_CALIB = 0; |
Lightvalve | 50:3c630b5eba9f | 1118 | // V_out = 0; |
Lightvalve | 50:3c630b5eba9f | 1119 | // PRES_SENSOR_A_PULSE_PER_BAR = CUR_PRES_A_sum / ((float) TMR_FREQ_5k - 1.0f) - PRES_A_NULL; |
Lightvalve | 50:3c630b5eba9f | 1120 | // PRES_SENSOR_A_PULSE_PER_BAR = PRES_SENSOR_A_PULSE_PER_BAR / ((float) PRES_SUPPLY - 1.0f); |
Lightvalve | 50:3c630b5eba9f | 1121 | // PRES_SENSOR_B_PULSE_PER_BAR = CUR_PRES_B_sum / ((float) TMR_FREQ_5k - 1.0f) - PRES_B_NULL; |
Lightvalve | 50:3c630b5eba9f | 1122 | // PRES_SENSOR_B_PULSE_PER_BAR = PRES_SENSOR_B_PULSE_PER_BAR / ((float) PRES_SUPPLY - 1.0f); |
Lightvalve | 50:3c630b5eba9f | 1123 | // CUR_PRES_A_sum = 0; |
Lightvalve | 50:3c630b5eba9f | 1124 | // CUR_PRES_B_sum = 0; |
Lightvalve | 50:3c630b5eba9f | 1125 | // CUR_PRES_A_mean = 0; |
Lightvalve | 50:3c630b5eba9f | 1126 | // CUR_PRES_B_mean = 0; |
Lightvalve | 50:3c630b5eba9f | 1127 | // |
Lightvalve | 50:3c630b5eba9f | 1128 | // ROM_RESET_DATA(); |
Lightvalve | 50:3c630b5eba9f | 1129 | // |
Lightvalve | 50:3c630b5eba9f | 1130 | // //spi_eeprom_write(RID_PRES_SENSOR_A_PULSE_PER_BAR, (int16_t) (PRES_SENSOR_A_PULSE_PER_BAR * 100.0f)); |
Lightvalve | 50:3c630b5eba9f | 1131 | // //spi_eeprom_write(RID_PRES_SENSOR_B_PULSE_PER_BAR, (int16_t) (PRES_SENSOR_B_PULSE_PER_BAR * 100.0f)); |
Lightvalve | 50:3c630b5eba9f | 1132 | // } |
Lightvalve | 50:3c630b5eba9f | 1133 | // TMR3_COUNT_PRES_CALIB++; |
Lightvalve | 50:3c630b5eba9f | 1134 | // break; |
Lightvalve | 50:3c630b5eba9f | 1135 | // } |
Lightvalve | 19:23b7c1ad8683 | 1136 | |
Lightvalve | 50:3c630b5eba9f | 1137 | // case MODE_ROTARY_FRICTION_TUNING: { |
Lightvalve | 50:3c630b5eba9f | 1138 | // 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 | 1139 | // V_out = PWM_out * sin(2 * 3.14159f * freq_fric_tune * TMR3_COUNT_ROTARY_FRIC_TUNE * 0.0001f); |
Lightvalve | 50:3c630b5eba9f | 1140 | // if (V_out > 0) V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1141 | // else V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 50:3c630b5eba9f | 1142 | // TMR3_COUNT_ROTARY_FRIC_TUNE++; |
Lightvalve | 50:3c630b5eba9f | 1143 | // if (TMR3_COUNT_ROTARY_FRIC_TUNE > TUNING_TIME * TMR_FREQ_5k) { |
Lightvalve | 50:3c630b5eba9f | 1144 | // TMR3_COUNT_ROTARY_FRIC_TUNE = 0; |
Lightvalve | 50:3c630b5eba9f | 1145 | // V_out = 0.0f; |
Lightvalve | 50:3c630b5eba9f | 1146 | // CONTROL_MODE = MODE_NO_ACT; |
Lightvalve | 50:3c630b5eba9f | 1147 | // } |
Lightvalve | 50:3c630b5eba9f | 1148 | // break; |
Lightvalve | 50:3c630b5eba9f | 1149 | // } |
Lightvalve | 14:8e7590227d22 | 1150 | |
Lightvalve | 14:8e7590227d22 | 1151 | case MODE_DDV_POS_VS_PWM_ID: { |
Lightvalve | 59:f308b1656d9c | 1152 | CONTROL_MODE = MODE_VALVE_OPEN_LOOP; |
Lightvalve | 13:747daba9cf59 | 1153 | VALVE_ID_timer = VALVE_ID_timer + 1; |
Lightvalve | 14:8e7590227d22 | 1154 | |
Lightvalve | 14:8e7590227d22 | 1155 | if(VALVE_ID_timer < TMR_FREQ_5k*1) { |
Lightvalve | 60:64181f1d3e60 | 1156 | Vout.ref = 3000.0f * sin(2.0f*3.14f*VALVE_ID_timer/TMR_FREQ_5k * 100.0f); |
Lightvalve | 14:8e7590227d22 | 1157 | } else if(VALVE_ID_timer < TMR_FREQ_5k*2) { |
Lightvalve | 59:f308b1656d9c | 1158 | Vout.ref = 1000.0f*(ID_index_array[ID_index]); |
Lightvalve | 14:8e7590227d22 | 1159 | } else if(VALVE_ID_timer == TMR_FREQ_5k*2) { |
Lightvalve | 13:747daba9cf59 | 1160 | VALVE_POS_TMP = 0; |
Lightvalve | 13:747daba9cf59 | 1161 | data_num = 0; |
Lightvalve | 14:8e7590227d22 | 1162 | } else if(VALVE_ID_timer < TMR_FREQ_5k*3) { |
Lightvalve | 13:747daba9cf59 | 1163 | data_num = data_num + 1; |
Lightvalve | 13:747daba9cf59 | 1164 | VALVE_POS_TMP = VALVE_POS_TMP + value; |
Lightvalve | 14:8e7590227d22 | 1165 | } else if(VALVE_ID_timer == TMR_FREQ_5k*3) { |
Lightvalve | 59:f308b1656d9c | 1166 | Vout.ref = 0.0f; |
Lightvalve | 59:f308b1656d9c | 1167 | } else { |
Lightvalve | 13:747daba9cf59 | 1168 | VALVE_POS_AVG[ID_index] = VALVE_POS_TMP / data_num; |
Lightvalve | 13:747daba9cf59 | 1169 | VALVE_ID_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1170 | ID_index= ID_index +1; |
Lightvalve | 13:747daba9cf59 | 1171 | } |
Lightvalve | 14:8e7590227d22 | 1172 | |
Lightvalve | 17:1865016ca2e7 | 1173 | if(ID_index>=25) { |
Lightvalve | 13:747daba9cf59 | 1174 | int i; |
Lightvalve | 13:747daba9cf59 | 1175 | VALVE_POS_AVG_OLD = VALVE_POS_AVG[0]; |
Lightvalve | 17:1865016ca2e7 | 1176 | for(i=0; i<25; i++) { |
Lightvalve | 13:747daba9cf59 | 1177 | VALVE_POS_VS_PWM[i] = (int16_t) (VALVE_POS_AVG[i]); |
Lightvalve | 14:8e7590227d22 | 1178 | if(VALVE_POS_AVG[i] > VALVE_POS_AVG_OLD) { |
Lightvalve | 13:747daba9cf59 | 1179 | VALVE_MAX_POS = VALVE_POS_AVG[i]; |
Lightvalve | 13:747daba9cf59 | 1180 | VALVE_POS_AVG_OLD = VALVE_MAX_POS; |
Lightvalve | 14:8e7590227d22 | 1181 | } else if(VALVE_POS_AVG[i] < VALVE_POS_AVG_OLD) { |
Lightvalve | 13:747daba9cf59 | 1182 | VALVE_MIN_POS = VALVE_POS_AVG[i]; |
Lightvalve | 13:747daba9cf59 | 1183 | VALVE_POS_AVG_OLD = VALVE_MIN_POS; |
Lightvalve | 13:747daba9cf59 | 1184 | } |
Lightvalve | 13:747daba9cf59 | 1185 | } |
Lightvalve | 59:f308b1656d9c | 1186 | ROM_RESET_DATA(); |
Lightvalve | 13:747daba9cf59 | 1187 | ID_index = 0; |
Lightvalve | 57:f4819de54e7a | 1188 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 13:747daba9cf59 | 1189 | } |
Lightvalve | 14:8e7590227d22 | 1190 | |
Lightvalve | 14:8e7590227d22 | 1191 | |
Lightvalve | 13:747daba9cf59 | 1192 | break; |
Lightvalve | 13:747daba9cf59 | 1193 | } |
Lightvalve | 14:8e7590227d22 | 1194 | |
Lightvalve | 14:8e7590227d22 | 1195 | case MODE_DDV_DEADZONE_AND_CENTER: { |
Lightvalve | 59:f308b1656d9c | 1196 | CONTROL_MODE = MODE_VALVE_OPEN_LOOP; |
Lightvalve | 13:747daba9cf59 | 1197 | VALVE_DZ_timer = VALVE_DZ_timer + 1; |
Lightvalve | 14:8e7590227d22 | 1198 | if(first_check == 0) { |
Lightvalve | 30:8d561f16383b | 1199 | if(VALVE_DZ_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1200 | Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 30:8d561f16383b | 1201 | } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1202 | Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 14:8e7590227d22 | 1203 | pos_plus_end = pos.sen; |
Lightvalve | 30:8d561f16383b | 1204 | } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1205 | Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 30:8d561f16383b | 1206 | } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1207 | Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 14:8e7590227d22 | 1208 | pos_minus_end = pos.sen; |
Lightvalve | 30:8d561f16383b | 1209 | } else if(VALVE_DZ_timer < (int) (3.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 | 30:8d561f16383b | 1211 | } else if(VALVE_DZ_timer < (int) (4.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1212 | 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 | 1213 | data_num = data_num + 1; |
Lightvalve | 13:747daba9cf59 | 1214 | VALVE_POS_TMP = VALVE_POS_TMP + value; |
Lightvalve | 30:8d561f16383b | 1215 | } else if(VALVE_DZ_timer == (int) (4.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1216 | 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 | 1217 | DDV_POS_AVG = VALVE_POS_TMP / data_num; |
Lightvalve | 14:8e7590227d22 | 1218 | START_POS = pos.sen; |
Lightvalve | 13:747daba9cf59 | 1219 | VALVE_POS_TMP = 0; |
Lightvalve | 13:747daba9cf59 | 1220 | data_num = 0; |
Lightvalve | 14:8e7590227d22 | 1221 | |
Lightvalve | 30:8d561f16383b | 1222 | } else if(VALVE_DZ_timer < (int) (5.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1223 | valve_pos.ref = DDV_POS_AVG; |
Lightvalve | 14:8e7590227d22 | 1224 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 14:8e7590227d22 | 1225 | |
Lightvalve | 30:8d561f16383b | 1226 | } else if(VALVE_DZ_timer < (int) (6.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1227 | valve_pos.ref = DDV_POS_AVG; |
Lightvalve | 14:8e7590227d22 | 1228 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 60:64181f1d3e60 | 1229 | |
Lightvalve | 30:8d561f16383b | 1230 | } else if(VALVE_DZ_timer == (int) (6.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1231 | valve_pos.ref = DDV_POS_AVG; |
Lightvalve | 14:8e7590227d22 | 1232 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 14:8e7590227d22 | 1233 | FINAL_POS = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1234 | |
Lightvalve | 60:64181f1d3e60 | 1235 | if((FINAL_POS - START_POS)>200) { |
Lightvalve | 13:747daba9cf59 | 1236 | DZ_case = 1; |
Lightvalve | 60:64181f1d3e60 | 1237 | } else if((FINAL_POS - START_POS)<-200) { |
Lightvalve | 13:747daba9cf59 | 1238 | DZ_case = -1; |
Lightvalve | 14:8e7590227d22 | 1239 | } else { |
Lightvalve | 13:747daba9cf59 | 1240 | DZ_case = 0; |
Lightvalve | 13:747daba9cf59 | 1241 | } |
Lightvalve | 61:bc8c8270f0ab | 1242 | |
Lightvalve | 60:64181f1d3e60 | 1243 | CAN_TX_PRES((int16_t) (DZ_case), (int16_t) (6)); |
Lightvalve | 50:3c630b5eba9f | 1244 | |
Lightvalve | 13:747daba9cf59 | 1245 | first_check = 1; |
Lightvalve | 13:747daba9cf59 | 1246 | DZ_DIRECTION = 1; |
Lightvalve | 13:747daba9cf59 | 1247 | VALVE_DZ_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1248 | Ref_Valve_Pos_Old = DDV_POS_AVG; |
Lightvalve | 13:747daba9cf59 | 1249 | DZ_NUM = 1; |
Lightvalve | 13:747daba9cf59 | 1250 | DZ_index = 1; |
Lightvalve | 14:8e7590227d22 | 1251 | |
Lightvalve | 13:747daba9cf59 | 1252 | } |
Lightvalve | 19:23b7c1ad8683 | 1253 | } else { |
Lightvalve | 14:8e7590227d22 | 1254 | if((DZ_case == -1 && DZ_NUM == 1) | (DZ_case == 1 && DZ_NUM == 1)) { |
Lightvalve | 30:8d561f16383b | 1255 | if(VALVE_DZ_timer < (int) (1.0 * (float) TMR_FREQ_5k)) { |
Lightvalve | 60:64181f1d3e60 | 1256 | 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 | 1257 | //pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; |
Lightvalve | 60:64181f1d3e60 | 1258 | //CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 30:8d561f16383b | 1259 | } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1260 | START_POS = pos.sen; |
Lightvalve | 30:8d561f16383b | 1261 | } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1262 | valve_pos.ref = Ref_Valve_Pos_Old - DZ_case * DZ_DIRECTION * 64 / DZ_index; |
Lightvalve | 14:8e7590227d22 | 1263 | if(valve_pos.ref <= VALVE_MIN_POS) { |
Lightvalve | 14:8e7590227d22 | 1264 | valve_pos.ref = VALVE_MIN_POS; |
Lightvalve | 14:8e7590227d22 | 1265 | } else if(valve_pos.ref >= VALVE_MAX_POS) { |
Lightvalve | 14:8e7590227d22 | 1266 | valve_pos.ref = VALVE_MAX_POS; |
Lightvalve | 13:747daba9cf59 | 1267 | } |
Lightvalve | 14:8e7590227d22 | 1268 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 60:64181f1d3e60 | 1269 | |
Lightvalve | 30:8d561f16383b | 1270 | } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1271 | Ref_Valve_Pos_Old = valve_pos.ref; |
Lightvalve | 14:8e7590227d22 | 1272 | FINAL_POS = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1273 | |
Lightvalve | 14:8e7590227d22 | 1274 | if((FINAL_POS - START_POS)>100) { |
Lightvalve | 14:8e7590227d22 | 1275 | DZ_DIRECTION = 1 * DZ_case; |
Lightvalve | 14:8e7590227d22 | 1276 | } else if((FINAL_POS - START_POS)<-100) { |
Lightvalve | 14:8e7590227d22 | 1277 | DZ_DIRECTION = -1 * DZ_case; |
Lightvalve | 14:8e7590227d22 | 1278 | } else { |
Lightvalve | 13:747daba9cf59 | 1279 | DZ_DIRECTION = 1 * DZ_case; |
Lightvalve | 13:747daba9cf59 | 1280 | } |
Lightvalve | 14:8e7590227d22 | 1281 | |
Lightvalve | 13:747daba9cf59 | 1282 | VALVE_DZ_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1283 | DZ_index= DZ_index *2; |
Lightvalve | 14:8e7590227d22 | 1284 | if(DZ_index >= 128) { |
Lightvalve | 14:8e7590227d22 | 1285 | FIRST_DZ = valve_pos.ref; |
Lightvalve | 13:747daba9cf59 | 1286 | DZ_NUM = 2; |
Lightvalve | 13:747daba9cf59 | 1287 | Ref_Valve_Pos_Old = FIRST_DZ; |
Lightvalve | 13:747daba9cf59 | 1288 | DZ_index = 1; |
Lightvalve | 13:747daba9cf59 | 1289 | DZ_DIRECTION = 1; |
Lightvalve | 13:747daba9cf59 | 1290 | } |
Lightvalve | 13:747daba9cf59 | 1291 | } |
Lightvalve | 14:8e7590227d22 | 1292 | } else if((DZ_case == -1 && DZ_NUM == 2) | (DZ_case == 1 && DZ_NUM == 2)) { |
Lightvalve | 30:8d561f16383b | 1293 | if(VALVE_DZ_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 60:64181f1d3e60 | 1294 | 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 | 1295 | //pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; |
Lightvalve | 60:64181f1d3e60 | 1296 | //CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 30:8d561f16383b | 1297 | } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1298 | START_POS = pos.sen; |
Lightvalve | 30:8d561f16383b | 1299 | } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 60:64181f1d3e60 | 1300 | valve_pos.ref = Ref_Valve_Pos_Old - DZ_case * DZ_DIRECTION * 64 / DZ_index; |
Lightvalve | 14:8e7590227d22 | 1301 | if(valve_pos.ref <= VALVE_MIN_POS) { |
Lightvalve | 14:8e7590227d22 | 1302 | valve_pos.ref = VALVE_MIN_POS; |
Lightvalve | 14:8e7590227d22 | 1303 | } else if(valve_pos.ref >= VALVE_MAX_POS) { |
Lightvalve | 14:8e7590227d22 | 1304 | valve_pos.ref = VALVE_MAX_POS; |
Lightvalve | 13:747daba9cf59 | 1305 | } |
Lightvalve | 14:8e7590227d22 | 1306 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 61:bc8c8270f0ab | 1307 | |
Lightvalve | 30:8d561f16383b | 1308 | } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1309 | Vout.ref = 0.0f; |
Lightvalve | 59:f308b1656d9c | 1310 | } else if(VALVE_DZ_timer > (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1311 | Ref_Valve_Pos_Old = valve_pos.ref; |
Lightvalve | 14:8e7590227d22 | 1312 | FINAL_POS = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1313 | |
Lightvalve | 14:8e7590227d22 | 1314 | if((FINAL_POS - START_POS)>100) { |
Lightvalve | 60:64181f1d3e60 | 1315 | DZ_DIRECTION = 1 * DZ_case; |
Lightvalve | 14:8e7590227d22 | 1316 | } else if((FINAL_POS - START_POS)<-100) { |
Lightvalve | 60:64181f1d3e60 | 1317 | DZ_DIRECTION = -1 * DZ_case; |
Lightvalve | 14:8e7590227d22 | 1318 | } else { |
Lightvalve | 60:64181f1d3e60 | 1319 | DZ_DIRECTION = -1 * DZ_case; |
Lightvalve | 13:747daba9cf59 | 1320 | } |
Lightvalve | 14:8e7590227d22 | 1321 | |
Lightvalve | 13:747daba9cf59 | 1322 | VALVE_DZ_timer = 0; |
Lightvalve | 60:64181f1d3e60 | 1323 | DZ_index= DZ_index * 2; |
Lightvalve | 14:8e7590227d22 | 1324 | if(DZ_index >= 128) { |
Lightvalve | 14:8e7590227d22 | 1325 | SECOND_DZ = valve_pos.ref; |
Lightvalve | 57:f4819de54e7a | 1326 | VALVE_CENTER = (int) (0.5f * (float) (FIRST_DZ) + 0.5f * (float) (SECOND_DZ)); |
Lightvalve | 13:747daba9cf59 | 1327 | first_check = 0; |
Lightvalve | 33:91b17819ec30 | 1328 | VALVE_DEADZONE_MINUS = (float) FIRST_DZ; |
Lightvalve | 33:91b17819ec30 | 1329 | VALVE_DEADZONE_PLUS = (float) SECOND_DZ; |
Lightvalve | 19:23b7c1ad8683 | 1330 | |
Lightvalve | 16:903b5a4433b4 | 1331 | ROM_RESET_DATA(); |
Lightvalve | 34:bb2ca2fc2a8e | 1332 | |
Lightvalve | 60:64181f1d3e60 | 1333 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 13:747daba9cf59 | 1334 | DZ_index = 1; |
Lightvalve | 13:747daba9cf59 | 1335 | } |
Lightvalve | 13:747daba9cf59 | 1336 | } |
Lightvalve | 14:8e7590227d22 | 1337 | } else if(DZ_case == 0 && DZ_NUM ==1) { |
Lightvalve | 30:8d561f16383b | 1338 | if(VALVE_DZ_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 60:64181f1d3e60 | 1339 | 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 | 1340 | //pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; |
Lightvalve | 60:64181f1d3e60 | 1341 | //CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 30:8d561f16383b | 1342 | } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1343 | START_POS = pos.sen; |
Lightvalve | 30:8d561f16383b | 1344 | } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1345 | valve_pos.ref = Ref_Valve_Pos_Old - DZ_DIRECTION * 64 / DZ_index; |
Lightvalve | 14:8e7590227d22 | 1346 | if(valve_pos.ref <= VALVE_MIN_POS) { |
Lightvalve | 14:8e7590227d22 | 1347 | valve_pos.ref = VALVE_MIN_POS; |
Lightvalve | 14:8e7590227d22 | 1348 | } else if(valve_pos.ref >= VALVE_MAX_POS) { |
Lightvalve | 14:8e7590227d22 | 1349 | valve_pos.ref = VALVE_MAX_POS; |
Lightvalve | 13:747daba9cf59 | 1350 | } |
Lightvalve | 14:8e7590227d22 | 1351 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 61:bc8c8270f0ab | 1352 | |
Lightvalve | 30:8d561f16383b | 1353 | } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1354 | Ref_Valve_Pos_Old = valve_pos.ref; |
Lightvalve | 14:8e7590227d22 | 1355 | FINAL_POS = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1356 | |
Lightvalve | 14:8e7590227d22 | 1357 | if((FINAL_POS - START_POS)>100) { |
Lightvalve | 14:8e7590227d22 | 1358 | DZ_DIRECTION = 1; |
Lightvalve | 14:8e7590227d22 | 1359 | } else if((FINAL_POS - START_POS)<-100) { |
Lightvalve | 14:8e7590227d22 | 1360 | DZ_DIRECTION = -1; |
Lightvalve | 14:8e7590227d22 | 1361 | } else { |
Lightvalve | 13:747daba9cf59 | 1362 | DZ_DIRECTION = 1; |
Lightvalve | 13:747daba9cf59 | 1363 | } |
Lightvalve | 13:747daba9cf59 | 1364 | VALVE_DZ_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1365 | DZ_index= DZ_index *2; |
Lightvalve | 14:8e7590227d22 | 1366 | if(DZ_index >= 128) { |
Lightvalve | 14:8e7590227d22 | 1367 | FIRST_DZ = valve_pos.ref; |
Lightvalve | 13:747daba9cf59 | 1368 | DZ_NUM = 2; |
Lightvalve | 13:747daba9cf59 | 1369 | Ref_Valve_Pos_Old = FIRST_DZ; |
Lightvalve | 13:747daba9cf59 | 1370 | DZ_index = 1; |
Lightvalve | 13:747daba9cf59 | 1371 | DZ_DIRECTION = 1; |
Lightvalve | 13:747daba9cf59 | 1372 | } |
Lightvalve | 13:747daba9cf59 | 1373 | } |
Lightvalve | 14:8e7590227d22 | 1374 | } else { |
Lightvalve | 30:8d561f16383b | 1375 | if(VALVE_DZ_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 60:64181f1d3e60 | 1376 | 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 | 1377 | //pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; |
Lightvalve | 60:64181f1d3e60 | 1378 | //CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 30:8d561f16383b | 1379 | } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1380 | START_POS = pos.sen; |
Lightvalve | 30:8d561f16383b | 1381 | } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1382 | valve_pos.ref = Ref_Valve_Pos_Old + DZ_DIRECTION * 64 / DZ_index; |
Lightvalve | 14:8e7590227d22 | 1383 | if(valve_pos.ref <= VALVE_MIN_POS) { |
Lightvalve | 14:8e7590227d22 | 1384 | valve_pos.ref = VALVE_MIN_POS; |
Lightvalve | 14:8e7590227d22 | 1385 | } else if(valve_pos.ref > VALVE_MAX_POS) { |
Lightvalve | 14:8e7590227d22 | 1386 | valve_pos.ref = VALVE_MAX_POS - 1; |
Lightvalve | 13:747daba9cf59 | 1387 | } |
Lightvalve | 14:8e7590227d22 | 1388 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 60:64181f1d3e60 | 1389 | |
Lightvalve | 30:8d561f16383b | 1390 | } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1391 | Vout.ref = 0.0f; |
Lightvalve | 59:f308b1656d9c | 1392 | } else if(VALVE_DZ_timer > (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1393 | Ref_Valve_Pos_Old = valve_pos.ref; |
Lightvalve | 14:8e7590227d22 | 1394 | FINAL_POS = pos.sen; |
Lightvalve | 61:bc8c8270f0ab | 1395 | |
Lightvalve | 60:64181f1d3e60 | 1396 | if((FINAL_POS - START_POS)>100) { |
Lightvalve | 13:747daba9cf59 | 1397 | DZ_DIRECTION = 1; |
Lightvalve | 60:64181f1d3e60 | 1398 | } else if((FINAL_POS - START_POS)<-100) { |
Lightvalve | 60:64181f1d3e60 | 1399 | DZ_DIRECTION = -1; |
Lightvalve | 60:64181f1d3e60 | 1400 | } else { |
Lightvalve | 13:747daba9cf59 | 1401 | DZ_DIRECTION = 1; |
Lightvalve | 60:64181f1d3e60 | 1402 | } |
Lightvalve | 14:8e7590227d22 | 1403 | |
Lightvalve | 13:747daba9cf59 | 1404 | VALVE_DZ_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1405 | DZ_index= DZ_index *2; |
Lightvalve | 14:8e7590227d22 | 1406 | if(DZ_index >= 128) { |
Lightvalve | 14:8e7590227d22 | 1407 | SECOND_DZ = valve_pos.ref; |
Lightvalve | 57:f4819de54e7a | 1408 | VALVE_CENTER = (int) (0.5f * (float) (FIRST_DZ) + 0.5f * (float) (SECOND_DZ)); |
Lightvalve | 13:747daba9cf59 | 1409 | first_check = 0; |
Lightvalve | 33:91b17819ec30 | 1410 | VALVE_DEADZONE_MINUS = (float) FIRST_DZ; |
Lightvalve | 33:91b17819ec30 | 1411 | VALVE_DEADZONE_PLUS = (float) SECOND_DZ; |
Lightvalve | 61:bc8c8270f0ab | 1412 | |
Lightvalve | 59:f308b1656d9c | 1413 | ROM_RESET_DATA(); |
Lightvalve | 34:bb2ca2fc2a8e | 1414 | |
Lightvalve | 57:f4819de54e7a | 1415 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 13:747daba9cf59 | 1416 | DZ_index = 1; |
Lightvalve | 13:747daba9cf59 | 1417 | } |
Lightvalve | 13:747daba9cf59 | 1418 | } |
Lightvalve | 13:747daba9cf59 | 1419 | } |
Lightvalve | 14:8e7590227d22 | 1420 | } |
Lightvalve | 13:747daba9cf59 | 1421 | break; |
Lightvalve | 13:747daba9cf59 | 1422 | } |
Lightvalve | 14:8e7590227d22 | 1423 | |
Lightvalve | 14:8e7590227d22 | 1424 | case MODE_DDV_POS_VS_FLOWRATE: { |
Lightvalve | 59:f308b1656d9c | 1425 | CONTROL_MODE = MODE_VALVE_OPEN_LOOP; |
Lightvalve | 13:747daba9cf59 | 1426 | VALVE_FR_timer = VALVE_FR_timer + 1; |
Lightvalve | 14:8e7590227d22 | 1427 | if(first_check == 0) { |
Lightvalve | 30:8d561f16383b | 1428 | if(VALVE_FR_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1429 | Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 23:59218d4a256d | 1430 | //CAN_TX_PRES((int16_t) (VALVE_FR_timer), (int16_t) (6)); |
Lightvalve | 30:8d561f16383b | 1431 | } else if(VALVE_FR_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1432 | Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 14:8e7590227d22 | 1433 | pos_plus_end = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1434 | // CAN_TX_PRES((int16_t) (V_out), (int16_t) (7)); |
Lightvalve | 30:8d561f16383b | 1435 | } else if(VALVE_FR_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1436 | Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 30:8d561f16383b | 1437 | } else if(VALVE_FR_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1438 | // CAN_TX_PRES((int16_t) (V_out), (int16_t) (8)); |
Lightvalve | 59:f308b1656d9c | 1439 | Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; |
Lightvalve | 14:8e7590227d22 | 1440 | pos_minus_end = pos.sen; |
Lightvalve | 13:747daba9cf59 | 1441 | first_check = 1; |
Lightvalve | 13:747daba9cf59 | 1442 | VALVE_FR_timer = 0; |
Lightvalve | 57:f4819de54e7a | 1443 | valve_pos.ref = (float) VALVE_CENTER; |
Lightvalve | 13:747daba9cf59 | 1444 | ID_index = 0; |
Lightvalve | 13:747daba9cf59 | 1445 | max_check = 0; |
Lightvalve | 13:747daba9cf59 | 1446 | min_check = 0; |
Lightvalve | 13:747daba9cf59 | 1447 | } |
Lightvalve | 14:8e7590227d22 | 1448 | } else { |
Lightvalve | 30:8d561f16383b | 1449 | if(VALVE_FR_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 59:f308b1656d9c | 1450 | //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 | 1451 | pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; |
Lightvalve | 59:f308b1656d9c | 1452 | CONTROL_MODE = MODE_JOINT_CONTROL; |
Lightvalve | 30:8d561f16383b | 1453 | } else if(VALVE_FR_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 13:747daba9cf59 | 1454 | data_num = 0; |
Lightvalve | 57:f4819de54e7a | 1455 | valve_pos.ref = 10.0f*((float) ID_index_array[ID_index]) + (float) VALVE_CENTER; |
Lightvalve | 14:8e7590227d22 | 1456 | |
Lightvalve | 14:8e7590227d22 | 1457 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 14:8e7590227d22 | 1458 | START_POS = pos.sen; |
Lightvalve | 30:8d561f16383b | 1459 | } else if(VALVE_FR_timer < (int) (5.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 57:f4819de54e7a | 1460 | valve_pos.ref = 10.0f*((float) ID_index_array[ID_index]) + (float) VALVE_CENTER; |
Lightvalve | 14:8e7590227d22 | 1461 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 13:747daba9cf59 | 1462 | data_num = data_num + 1; |
Lightvalve | 30:8d561f16383b | 1463 | if(abs(0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen) > 20000.0f) { |
Lightvalve | 14:8e7590227d22 | 1464 | FINAL_POS = pos.sen; |
Lightvalve | 14:8e7590227d22 | 1465 | one_period_end = 1; |
Lightvalve | 13:747daba9cf59 | 1466 | } |
Lightvalve | 30:8d561f16383b | 1467 | } else if(VALVE_FR_timer == (int) (5.0f * (float) TMR_FREQ_5k)) { |
Lightvalve | 14:8e7590227d22 | 1468 | FINAL_POS = pos.sen; |
Lightvalve | 13:747daba9cf59 | 1469 | one_period_end = 1; |
Lightvalve | 59:f308b1656d9c | 1470 | V_out = 0.0f; |
Lightvalve | 13:747daba9cf59 | 1471 | } |
Lightvalve | 14:8e7590227d22 | 1472 | |
Lightvalve | 14:8e7590227d22 | 1473 | if(one_period_end == 1) { |
Lightvalve | 14:8e7590227d22 | 1474 | if(valve_pos.ref > VALVE_MAX_POS) { |
Lightvalve | 13:747daba9cf59 | 1475 | max_check = 1; |
Lightvalve | 14:8e7590227d22 | 1476 | } else if(valve_pos.ref < VALVE_MIN_POS) { |
Lightvalve | 13:747daba9cf59 | 1477 | min_check = 1; |
Lightvalve | 13:747daba9cf59 | 1478 | } |
Lightvalve | 13:747daba9cf59 | 1479 | JOINT_VEL[ID_index] = (FINAL_POS - START_POS) / data_num * TMR_FREQ_5k; // pulse/sec |
Lightvalve | 19:23b7c1ad8683 | 1480 | |
Lightvalve | 13:747daba9cf59 | 1481 | VALVE_FR_timer = 0; |
Lightvalve | 13:747daba9cf59 | 1482 | one_period_end = 0; |
Lightvalve | 13:747daba9cf59 | 1483 | ID_index= ID_index +1; |
Lightvalve | 30:8d561f16383b | 1484 | V_out = 0.0f; |
Lightvalve | 13:747daba9cf59 | 1485 | } |
Lightvalve | 14:8e7590227d22 | 1486 | |
Lightvalve | 14:8e7590227d22 | 1487 | if(max_check == 1 && min_check == 1) { |
Lightvalve | 19:23b7c1ad8683 | 1488 | |
Lightvalve | 13:747daba9cf59 | 1489 | VALVE_POS_NUM = ID_index; |
Lightvalve | 59:f308b1656d9c | 1490 | ROM_RESET_DATA(); |
Lightvalve | 13:747daba9cf59 | 1491 | ID_index = 0; |
Lightvalve | 13:747daba9cf59 | 1492 | first_check = 0; |
Lightvalve | 13:747daba9cf59 | 1493 | VALVE_FR_timer = 0; |
Lightvalve | 57:f4819de54e7a | 1494 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 49:e7bcfc244d40 | 1495 | // CAN_TX_PRES((int16_t) (VALVE_FR_timer), (int16_t) (6)); |
Lightvalve | 13:747daba9cf59 | 1496 | } |
Lightvalve | 13:747daba9cf59 | 1497 | } |
Lightvalve | 13:747daba9cf59 | 1498 | break; |
Lightvalve | 13:747daba9cf59 | 1499 | } |
Lightvalve | 58:2eade98630e2 | 1500 | |
Lightvalve | 57:f4819de54e7a | 1501 | case MODE_SYSTEM_ID: { |
Lightvalve | 57:f4819de54e7a | 1502 | freq_sysid_Iref = (double) cnt_sysid * DT_TMR3 * 3.; |
Lightvalve | 57:f4819de54e7a | 1503 | valve_pos.ref = 2500.0f * sin(2.0f * 3.14159f * freq_sysid_Iref * (double) cnt_sysid * DT_TMR3); |
Lightvalve | 57:f4819de54e7a | 1504 | CONTROL_MODE = MODE_VALVE_OPEN_LOOP; |
Lightvalve | 57:f4819de54e7a | 1505 | cnt_sysid++; |
Lightvalve | 57:f4819de54e7a | 1506 | if (freq_sysid_Iref >= 300) { |
Lightvalve | 57:f4819de54e7a | 1507 | cnt_sysid = 0; |
Lightvalve | 57:f4819de54e7a | 1508 | CONTROL_UTILITY_MODE = MODE_NO_ACT; |
Lightvalve | 57:f4819de54e7a | 1509 | } |
Lightvalve | 57:f4819de54e7a | 1510 | break; |
Lightvalve | 57:f4819de54e7a | 1511 | } |
Lightvalve | 58:2eade98630e2 | 1512 | |
Lightvalve | 58:2eade98630e2 | 1513 | |
Lightvalve | 57:f4819de54e7a | 1514 | |
Lightvalve | 57:f4819de54e7a | 1515 | default: |
Lightvalve | 57:f4819de54e7a | 1516 | break; |
Lightvalve | 57:f4819de54e7a | 1517 | } |
Lightvalve | 57:f4819de54e7a | 1518 | |
Lightvalve | 57:f4819de54e7a | 1519 | // CONTROL MODE ------------------------------------------------------------ |
Lightvalve | 57:f4819de54e7a | 1520 | |
Lightvalve | 57:f4819de54e7a | 1521 | switch (CONTROL_MODE) { |
Lightvalve | 57:f4819de54e7a | 1522 | case MODE_NO_ACT: { |
Lightvalve | 57:f4819de54e7a | 1523 | V_out = 0.0f; |
Lightvalve | 57:f4819de54e7a | 1524 | break; |
Lightvalve | 57:f4819de54e7a | 1525 | } |
Lightvalve | 57:f4819de54e7a | 1526 | |
Lightvalve | 57:f4819de54e7a | 1527 | case MODE_VALVE_POSITION_CONTROL: { |
Lightvalve | 67:c2812cf26c38 | 1528 | if (OPERATING_MODE == 5) { //SW Valve |
Lightvalve | 57:f4819de54e7a | 1529 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 59:f308b1656d9c | 1530 | V_out = Vout.ref; |
Lightvalve | 67:c2812cf26c38 | 1531 | } else if (CURRENT_CONTROL_MODE == 0) { //PWM |
Lightvalve | 67:c2812cf26c38 | 1532 | V_out = valve_pos.ref; |
Lightvalve | 67:c2812cf26c38 | 1533 | } else { |
Lightvalve | 67:c2812cf26c38 | 1534 | I_REF = valve_pos.ref * 0.001f; |
Lightvalve | 57:f4819de54e7a | 1535 | } |
Lightvalve | 58:2eade98630e2 | 1536 | |
Lightvalve | 57:f4819de54e7a | 1537 | break; |
Lightvalve | 57:f4819de54e7a | 1538 | } |
Lightvalve | 57:f4819de54e7a | 1539 | |
Lightvalve | 57:f4819de54e7a | 1540 | case MODE_JOINT_CONTROL: { |
Lightvalve | 57:f4819de54e7a | 1541 | double torq_ref = 0.0f; |
Lightvalve | 57:f4819de54e7a | 1542 | pos.err = (pos.ref - pos.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm] |
Lightvalve | 67:c2812cf26c38 | 1543 | vel.err = (0.0f - vel.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm/s] |
Lightvalve | 57:f4819de54e7a | 1544 | pos.err_sum += pos.err/(float) TMR_FREQ_5k; //[mm] |
Lightvalve | 67:c2812cf26c38 | 1545 | |
Lightvalve | 67:c2812cf26c38 | 1546 | //K & D Low Pass Filter |
Lightvalve | 67:c2812cf26c38 | 1547 | float alpha_K_D = 1.0f/(1.0f + 5000.0f/(2.0f*3.14f*30.0f)); // f_cutoff : 30Hz |
Lightvalve | 67:c2812cf26c38 | 1548 | K_LPF = K_LPF*(1.0f-alpha_K_D)+K_SPRING*(alpha_K_D); |
Lightvalve | 67:c2812cf26c38 | 1549 | D_LPF = D_LPF*(1.0f-alpha_K_D)+D_DAMPER*(alpha_K_D); |
Lightvalve | 67:c2812cf26c38 | 1550 | |
Lightvalve | 67:c2812cf26c38 | 1551 | torq_ref = torq.ref + K_LPF * pos.err - D_LPF * vel.sen / ENC_PULSE_PER_POSITION; //[N] |
Lightvalve | 57:f4819de54e7a | 1552 | |
Lightvalve | 57:f4819de54e7a | 1553 | // torque feedback |
Lightvalve | 67:c2812cf26c38 | 1554 | torq.err = torq_ref - torq.sen; //[N] |
Lightvalve | 57:f4819de54e7a | 1555 | torq.err_sum += torq.err/(float) TMR_FREQ_5k; //[N] |
Lightvalve | 57:f4819de54e7a | 1556 | |
Lightvalve | 57:f4819de54e7a | 1557 | if (((OPERATING_MODE&0b110)>>1) == 0 || ((OPERATING_MODE&0b110)>>1) == 1) { |
Lightvalve | 58:2eade98630e2 | 1558 | |
Lightvalve | 57:f4819de54e7a | 1559 | double I_REF_POS = 0.0f; |
Lightvalve | 57:f4819de54e7a | 1560 | double I_REF_FORCE_FB = 0.0f; // I_REF by Force Feedback |
Lightvalve | 57:f4819de54e7a | 1561 | double I_REF_VC = 0.0f; // I_REF for velocity compensation |
Lightvalve | 57:f4819de54e7a | 1562 | |
Lightvalve | 57:f4819de54e7a | 1563 | double temp_vel_pos = 0.0f; |
Lightvalve | 57:f4819de54e7a | 1564 | double temp_vel_torq = 0.0f; |
Lightvalve | 57:f4819de54e7a | 1565 | double wn_Pos = 2.0f * PI * 5.0f; // f_cut : 5Hz Position Control |
Lightvalve | 58:2eade98630e2 | 1566 | |
Lightvalve | 69:3995ffeaa786 | 1567 | if ((OPERATING_MODE & 0x01) == 0) { // Rotary Mode |
Lightvalve | 57:f4819de54e7a | 1568 | 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 | 1569 | // L when P-gain = 100, f_cut = 10Hz L feedforward velocity |
Lightvalve | 69:3995ffeaa786 | 1570 | } else if ((OPERATING_MODE & 0x01) == 1) { |
Lightvalve | 57:f4819de54e7a | 1571 | 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 | 1572 | // L when P-gain = 100, f_cut = 10Hz L feedforward velocity |
Lightvalve | 57:f4819de54e7a | 1573 | } |
Lightvalve | 57:f4819de54e7a | 1574 | 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 | 1575 | else I_REF_POS = temp_vel_pos * ((double) PISTON_AREA_B * 0.00006f / (K_v * sqrt(2.0f / (alpha3 + 1.0f)))); |
Lightvalve | 57:f4819de54e7a | 1576 | |
Lightvalve | 57:f4819de54e7a | 1577 | // velocity compensation for torque control |
Lightvalve | 69:3995ffeaa786 | 1578 | if ((OPERATING_MODE & 0x01) == 0) { // Rotary Mode |
Lightvalve | 57:f4819de54e7a | 1579 | I_REF_FORCE_FB = 0.001f * ((double) P_GAIN_JOINT_TORQUE * torq.err + (double) I_GAIN_JOINT_TORQUE * torq.err_sum); |
Lightvalve | 57:f4819de54e7a | 1580 | // 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 | 1581 | temp_vel_torq = (0.01f * (double) VELOCITY_COMP_GAIN * vel.ref / (double) ENC_PULSE_PER_POSITION) * PI / 180.0f; // rad/s |
Lightvalve | 57:f4819de54e7a | 1582 | // L feedforward velocity |
Lightvalve | 69:3995ffeaa786 | 1583 | } else if ((OPERATING_MODE & 0x01) == 1) { |
Lightvalve | 57:f4819de54e7a | 1584 | 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 | 1585 | // temp_vel_torq = (0.01 * (double) VELOCITY_COMP_GAIN * (double) CUR_VELOCITY / (double) ENC_PULSE_PER_POSITION); // mm/s |
Lightvalve | 57:f4819de54e7a | 1586 | temp_vel_torq = (0.01f * (double) VELOCITY_COMP_GAIN * vel.ref / (double) ENC_PULSE_PER_POSITION); // mm/s |
Lightvalve | 57:f4819de54e7a | 1587 | // L feedforward velocity |
Lightvalve | 57:f4819de54e7a | 1588 | } |
Lightvalve | 57:f4819de54e7a | 1589 | 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 | 1590 | else I_REF_VC = temp_vel_torq * ((double) PISTON_AREA_B * 0.00006f / (K_v * sqrt(2.0f / (alpha3 + 1.0f)))); |
Lightvalve | 57:f4819de54e7a | 1591 | // L velocity(rad/s or mm/s) >> I_ref(mA) |
Lightvalve | 57:f4819de54e7a | 1592 | // Ref_Joint_FT_dot = (Ref_Joint_FT_Nm - Ref_Joint_FT_Nm_old) / TMR_DT_5k; |
Lightvalve | 57:f4819de54e7a | 1593 | // Ref_Joint_FT_Nm_old = Ref_Joint_FT_Nm; |
Lightvalve | 57:f4819de54e7a | 1594 | |
Lightvalve | 57:f4819de54e7a | 1595 | I_REF = (1.0f - alpha_trans) * I_REF_POS + alpha_trans * (I_REF_VC + I_REF_FORCE_FB); |
Lightvalve | 67:c2812cf26c38 | 1596 | |
Lightvalve | 67:c2812cf26c38 | 1597 | // Anti-windup for FT |
Lightvalve | 67:c2812cf26c38 | 1598 | if (I_GAIN_JOINT_TORQUE != 0) { |
Lightvalve | 67:c2812cf26c38 | 1599 | double I_MAX = 10.0f; // Maximum Current : 10mV |
Lightvalve | 67:c2812cf26c38 | 1600 | double Ka = 2.0f / ((double) I_GAIN_JOINT_TORQUE * 0.001f); |
Lightvalve | 67:c2812cf26c38 | 1601 | if (I_REF > I_MAX) { |
Lightvalve | 67:c2812cf26c38 | 1602 | double I_rem = I_REF - I_MAX; |
Lightvalve | 67:c2812cf26c38 | 1603 | I_rem = Ka*I_rem; |
Lightvalve | 67:c2812cf26c38 | 1604 | I_REF = I_MAX; |
Lightvalve | 67:c2812cf26c38 | 1605 | torq.err_sum = torq.err_sum - I_rem /(float) TMR_FREQ_5k; |
Lightvalve | 67:c2812cf26c38 | 1606 | } else if (I_REF < -I_MAX) { |
Lightvalve | 67:c2812cf26c38 | 1607 | double I_rem = I_REF - (-I_MAX); |
Lightvalve | 67:c2812cf26c38 | 1608 | I_rem = Ka*I_rem; |
Lightvalve | 67:c2812cf26c38 | 1609 | I_REF = -I_MAX; |
Lightvalve | 67:c2812cf26c38 | 1610 | torq.err_sum = torq.err_sum - I_rem /(float) TMR_FREQ_5k; |
Lightvalve | 67:c2812cf26c38 | 1611 | } |
Lightvalve | 67:c2812cf26c38 | 1612 | } |
Lightvalve | 57:f4819de54e7a | 1613 | |
Lightvalve | 57:f4819de54e7a | 1614 | } else { |
Lightvalve | 57:f4819de54e7a | 1615 | float VALVE_POS_RAW_FORCE_FB = 0.0f; |
Lightvalve | 72:3436ce769b1e | 1616 | float VALVE_POS_RAW_FORCE_FF = 0.0f; |
Lightvalve | 72:3436ce769b1e | 1617 | float VALVE_POS_RAW = 0.0f; |
Lightvalve | 72:3436ce769b1e | 1618 | |
Lightvalve | 57:f4819de54e7a | 1619 | 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 | 1620 | + 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 | 1621 | |
Lightvalve | 72:3436ce769b1e | 1622 | 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 | 1623 | |
Lightvalve | 72:3436ce769b1e | 1624 | VALVE_POS_RAW = VALVE_POS_RAW_FORCE_FB + VALVE_POS_RAW_FORCE_FF; |
Lightvalve | 72:3436ce769b1e | 1625 | |
Lightvalve | 72:3436ce769b1e | 1626 | |
Lightvalve | 72:3436ce769b1e | 1627 | if (VALVE_POS_RAW >= 0) { |
Lightvalve | 72:3436ce769b1e | 1628 | valve_pos.ref = VALVE_POS_RAW + VALVE_DEADZONE_PLUS; |
Lightvalve | 57:f4819de54e7a | 1629 | } else { |
Lightvalve | 72:3436ce769b1e | 1630 | valve_pos.ref = VALVE_POS_RAW + VALVE_DEADZONE_MINUS; |
Lightvalve | 57:f4819de54e7a | 1631 | } |
Lightvalve | 57:f4819de54e7a | 1632 | |
Lightvalve | 57:f4819de54e7a | 1633 | if(I_GAIN_JOINT_TORQUE != 0) { |
Lightvalve | 57:f4819de54e7a | 1634 | double Ka = 1.0f / (double) I_GAIN_JOINT_TORQUE * 100.0f; |
Lightvalve | 57:f4819de54e7a | 1635 | if(valve_pos.ref>VALVE_MAX_POS) { |
Lightvalve | 57:f4819de54e7a | 1636 | double valve_pos_rem = valve_pos.ref - VALVE_MAX_POS; |
Lightvalve | 57:f4819de54e7a | 1637 | valve_pos_rem = valve_pos_rem * Ka; |
Lightvalve | 57:f4819de54e7a | 1638 | valve_pos.ref = VALVE_MAX_POS; |
Lightvalve | 57:f4819de54e7a | 1639 | torq.err_sum = torq.err_sum - valve_pos_rem/(float) TMR_FREQ_5k; |
Lightvalve | 57:f4819de54e7a | 1640 | } else if(valve_pos.ref < VALVE_MIN_POS) { |
Lightvalve | 57:f4819de54e7a | 1641 | double valve_pos_rem = valve_pos.ref - VALVE_MIN_POS; |
Lightvalve | 57:f4819de54e7a | 1642 | valve_pos_rem = valve_pos_rem * Ka; |
Lightvalve | 57:f4819de54e7a | 1643 | valve_pos.ref = VALVE_MIN_POS; |
Lightvalve | 57:f4819de54e7a | 1644 | torq.err_sum = torq.err_sum - valve_pos_rem/(float) TMR_FREQ_5k; |
Lightvalve | 57:f4819de54e7a | 1645 | } |
Lightvalve | 57:f4819de54e7a | 1646 | } |
Lightvalve | 61:bc8c8270f0ab | 1647 | |
Lightvalve | 57:f4819de54e7a | 1648 | VALVE_POS_CONTROL(valve_pos.ref); |
Lightvalve | 61:bc8c8270f0ab | 1649 | |
Lightvalve | 67:c2812cf26c38 | 1650 | // Vout.ref = (float) P_GAIN_JOINT_POSITION * 0.01f * ((float) pos.err); |
Lightvalve | 60:64181f1d3e60 | 1651 | V_out = (float) Vout.ref; |
Lightvalve | 57:f4819de54e7a | 1652 | |
Lightvalve | 57:f4819de54e7a | 1653 | } |
Lightvalve | 72:3436ce769b1e | 1654 | |
Lightvalve | 72:3436ce769b1e | 1655 | torq_ref_past = torq_ref; |
Lightvalve | 58:2eade98630e2 | 1656 | |
Lightvalve | 57:f4819de54e7a | 1657 | break; |
Lightvalve | 57:f4819de54e7a | 1658 | } |
Lightvalve | 58:2eade98630e2 | 1659 | |
Lightvalve | 57:f4819de54e7a | 1660 | case MODE_VALVE_OPEN_LOOP: { |
Lightvalve | 57:f4819de54e7a | 1661 | V_out = (float) Vout.ref; |
Lightvalve | 57:f4819de54e7a | 1662 | break; |
Lightvalve | 57:f4819de54e7a | 1663 | } |
Lightvalve | 14:8e7590227d22 | 1664 | |
Lightvalve | 12:6f2531038ea4 | 1665 | default: |
Lightvalve | 12:6f2531038ea4 | 1666 | break; |
Lightvalve | 12:6f2531038ea4 | 1667 | } |
Lightvalve | 14:8e7590227d22 | 1668 | |
Lightvalve | 57:f4819de54e7a | 1669 | |
Lightvalve | 57:f4819de54e7a | 1670 | if (((OPERATING_MODE&0b110)>>1) == 0 || ((OPERATING_MODE&0b110)>>1) == 1) { //Moog Valve or KNR Valve |
Lightvalve | 58:2eade98630e2 | 1671 | |
Lightvalve | 57:f4819de54e7a | 1672 | //////////////////////////////////////////////////////////////////////////// |
Lightvalve | 57:f4819de54e7a | 1673 | //////////////////////////// CURRENT CONTROL ////////////////////////////// |
Lightvalve | 57:f4819de54e7a | 1674 | //////////////////////////////////////////////////////////////////////////// |
Lightvalve | 57:f4819de54e7a | 1675 | if (CURRENT_CONTROL_MODE) { |
Lightvalve | 67:c2812cf26c38 | 1676 | double alpha_update_Iref = 1.0f / (1.0f + 5000.0f / (2.0f * 3.14f * 300.0f)); // f_cutoff : 500Hz |
Lightvalve | 57:f4819de54e7a | 1677 | I_REF_fil = (1.0f - alpha_update_Iref) * I_REF_fil + alpha_update_Iref*I_REF; |
Lightvalve | 57:f4819de54e7a | 1678 | |
Lightvalve | 57:f4819de54e7a | 1679 | I_ERR = I_REF_fil - cur.sen; |
Lightvalve | 67:c2812cf26c38 | 1680 | I_ERR_INT = I_ERR_INT + (I_ERR) * 0.0002f; |
Lightvalve | 57:f4819de54e7a | 1681 | |
Lightvalve | 57:f4819de54e7a | 1682 | |
Lightvalve | 57:f4819de54e7a | 1683 | // Moog Valve Current Control Gain |
Lightvalve | 67:c2812cf26c38 | 1684 | double R_model = 500.0f; // ohm |
Lightvalve | 57:f4819de54e7a | 1685 | double L_model = 1.2f; |
Lightvalve | 57:f4819de54e7a | 1686 | double w0 = 2.0f * 3.14f * 150.0f; |
Lightvalve | 57:f4819de54e7a | 1687 | double KP_I = 0.1f * L_model*w0; |
Lightvalve | 57:f4819de54e7a | 1688 | double KI_I = 0.1f * R_model*w0; |
Lightvalve | 57:f4819de54e7a | 1689 | |
Lightvalve | 57:f4819de54e7a | 1690 | // KNR Valve Current Control Gain |
Lightvalve | 57:f4819de54e7a | 1691 | if (((OPERATING_MODE & 0b110)>>1) == 1) { // KNR Valve |
Lightvalve | 57:f4819de54e7a | 1692 | R_model = 163.0f; // ohm |
Lightvalve | 57:f4819de54e7a | 1693 | L_model = 1.0f; |
Lightvalve | 57:f4819de54e7a | 1694 | w0 = 2.0f * 3.14f * 80.0f; |
Lightvalve | 57:f4819de54e7a | 1695 | KP_I = 1.0f * L_model*w0; |
Lightvalve | 57:f4819de54e7a | 1696 | KI_I = 0.08f * R_model*w0; |
Lightvalve | 57:f4819de54e7a | 1697 | } |
Lightvalve | 57:f4819de54e7a | 1698 | |
Lightvalve | 57:f4819de54e7a | 1699 | double FF_gain = 1.0f; |
Lightvalve | 57:f4819de54e7a | 1700 | |
Lightvalve | 67:c2812cf26c38 | 1701 | VALVE_PWM_RAW = KP_I * 2.0f * I_ERR + KI_I * 2.0f* I_ERR_INT; |
Lightvalve | 57:f4819de54e7a | 1702 | // VALVE_PWM_RAW = VALVE_PWM_RAW + FF_gain * (R_model*I_REF); // Unit : mV |
Lightvalve | 57:f4819de54e7a | 1703 | I_REF_fil_diff = I_REF_fil - I_REF_fil_old; |
Lightvalve | 57:f4819de54e7a | 1704 | I_REF_fil_old = I_REF_fil; |
Lightvalve | 67:c2812cf26c38 | 1705 | // 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 | 1706 | VALVE_PWM_RAW = VALVE_PWM_RAW + FF_gain * (R_model * I_REF_fil); // Unit : mV |
Lightvalve | 67:c2812cf26c38 | 1707 | double V_MAX = 12000.0f; // Maximum Voltage : 12V = 12000mV |
Lightvalve | 57:f4819de54e7a | 1708 | |
Lightvalve | 57:f4819de54e7a | 1709 | double Ka = 3.0f / KP_I; |
Lightvalve | 57:f4819de54e7a | 1710 | if (VALVE_PWM_RAW > V_MAX) { |
Lightvalve | 57:f4819de54e7a | 1711 | V_rem = VALVE_PWM_RAW - V_MAX; |
Lightvalve | 57:f4819de54e7a | 1712 | V_rem = Ka*V_rem; |
Lightvalve | 57:f4819de54e7a | 1713 | VALVE_PWM_RAW = V_MAX; |
Lightvalve | 67:c2812cf26c38 | 1714 | I_ERR_INT = I_ERR_INT - V_rem * 0.0002f; |
Lightvalve | 57:f4819de54e7a | 1715 | } else if (VALVE_PWM_RAW < -V_MAX) { |
Lightvalve | 57:f4819de54e7a | 1716 | V_rem = VALVE_PWM_RAW - (-V_MAX); |
Lightvalve | 57:f4819de54e7a | 1717 | V_rem = Ka*V_rem; |
Lightvalve | 57:f4819de54e7a | 1718 | VALVE_PWM_RAW = -V_MAX; |
Lightvalve | 67:c2812cf26c38 | 1719 | I_ERR_INT = I_ERR_INT - V_rem * 0.0002f; |
Lightvalve | 57:f4819de54e7a | 1720 | } |
Lightvalve | 57:f4819de54e7a | 1721 | Cur_Valve_Open_pulse = cur.sen / mA_PER_pulse; |
Lightvalve | 57:f4819de54e7a | 1722 | } else { |
Lightvalve | 57:f4819de54e7a | 1723 | VALVE_PWM_RAW = I_REF * mV_PER_mA; |
Lightvalve | 57:f4819de54e7a | 1724 | Cur_Valve_Open_pulse = I_REF / mA_PER_pulse; |
Lightvalve | 57:f4819de54e7a | 1725 | } |
Lightvalve | 57:f4819de54e7a | 1726 | |
Lightvalve | 57:f4819de54e7a | 1727 | //////////////////////////////////////////////////////////////////////////// |
Lightvalve | 57:f4819de54e7a | 1728 | ///////////////// Dead Zone Cancellation & Linearization ////////////////// |
Lightvalve | 57:f4819de54e7a | 1729 | //////////////////////////////////////////////////////////////////////////// |
Lightvalve | 57:f4819de54e7a | 1730 | // Dead Zone Cancellation (Mechanical Valve dead-zone) |
Lightvalve | 57:f4819de54e7a | 1731 | if (FLAG_VALVE_DEADZONE) { |
Lightvalve | 57:f4819de54e7a | 1732 | if (VALVE_PWM_RAW > 0) VALVE_PWM_RAW = VALVE_PWM_RAW + VALVE_DEADZONE_PLUS * mV_PER_pulse; // unit: mV |
Lightvalve | 57:f4819de54e7a | 1733 | else if (VALVE_PWM_RAW < 0) VALVE_PWM_RAW = VALVE_PWM_RAW + VALVE_DEADZONE_MINUS * mV_PER_pulse; // unit: mV |
Lightvalve | 57:f4819de54e7a | 1734 | |
Lightvalve | 57:f4819de54e7a | 1735 | VALVE_PWM_VALVE_DZ = VALVE_PWM_RAW + (double)VALVE_CENTER * mV_PER_pulse; // unit: mV |
Lightvalve | 57:f4819de54e7a | 1736 | |
Lightvalve | 57:f4819de54e7a | 1737 | } else { |
Lightvalve | 57:f4819de54e7a | 1738 | VALVE_PWM_VALVE_DZ = VALVE_PWM_RAW; |
Lightvalve | 57:f4819de54e7a | 1739 | } |
Lightvalve | 57:f4819de54e7a | 1740 | |
Lightvalve | 57:f4819de54e7a | 1741 | // Output Voltage Linearization |
Lightvalve | 57:f4819de54e7a | 1742 | double CUR_PWM_nonlin = VALVE_PWM_VALVE_DZ; // Unit : mV |
Lightvalve | 67:c2812cf26c38 | 1743 | double CUR_PWM_lin = PWM_duty_byLT(CUR_PWM_nonlin); // -8000~8000 |
Lightvalve | 57:f4819de54e7a | 1744 | |
Lightvalve | 57:f4819de54e7a | 1745 | // Dead Zone Cancellation (Electrical dead-zone) |
Lightvalve | 67:c2812cf26c38 | 1746 | if (CUR_PWM_lin > 0) V_out = (float) (CUR_PWM_lin + 169.0f); |
Lightvalve | 67:c2812cf26c38 | 1747 | else if (CUR_PWM_lin < 0) V_out = (float) (CUR_PWM_lin - 174.0f); |
Lightvalve | 67:c2812cf26c38 | 1748 | else V_out = (float) (CUR_PWM_lin); |
Lightvalve | 57:f4819de54e7a | 1749 | } |
Lightvalve | 67:c2812cf26c38 | 1750 | |
Lightvalve | 67:c2812cf26c38 | 1751 | // if(V_out > 0.0f) V_out = (float) (V_out + 169.0f); |
Lightvalve | 67:c2812cf26c38 | 1752 | // else if(V_out < 0.0f) V_out = (float) (V_out - 174.0f); |
Lightvalve | 67:c2812cf26c38 | 1753 | // else V_out = V_out; |
Lightvalve | 67:c2812cf26c38 | 1754 | |
jobuuu | 7:e9086c72bb22 | 1755 | /******************************************************* |
jobuuu | 7:e9086c72bb22 | 1756 | *** PWM |
jobuuu | 7:e9086c72bb22 | 1757 | ********************************************************/ |
Lightvalve | 67:c2812cf26c38 | 1758 | if(DIR_VALVE<0){ |
Lightvalve | 67:c2812cf26c38 | 1759 | V_out = -V_out; |
Lightvalve | 67:c2812cf26c38 | 1760 | } |
Lightvalve | 67:c2812cf26c38 | 1761 | |
Lightvalve | 49:e7bcfc244d40 | 1762 | if (V_out >= VALVE_VOLTAGE_LIMIT*1000.0f) { |
Lightvalve | 49:e7bcfc244d40 | 1763 | V_out = VALVE_VOLTAGE_LIMIT*1000.0f; |
Lightvalve | 49:e7bcfc244d40 | 1764 | } else if(V_out<=-VALVE_VOLTAGE_LIMIT*1000.0f) { |
Lightvalve | 49:e7bcfc244d40 | 1765 | V_out = -VALVE_VOLTAGE_LIMIT*1000.0f; |
Lightvalve | 27:a2254a485f23 | 1766 | } |
Lightvalve | 49:e7bcfc244d40 | 1767 | PWM_out= V_out/(SUPPLY_VOLTAGE*1000.0f); // Full duty : 12000.0mV |
Lightvalve | 13:747daba9cf59 | 1768 | |
Lightvalve | 19:23b7c1ad8683 | 1769 | // Saturation of output voltage to 12.0V |
Lightvalve | 30:8d561f16383b | 1770 | if(PWM_out > 1.0f) PWM_out=1.0f; |
Lightvalve | 30:8d561f16383b | 1771 | else if (PWM_out < -1.0f) PWM_out=-1.0f; |
Lightvalve | 13:747daba9cf59 | 1772 | |
Lightvalve | 30:8d561f16383b | 1773 | if (PWM_out>0.0f) { |
Lightvalve | 30:8d561f16383b | 1774 | dtc_v=0.0f; |
jobuuu | 1:e04e563be5ce | 1775 | dtc_w=PWM_out; |
jobuuu | 1:e04e563be5ce | 1776 | } else { |
jobuuu | 2:a1c0a37df760 | 1777 | dtc_v=-PWM_out; |
Lightvalve | 30:8d561f16383b | 1778 | dtc_w=0.0f; |
jobuuu | 1:e04e563be5ce | 1779 | } |
Lightvalve | 13:747daba9cf59 | 1780 | |
jobuuu | 1:e04e563be5ce | 1781 | //pwm |
Lightvalve | 30:8d561f16383b | 1782 | TIM4->CCR2 = (PWM_ARR)*(1.0f-dtc_v); |
Lightvalve | 30:8d561f16383b | 1783 | TIM4->CCR1 = (PWM_ARR)*(1.0f-dtc_w); |
Lightvalve | 67:c2812cf26c38 | 1784 | |
Lightvalve | 61:bc8c8270f0ab | 1785 | |
Lightvalve | 57:f4819de54e7a | 1786 | if (TMR2_COUNT_CAN_TX % (int) ((int) TMR_FREQ_5k/CAN_FREQ) == 0) { |
Lightvalve | 20:806196fda269 | 1787 | |
Lightvalve | 54:647072f5307a | 1788 | // Position, Velocity, and Torque (ID:1200) |
Lightvalve | 56:6f50d9d3bfee | 1789 | if (flag_data_request[0] == HIGH) { |
Lightvalve | 57:f4819de54e7a | 1790 | if ((OPERATING_MODE & 0b01) == 0) { // Rotary Actuator |
Lightvalve | 54:647072f5307a | 1791 | if (SENSING_MODE == 0) { |
Lightvalve | 67:c2812cf26c38 | 1792 | CAN_TX_POSITION_FT((int16_t) (pos.sen), (int16_t) (vel.sen/10.0f), (int16_t) (torq.sen*10.0f)); |
Lightvalve | 54:647072f5307a | 1793 | } else if (SENSING_MODE == 1) { |
Lightvalve | 58:2eade98630e2 | 1794 | 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 | 1795 | } |
Lightvalve | 57:f4819de54e7a | 1796 | } else if ((OPERATING_MODE & 0b01) == 1) { // Linear Actuator |
Lightvalve | 54:647072f5307a | 1797 | if (SENSING_MODE == 0) { |
Lightvalve | 67:c2812cf26c38 | 1798 | 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 | 1799 | } else if (SENSING_MODE == 1) { |
Lightvalve | 67:c2812cf26c38 | 1800 | 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 | 1801 | } |
Lightvalve | 52:8ea76864368a | 1802 | } |
Lightvalve | 52:8ea76864368a | 1803 | } |
Lightvalve | 56:6f50d9d3bfee | 1804 | if (flag_data_request[1] == HIGH) { |
Lightvalve | 54:647072f5307a | 1805 | //valve position |
Lightvalve | 54:647072f5307a | 1806 | double t_value = 0; |
Lightvalve | 67:c2812cf26c38 | 1807 | if(valve_pos.ref>=(float) VALVE_CENTER) { |
Lightvalve | 67:c2812cf26c38 | 1808 | t_value = 10000.0f*((double)valve_pos.ref - (double)VALVE_CENTER)/((double)VALVE_MAX_POS - (double)VALVE_CENTER); |
Lightvalve | 67:c2812cf26c38 | 1809 | } else { |
Lightvalve | 67:c2812cf26c38 | 1810 | t_value = -10000.0f*((double)valve_pos.ref - (double)VALVE_CENTER)/((double)VALVE_MIN_POS - (double)VALVE_CENTER); |
Lightvalve | 67:c2812cf26c38 | 1811 | } |
Lightvalve | 67:c2812cf26c38 | 1812 | // if(OPERATING_MODE==5) { |
Lightvalve | 67:c2812cf26c38 | 1813 | // t_value = (double) value; |
Lightvalve | 67:c2812cf26c38 | 1814 | // } else if(CURRENT_CONTROL_MODE==1) { |
Lightvalve | 67:c2812cf26c38 | 1815 | // t_value = cur.sen; |
Lightvalve | 57:f4819de54e7a | 1816 | // } else { |
Lightvalve | 67:c2812cf26c38 | 1817 | // t_value = V_out; |
Lightvalve | 67:c2812cf26c38 | 1818 | // } |
Lightvalve | 67:c2812cf26c38 | 1819 | CAN_TX_TORQUE((int16_t) (t_value)); //1300 |
Lightvalve | 67:c2812cf26c38 | 1820 | //CAN_TX_TORQUE((int16_t) (cur.sen * 1000.0f)); //1300 |
Lightvalve | 67:c2812cf26c38 | 1821 | //CAN_TX_TORQUE((int16_t) (I_REF * 1000.0f)); //1300 |
Lightvalve | 54:647072f5307a | 1822 | } |
Lightvalve | 58:2eade98630e2 | 1823 | |
Lightvalve | 58:2eade98630e2 | 1824 | |
Lightvalve | 56:6f50d9d3bfee | 1825 | if (flag_data_request[2] == HIGH) { |
Lightvalve | 56:6f50d9d3bfee | 1826 | //pressure A and B |
Lightvalve | 57:f4819de54e7a | 1827 | CAN_TX_PRES((int16_t) (pres_A.sen), (int16_t) (pres_B.sen)); // CUR_PRES_X : 0(0bar)~4096(210bar) //1400 |
Lightvalve | 55:b25725257569 | 1828 | } |
Lightvalve | 58:2eade98630e2 | 1829 | |
Lightvalve | 57:f4819de54e7a | 1830 | //If it doesn't rest, below can can not work. |
Lightvalve | 57:f4819de54e7a | 1831 | for (can_rest = 0; can_rest < 10000; can_rest++) { |
Lightvalve | 57:f4819de54e7a | 1832 | ; |
Lightvalve | 57:f4819de54e7a | 1833 | } |
Lightvalve | 58:2eade98630e2 | 1834 | |
Lightvalve | 56:6f50d9d3bfee | 1835 | if (flag_data_request[3] == HIGH) { |
Lightvalve | 54:647072f5307a | 1836 | //PWM |
Lightvalve | 73:f80dc3970c99 | 1837 | //CAN_TX_PWM((int16_t) value); //1500 |
Lightvalve | 73:f80dc3970c99 | 1838 | CAN_TX_PWM((int16_t) input_NN[0] * 100.0f); //1500 |
Lightvalve | 54:647072f5307a | 1839 | } |
Lightvalve | 57:f4819de54e7a | 1840 | //for (i = 0; i < 10000; i++) { |
Lightvalve | 57:f4819de54e7a | 1841 | // ; |
Lightvalve | 57:f4819de54e7a | 1842 | // } |
Lightvalve | 56:6f50d9d3bfee | 1843 | if (flag_data_request[4] == HIGH) { |
Lightvalve | 54:647072f5307a | 1844 | //valve position |
Lightvalve | 73:f80dc3970c99 | 1845 | 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 | 1846 | } |
Lightvalve | 20:806196fda269 | 1847 | |
Lightvalve | 54:647072f5307a | 1848 | // Others : Reference position, Reference FT, PWM, Current (ID:1300) |
Lightvalve | 52:8ea76864368a | 1849 | // if (flag_data_request[1] == HIGH) { |
Lightvalve | 52:8ea76864368a | 1850 | // CAN_TX_SOMETHING((int) (FORCE_VREF), (int16_t) (1), (int16_t) (2), (int16_t) (3)); |
Lightvalve | 52:8ea76864368a | 1851 | // } |
Lightvalve | 54:647072f5307a | 1852 | //if (flag_delay_test == 1){ |
Lightvalve | 58:2eade98630e2 | 1853 | //CAN_TX_PRES((int16_t) (0),(int16_t) torq_ref); |
Lightvalve | 54:647072f5307a | 1854 | //} |
Lightvalve | 52:8ea76864368a | 1855 | |
Lightvalve | 54:647072f5307a | 1856 | TMR2_COUNT_CAN_TX = 0; |
Lightvalve | 54:647072f5307a | 1857 | } |
Lightvalve | 54:647072f5307a | 1858 | TMR2_COUNT_CAN_TX++; |
Lightvalve | 52:8ea76864368a | 1859 | |
Lightvalve | 20:806196fda269 | 1860 | } |
Lightvalve | 52:8ea76864368a | 1861 | TIM3->SR = 0x0; // reset the status register |
Lightvalve | 52:8ea76864368a | 1862 | |
Lightvalve | 58:2eade98630e2 | 1863 | } |