Sungwoo Kim
/
HydraulicControlBoard_PostLIGHT_Original
Original Version of STM Board
CAN/function_CAN.cpp@73:f80dc3970c99, 2020-06-08 (annotated)
- Committer:
- Lightvalve
- Date:
- Mon Jun 08 11:00:23 2020 +0000
- Revision:
- 73:f80dc3970c99
- Parent:
- 72:3436ce769b1e
- Child:
- 85:a3b46118b5cd
200608
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jobuuu | 2:a1c0a37df760 | 1 | #include "function_CAN.h" |
Lightvalve | 11:82d8768d7351 | 2 | #include "setting.h" |
Lightvalve | 11:82d8768d7351 | 3 | #include "function_utilities.h" |
Lightvalve | 11:82d8768d7351 | 4 | #include "SPI_EEP_ENC.h" |
Lightvalve | 16:903b5a4433b4 | 5 | #include "stm32f4xx_flash.h" |
Lightvalve | 16:903b5a4433b4 | 6 | #include "FlashWriter.h" |
jobuuu | 2:a1c0a37df760 | 7 | |
jobuuu | 2:a1c0a37df760 | 8 | // CAN ID Setting Variables |
jobuuu | 2:a1c0a37df760 | 9 | int CID_RX_CMD = 100; |
jobuuu | 2:a1c0a37df760 | 10 | int CID_RX_REF_POSITION = 200; |
Lightvalve | 49:e7bcfc244d40 | 11 | int CID_RX_REF_VALVE_POS = 300; |
Lightvalve | 49:e7bcfc244d40 | 12 | int CID_RX_REF_PWM = 400; |
jobuuu | 2:a1c0a37df760 | 13 | |
jobuuu | 2:a1c0a37df760 | 14 | int CID_TX_INFO = 1100; |
jobuuu | 2:a1c0a37df760 | 15 | int CID_TX_POSITION = 1200; |
jobuuu | 2:a1c0a37df760 | 16 | int CID_TX_TORQUE = 1300; |
jobuuu | 2:a1c0a37df760 | 17 | int CID_TX_PRES = 1400; |
jobuuu | 7:e9086c72bb22 | 18 | int CID_TX_VOUT = 1500; |
jobuuu | 2:a1c0a37df760 | 19 | int CID_TX_VALVE_POSITION = 1600; |
jobuuu | 2:a1c0a37df760 | 20 | |
Lightvalve | 12:6f2531038ea4 | 21 | // variables |
Lightvalve | 12:6f2531038ea4 | 22 | uint8_t can_index = 0; |
Lightvalve | 67:c2812cf26c38 | 23 | |
Lightvalve | 66:a8e6799dbce3 | 24 | extern DigitalOut LED; |
Lightvalve | 12:6f2531038ea4 | 25 | |
Lightvalve | 68:328e1be06f5d | 26 | extern float x_past[]; |
Lightvalve | 68:328e1be06f5d | 27 | extern float f_past[]; |
Lightvalve | 68:328e1be06f5d | 28 | extern float f_future[]; |
Lightvalve | 73:f80dc3970c99 | 29 | extern float input_NN[]; |
Lightvalve | 68:328e1be06f5d | 30 | |
Lightvalve | 11:82d8768d7351 | 31 | /******************************************************************************* |
Lightvalve | 11:82d8768d7351 | 32 | * CAN functions |
Lightvalve | 11:82d8768d7351 | 33 | ******************************************************************************/ |
Lightvalve | 11:82d8768d7351 | 34 | void CAN_ID_INIT(void) { |
jobuuu | 7:e9086c72bb22 | 35 | |
Lightvalve | 11:82d8768d7351 | 36 | CID_RX_CMD = (int) (BNO + INIT_CID_RX_CMD); |
Lightvalve | 11:82d8768d7351 | 37 | CID_RX_REF_POSITION = (int) (BNO + INIT_CID_RX_REF_POSITION); |
Lightvalve | 49:e7bcfc244d40 | 38 | CID_RX_REF_VALVE_POS = (int) (BNO + INIT_CID_RX_REF_VALVE_POS); |
Lightvalve | 45:35fa6884d0c6 | 39 | CID_RX_REF_PWM = (int) (BNO + INIT_CID_RX_REF_PWM); |
Lightvalve | 11:82d8768d7351 | 40 | |
Lightvalve | 11:82d8768d7351 | 41 | CID_TX_INFO = (int) (BNO + INIT_CID_TX_INFO); |
Lightvalve | 11:82d8768d7351 | 42 | CID_TX_POSITION = (int) (BNO + INIT_CID_TX_POSITION); |
Lightvalve | 11:82d8768d7351 | 43 | CID_TX_TORQUE = (int) (BNO + INIT_CID_TX_TORQUE); |
Lightvalve | 11:82d8768d7351 | 44 | CID_TX_PRES = (int) (BNO + INIT_CID_TX_PRES); |
Lightvalve | 11:82d8768d7351 | 45 | CID_TX_VOUT = (int) (BNO + INIT_CID_TX_VOUT); |
Lightvalve | 11:82d8768d7351 | 46 | CID_TX_VALVE_POSITION = (int) (BNO + INIT_CID_TX_VALVE_POSITION); |
Lightvalve | 11:82d8768d7351 | 47 | } |
jobuuu | 2:a1c0a37df760 | 48 | |
Lightvalve | 28:2a62d73e3dd0 | 49 | void ReadCMD(int16_t CMD) |
jobuuu | 2:a1c0a37df760 | 50 | { |
jobuuu | 2:a1c0a37df760 | 51 | switch(CMD){ |
Lightvalve | 11:82d8768d7351 | 52 | case CRX_ASK_INFO: { |
Lightvalve | 11:82d8768d7351 | 53 | CAN_TX_INFO(); |
Lightvalve | 11:82d8768d7351 | 54 | break; |
Lightvalve | 11:82d8768d7351 | 55 | } |
Lightvalve | 11:82d8768d7351 | 56 | case CRX_ASK_BNO: { |
Lightvalve | 11:82d8768d7351 | 57 | CAN_TX_BNO(); |
Lightvalve | 11:82d8768d7351 | 58 | break; |
Lightvalve | 11:82d8768d7351 | 59 | } |
Lightvalve | 11:82d8768d7351 | 60 | case CRX_SET_BNO: { |
Lightvalve | 11:82d8768d7351 | 61 | BNO = (int16_t) msg.data[1]; |
Lightvalve | 16:903b5a4433b4 | 62 | |
Lightvalve | 16:903b5a4433b4 | 63 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 64 | |
Lightvalve | 16:903b5a4433b4 | 65 | //spi_eeprom_write(RID_BNO, (int16_t) BNO); |
Lightvalve | 11:82d8768d7351 | 66 | CAN_ID_INIT(); // can id init |
Lightvalve | 11:82d8768d7351 | 67 | break; |
Lightvalve | 11:82d8768d7351 | 68 | } |
Lightvalve | 11:82d8768d7351 | 69 | case CRX_ASK_OPERATING_MODE: { |
Lightvalve | 11:82d8768d7351 | 70 | CAN_TX_OPERATING_MODE(); |
Lightvalve | 11:82d8768d7351 | 71 | break; |
Lightvalve | 11:82d8768d7351 | 72 | } |
Lightvalve | 11:82d8768d7351 | 73 | case CRX_SET_OPERATING_MODE: { |
Lightvalve | 52:8ea76864368a | 74 | OPERATING_MODE = (uint8_t) msg.data[1]; |
Lightvalve | 52:8ea76864368a | 75 | SENSING_MODE = (uint8_t) msg.data[2]; |
Lightvalve | 52:8ea76864368a | 76 | CURRENT_CONTROL_MODE = (uint8_t) msg.data[3]; |
Lightvalve | 52:8ea76864368a | 77 | FLAG_VALVE_DEADZONE = (uint8_t) msg.data[4]; |
Lightvalve | 16:903b5a4433b4 | 78 | ROM_RESET_DATA(); |
Lightvalve | 11:82d8768d7351 | 79 | break; |
Lightvalve | 11:82d8768d7351 | 80 | } |
Lightvalve | 11:82d8768d7351 | 81 | case CRX_SET_ENC_ZERO: { |
Lightvalve | 11:82d8768d7351 | 82 | ENC_SET_ZERO(); |
Lightvalve | 11:82d8768d7351 | 83 | |
Lightvalve | 11:82d8768d7351 | 84 | break; |
Lightvalve | 11:82d8768d7351 | 85 | } |
Lightvalve | 11:82d8768d7351 | 86 | case CRX_SET_FET_ON: { |
Lightvalve | 11:82d8768d7351 | 87 | |
Lightvalve | 11:82d8768d7351 | 88 | break; |
Lightvalve | 11:82d8768d7351 | 89 | } |
Lightvalve | 11:82d8768d7351 | 90 | |
Lightvalve | 45:35fa6884d0c6 | 91 | case CRX_SET_POS_TORQ_TRANS: { |
Lightvalve | 45:35fa6884d0c6 | 92 | MODE_POS_FT_TRANS = (int16_t) msg.data[1]; |
Lightvalve | 45:35fa6884d0c6 | 93 | /* |
Lightvalve | 45:35fa6884d0c6 | 94 | MODE_POS_FT_TRANS == 0 : Position Control |
Lightvalve | 45:35fa6884d0c6 | 95 | MODE_POS_FT_TRANS == 1 : Trasition(Position->Torque) |
Lightvalve | 45:35fa6884d0c6 | 96 | MODE_POS_FT_TRANS == 2 : Torque Control (Convert to 2 automatically 3sec after transition) |
Lightvalve | 45:35fa6884d0c6 | 97 | MODE_POS_FT_TRANS == 3 : Transition(Toque->Position) |
Lightvalve | 45:35fa6884d0c6 | 98 | */ |
Lightvalve | 11:82d8768d7351 | 99 | break; |
Lightvalve | 11:82d8768d7351 | 100 | } |
Lightvalve | 11:82d8768d7351 | 101 | |
Lightvalve | 11:82d8768d7351 | 102 | case CRX_ASK_CAN_FREQ: { |
Lightvalve | 11:82d8768d7351 | 103 | CAN_TX_CAN_FREQ(); |
Lightvalve | 11:82d8768d7351 | 104 | |
Lightvalve | 11:82d8768d7351 | 105 | break; |
Lightvalve | 11:82d8768d7351 | 106 | } |
Lightvalve | 11:82d8768d7351 | 107 | |
Lightvalve | 11:82d8768d7351 | 108 | case CRX_SET_CAN_FREQ: { |
Lightvalve | 11:82d8768d7351 | 109 | CAN_FREQ = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 16:903b5a4433b4 | 110 | ROM_RESET_DATA(); |
Lightvalve | 11:82d8768d7351 | 111 | break; |
Lightvalve | 11:82d8768d7351 | 112 | } |
Lightvalve | 11:82d8768d7351 | 113 | |
Lightvalve | 11:82d8768d7351 | 114 | case CRX_ASK_CONTROL_MODE: { |
Lightvalve | 11:82d8768d7351 | 115 | CAN_TX_CONTROL_MODE(); |
Lightvalve | 11:82d8768d7351 | 116 | |
Lightvalve | 11:82d8768d7351 | 117 | break; |
Lightvalve | 11:82d8768d7351 | 118 | } |
Lightvalve | 11:82d8768d7351 | 119 | |
Lightvalve | 11:82d8768d7351 | 120 | case CRX_SET_CONTROL_MODE: { |
Lightvalve | 57:f4819de54e7a | 121 | //CONTROL_MODE = (int16_t) (msg.data[1]); |
Lightvalve | 57:f4819de54e7a | 122 | CONTROL_UTILITY_MODE = (int16_t) (msg.data[1]); |
Lightvalve | 12:6f2531038ea4 | 123 | if (CONTROL_MODE == 22) { //MODE_FIND_HOME |
Lightvalve | 11:82d8768d7351 | 124 | FLAG_FIND_HOME = true; |
Lightvalve | 11:82d8768d7351 | 125 | } |
Lightvalve | 11:82d8768d7351 | 126 | break; |
Lightvalve | 11:82d8768d7351 | 127 | } |
Lightvalve | 11:82d8768d7351 | 128 | |
Lightvalve | 11:82d8768d7351 | 129 | case CRX_SET_DATA_REQUEST: { |
Lightvalve | 11:82d8768d7351 | 130 | int request_type = msg.data[2]; |
Lightvalve | 11:82d8768d7351 | 131 | flag_data_request[request_type] = msg.data[1]; |
Lightvalve | 14:8e7590227d22 | 132 | //pc.printf("can middle %d\n", request_type); |
Lightvalve | 11:82d8768d7351 | 133 | |
Lightvalve | 12:6f2531038ea4 | 134 | // if (flag_data_request[1] == HIGH) SPI_VREF_DAC_WRITE(PRES_A_VREF, PRES_B_VREF, TORQUE_VREF, 0); // set DAC |
Lightvalve | 15:bd0d12728506 | 135 | //if (flag_data_request[1] == HIGH) dac_1 = PRES_A_VREF/3.3; |
Lightvalve | 12:6f2531038ea4 | 136 | // if (flag_data_request[2] == HIGH) SPI_VREF_DAC_WRITE(PRES_A_VREF, PRES_B_VREF, TORQUE_VREF, 0); // set DAC |
Lightvalve | 15:bd0d12728506 | 137 | //if (flag_data_request[2] == HIGH) dac_2 = PRES_B_VREF/3.3; |
Lightvalve | 11:82d8768d7351 | 138 | |
Lightvalve | 11:82d8768d7351 | 139 | break; |
Lightvalve | 11:82d8768d7351 | 140 | } |
Lightvalve | 11:82d8768d7351 | 141 | |
Lightvalve | 11:82d8768d7351 | 142 | case CRX_ASK_JOINT_ENC_DIR: { |
Lightvalve | 11:82d8768d7351 | 143 | CAN_TX_JOINT_ENC_DIR(); |
Lightvalve | 11:82d8768d7351 | 144 | |
Lightvalve | 11:82d8768d7351 | 145 | break; |
Lightvalve | 11:82d8768d7351 | 146 | } |
Lightvalve | 11:82d8768d7351 | 147 | |
Lightvalve | 11:82d8768d7351 | 148 | case CRX_SET_JOINT_ENC_DIR: { |
Lightvalve | 11:82d8768d7351 | 149 | DIR_JOINT_ENC = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 11:82d8768d7351 | 150 | if (DIR_JOINT_ENC >= 0) |
Lightvalve | 11:82d8768d7351 | 151 | DIR_JOINT_ENC = 1; |
Lightvalve | 11:82d8768d7351 | 152 | else |
Lightvalve | 11:82d8768d7351 | 153 | DIR_JOINT_ENC = -1; |
Lightvalve | 16:903b5a4433b4 | 154 | |
Lightvalve | 16:903b5a4433b4 | 155 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 156 | |
Lightvalve | 16:903b5a4433b4 | 157 | //spi_eeprom_write(RID_JOINT_ENC_DIR, (int16_t) DIR_JOINT_ENC); |
Lightvalve | 11:82d8768d7351 | 158 | |
Lightvalve | 11:82d8768d7351 | 159 | break; |
Lightvalve | 11:82d8768d7351 | 160 | } |
Lightvalve | 11:82d8768d7351 | 161 | |
Lightvalve | 11:82d8768d7351 | 162 | case CRX_ASK_VALVE_DIR: { |
Lightvalve | 11:82d8768d7351 | 163 | CAN_TX_VALVE_DIR(); |
Lightvalve | 11:82d8768d7351 | 164 | |
Lightvalve | 11:82d8768d7351 | 165 | break; |
Lightvalve | 11:82d8768d7351 | 166 | } |
Lightvalve | 11:82d8768d7351 | 167 | |
Lightvalve | 11:82d8768d7351 | 168 | case CRX_SET_VALVE_DIR: { |
Lightvalve | 11:82d8768d7351 | 169 | DIR_VALVE = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 11:82d8768d7351 | 170 | if (DIR_VALVE >= 0) |
Lightvalve | 11:82d8768d7351 | 171 | DIR_VALVE = 1; |
Lightvalve | 11:82d8768d7351 | 172 | else |
Lightvalve | 11:82d8768d7351 | 173 | DIR_VALVE = -1; |
Lightvalve | 16:903b5a4433b4 | 174 | |
Lightvalve | 16:903b5a4433b4 | 175 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 176 | |
Lightvalve | 16:903b5a4433b4 | 177 | //spi_eeprom_write(RID_VALVE_DIR, (int16_t) DIR_VALVE); |
Lightvalve | 11:82d8768d7351 | 178 | |
Lightvalve | 11:82d8768d7351 | 179 | break; |
Lightvalve | 11:82d8768d7351 | 180 | } |
Lightvalve | 11:82d8768d7351 | 181 | |
Lightvalve | 11:82d8768d7351 | 182 | case CRX_ASK_VALVE_ENC_DIR: { |
Lightvalve | 11:82d8768d7351 | 183 | CAN_TX_VALVE_ENC_DIR(); |
Lightvalve | 11:82d8768d7351 | 184 | |
Lightvalve | 11:82d8768d7351 | 185 | break; |
Lightvalve | 11:82d8768d7351 | 186 | } |
Lightvalve | 11:82d8768d7351 | 187 | |
Lightvalve | 11:82d8768d7351 | 188 | case CRX_SET_VALVE_ENC_DIR: { |
Lightvalve | 11:82d8768d7351 | 189 | DIR_VALVE_ENC = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 11:82d8768d7351 | 190 | if (DIR_VALVE_ENC >= 0) |
Lightvalve | 11:82d8768d7351 | 191 | DIR_VALVE_ENC = 1; |
Lightvalve | 11:82d8768d7351 | 192 | else |
Lightvalve | 11:82d8768d7351 | 193 | DIR_VALVE_ENC = -1; |
Lightvalve | 16:903b5a4433b4 | 194 | |
Lightvalve | 16:903b5a4433b4 | 195 | ROM_RESET_DATA(); |
Lightvalve | 11:82d8768d7351 | 196 | |
Lightvalve | 16:903b5a4433b4 | 197 | //spi_eeprom_write(RID_VALVE_ENC_DIR, (int16_t) DIR_VALVE_ENC); |
Lightvalve | 11:82d8768d7351 | 198 | |
Lightvalve | 11:82d8768d7351 | 199 | break; |
Lightvalve | 11:82d8768d7351 | 200 | } |
Lightvalve | 11:82d8768d7351 | 201 | |
Lightvalve | 11:82d8768d7351 | 202 | case CRX_ASK_VOLTAGE_SUPPLY: { |
Lightvalve | 11:82d8768d7351 | 203 | CAN_TX_VOLTAGE_SUPPLY(); |
Lightvalve | 11:82d8768d7351 | 204 | |
Lightvalve | 11:82d8768d7351 | 205 | break; |
Lightvalve | 11:82d8768d7351 | 206 | } |
Lightvalve | 11:82d8768d7351 | 207 | |
Lightvalve | 11:82d8768d7351 | 208 | case CRX_SET_VOLTAGE_SUPPLY: { |
Lightvalve | 30:8d561f16383b | 209 | SUPPLY_VOLTAGE = (double) ((int16_t) (msg.data[1] | msg.data[2] << 8)) / 10.0f; |
Lightvalve | 16:903b5a4433b4 | 210 | |
Lightvalve | 16:903b5a4433b4 | 211 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 212 | |
Lightvalve | 16:903b5a4433b4 | 213 | //spi_eeprom_write(RID_VOLATGE_SUPPLY, (int16_t) (SUPPLY_VOLTAGE * 10.)); |
Lightvalve | 11:82d8768d7351 | 214 | |
Lightvalve | 11:82d8768d7351 | 215 | break; |
Lightvalve | 11:82d8768d7351 | 216 | } |
Lightvalve | 11:82d8768d7351 | 217 | |
Lightvalve | 11:82d8768d7351 | 218 | case CRX_ASK_VOLTAGE_VALVE: { |
Lightvalve | 11:82d8768d7351 | 219 | CAN_TX_VOLTAGE_VALVE(); |
Lightvalve | 11:82d8768d7351 | 220 | |
Lightvalve | 11:82d8768d7351 | 221 | break; |
Lightvalve | 11:82d8768d7351 | 222 | } |
Lightvalve | 11:82d8768d7351 | 223 | |
Lightvalve | 11:82d8768d7351 | 224 | case CRX_SET_VOLTAGE_VALVE: { |
Lightvalve | 30:8d561f16383b | 225 | VALVE_VOLTAGE_LIMIT = (double) ((int16_t) (msg.data[1] | msg.data[2] << 8)) / 10.0f; |
Lightvalve | 16:903b5a4433b4 | 226 | |
Lightvalve | 16:903b5a4433b4 | 227 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 228 | |
Lightvalve | 16:903b5a4433b4 | 229 | //spi_eeprom_write(RID_VOLTAGE_VALVE, (int16_t) (VALVE_VOLTAGE_LIMIT * 10.)); |
Lightvalve | 11:82d8768d7351 | 230 | |
Lightvalve | 11:82d8768d7351 | 231 | |
Lightvalve | 11:82d8768d7351 | 232 | break; |
Lightvalve | 11:82d8768d7351 | 233 | } |
Lightvalve | 12:6f2531038ea4 | 234 | |
Lightvalve | 11:82d8768d7351 | 235 | case CRX_SET_HOMEPOS: { |
Lightvalve | 57:f4819de54e7a | 236 | //CONTROL_MODE = 22; |
Lightvalve | 57:f4819de54e7a | 237 | CONTROL_UTILITY_MODE = 22; |
Lightvalve | 11:82d8768d7351 | 238 | break; |
Lightvalve | 11:82d8768d7351 | 239 | } |
Lightvalve | 11:82d8768d7351 | 240 | |
Lightvalve | 11:82d8768d7351 | 241 | case CRX_ASK_PID_GAIN: { |
Lightvalve | 11:82d8768d7351 | 242 | CAN_TX_PID_GAIN(msg.data[1]); |
Lightvalve | 11:82d8768d7351 | 243 | |
Lightvalve | 11:82d8768d7351 | 244 | break; |
Lightvalve | 11:82d8768d7351 | 245 | } |
Lightvalve | 11:82d8768d7351 | 246 | |
Lightvalve | 11:82d8768d7351 | 247 | case CRX_SET_PID_GAIN: { |
Lightvalve | 11:82d8768d7351 | 248 | if (msg.data[1] == 0) { |
Lightvalve | 11:82d8768d7351 | 249 | P_GAIN_VALVE_POSITION = (int16_t) (msg.data[2] | msg.data[3] << 8); |
Lightvalve | 11:82d8768d7351 | 250 | I_GAIN_VALVE_POSITION = (int16_t) (msg.data[4] | msg.data[5] << 8); |
Lightvalve | 11:82d8768d7351 | 251 | D_GAIN_VALVE_POSITION = (int16_t) (msg.data[6] | msg.data[7] << 8); |
Lightvalve | 16:903b5a4433b4 | 252 | |
Lightvalve | 16:903b5a4433b4 | 253 | ROM_RESET_DATA(); |
Lightvalve | 11:82d8768d7351 | 254 | |
Lightvalve | 11:82d8768d7351 | 255 | } else if (msg.data[1] == 1) { |
Lightvalve | 11:82d8768d7351 | 256 | P_GAIN_JOINT_POSITION = (int16_t) (msg.data[2] | msg.data[3] << 8); |
Lightvalve | 11:82d8768d7351 | 257 | I_GAIN_JOINT_POSITION = (int16_t) (msg.data[4] | msg.data[5] << 8); |
Lightvalve | 11:82d8768d7351 | 258 | D_GAIN_JOINT_POSITION = (int16_t) (msg.data[6] | msg.data[7] << 8); |
Lightvalve | 16:903b5a4433b4 | 259 | |
Lightvalve | 16:903b5a4433b4 | 260 | ROM_RESET_DATA(); |
Lightvalve | 48:889798ff9329 | 261 | |
Lightvalve | 11:82d8768d7351 | 262 | } else if (msg.data[1] == 2) { |
Lightvalve | 11:82d8768d7351 | 263 | P_GAIN_JOINT_TORQUE = (int16_t) (msg.data[2] | msg.data[3] << 8); |
Lightvalve | 11:82d8768d7351 | 264 | I_GAIN_JOINT_TORQUE = (int16_t) (msg.data[4] | msg.data[5] << 8); |
Lightvalve | 11:82d8768d7351 | 265 | D_GAIN_JOINT_TORQUE = (int16_t) (msg.data[6] | msg.data[7] << 8); |
Lightvalve | 16:903b5a4433b4 | 266 | |
Lightvalve | 16:903b5a4433b4 | 267 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 268 | |
Lightvalve | 46:2694daea349b | 269 | } else if (msg.data[1] == 3) { |
Lightvalve | 67:c2812cf26c38 | 270 | K_SPRING = (float) (((float) ((int16_t) (msg.data[2] | msg.data[3] << 8))) * 0.1f); |
Lightvalve | 67:c2812cf26c38 | 271 | D_DAMPER = (float) (((float) ((int16_t) (msg.data[4] | msg.data[5] << 8))) * 0.01f); |
Lightvalve | 46:2694daea349b | 272 | |
Lightvalve | 67:c2812cf26c38 | 273 | // ROM_RESET_DATA(); //For Real-time changing |
Lightvalve | 72:3436ce769b1e | 274 | } else if (msg.data[1] == 4) { |
Lightvalve | 72:3436ce769b1e | 275 | P_GAIN_JOINT_TORQUE_FF = (int16_t) (msg.data[2] | msg.data[3] << 8); |
Lightvalve | 72:3436ce769b1e | 276 | I_GAIN_JOINT_TORQUE_FF = (int16_t) (msg.data[4] | msg.data[5] << 8); |
Lightvalve | 72:3436ce769b1e | 277 | D_GAIN_JOINT_TORQUE_FF = (int16_t) (msg.data[6] | msg.data[7] << 8); |
Lightvalve | 72:3436ce769b1e | 278 | |
Lightvalve | 72:3436ce769b1e | 279 | ROM_RESET_DATA(); |
Lightvalve | 11:82d8768d7351 | 280 | } |
Lightvalve | 11:82d8768d7351 | 281 | |
Lightvalve | 11:82d8768d7351 | 282 | break; |
Lightvalve | 11:82d8768d7351 | 283 | } |
Lightvalve | 11:82d8768d7351 | 284 | |
Lightvalve | 11:82d8768d7351 | 285 | case CRX_ASK_VALVE_DEADZONE: { |
Lightvalve | 11:82d8768d7351 | 286 | CAN_TX_VALVE_DEADZONE(); |
Lightvalve | 11:82d8768d7351 | 287 | |
Lightvalve | 11:82d8768d7351 | 288 | break; |
Lightvalve | 11:82d8768d7351 | 289 | } |
Lightvalve | 11:82d8768d7351 | 290 | |
Lightvalve | 11:82d8768d7351 | 291 | case CRX_SET_VALVE_DEADZONE: { |
Lightvalve | 11:82d8768d7351 | 292 | VALVE_CENTER = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 11:82d8768d7351 | 293 | VALVE_DEADZONE_PLUS = (int16_t) (msg.data[3] | msg.data[4] << 8); |
Lightvalve | 11:82d8768d7351 | 294 | VALVE_DEADZONE_MINUS = (int16_t) (msg.data[5] | msg.data[6] << 8); |
Lightvalve | 16:903b5a4433b4 | 295 | |
Lightvalve | 16:903b5a4433b4 | 296 | ROM_RESET_DATA(); |
Lightvalve | 11:82d8768d7351 | 297 | |
Lightvalve | 11:82d8768d7351 | 298 | break; |
Lightvalve | 11:82d8768d7351 | 299 | } |
Lightvalve | 11:82d8768d7351 | 300 | |
Lightvalve | 11:82d8768d7351 | 301 | case CRX_ASK_VELOCITY_COMP_GAIN: { |
Lightvalve | 11:82d8768d7351 | 302 | CAN_TX_VELOCITY_COMP_GAIN(); |
Lightvalve | 11:82d8768d7351 | 303 | |
Lightvalve | 11:82d8768d7351 | 304 | break; |
Lightvalve | 11:82d8768d7351 | 305 | } |
Lightvalve | 11:82d8768d7351 | 306 | |
Lightvalve | 11:82d8768d7351 | 307 | case CRX_SET_VELOCITY_COMP_GAIN: { |
Lightvalve | 11:82d8768d7351 | 308 | VELOCITY_COMP_GAIN = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 16:903b5a4433b4 | 309 | |
Lightvalve | 16:903b5a4433b4 | 310 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 311 | |
Lightvalve | 16:903b5a4433b4 | 312 | //spi_eeprom_write(RID_VELOCITY_COMP_GAIN, (int16_t) VELOCITY_COMP_GAIN); |
Lightvalve | 11:82d8768d7351 | 313 | |
Lightvalve | 11:82d8768d7351 | 314 | break; |
Lightvalve | 11:82d8768d7351 | 315 | } |
Lightvalve | 11:82d8768d7351 | 316 | |
Lightvalve | 11:82d8768d7351 | 317 | case CRX_ASK_COMPLIANCE_GAIN: { |
Lightvalve | 11:82d8768d7351 | 318 | CAN_TX_COMPLIANCE_GAIN(); |
Lightvalve | 11:82d8768d7351 | 319 | |
Lightvalve | 11:82d8768d7351 | 320 | break; |
Lightvalve | 11:82d8768d7351 | 321 | } |
Lightvalve | 11:82d8768d7351 | 322 | |
Lightvalve | 11:82d8768d7351 | 323 | case CRX_SET_COMPLIANCE_GAIN: { |
Lightvalve | 11:82d8768d7351 | 324 | COMPLIANCE_GAIN = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 11:82d8768d7351 | 325 | |
Lightvalve | 16:903b5a4433b4 | 326 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 327 | |
Lightvalve | 16:903b5a4433b4 | 328 | //spi_eeprom_write(RID_COMPLIANCE_GAIN, (int16_t) COMPLIANCE_GAIN); |
Lightvalve | 11:82d8768d7351 | 329 | |
Lightvalve | 11:82d8768d7351 | 330 | break; |
Lightvalve | 11:82d8768d7351 | 331 | } |
Lightvalve | 11:82d8768d7351 | 332 | |
Lightvalve | 11:82d8768d7351 | 333 | case CRX_ASK_VALVE_FF: { |
Lightvalve | 11:82d8768d7351 | 334 | CAN_TX_VALVE_FF(); |
Lightvalve | 11:82d8768d7351 | 335 | |
Lightvalve | 11:82d8768d7351 | 336 | break; |
Lightvalve | 11:82d8768d7351 | 337 | } |
Lightvalve | 11:82d8768d7351 | 338 | |
Lightvalve | 11:82d8768d7351 | 339 | case CRX_SET_VALVE_FF: { |
Lightvalve | 11:82d8768d7351 | 340 | VALVE_FF = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 16:903b5a4433b4 | 341 | |
Lightvalve | 16:903b5a4433b4 | 342 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 343 | |
Lightvalve | 16:903b5a4433b4 | 344 | //spi_eeprom_write(RID_VALVE_FF, (int16_t) VALVE_FF); |
Lightvalve | 11:82d8768d7351 | 345 | |
Lightvalve | 11:82d8768d7351 | 346 | break; |
Lightvalve | 11:82d8768d7351 | 347 | } |
Lightvalve | 11:82d8768d7351 | 348 | |
Lightvalve | 11:82d8768d7351 | 349 | case CRX_ASK_BULK_MODULUS: { |
Lightvalve | 11:82d8768d7351 | 350 | CAN_TX_BULK_MODULUS(); |
Lightvalve | 11:82d8768d7351 | 351 | |
Lightvalve | 11:82d8768d7351 | 352 | break; |
Lightvalve | 11:82d8768d7351 | 353 | } |
Lightvalve | 11:82d8768d7351 | 354 | |
Lightvalve | 11:82d8768d7351 | 355 | case CRX_SET_BULK_MODULUS: { |
Lightvalve | 11:82d8768d7351 | 356 | BULK_MODULUS = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 16:903b5a4433b4 | 357 | |
Lightvalve | 16:903b5a4433b4 | 358 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 359 | |
Lightvalve | 16:903b5a4433b4 | 360 | //spi_eeprom_write(RID_BULK_MODULUS, (int16_t) BULK_MODULUS); |
Lightvalve | 11:82d8768d7351 | 361 | |
Lightvalve | 11:82d8768d7351 | 362 | break; |
Lightvalve | 11:82d8768d7351 | 363 | } |
Lightvalve | 11:82d8768d7351 | 364 | |
Lightvalve | 11:82d8768d7351 | 365 | case CRX_ASK_CHAMBER_VOLUME: { |
Lightvalve | 11:82d8768d7351 | 366 | CAN_TX_CHAMBER_VOLUME(); |
Lightvalve | 11:82d8768d7351 | 367 | |
Lightvalve | 11:82d8768d7351 | 368 | break; |
Lightvalve | 11:82d8768d7351 | 369 | } |
Lightvalve | 11:82d8768d7351 | 370 | |
Lightvalve | 11:82d8768d7351 | 371 | case CRX_SET_CHAMBER_VOLUME: { |
Lightvalve | 11:82d8768d7351 | 372 | CHAMBER_VOLUME_A = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 11:82d8768d7351 | 373 | CHAMBER_VOLUME_B = (int16_t) (msg.data[3] | msg.data[4] << 8); |
Lightvalve | 11:82d8768d7351 | 374 | |
Lightvalve | 16:903b5a4433b4 | 375 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 376 | |
Lightvalve | 16:903b5a4433b4 | 377 | //spi_eeprom_write(RID_CHAMBER_VOLUME_A, (int16_t) CHAMBER_VOLUME_A); |
Lightvalve | 16:903b5a4433b4 | 378 | //spi_eeprom_write(RID_CHAMBER_VOLUME_B, (int16_t) CHAMBER_VOLUME_B); |
Lightvalve | 11:82d8768d7351 | 379 | |
Lightvalve | 11:82d8768d7351 | 380 | break; |
Lightvalve | 11:82d8768d7351 | 381 | } |
Lightvalve | 11:82d8768d7351 | 382 | |
Lightvalve | 11:82d8768d7351 | 383 | case CRX_ASK_PISTON_AREA: { |
Lightvalve | 11:82d8768d7351 | 384 | CAN_TX_PISTON_AREA(); |
Lightvalve | 11:82d8768d7351 | 385 | |
Lightvalve | 11:82d8768d7351 | 386 | break; |
Lightvalve | 11:82d8768d7351 | 387 | } |
Lightvalve | 11:82d8768d7351 | 388 | |
Lightvalve | 11:82d8768d7351 | 389 | case CRX_SET_PISTON_AREA: { |
Lightvalve | 11:82d8768d7351 | 390 | PISTON_AREA_A = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 11:82d8768d7351 | 391 | PISTON_AREA_B = (int16_t) (msg.data[3] | msg.data[4] << 8); |
Lightvalve | 69:3995ffeaa786 | 392 | PISTON_AREA_alpha = (double)PISTON_AREA_A/(double)PISTON_AREA_B; |
Lightvalve | 57:f4819de54e7a | 393 | alpha3 = PISTON_AREA_alpha * PISTON_AREA_alpha*PISTON_AREA_alpha; |
Lightvalve | 16:903b5a4433b4 | 394 | |
Lightvalve | 16:903b5a4433b4 | 395 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 396 | |
Lightvalve | 16:903b5a4433b4 | 397 | //spi_eeprom_write(RID_PISTON_AREA_A, (int16_t) PISTON_AREA_A); |
Lightvalve | 16:903b5a4433b4 | 398 | //spi_eeprom_write(RID_PISTON_AREA_B, (int16_t) PISTON_AREA_B); |
Lightvalve | 11:82d8768d7351 | 399 | break; |
Lightvalve | 11:82d8768d7351 | 400 | } |
Lightvalve | 11:82d8768d7351 | 401 | |
Lightvalve | 11:82d8768d7351 | 402 | case CRX_ASK_PRES: { |
Lightvalve | 11:82d8768d7351 | 403 | CAN_TX_PRES_A_AND_B(); |
Lightvalve | 12:6f2531038ea4 | 404 | // SPI_VREF_DAC_WRITE(PRES_A_VREF, PRES_B_VREF, TORQUE_VREF, 0); |
Lightvalve | 16:903b5a4433b4 | 405 | //dac_1 = PRES_A_VREF; |
Lightvalve | 16:903b5a4433b4 | 406 | //dac_2 = PRES_B_VREF; |
Lightvalve | 12:6f2531038ea4 | 407 | |
Lightvalve | 11:82d8768d7351 | 408 | break; |
Lightvalve | 11:82d8768d7351 | 409 | } |
Lightvalve | 11:82d8768d7351 | 410 | |
Lightvalve | 11:82d8768d7351 | 411 | case CRX_SET_PRES: { |
Lightvalve | 11:82d8768d7351 | 412 | PRES_SUPPLY = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 11:82d8768d7351 | 413 | PRES_RETURN = (int16_t) (msg.data[3] | msg.data[4] << 8); |
Lightvalve | 16:903b5a4433b4 | 414 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 415 | //spi_eeprom_write(RID_PRES_SUPPLY, (int16_t) PRES_SUPPLY); |
Lightvalve | 16:903b5a4433b4 | 416 | //spi_eeprom_write(RID_PRES_RETURN, (int16_t) PRES_RETURN); |
Lightvalve | 11:82d8768d7351 | 417 | |
Lightvalve | 11:82d8768d7351 | 418 | |
Lightvalve | 11:82d8768d7351 | 419 | break; |
Lightvalve | 11:82d8768d7351 | 420 | } |
Lightvalve | 11:82d8768d7351 | 421 | |
Lightvalve | 11:82d8768d7351 | 422 | case CRX_ASK_ENC_LIMIT: { |
Lightvalve | 11:82d8768d7351 | 423 | CAN_TX_ENC_LIMIT(); |
Lightvalve | 11:82d8768d7351 | 424 | |
Lightvalve | 11:82d8768d7351 | 425 | break; |
Lightvalve | 11:82d8768d7351 | 426 | } |
Lightvalve | 11:82d8768d7351 | 427 | |
Lightvalve | 11:82d8768d7351 | 428 | case CRX_SET_ENC_LIMIT: { |
Lightvalve | 11:82d8768d7351 | 429 | ENC_LIMIT_MINUS = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 11:82d8768d7351 | 430 | ENC_LIMIT_PLUS = (int16_t) (msg.data[3] | msg.data[4] << 8); |
Lightvalve | 16:903b5a4433b4 | 431 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 432 | //spi_eeprom_write(RID_ENC_LIMIT_MINUS, (int16_t) ENC_LIMIT_MINUS); |
Lightvalve | 16:903b5a4433b4 | 433 | //spi_eeprom_write(RID_ENC_LIMIT_PLUS, (int16_t) ENC_LIMIT_PLUS); |
Lightvalve | 11:82d8768d7351 | 434 | |
Lightvalve | 11:82d8768d7351 | 435 | break; |
Lightvalve | 11:82d8768d7351 | 436 | } |
Lightvalve | 11:82d8768d7351 | 437 | |
Lightvalve | 11:82d8768d7351 | 438 | case CRX_ASK_STROKE: { |
Lightvalve | 11:82d8768d7351 | 439 | CAN_TX_STROKE(); |
Lightvalve | 11:82d8768d7351 | 440 | break; |
Lightvalve | 11:82d8768d7351 | 441 | } |
Lightvalve | 11:82d8768d7351 | 442 | |
Lightvalve | 11:82d8768d7351 | 443 | case CRX_SET_STROKE: { |
Lightvalve | 11:82d8768d7351 | 444 | STROKE = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 16:903b5a4433b4 | 445 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 446 | //spi_eeprom_write(RID_STROKE, (int16_t) STROKE); |
Lightvalve | 11:82d8768d7351 | 447 | |
Lightvalve | 11:82d8768d7351 | 448 | break; |
Lightvalve | 11:82d8768d7351 | 449 | } |
Lightvalve | 11:82d8768d7351 | 450 | |
Lightvalve | 11:82d8768d7351 | 451 | case CRX_ASK_VALVE_LIMIT: { |
Lightvalve | 11:82d8768d7351 | 452 | CAN_TX_VALVE_LIMIT(); |
Lightvalve | 11:82d8768d7351 | 453 | |
Lightvalve | 11:82d8768d7351 | 454 | break; |
Lightvalve | 11:82d8768d7351 | 455 | } |
Lightvalve | 11:82d8768d7351 | 456 | |
Lightvalve | 11:82d8768d7351 | 457 | case CRX_SET_VALVE_LIMIT: { |
Lightvalve | 57:f4819de54e7a | 458 | VALVE_MIN_POS = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 57:f4819de54e7a | 459 | VALVE_MAX_POS = (int16_t) (msg.data[3] | msg.data[4] << 8); |
Lightvalve | 16:903b5a4433b4 | 460 | ROM_RESET_DATA(); |
Lightvalve | 11:82d8768d7351 | 461 | |
Lightvalve | 11:82d8768d7351 | 462 | break; |
Lightvalve | 11:82d8768d7351 | 463 | } |
Lightvalve | 11:82d8768d7351 | 464 | |
Lightvalve | 11:82d8768d7351 | 465 | case CRX_ASK_ENC_PULSE_PER_POSITION: { |
Lightvalve | 11:82d8768d7351 | 466 | CAN_TX_ENC_PULSE_PER_POSITION(); |
Lightvalve | 11:82d8768d7351 | 467 | |
Lightvalve | 11:82d8768d7351 | 468 | break; |
Lightvalve | 11:82d8768d7351 | 469 | } |
Lightvalve | 11:82d8768d7351 | 470 | |
Lightvalve | 11:82d8768d7351 | 471 | case CRX_SET_ENC_PULSE_PER_POSITION: { |
Lightvalve | 11:82d8768d7351 | 472 | ENC_PULSE_PER_POSITION = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 16:903b5a4433b4 | 473 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 474 | //spi_eeprom_write(RID_ENC_PULSE_PER_POSITION, (int16_t) ENC_PULSE_PER_POSITION); |
Lightvalve | 11:82d8768d7351 | 475 | |
Lightvalve | 11:82d8768d7351 | 476 | break; |
Lightvalve | 11:82d8768d7351 | 477 | } |
Lightvalve | 11:82d8768d7351 | 478 | |
Lightvalve | 11:82d8768d7351 | 479 | case CRX_ASK_TORQUE_SENSOR_PULSE_PER_TORQUE: { |
Lightvalve | 11:82d8768d7351 | 480 | CAN_TX_TORQUE_SENSOR_PULSE_PER_TORQUE(); |
Lightvalve | 11:82d8768d7351 | 481 | |
Lightvalve | 11:82d8768d7351 | 482 | break; |
Lightvalve | 11:82d8768d7351 | 483 | } |
Lightvalve | 11:82d8768d7351 | 484 | |
Lightvalve | 11:82d8768d7351 | 485 | case CRX_SET_TORQUE_SENSOR_PULSE_PER_TORQUE: { |
Lightvalve | 48:889798ff9329 | 486 | TORQUE_SENSOR_PULSE_PER_TORQUE = (float) ((int16_t) (msg.data[1] | msg.data[2] << 8) * 0.01f); |
Lightvalve | 16:903b5a4433b4 | 487 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 488 | //spi_eeprom_write(RID_TORQUE_SENSOR_PULSE_PER_TORQUE, (int16_t) TORQUE_SENSOR_PULSE_PER_TORQUE); |
Lightvalve | 11:82d8768d7351 | 489 | |
Lightvalve | 11:82d8768d7351 | 490 | break; |
Lightvalve | 11:82d8768d7351 | 491 | } |
Lightvalve | 11:82d8768d7351 | 492 | |
Lightvalve | 11:82d8768d7351 | 493 | case CRX_ASK_PRES_SENSOR_PULSE_PER_PRES: { |
Lightvalve | 11:82d8768d7351 | 494 | CAN_TX_PRES_SENSOR_PULSE_PER_PRES(); |
Lightvalve | 11:82d8768d7351 | 495 | |
Lightvalve | 11:82d8768d7351 | 496 | break; |
Lightvalve | 11:82d8768d7351 | 497 | } |
Lightvalve | 11:82d8768d7351 | 498 | |
Lightvalve | 11:82d8768d7351 | 499 | case CRX_SET_PRES_SENSOR_PULSE_PER_PRES: { |
Lightvalve | 30:8d561f16383b | 500 | PRES_SENSOR_A_PULSE_PER_BAR = (double) ((int16_t) (msg.data[1] | msg.data[2] << 8)) * 0.01f; |
Lightvalve | 30:8d561f16383b | 501 | PRES_SENSOR_B_PULSE_PER_BAR = (double) ((int16_t) (msg.data[3] | msg.data[4] << 8)) * 0.01f; |
Lightvalve | 16:903b5a4433b4 | 502 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 503 | //spi_eeprom_write(RID_PRES_SENSOR_A_PULSE_PER_BAR, (int16_t) (PRES_SENSOR_A_PULSE_PER_BAR * 100.)); |
Lightvalve | 16:903b5a4433b4 | 504 | //(RID_PRES_SENSOR_B_PULSE_PER_BAR, (int16_t) (PRES_SENSOR_B_PULSE_PER_BAR * 100.)); |
Lightvalve | 11:82d8768d7351 | 505 | |
Lightvalve | 11:82d8768d7351 | 506 | break; |
Lightvalve | 11:82d8768d7351 | 507 | } |
Lightvalve | 11:82d8768d7351 | 508 | |
Lightvalve | 11:82d8768d7351 | 509 | case CRX_ASK_FRICTION: { |
Lightvalve | 11:82d8768d7351 | 510 | CAN_TX_FRICTION(); |
Lightvalve | 11:82d8768d7351 | 511 | |
Lightvalve | 11:82d8768d7351 | 512 | break; |
Lightvalve | 11:82d8768d7351 | 513 | } |
Lightvalve | 11:82d8768d7351 | 514 | |
Lightvalve | 11:82d8768d7351 | 515 | case CRX_SET_FRICTION: { |
Lightvalve | 30:8d561f16383b | 516 | FRICTION = (double) ((int16_t) (msg.data[1] | msg.data[2] << 8)) / 10.0f; |
Lightvalve | 16:903b5a4433b4 | 517 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 518 | //spi_eeprom_write(RID_FRICTION, (int16_t) (FRICTION * 10.)); |
Lightvalve | 11:82d8768d7351 | 519 | |
Lightvalve | 11:82d8768d7351 | 520 | break; |
Lightvalve | 11:82d8768d7351 | 521 | } |
Lightvalve | 11:82d8768d7351 | 522 | |
Lightvalve | 11:82d8768d7351 | 523 | case CRX_ASK_VALVE_GAIN_PLUS: { |
Lightvalve | 11:82d8768d7351 | 524 | CAN_TX_VALVE_GAIN_PLUS(); |
Lightvalve | 11:82d8768d7351 | 525 | |
Lightvalve | 11:82d8768d7351 | 526 | break; |
Lightvalve | 11:82d8768d7351 | 527 | } |
Lightvalve | 11:82d8768d7351 | 528 | case CRX_SET_VALVE_GAIN_PLUS: { |
Lightvalve | 30:8d561f16383b | 529 | VALVE_GAIN_LPM_PER_V[0] = (double) msg.data[1] / 50.0f; |
Lightvalve | 30:8d561f16383b | 530 | VALVE_GAIN_LPM_PER_V[2] = (double) msg.data[2] / 50.0f; |
Lightvalve | 30:8d561f16383b | 531 | VALVE_GAIN_LPM_PER_V[4] = (double) msg.data[3] / 50.0f; |
Lightvalve | 30:8d561f16383b | 532 | VALVE_GAIN_LPM_PER_V[6] = (double) msg.data[4] / 50.0f; |
Lightvalve | 30:8d561f16383b | 533 | VALVE_GAIN_LPM_PER_V[8] = (double) msg.data[5] / 50.0f; |
Lightvalve | 16:903b5a4433b4 | 534 | ROM_RESET_DATA(); |
Lightvalve | 30:8d561f16383b | 535 | //spi_eeprom_write(RID_VALVE_GAIN_PLUS_1, (int16_t) (VALVE_GAIN_LPM_PER_V[0] * 100.0f)); |
Lightvalve | 30:8d561f16383b | 536 | //spi_eeprom_write(RID_VALVE_GAIN_PLUS_2, (int16_t) (VALVE_GAIN_LPM_PER_V[2] * 100.0f)); |
Lightvalve | 30:8d561f16383b | 537 | //spi_eeprom_write(RID_VALVE_GAIN_PLUS_3, (int16_t) (VALVE_GAIN_LPM_PER_V[4] * 100.0f)); |
Lightvalve | 30:8d561f16383b | 538 | //spi_eeprom_write(RID_VALVE_GAIN_PLUS_4, (int16_t) (VALVE_GAIN_LPM_PER_V[6] * 100.0f)); |
Lightvalve | 30:8d561f16383b | 539 | //spi_eeprom_write(RID_VALVE_GAIN_PLUS_5, (int16_t) (VALVE_GAIN_LPM_PER_V[8] * 100.0f)); |
Lightvalve | 11:82d8768d7351 | 540 | |
Lightvalve | 11:82d8768d7351 | 541 | break; |
Lightvalve | 11:82d8768d7351 | 542 | } |
Lightvalve | 11:82d8768d7351 | 543 | |
Lightvalve | 11:82d8768d7351 | 544 | case CRX_ASK_VALVE_GAIN_MINUS: { |
Lightvalve | 11:82d8768d7351 | 545 | CAN_TX_VALVE_GAIN_MINUS(); |
Lightvalve | 11:82d8768d7351 | 546 | |
Lightvalve | 11:82d8768d7351 | 547 | break; |
Lightvalve | 11:82d8768d7351 | 548 | } |
Lightvalve | 11:82d8768d7351 | 549 | case CRX_SET_VALVE_GAIN_MINUS: { |
Lightvalve | 30:8d561f16383b | 550 | VALVE_GAIN_LPM_PER_V[1] = (double) msg.data[1] / 50.0f; |
Lightvalve | 30:8d561f16383b | 551 | VALVE_GAIN_LPM_PER_V[3] = (double) msg.data[2] / 50.0f; |
Lightvalve | 30:8d561f16383b | 552 | VALVE_GAIN_LPM_PER_V[5] = (double) msg.data[3] / 50.0f; |
Lightvalve | 30:8d561f16383b | 553 | VALVE_GAIN_LPM_PER_V[7] = (double) msg.data[4] / 50.0f; |
Lightvalve | 30:8d561f16383b | 554 | VALVE_GAIN_LPM_PER_V[9] = (double) msg.data[5] / 50.0f; |
Lightvalve | 16:903b5a4433b4 | 555 | ROM_RESET_DATA(); |
Lightvalve | 30:8d561f16383b | 556 | //spi_eeprom_write(RID_VALVE_GAIN_MINUS_1, (int16_t) (VALVE_GAIN_LPM_PER_V[1] * 100.0f)); |
Lightvalve | 30:8d561f16383b | 557 | //spi_eeprom_write(RID_VALVE_GAIN_MINUS_2, (int16_t) (VALVE_GAIN_LPM_PER_V[3] * 100.0f)); |
Lightvalve | 30:8d561f16383b | 558 | //spi_eeprom_write(RID_VALVE_GAIN_MINUS_3, (int16_t) (VALVE_GAIN_LPM_PER_V[5] * 100.0f)); |
Lightvalve | 30:8d561f16383b | 559 | //spi_eeprom_write(RID_VALVE_GAIN_MINUS_4, (int16_t) (VALVE_GAIN_LPM_PER_V[7] * 100.0f)); |
Lightvalve | 30:8d561f16383b | 560 | //(RID_VALVE_GAIN_MINUS_5, (int16_t) (VALVE_GAIN_LPM_PER_V[9] * 100.0f)); |
Lightvalve | 11:82d8768d7351 | 561 | |
Lightvalve | 11:82d8768d7351 | 562 | break; |
Lightvalve | 11:82d8768d7351 | 563 | } |
Lightvalve | 11:82d8768d7351 | 564 | case CRX_ASK_DDV_VALVE_DEADZONE: { |
Lightvalve | 11:82d8768d7351 | 565 | CAN_TX_DDV_VALVE_DEADZONE(); |
Lightvalve | 11:82d8768d7351 | 566 | break; |
Lightvalve | 11:82d8768d7351 | 567 | } |
Lightvalve | 11:82d8768d7351 | 568 | |
Lightvalve | 11:82d8768d7351 | 569 | case CRX_LOW_REF: { |
Lightvalve | 11:82d8768d7351 | 570 | REFERENCE_MODE = msg.data[1]; |
Lightvalve | 11:82d8768d7351 | 571 | |
Lightvalve | 11:82d8768d7351 | 572 | REF_NUM = msg.data[2]; |
Lightvalve | 30:8d561f16383b | 573 | REF_PERIOD = (double) ((int16_t) (msg.data[3] | msg.data[4] << 8)) / 100.0f; |
Lightvalve | 30:8d561f16383b | 574 | if (REF_PERIOD <= 0.0f) REF_MOVE_TIME_5k = TMR_FREQ_5k / CAN_FREQ; |
Lightvalve | 11:82d8768d7351 | 575 | else REF_MOVE_TIME_5k = (int) (REF_PERIOD * (double) TMR_FREQ_5k); |
Lightvalve | 30:8d561f16383b | 576 | REF_MAG = (double) ((int16_t) (msg.data[5] | msg.data[6] << 8)) / 100.0f; |
Lightvalve | 11:82d8768d7351 | 577 | |
Lightvalve | 11:82d8768d7351 | 578 | break; |
Lightvalve | 11:82d8768d7351 | 579 | } |
Lightvalve | 11:82d8768d7351 | 580 | |
Lightvalve | 11:82d8768d7351 | 581 | case CRX_JUMP_STATUS: { |
Lightvalve | 11:82d8768d7351 | 582 | MODE_JUMP_STATUS = msg.data[1]; |
Lightvalve | 11:82d8768d7351 | 583 | |
Lightvalve | 11:82d8768d7351 | 584 | break; |
Lightvalve | 11:82d8768d7351 | 585 | } |
Lightvalve | 11:82d8768d7351 | 586 | |
Lightvalve | 11:82d8768d7351 | 587 | case CRX_SET_ERR_CLEAR: { |
Lightvalve | 11:82d8768d7351 | 588 | |
Lightvalve | 12:6f2531038ea4 | 589 | for (int i = 0; i < num_err; i++) { |
Lightvalve | 11:82d8768d7351 | 590 | flag_err[i] = FALSE; |
Lightvalve | 11:82d8768d7351 | 591 | flag_err_old[i] = FALSE; |
Lightvalve | 11:82d8768d7351 | 592 | } |
Lightvalve | 11:82d8768d7351 | 593 | |
Lightvalve | 11:82d8768d7351 | 594 | flag_err_rt = FALSE; |
Lightvalve | 11:82d8768d7351 | 595 | |
Lightvalve | 11:82d8768d7351 | 596 | |
Lightvalve | 11:82d8768d7351 | 597 | break; |
Lightvalve | 11:82d8768d7351 | 598 | } |
Lightvalve | 11:82d8768d7351 | 599 | |
Lightvalve | 11:82d8768d7351 | 600 | case CRX_ASK_HOMEPOS_OFFSET: { |
Lightvalve | 11:82d8768d7351 | 601 | CAN_TX_HOMEPOS_OFFSET(); |
Lightvalve | 11:82d8768d7351 | 602 | break; |
Lightvalve | 11:82d8768d7351 | 603 | } |
Lightvalve | 11:82d8768d7351 | 604 | case CRX_SET_HOMEPOS_OFFSET: { |
Lightvalve | 11:82d8768d7351 | 605 | HOMEPOS_OFFSET = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 16:903b5a4433b4 | 606 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 607 | //spi_eeprom_write(RID_HOMEPOS_OFFSET, (int16_t) HOMEPOS_OFFSET); |
Lightvalve | 11:82d8768d7351 | 608 | break; |
Lightvalve | 11:82d8768d7351 | 609 | } |
Lightvalve | 11:82d8768d7351 | 610 | |
Lightvalve | 11:82d8768d7351 | 611 | case CRX_ASK_HOMEPOS_VALVE_OPENING: { |
Lightvalve | 11:82d8768d7351 | 612 | CAN_TX_HOMPOS_VALVE_OPENING(); |
Lightvalve | 11:82d8768d7351 | 613 | break; |
Lightvalve | 11:82d8768d7351 | 614 | } |
Lightvalve | 11:82d8768d7351 | 615 | case CRX_SET_HOMEPOS_VALVE_OPENING: { |
Lightvalve | 11:82d8768d7351 | 616 | HOMEPOS_VALVE_OPENING = (int16_t) (msg.data[1] | msg.data[2] << 8); |
Lightvalve | 16:903b5a4433b4 | 617 | ROM_RESET_DATA(); |
Lightvalve | 16:903b5a4433b4 | 618 | //spi_eeprom_write(RID_HOMEPOS_VALVE_OPENING, (int16_t) HOMEPOS_VALVE_OPENING); |
Lightvalve | 11:82d8768d7351 | 619 | break; |
Lightvalve | 11:82d8768d7351 | 620 | } |
Lightvalve | 11:82d8768d7351 | 621 | |
Lightvalve | 11:82d8768d7351 | 622 | case CRX_ASK_VALVE_PWM_VS_VALVE_POS: { |
Lightvalve | 11:82d8768d7351 | 623 | can_index = (int16_t) msg.data[1]; |
Lightvalve | 11:82d8768d7351 | 624 | CAN_TX_VALVE_PWM_VS_VALVE_POS(can_index); |
Lightvalve | 11:82d8768d7351 | 625 | break; |
Lightvalve | 11:82d8768d7351 | 626 | } |
Lightvalve | 11:82d8768d7351 | 627 | case CRX_ASK_VALVE_POS_VS_FLOWRATE: { |
Lightvalve | 11:82d8768d7351 | 628 | can_index = (int16_t) msg.data[1]; |
Lightvalve | 11:82d8768d7351 | 629 | CAN_TX_VALVE_POS_VS_FLOWRATE(can_index); |
Lightvalve | 11:82d8768d7351 | 630 | break; |
Lightvalve | 11:82d8768d7351 | 631 | } |
Lightvalve | 11:82d8768d7351 | 632 | case CRX_ASK_VALVE_POS_NUM: { |
Lightvalve | 11:82d8768d7351 | 633 | CAN_TX_VALVE_POS_NUM(); |
Lightvalve | 11:82d8768d7351 | 634 | break; |
Lightvalve | 11:82d8768d7351 | 635 | } |
Lightvalve | 28:2a62d73e3dd0 | 636 | |
Lightvalve | 28:2a62d73e3dd0 | 637 | case CRX_SET_ROM: { |
Lightvalve | 28:2a62d73e3dd0 | 638 | ROM_RESET_DATA(); |
Lightvalve | 28:2a62d73e3dd0 | 639 | break; |
Lightvalve | 28:2a62d73e3dd0 | 640 | } |
Lightvalve | 32:4b8c0fedaf2c | 641 | case CRX_SET_VALVE_CENTER_OFFSET: { |
Lightvalve | 57:f4819de54e7a | 642 | VALVE_CENTER_OFFSET = ((float) ((int16_t) (msg.data[1] | msg.data[2] << 8))) * 0.1f; |
Lightvalve | 57:f4819de54e7a | 643 | VALVE_CENTER = VALVE_CENTER + VALVE_CENTER_OFFSET; |
Lightvalve | 33:91b17819ec30 | 644 | ROM_RESET_DATA(); |
Lightvalve | 33:91b17819ec30 | 645 | break; |
Lightvalve | 33:91b17819ec30 | 646 | } |
Lightvalve | 33:91b17819ec30 | 647 | case CRX_SET_VALVE_DZ_MINUS_OFFSET: { |
Lightvalve | 33:91b17819ec30 | 648 | VALVE_DZ_MINUS_OFFSET = ((float) ((int16_t) (msg.data[1] | msg.data[2] << 8))) * 0.1f; |
Lightvalve | 33:91b17819ec30 | 649 | VALVE_DEADZONE_MINUS = VALVE_DEADZONE_MINUS + VALVE_DZ_MINUS_OFFSET; |
Lightvalve | 33:91b17819ec30 | 650 | ROM_RESET_DATA(); |
Lightvalve | 33:91b17819ec30 | 651 | break; |
Lightvalve | 33:91b17819ec30 | 652 | } |
Lightvalve | 33:91b17819ec30 | 653 | case CRX_SET_VALVE_DZ_PLUS_OFFSET: { |
Lightvalve | 33:91b17819ec30 | 654 | VALVE_DZ_PLUS_OFFSET = ((float) ((int16_t) (msg.data[1] | msg.data[2] << 8))) * 0.1f; |
Lightvalve | 33:91b17819ec30 | 655 | VALVE_DEADZONE_PLUS = VALVE_DEADZONE_PLUS + VALVE_DZ_PLUS_OFFSET; |
Lightvalve | 32:4b8c0fedaf2c | 656 | ROM_RESET_DATA(); |
Lightvalve | 32:4b8c0fedaf2c | 657 | break; |
Lightvalve | 32:4b8c0fedaf2c | 658 | } |
Lightvalve | 36:a46e63505ed8 | 659 | case CRX_SET_PID_GAIN_OPP: { |
Lightvalve | 36:a46e63505ed8 | 660 | if (msg.data[1] == 0) { |
Lightvalve | 36:a46e63505ed8 | 661 | P_GAIN_VALVE_POSITION = (int16_t) (msg.data[2] | msg.data[3] << 8); |
Lightvalve | 36:a46e63505ed8 | 662 | I_GAIN_VALVE_POSITION = (int16_t) (msg.data[4] | msg.data[5] << 8); |
Lightvalve | 36:a46e63505ed8 | 663 | D_GAIN_VALVE_POSITION = (int16_t) (msg.data[6] | msg.data[7] << 8); |
Lightvalve | 36:a46e63505ed8 | 664 | |
Lightvalve | 36:a46e63505ed8 | 665 | ROM_RESET_DATA(); |
Lightvalve | 36:a46e63505ed8 | 666 | |
Lightvalve | 36:a46e63505ed8 | 667 | //spi_eeprom_write(RID_P_GAIN_VALVE_POSITION, (int16_t) P_GAIN_VALVE_POSITION); |
Lightvalve | 36:a46e63505ed8 | 668 | //spi_eeprom_write(RID_I_GAIN_VALVE_POSITION, (int16_t) I_GAIN_VALVE_POSITION); |
Lightvalve | 36:a46e63505ed8 | 669 | //spi_eeprom_write(RID_D_GAIN_VALVE_POSITION, (int16_t) D_GAIN_VALVE_POSITION); |
Lightvalve | 36:a46e63505ed8 | 670 | |
Lightvalve | 36:a46e63505ed8 | 671 | |
Lightvalve | 36:a46e63505ed8 | 672 | } else if (msg.data[1] == 1) { |
Lightvalve | 36:a46e63505ed8 | 673 | P_GAIN_JOINT_POSITION = (int16_t) (msg.data[2] | msg.data[3] << 8); |
Lightvalve | 36:a46e63505ed8 | 674 | I_GAIN_JOINT_POSITION = (int16_t) (msg.data[4] | msg.data[5] << 8); |
Lightvalve | 36:a46e63505ed8 | 675 | D_GAIN_JOINT_POSITION = (int16_t) (msg.data[6] | msg.data[7] << 8); |
Lightvalve | 36:a46e63505ed8 | 676 | |
Lightvalve | 36:a46e63505ed8 | 677 | ROM_RESET_DATA(); |
Lightvalve | 36:a46e63505ed8 | 678 | |
Lightvalve | 36:a46e63505ed8 | 679 | //spi_eeprom_write(RID_P_GAIN_JOINT_POSITION, (int16_t) P_GAIN_JOINT_POSITION); |
Lightvalve | 36:a46e63505ed8 | 680 | //spi_eeprom_write(RID_I_GAIN_JOINT_POSITION, (int16_t) I_GAIN_JOINT_POSITION); |
Lightvalve | 36:a46e63505ed8 | 681 | //spi_eeprom_write(RID_D_GAIN_JOINT_POSITION, (int16_t) D_GAIN_JOINT_POSITION); |
Lightvalve | 36:a46e63505ed8 | 682 | } else if (msg.data[1] == 2) { |
Lightvalve | 36:a46e63505ed8 | 683 | P_GAIN_JOINT_TORQUE = (int16_t) (msg.data[2] | msg.data[3] << 8); |
Lightvalve | 36:a46e63505ed8 | 684 | I_GAIN_JOINT_TORQUE = (int16_t) (msg.data[4] | msg.data[5] << 8); |
Lightvalve | 36:a46e63505ed8 | 685 | D_GAIN_JOINT_TORQUE = (int16_t) (msg.data[6] | msg.data[7] << 8); |
Lightvalve | 36:a46e63505ed8 | 686 | |
Lightvalve | 36:a46e63505ed8 | 687 | ROM_RESET_DATA(); |
Lightvalve | 36:a46e63505ed8 | 688 | |
Lightvalve | 36:a46e63505ed8 | 689 | //spi_eeprom_write(RID_P_GAIN_JOINT_TORQUE, (int16_t) P_GAIN_JOINT_TORQUE); |
Lightvalve | 36:a46e63505ed8 | 690 | //spi_eeprom_write(RID_I_GAIN_JOINT_TORQUE, (int16_t) I_GAIN_JOINT_TORQUE); |
Lightvalve | 36:a46e63505ed8 | 691 | //spi_eeprom_write(RID_D_GAIN_JOINT_TORQUE, (int16_t) D_GAIN_JOINT_TORQUE); |
Lightvalve | 36:a46e63505ed8 | 692 | } |
Lightvalve | 36:a46e63505ed8 | 693 | break; |
Lightvalve | 36:a46e63505ed8 | 694 | } |
Lightvalve | 38:118df027d851 | 695 | case CRX_ASK_VALVE_MAX_MIN_POS: { |
Lightvalve | 57:f4819de54e7a | 696 | //CAN_TX_DDV_VALVE_DEADZONE(); |
Lightvalve | 38:118df027d851 | 697 | CAN_TX_DDV_VALVE_MAX_MIN_POS(); |
Lightvalve | 38:118df027d851 | 698 | break; |
Lightvalve | 38:118df027d851 | 699 | } |
Lightvalve | 54:647072f5307a | 700 | case CRX_DELAY_TEST:{ |
Lightvalve | 54:647072f5307a | 701 | flag_delay_test = 1; |
Lightvalve | 54:647072f5307a | 702 | break; |
Lightvalve | 54:647072f5307a | 703 | } |
Lightvalve | 68:328e1be06f5d | 704 | case CRX_SET_NN_CONTROL_FLAG: { |
Lightvalve | 68:328e1be06f5d | 705 | NN_Control_Flag = (int16_t) msg.data[1]; |
Lightvalve | 68:328e1be06f5d | 706 | CONTROL_UTILITY_MODE = 1; |
Lightvalve | 68:328e1be06f5d | 707 | break; |
Lightvalve | 68:328e1be06f5d | 708 | } |
Lightvalve | 38:118df027d851 | 709 | |
jobuuu | 2:a1c0a37df760 | 710 | default: |
jobuuu | 2:a1c0a37df760 | 711 | break; |
jobuuu | 2:a1c0a37df760 | 712 | } |
jobuuu | 2:a1c0a37df760 | 713 | } |
jobuuu | 2:a1c0a37df760 | 714 | |
jobuuu | 2:a1c0a37df760 | 715 | void CAN_RX_HANDLER() |
jobuuu | 2:a1c0a37df760 | 716 | { |
Lightvalve | 23:59218d4a256d | 717 | |
jobuuu | 2:a1c0a37df760 | 718 | can.read(msg); |
jobuuu | 2:a1c0a37df760 | 719 | unsigned int address = msg.id; |
jobuuu | 7:e9086c72bb22 | 720 | if(address==CID_RX_CMD){ |
jobuuu | 2:a1c0a37df760 | 721 | unsigned int CMD = msg.data[0]; |
jobuuu | 2:a1c0a37df760 | 722 | ReadCMD(CMD); |
Lightvalve | 57:f4819de54e7a | 723 | |
jobuuu | 7:e9086c72bb22 | 724 | } else if(address==CID_RX_REF_POSITION) { |
Lightvalve | 57:f4819de54e7a | 725 | |
Lightvalve | 43:b084e5f5d0d5 | 726 | int16_t temp_pos = (int16_t) (msg.data[0] | msg.data[1] << 8); |
Lightvalve | 43:b084e5f5d0d5 | 727 | int16_t temp_vel = (int16_t) (msg.data[2] | msg.data[3] << 8); |
Lightvalve | 57:f4819de54e7a | 728 | int16_t temp_torq = (int16_t) (msg.data[4] | msg.data[5] << 8); |
Lightvalve | 41:abbd4e2af68b | 729 | |
Lightvalve | 57:f4819de54e7a | 730 | if((OPERATING_MODE&0b001)==0) { // Rotary Actuator |
Lightvalve | 57:f4819de54e7a | 731 | pos.ref = (double)temp_pos * 1.0f; |
Lightvalve | 57:f4819de54e7a | 732 | vel.ref = (double)temp_vel * 10.0f; |
Lightvalve | 57:f4819de54e7a | 733 | } |
Lightvalve | 57:f4819de54e7a | 734 | else { //Linear Actuator |
Lightvalve | 67:c2812cf26c38 | 735 | pos.ref = (double)temp_pos * 10.0f; |
Lightvalve | 67:c2812cf26c38 | 736 | vel.ref = (double)temp_vel * 256.0f; |
Lightvalve | 57:f4819de54e7a | 737 | } |
Lightvalve | 57:f4819de54e7a | 738 | |
Lightvalve | 68:328e1be06f5d | 739 | torq.ref = (double)temp_torq * 0.1f / TORQUE_SENSOR_PULSE_PER_TORQUE; //N |
Lightvalve | 68:328e1be06f5d | 740 | |
Lightvalve | 68:328e1be06f5d | 741 | |
Lightvalve | 68:328e1be06f5d | 742 | ///////////////Make Data/////////////////// |
Lightvalve | 68:328e1be06f5d | 743 | for(int i=0; i<num_array_x_past-1;i++){ |
Lightvalve | 68:328e1be06f5d | 744 | x_past[i] = x_past[i+1]; |
Lightvalve | 68:328e1be06f5d | 745 | } |
Lightvalve | 68:328e1be06f5d | 746 | x_past[num_array_x_past-1] = pos.sen / ENC_PULSE_PER_POSITION; //mm |
Lightvalve | 68:328e1be06f5d | 747 | |
Lightvalve | 68:328e1be06f5d | 748 | for(int i=0; i<num_array_f_past-1;i++){ |
Lightvalve | 68:328e1be06f5d | 749 | f_past[i] = f_past[i+1]; |
Lightvalve | 68:328e1be06f5d | 750 | } |
Lightvalve | 68:328e1be06f5d | 751 | f_past[num_array_f_past-1] = torq.sen; //N |
Lightvalve | 68:328e1be06f5d | 752 | |
Lightvalve | 68:328e1be06f5d | 753 | f_future[0] = torq.sen; //N |
Lightvalve | 68:328e1be06f5d | 754 | for(int i=1;i<num_array_f_future-1;i++){ |
Lightvalve | 68:328e1be06f5d | 755 | f_future[i] = f_future[i+1]; |
Lightvalve | 68:328e1be06f5d | 756 | } |
Lightvalve | 68:328e1be06f5d | 757 | f_future[num_array_f_future-1] = torq.ref; //N |
Lightvalve | 68:328e1be06f5d | 758 | |
Lightvalve | 68:328e1be06f5d | 759 | int ind = 0; |
Lightvalve | 68:328e1be06f5d | 760 | for(int i=0;i<numpast_x;i++){ |
Lightvalve | 73:f80dc3970c99 | 761 | input_NN[ind] = x_past[2*i] / 60.0f; |
Lightvalve | 68:328e1be06f5d | 762 | ind = ind + 1; |
Lightvalve | 68:328e1be06f5d | 763 | } |
Lightvalve | 73:f80dc3970c99 | 764 | input_NN[ind] = (pos.sen / ENC_PULSE_PER_POSITION) / 60.0f; |
Lightvalve | 68:328e1be06f5d | 765 | ind = ind + 1; |
Lightvalve | 68:328e1be06f5d | 766 | for(int i=0;i<numpast_f;i++){ |
Lightvalve | 73:f80dc3970c99 | 767 | input_NN[ind] = f_past[2*i] / 10000.0f + 0.5f; |
Lightvalve | 68:328e1be06f5d | 768 | ind = ind + 1; |
Lightvalve | 68:328e1be06f5d | 769 | } |
Lightvalve | 73:f80dc3970c99 | 770 | input_NN[ind] = torq.sen / 10000.0f + 0.5f; |
Lightvalve | 68:328e1be06f5d | 771 | ind = ind + 1; |
Lightvalve | 68:328e1be06f5d | 772 | for(int i=0;i<numfuture_f;i++){ |
Lightvalve | 73:f80dc3970c99 | 773 | input_NN[ind] = (f_future[2*i+2] - f_future[0])/10000.0f+0.5f; |
Lightvalve | 68:328e1be06f5d | 774 | ind = ind + 1; |
Lightvalve | 68:328e1be06f5d | 775 | } |
Lightvalve | 66:a8e6799dbce3 | 776 | |
Lightvalve | 49:e7bcfc244d40 | 777 | } else if(address==CID_RX_REF_VALVE_POS) { |
Lightvalve | 47:fdcb8bd86fd6 | 778 | int16_t temp_ref_valve_pos = (int16_t) (msg.data[0] | msg.data[1] << 8); |
Lightvalve | 57:f4819de54e7a | 779 | |
Lightvalve | 57:f4819de54e7a | 780 | if (((OPERATING_MODE&0b110)>>1) == 0) { //Moog Valve |
Lightvalve | 57:f4819de54e7a | 781 | valve_pos.ref = (double) temp_ref_valve_pos; |
Lightvalve | 57:f4819de54e7a | 782 | } else if (((OPERATING_MODE&0b110)>>1) == 1) { //KNR Valve |
Lightvalve | 57:f4819de54e7a | 783 | valve_pos.ref = (double) temp_ref_valve_pos; |
Lightvalve | 57:f4819de54e7a | 784 | } else { //SW Valve |
Lightvalve | 57:f4819de54e7a | 785 | if(temp_ref_valve_pos >= 0) { |
Lightvalve | 57:f4819de54e7a | 786 | valve_pos.ref = (double)VALVE_CENTER + (double)temp_ref_valve_pos * ((double)VALVE_MAX_POS-(double)VALVE_CENTER)/10000.0f; |
Lightvalve | 57:f4819de54e7a | 787 | } else { |
Lightvalve | 57:f4819de54e7a | 788 | valve_pos.ref = (double)VALVE_CENTER - (double)temp_ref_valve_pos * ((double)VALVE_MIN_POS-(double)VALVE_CENTER)/10000.0f; |
Lightvalve | 57:f4819de54e7a | 789 | } |
Lightvalve | 47:fdcb8bd86fd6 | 790 | } |
Lightvalve | 49:e7bcfc244d40 | 791 | } else if(address==CID_RX_REF_PWM){ |
Lightvalve | 49:e7bcfc244d40 | 792 | int temp_ref_pwm = (int16_t) (msg.data[0] | msg.data[1] << 8); |
Lightvalve | 49:e7bcfc244d40 | 793 | Vout.ref = (double) temp_ref_pwm; |
Lightvalve | 45:35fa6884d0c6 | 794 | } |
jobuuu | 2:a1c0a37df760 | 795 | } |
jobuuu | 2:a1c0a37df760 | 796 | |
jobuuu | 2:a1c0a37df760 | 797 | /****************************************************************************** |
jobuuu | 2:a1c0a37df760 | 798 | Information Transmission Functions |
jobuuu | 2:a1c0a37df760 | 799 | *******************************************************************************/ |
Lightvalve | 11:82d8768d7351 | 800 | |
Lightvalve | 11:82d8768d7351 | 801 | void CAN_TX_INFO(void) { |
Lightvalve | 12:6f2531038ea4 | 802 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 803 | |
jobuuu | 2:a1c0a37df760 | 804 | temp_msg.id = CID_TX_INFO; |
jobuuu | 2:a1c0a37df760 | 805 | temp_msg.len = 7; |
Lightvalve | 12:6f2531038ea4 | 806 | temp_msg.data[0] = (uint8_t) CTX_SEND_INFO; |
Lightvalve | 12:6f2531038ea4 | 807 | temp_msg.data[1] = (uint8_t) BNO; |
Lightvalve | 12:6f2531038ea4 | 808 | temp_msg.data[2] = (uint8_t) CAN_FREQ; |
Lightvalve | 12:6f2531038ea4 | 809 | temp_msg.data[3] = (uint8_t) (CAN_FREQ >> 8); |
Lightvalve | 12:6f2531038ea4 | 810 | temp_msg.data[4] = (uint8_t) (flag_err[7] << 7 | flag_err[6] << 6 | flag_err[5] << 5 | flag_err[4] << 4 | flag_err[3] << 3 | flag_err[2] << 2 | flag_err[1] << 1 | flag_err[0]); |
Lightvalve | 57:f4819de54e7a | 811 | temp_msg.data[5] = (uint8_t) CONTROL_UTILITY_MODE; |
Lightvalve | 12:6f2531038ea4 | 812 | temp_msg.data[6] = (uint8_t) OPERATING_MODE; |
jobuuu | 2:a1c0a37df760 | 813 | |
jobuuu | 2:a1c0a37df760 | 814 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 815 | } |
jobuuu | 2:a1c0a37df760 | 816 | |
Lightvalve | 11:82d8768d7351 | 817 | void CAN_TX_BNO(void) { |
Lightvalve | 12:6f2531038ea4 | 818 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 819 | |
jobuuu | 2:a1c0a37df760 | 820 | temp_msg.id = CID_TX_INFO; |
jobuuu | 2:a1c0a37df760 | 821 | temp_msg.len = 2; |
Lightvalve | 12:6f2531038ea4 | 822 | temp_msg.data[0] = (uint8_t) CTX_SEND_BNO; |
Lightvalve | 12:6f2531038ea4 | 823 | temp_msg.data[1] = (uint8_t) BNO; |
jobuuu | 2:a1c0a37df760 | 824 | |
jobuuu | 2:a1c0a37df760 | 825 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 826 | } |
jobuuu | 2:a1c0a37df760 | 827 | |
Lightvalve | 11:82d8768d7351 | 828 | void CAN_TX_OPERATING_MODE(void) { |
jobuuu | 2:a1c0a37df760 | 829 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 830 | |
jobuuu | 2:a1c0a37df760 | 831 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 52:8ea76864368a | 832 | temp_msg.len = 5; |
Lightvalve | 12:6f2531038ea4 | 833 | temp_msg.data[0] = (uint8_t) CTX_SEND_OPERATING_MODE; |
Lightvalve | 12:6f2531038ea4 | 834 | temp_msg.data[1] = (uint8_t) OPERATING_MODE; |
Lightvalve | 52:8ea76864368a | 835 | temp_msg.data[2] = (uint8_t) SENSING_MODE; |
Lightvalve | 52:8ea76864368a | 836 | temp_msg.data[3] = (uint8_t) CURRENT_CONTROL_MODE; |
Lightvalve | 52:8ea76864368a | 837 | temp_msg.data[4] = (uint8_t) FLAG_VALVE_DEADZONE; |
jobuuu | 2:a1c0a37df760 | 838 | |
jobuuu | 2:a1c0a37df760 | 839 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 840 | } |
jobuuu | 2:a1c0a37df760 | 841 | |
Lightvalve | 11:82d8768d7351 | 842 | void CAN_TX_CAN_FREQ(void) { |
jobuuu | 2:a1c0a37df760 | 843 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 844 | |
jobuuu | 2:a1c0a37df760 | 845 | temp_msg.id = CID_TX_INFO; |
jobuuu | 2:a1c0a37df760 | 846 | temp_msg.len = 3; |
jobuuu | 2:a1c0a37df760 | 847 | temp_msg.data[0] = (uint8_t) CTX_SEND_CAN_FREQ; |
jobuuu | 2:a1c0a37df760 | 848 | temp_msg.data[1] = (uint8_t) CAN_FREQ; |
jobuuu | 2:a1c0a37df760 | 849 | temp_msg.data[2] = (uint8_t) (CAN_FREQ >> 8); |
jobuuu | 2:a1c0a37df760 | 850 | |
jobuuu | 2:a1c0a37df760 | 851 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 852 | } |
Lightvalve | 11:82d8768d7351 | 853 | |
Lightvalve | 11:82d8768d7351 | 854 | void CAN_TX_CONTROL_MODE(void) { |
jobuuu | 2:a1c0a37df760 | 855 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 856 | |
jobuuu | 2:a1c0a37df760 | 857 | temp_msg.id = CID_TX_INFO; |
jobuuu | 2:a1c0a37df760 | 858 | temp_msg.len = 2; |
Lightvalve | 12:6f2531038ea4 | 859 | temp_msg.data[0] = (uint8_t) CTX_SEND_CONTROL_MODE; |
Lightvalve | 57:f4819de54e7a | 860 | temp_msg.data[1] = (uint8_t) CONTROL_UTILITY_MODE; |
jobuuu | 2:a1c0a37df760 | 861 | |
jobuuu | 2:a1c0a37df760 | 862 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 863 | } |
Lightvalve | 11:82d8768d7351 | 864 | |
Lightvalve | 11:82d8768d7351 | 865 | void CAN_TX_JOINT_ENC_DIR(void) { |
jobuuu | 2:a1c0a37df760 | 866 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 867 | |
jobuuu | 2:a1c0a37df760 | 868 | temp_msg.id = CID_TX_INFO; |
jobuuu | 2:a1c0a37df760 | 869 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 870 | temp_msg.data[0] = (uint8_t) CTX_SEND_JOINT_ENC_DIR; |
Lightvalve | 12:6f2531038ea4 | 871 | temp_msg.data[1] = (uint8_t) DIR_JOINT_ENC; |
Lightvalve | 12:6f2531038ea4 | 872 | temp_msg.data[2] = (uint8_t) (DIR_JOINT_ENC >> 8); |
jobuuu | 2:a1c0a37df760 | 873 | |
jobuuu | 2:a1c0a37df760 | 874 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 875 | } |
jobuuu | 2:a1c0a37df760 | 876 | |
Lightvalve | 11:82d8768d7351 | 877 | void CAN_TX_VALVE_DIR(void) { |
jobuuu | 2:a1c0a37df760 | 878 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 879 | |
jobuuu | 2:a1c0a37df760 | 880 | temp_msg.id = CID_TX_INFO; |
jobuuu | 2:a1c0a37df760 | 881 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 882 | temp_msg.data[0] = (uint8_t) CTX_SEND_VALVE_DIR; |
Lightvalve | 12:6f2531038ea4 | 883 | temp_msg.data[1] = (uint8_t) DIR_VALVE; |
Lightvalve | 12:6f2531038ea4 | 884 | temp_msg.data[2] = (uint8_t) (DIR_VALVE >> 8); |
jobuuu | 2:a1c0a37df760 | 885 | |
jobuuu | 2:a1c0a37df760 | 886 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 887 | } |
jobuuu | 2:a1c0a37df760 | 888 | |
Lightvalve | 11:82d8768d7351 | 889 | void CAN_TX_VALVE_ENC_DIR(void) { |
jobuuu | 2:a1c0a37df760 | 890 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 891 | |
jobuuu | 2:a1c0a37df760 | 892 | temp_msg.id = CID_TX_INFO; |
jobuuu | 2:a1c0a37df760 | 893 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 894 | temp_msg.data[0] = (uint8_t) CTX_SEND_VALVE_ENC_DIR; |
Lightvalve | 12:6f2531038ea4 | 895 | temp_msg.data[1] = (uint8_t) DIR_VALVE_ENC; |
Lightvalve | 12:6f2531038ea4 | 896 | temp_msg.data[2] = (uint8_t) (DIR_VALVE_ENC >> 8); |
jobuuu | 2:a1c0a37df760 | 897 | |
jobuuu | 2:a1c0a37df760 | 898 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 899 | } |
jobuuu | 2:a1c0a37df760 | 900 | |
Lightvalve | 11:82d8768d7351 | 901 | void CAN_TX_VOLTAGE_SUPPLY(void) { |
Lightvalve | 49:e7bcfc244d40 | 902 | int16_t send_voltage_supply = (int16_t) (SUPPLY_VOLTAGE * 10.0f); |
jobuuu | 2:a1c0a37df760 | 903 | |
jobuuu | 2:a1c0a37df760 | 904 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 905 | |
jobuuu | 2:a1c0a37df760 | 906 | temp_msg.id = CID_TX_INFO; |
jobuuu | 2:a1c0a37df760 | 907 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 908 | temp_msg.data[0] = (uint8_t) CTX_SEND_VOLTAGE_SUPPLY; |
Lightvalve | 12:6f2531038ea4 | 909 | temp_msg.data[1] = (uint8_t) (send_voltage_supply); |
Lightvalve | 12:6f2531038ea4 | 910 | temp_msg.data[2] = (uint8_t) (send_voltage_supply >> 8); |
jobuuu | 2:a1c0a37df760 | 911 | |
jobuuu | 2:a1c0a37df760 | 912 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 913 | } |
jobuuu | 2:a1c0a37df760 | 914 | |
Lightvalve | 11:82d8768d7351 | 915 | void CAN_TX_VOLTAGE_VALVE(void) { |
Lightvalve | 49:e7bcfc244d40 | 916 | int16_t send_voltage_valve = (int16_t) (VALVE_VOLTAGE_LIMIT * 10.0f); |
jobuuu | 2:a1c0a37df760 | 917 | |
jobuuu | 2:a1c0a37df760 | 918 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 919 | |
jobuuu | 2:a1c0a37df760 | 920 | temp_msg.id = CID_TX_INFO; |
jobuuu | 2:a1c0a37df760 | 921 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 922 | temp_msg.data[0] = (uint8_t) CTX_SEND_VOLTAGE_VALVE; |
Lightvalve | 12:6f2531038ea4 | 923 | temp_msg.data[1] = (uint8_t) send_voltage_valve; |
Lightvalve | 12:6f2531038ea4 | 924 | temp_msg.data[2] = (uint8_t) (send_voltage_valve >> 8); |
jobuuu | 2:a1c0a37df760 | 925 | |
jobuuu | 2:a1c0a37df760 | 926 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 927 | } |
Lightvalve | 11:82d8768d7351 | 928 | |
jobuuu | 2:a1c0a37df760 | 929 | |
Lightvalve | 11:82d8768d7351 | 930 | void CAN_TX_PID_GAIN(int t_type) { |
jobuuu | 2:a1c0a37df760 | 931 | // t_type = 0 : valve position control gain |
jobuuu | 2:a1c0a37df760 | 932 | // t_type = 1 : joint position control gain |
jobuuu | 2:a1c0a37df760 | 933 | // t_type = 2 : joint torque control gain |
jobuuu | 2:a1c0a37df760 | 934 | |
Lightvalve | 12:6f2531038ea4 | 935 | int16_t sendPgain=0, sendIgain=0, sendDgain=0; |
jobuuu | 2:a1c0a37df760 | 936 | if (t_type == 0) { |
Lightvalve | 30:8d561f16383b | 937 | sendPgain = (int16_t) (P_GAIN_VALVE_POSITION); |
Lightvalve | 30:8d561f16383b | 938 | sendIgain = (int16_t) (I_GAIN_VALVE_POSITION); |
Lightvalve | 30:8d561f16383b | 939 | sendDgain = (int16_t) (D_GAIN_VALVE_POSITION); |
jobuuu | 2:a1c0a37df760 | 940 | } else if (t_type == 1) { |
Lightvalve | 12:6f2531038ea4 | 941 | sendPgain = (int16_t) (P_GAIN_JOINT_POSITION); |
Lightvalve | 12:6f2531038ea4 | 942 | sendIgain = (int16_t) (I_GAIN_JOINT_POSITION); |
Lightvalve | 12:6f2531038ea4 | 943 | sendDgain = (int16_t) (D_GAIN_JOINT_POSITION); |
jobuuu | 2:a1c0a37df760 | 944 | } else if (t_type == 2) { |
Lightvalve | 12:6f2531038ea4 | 945 | sendPgain = (int16_t) (P_GAIN_JOINT_TORQUE); |
Lightvalve | 12:6f2531038ea4 | 946 | sendIgain = (int16_t) (I_GAIN_JOINT_TORQUE); |
Lightvalve | 12:6f2531038ea4 | 947 | sendDgain = (int16_t) (D_GAIN_JOINT_TORQUE); |
Lightvalve | 46:2694daea349b | 948 | } else if (t_type == 3) { |
Lightvalve | 67:c2812cf26c38 | 949 | sendPgain = (int16_t) (K_SPRING * 10.0f); |
Lightvalve | 67:c2812cf26c38 | 950 | sendIgain = (int16_t) (D_DAMPER * 100.0f); |
jobuuu | 2:a1c0a37df760 | 951 | } |
jobuuu | 2:a1c0a37df760 | 952 | |
jobuuu | 2:a1c0a37df760 | 953 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 954 | |
jobuuu | 2:a1c0a37df760 | 955 | temp_msg.id = CID_TX_INFO; |
jobuuu | 2:a1c0a37df760 | 956 | temp_msg.len = 8; |
Lightvalve | 12:6f2531038ea4 | 957 | temp_msg.data[0] = (uint8_t) CTX_SEND_PID_GAIN; |
Lightvalve | 12:6f2531038ea4 | 958 | temp_msg.data[1] = (uint8_t) t_type; |
Lightvalve | 12:6f2531038ea4 | 959 | temp_msg.data[2] = (uint8_t) sendPgain; |
Lightvalve | 12:6f2531038ea4 | 960 | temp_msg.data[3] = (uint8_t) (sendPgain >> 8); |
Lightvalve | 12:6f2531038ea4 | 961 | temp_msg.data[4] = (uint8_t) sendIgain; |
Lightvalve | 12:6f2531038ea4 | 962 | temp_msg.data[5] = (uint8_t) (sendIgain >> 8); |
Lightvalve | 12:6f2531038ea4 | 963 | temp_msg.data[6] = (uint8_t) sendDgain; |
Lightvalve | 12:6f2531038ea4 | 964 | temp_msg.data[7] = (uint8_t) (sendDgain >> 8); |
jobuuu | 2:a1c0a37df760 | 965 | |
jobuuu | 2:a1c0a37df760 | 966 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 967 | } |
jobuuu | 2:a1c0a37df760 | 968 | |
Lightvalve | 11:82d8768d7351 | 969 | |
Lightvalve | 11:82d8768d7351 | 970 | void CAN_TX_VALVE_DEADZONE(void) { |
jobuuu | 2:a1c0a37df760 | 971 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 972 | |
jobuuu | 2:a1c0a37df760 | 973 | temp_msg.id = CID_TX_INFO; |
jobuuu | 2:a1c0a37df760 | 974 | temp_msg.len = 7; |
Lightvalve | 12:6f2531038ea4 | 975 | temp_msg.data[0] = (uint8_t) CTX_SEND_VALVE_DEADZONE; |
Lightvalve | 57:f4819de54e7a | 976 | temp_msg.data[1] = (uint8_t) VALVE_CENTER; |
Lightvalve | 57:f4819de54e7a | 977 | temp_msg.data[2] = (uint8_t) (VALVE_CENTER >> 8); |
Lightvalve | 12:6f2531038ea4 | 978 | temp_msg.data[3] = (uint8_t) (int) (VALVE_DEADZONE_PLUS); |
Lightvalve | 12:6f2531038ea4 | 979 | temp_msg.data[4] = (uint8_t) ((int) (VALVE_DEADZONE_PLUS) >> 8); |
Lightvalve | 12:6f2531038ea4 | 980 | temp_msg.data[5] = (uint8_t) (int) (VALVE_DEADZONE_MINUS); |
Lightvalve | 12:6f2531038ea4 | 981 | temp_msg.data[6] = (uint8_t) ((int) (VALVE_DEADZONE_MINUS) >> 8); |
jobuuu | 2:a1c0a37df760 | 982 | |
jobuuu | 2:a1c0a37df760 | 983 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 984 | } |
jobuuu | 2:a1c0a37df760 | 985 | |
Lightvalve | 11:82d8768d7351 | 986 | void CAN_TX_VELOCITY_COMP_GAIN(void) { |
Lightvalve | 11:82d8768d7351 | 987 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 988 | |
Lightvalve | 11:82d8768d7351 | 989 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 990 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 991 | temp_msg.data[0] = (uint8_t) CTX_SEND_VELOCITY_COMP_GAIN; |
Lightvalve | 12:6f2531038ea4 | 992 | temp_msg.data[1] = (uint8_t) VELOCITY_COMP_GAIN; |
Lightvalve | 12:6f2531038ea4 | 993 | temp_msg.data[2] = (uint8_t) (VELOCITY_COMP_GAIN >> 8); |
Lightvalve | 11:82d8768d7351 | 994 | |
Lightvalve | 11:82d8768d7351 | 995 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 996 | } |
Lightvalve | 11:82d8768d7351 | 997 | |
Lightvalve | 11:82d8768d7351 | 998 | void CAN_TX_COMPLIANCE_GAIN(void) { |
Lightvalve | 11:82d8768d7351 | 999 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1000 | |
Lightvalve | 11:82d8768d7351 | 1001 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1002 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 1003 | temp_msg.data[0] = (uint8_t) CTX_SEND_COMPLIANCE_GAIN; |
Lightvalve | 12:6f2531038ea4 | 1004 | temp_msg.data[1] = (uint8_t) COMPLIANCE_GAIN; |
Lightvalve | 12:6f2531038ea4 | 1005 | temp_msg.data[2] = (uint8_t) (COMPLIANCE_GAIN >> 8); |
Lightvalve | 11:82d8768d7351 | 1006 | |
Lightvalve | 11:82d8768d7351 | 1007 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1008 | } |
Lightvalve | 11:82d8768d7351 | 1009 | |
Lightvalve | 11:82d8768d7351 | 1010 | void CAN_TX_VALVE_FF(void) { |
Lightvalve | 11:82d8768d7351 | 1011 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1012 | |
Lightvalve | 11:82d8768d7351 | 1013 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1014 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 1015 | temp_msg.data[0] = (uint8_t) CTX_SEND_VALVE_FF; |
Lightvalve | 12:6f2531038ea4 | 1016 | temp_msg.data[1] = (uint8_t) VALVE_FF; |
Lightvalve | 12:6f2531038ea4 | 1017 | temp_msg.data[2] = (uint8_t) (VALVE_FF >> 8); |
Lightvalve | 11:82d8768d7351 | 1018 | |
Lightvalve | 11:82d8768d7351 | 1019 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1020 | } |
Lightvalve | 11:82d8768d7351 | 1021 | |
Lightvalve | 11:82d8768d7351 | 1022 | void CAN_TX_BULK_MODULUS(void) { |
Lightvalve | 11:82d8768d7351 | 1023 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1024 | |
Lightvalve | 11:82d8768d7351 | 1025 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1026 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 1027 | temp_msg.data[0] = (uint8_t) CTX_SEND_BULK_MODULUS; |
Lightvalve | 12:6f2531038ea4 | 1028 | temp_msg.data[1] = (uint8_t) BULK_MODULUS; |
Lightvalve | 12:6f2531038ea4 | 1029 | temp_msg.data[2] = (uint8_t) (BULK_MODULUS >> 8); |
Lightvalve | 11:82d8768d7351 | 1030 | |
Lightvalve | 11:82d8768d7351 | 1031 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1032 | } |
Lightvalve | 11:82d8768d7351 | 1033 | |
Lightvalve | 11:82d8768d7351 | 1034 | void CAN_TX_CHAMBER_VOLUME(void) { |
Lightvalve | 11:82d8768d7351 | 1035 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1036 | |
Lightvalve | 11:82d8768d7351 | 1037 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1038 | temp_msg.len = 5; |
Lightvalve | 12:6f2531038ea4 | 1039 | temp_msg.data[0] = (uint8_t) CTX_SEND_CHAMBER_VOLUME; |
Lightvalve | 12:6f2531038ea4 | 1040 | temp_msg.data[1] = (uint8_t) CHAMBER_VOLUME_A; |
Lightvalve | 12:6f2531038ea4 | 1041 | temp_msg.data[2] = (uint8_t) (CHAMBER_VOLUME_A >> 8); |
Lightvalve | 12:6f2531038ea4 | 1042 | temp_msg.data[3] = (uint8_t) CHAMBER_VOLUME_B; |
Lightvalve | 12:6f2531038ea4 | 1043 | temp_msg.data[4] = (uint8_t) (CHAMBER_VOLUME_B >> 8); |
Lightvalve | 11:82d8768d7351 | 1044 | |
Lightvalve | 11:82d8768d7351 | 1045 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1046 | } |
Lightvalve | 11:82d8768d7351 | 1047 | |
Lightvalve | 11:82d8768d7351 | 1048 | void CAN_TX_PISTON_AREA(void) { |
jobuuu | 2:a1c0a37df760 | 1049 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1050 | |
Lightvalve | 11:82d8768d7351 | 1051 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1052 | temp_msg.len = 5; |
Lightvalve | 12:6f2531038ea4 | 1053 | temp_msg.data[0] = (uint8_t) CTX_SEND_PISTON_AREA; |
Lightvalve | 12:6f2531038ea4 | 1054 | temp_msg.data[1] = (uint8_t) PISTON_AREA_A; |
Lightvalve | 12:6f2531038ea4 | 1055 | temp_msg.data[2] = (uint8_t) (PISTON_AREA_A >> 8); |
Lightvalve | 12:6f2531038ea4 | 1056 | temp_msg.data[3] = (uint8_t) PISTON_AREA_B; |
Lightvalve | 12:6f2531038ea4 | 1057 | temp_msg.data[4] = (uint8_t) (PISTON_AREA_B >> 8); |
jobuuu | 2:a1c0a37df760 | 1058 | |
Lightvalve | 11:82d8768d7351 | 1059 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1060 | } |
Lightvalve | 11:82d8768d7351 | 1061 | |
Lightvalve | 11:82d8768d7351 | 1062 | void CAN_TX_PRES_A_AND_B(void) { |
Lightvalve | 11:82d8768d7351 | 1063 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1064 | |
Lightvalve | 11:82d8768d7351 | 1065 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1066 | temp_msg.len = 5; |
Lightvalve | 12:6f2531038ea4 | 1067 | temp_msg.data[0] = (uint8_t) CTX_SEND_PRES; |
Lightvalve | 12:6f2531038ea4 | 1068 | temp_msg.data[1] = (uint8_t) PRES_SUPPLY; |
Lightvalve | 12:6f2531038ea4 | 1069 | temp_msg.data[2] = (uint8_t) (PRES_SUPPLY >> 8); |
Lightvalve | 12:6f2531038ea4 | 1070 | temp_msg.data[3] = (uint8_t) PRES_RETURN; |
Lightvalve | 12:6f2531038ea4 | 1071 | temp_msg.data[4] = (uint8_t) (PRES_RETURN >> 8); |
Lightvalve | 11:82d8768d7351 | 1072 | |
Lightvalve | 11:82d8768d7351 | 1073 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1074 | } |
Lightvalve | 11:82d8768d7351 | 1075 | |
Lightvalve | 11:82d8768d7351 | 1076 | void CAN_TX_ENC_LIMIT(void) { |
Lightvalve | 11:82d8768d7351 | 1077 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1078 | |
Lightvalve | 11:82d8768d7351 | 1079 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1080 | temp_msg.len = 5; |
Lightvalve | 12:6f2531038ea4 | 1081 | temp_msg.data[0] = (uint8_t) CTX_SEND_ENC_LIMIT; |
Lightvalve | 12:6f2531038ea4 | 1082 | temp_msg.data[1] = (uint8_t) ENC_LIMIT_MINUS; |
Lightvalve | 12:6f2531038ea4 | 1083 | temp_msg.data[2] = (uint8_t) (ENC_LIMIT_MINUS >> 8); |
Lightvalve | 12:6f2531038ea4 | 1084 | temp_msg.data[3] = (uint8_t) ENC_LIMIT_PLUS; |
Lightvalve | 12:6f2531038ea4 | 1085 | temp_msg.data[4] = (uint8_t) (ENC_LIMIT_PLUS >> 8); |
Lightvalve | 11:82d8768d7351 | 1086 | |
Lightvalve | 11:82d8768d7351 | 1087 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1088 | } |
Lightvalve | 11:82d8768d7351 | 1089 | |
Lightvalve | 11:82d8768d7351 | 1090 | void CAN_TX_STROKE(void) { |
Lightvalve | 11:82d8768d7351 | 1091 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1092 | |
Lightvalve | 11:82d8768d7351 | 1093 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1094 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 1095 | temp_msg.data[0] = (uint8_t) CTX_SEND_STROKE; |
Lightvalve | 12:6f2531038ea4 | 1096 | temp_msg.data[1] = (uint8_t) STROKE; |
Lightvalve | 12:6f2531038ea4 | 1097 | temp_msg.data[2] = (uint8_t) (STROKE >> 8); |
Lightvalve | 11:82d8768d7351 | 1098 | |
Lightvalve | 11:82d8768d7351 | 1099 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1100 | } |
Lightvalve | 11:82d8768d7351 | 1101 | |
Lightvalve | 11:82d8768d7351 | 1102 | void CAN_TX_VALVE_LIMIT(void) { |
Lightvalve | 11:82d8768d7351 | 1103 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1104 | |
Lightvalve | 11:82d8768d7351 | 1105 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1106 | temp_msg.len = 5; |
Lightvalve | 12:6f2531038ea4 | 1107 | temp_msg.data[0] = (uint8_t) CTX_SEND_VALVE_LIMIT; |
Lightvalve | 57:f4819de54e7a | 1108 | temp_msg.data[1] = (uint8_t) VALVE_MIN_POS; |
Lightvalve | 57:f4819de54e7a | 1109 | temp_msg.data[2] = (uint8_t) (VALVE_MIN_POS >> 8); |
Lightvalve | 57:f4819de54e7a | 1110 | temp_msg.data[3] = (uint8_t) VALVE_MAX_POS; |
Lightvalve | 57:f4819de54e7a | 1111 | temp_msg.data[4] = (uint8_t) (VALVE_MAX_POS >> 8); |
Lightvalve | 11:82d8768d7351 | 1112 | |
Lightvalve | 11:82d8768d7351 | 1113 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1114 | } |
Lightvalve | 11:82d8768d7351 | 1115 | |
Lightvalve | 11:82d8768d7351 | 1116 | void CAN_TX_ENC_PULSE_PER_POSITION(void) { |
Lightvalve | 11:82d8768d7351 | 1117 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1118 | |
jobuuu | 2:a1c0a37df760 | 1119 | temp_msg.id = CID_TX_INFO; |
jobuuu | 2:a1c0a37df760 | 1120 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 1121 | temp_msg.data[0] = (uint8_t) CTX_SEND_ENC_PULSE_PER_POSITION; |
Lightvalve | 54:647072f5307a | 1122 | int temp_enc_pulse_per_position = (int) (ENC_PULSE_PER_POSITION); |
Lightvalve | 48:889798ff9329 | 1123 | temp_msg.data[1] = (uint8_t) temp_enc_pulse_per_position; |
Lightvalve | 48:889798ff9329 | 1124 | temp_msg.data[2] = (uint8_t) (temp_enc_pulse_per_position >> 8); |
jobuuu | 2:a1c0a37df760 | 1125 | |
jobuuu | 2:a1c0a37df760 | 1126 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 1127 | } |
jobuuu | 2:a1c0a37df760 | 1128 | |
Lightvalve | 11:82d8768d7351 | 1129 | void CAN_TX_TORQUE_SENSOR_PULSE_PER_TORQUE(void) { |
jobuuu | 2:a1c0a37df760 | 1130 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1131 | |
jobuuu | 2:a1c0a37df760 | 1132 | temp_msg.id = CID_TX_INFO; |
jobuuu | 2:a1c0a37df760 | 1133 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 1134 | temp_msg.data[0] = (uint8_t) CTX_SEND_TORQUE_SENSOR_PULSE_PER_TORQUE; |
Lightvalve | 48:889798ff9329 | 1135 | int temp_torque_sensor_pulse_per_torque = (int) (TORQUE_SENSOR_PULSE_PER_TORQUE * 100.0f); |
Lightvalve | 48:889798ff9329 | 1136 | temp_msg.data[1] = (uint8_t) temp_torque_sensor_pulse_per_torque; |
Lightvalve | 48:889798ff9329 | 1137 | temp_msg.data[2] = (uint8_t) (temp_torque_sensor_pulse_per_torque >> 8); |
jobuuu | 2:a1c0a37df760 | 1138 | |
jobuuu | 2:a1c0a37df760 | 1139 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 1140 | } |
jobuuu | 2:a1c0a37df760 | 1141 | |
Lightvalve | 11:82d8768d7351 | 1142 | void CAN_TX_PRES_SENSOR_PULSE_PER_PRES(void) { |
jobuuu | 2:a1c0a37df760 | 1143 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1144 | |
jobuuu | 2:a1c0a37df760 | 1145 | temp_msg.id = CID_TX_INFO; |
jobuuu | 2:a1c0a37df760 | 1146 | temp_msg.len = 5; |
Lightvalve | 12:6f2531038ea4 | 1147 | temp_msg.data[0] = (uint8_t) CTX_SEND_PRES_SENSOR_PULSE_PER_BAR; |
Lightvalve | 30:8d561f16383b | 1148 | temp_msg.data[1] = (uint8_t) (int) (PRES_SENSOR_A_PULSE_PER_BAR * 100.0f); |
Lightvalve | 30:8d561f16383b | 1149 | temp_msg.data[2] = (uint8_t) ((int) (PRES_SENSOR_A_PULSE_PER_BAR * 100.0f) >> 8); |
Lightvalve | 30:8d561f16383b | 1150 | temp_msg.data[3] = (uint8_t) (int) (PRES_SENSOR_B_PULSE_PER_BAR * 100.0f); |
Lightvalve | 30:8d561f16383b | 1151 | temp_msg.data[4] = (uint8_t) ((int) (PRES_SENSOR_B_PULSE_PER_BAR * 100.0f) >> 8); |
jobuuu | 2:a1c0a37df760 | 1152 | |
jobuuu | 2:a1c0a37df760 | 1153 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 1154 | } |
jobuuu | 2:a1c0a37df760 | 1155 | |
Lightvalve | 11:82d8768d7351 | 1156 | void CAN_TX_FRICTION(void) { |
Lightvalve | 11:82d8768d7351 | 1157 | CANMessage temp_msg; |
Lightvalve | 12:6f2531038ea4 | 1158 | int16_t send_friction; |
Lightvalve | 30:8d561f16383b | 1159 | send_friction = (int16_t) (FRICTION * 10.0f); |
Lightvalve | 11:82d8768d7351 | 1160 | |
Lightvalve | 11:82d8768d7351 | 1161 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1162 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 1163 | temp_msg.data[0] = (uint8_t) CTX_SEND_FRICTION; |
Lightvalve | 12:6f2531038ea4 | 1164 | temp_msg.data[1] = (uint8_t) send_friction; |
Lightvalve | 12:6f2531038ea4 | 1165 | temp_msg.data[2] = (uint8_t) (send_friction >> 8); |
Lightvalve | 11:82d8768d7351 | 1166 | |
Lightvalve | 11:82d8768d7351 | 1167 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1168 | } |
Lightvalve | 11:82d8768d7351 | 1169 | |
Lightvalve | 11:82d8768d7351 | 1170 | void CAN_TX_VALVE_GAIN_PLUS(void) { |
Lightvalve | 11:82d8768d7351 | 1171 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1172 | |
Lightvalve | 11:82d8768d7351 | 1173 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1174 | temp_msg.len = 6; |
Lightvalve | 12:6f2531038ea4 | 1175 | temp_msg.data[0] = (uint8_t) CTX_SEND_VALVE_GAIN_PLUS; |
Lightvalve | 30:8d561f16383b | 1176 | temp_msg.data[1] = (uint8_t) (VALVE_GAIN_LPM_PER_V[0] * 50.0f); |
Lightvalve | 30:8d561f16383b | 1177 | temp_msg.data[2] = (uint8_t) (VALVE_GAIN_LPM_PER_V[2] * 50.0f); |
Lightvalve | 30:8d561f16383b | 1178 | temp_msg.data[3] = (uint8_t) (VALVE_GAIN_LPM_PER_V[4] * 50.0f); |
Lightvalve | 30:8d561f16383b | 1179 | temp_msg.data[4] = (uint8_t) (VALVE_GAIN_LPM_PER_V[6] * 50.0f); |
Lightvalve | 30:8d561f16383b | 1180 | temp_msg.data[5] = (uint8_t) (VALVE_GAIN_LPM_PER_V[8] * 50.0f); |
Lightvalve | 11:82d8768d7351 | 1181 | |
Lightvalve | 11:82d8768d7351 | 1182 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1183 | } |
Lightvalve | 11:82d8768d7351 | 1184 | |
Lightvalve | 11:82d8768d7351 | 1185 | void CAN_TX_DDV_VALVE_DEADZONE(void) { |
Lightvalve | 11:82d8768d7351 | 1186 | CANMessage temp_msg; |
Lightvalve | 48:889798ff9329 | 1187 | float temp_valve_deadzone_minus = 0.0f; |
Lightvalve | 48:889798ff9329 | 1188 | float temp_valve_deadzone_plus = 0.0f; |
Lightvalve | 48:889798ff9329 | 1189 | float temp_ddv_center = 0.0f; |
Lightvalve | 48:889798ff9329 | 1190 | |
Lightvalve | 57:f4819de54e7a | 1191 | //temp_valve_deadzone_plus = 10000.0f*((double)VALVE_DEADZONE_PLUS-(double)VALVE_CENTER)/((double)VALVE_MAX_POS-(double)VALVE_CENTER); |
Lightvalve | 57:f4819de54e7a | 1192 | //temp_valve_deadzone_minus = -10000.0f*((double)VALVE_DEADZONE_MINUS-(double)VALVE_CENTER)/((double)VALVE_MIN_POS-(double)VALVE_CENTER); |
Lightvalve | 57:f4819de54e7a | 1193 | temp_valve_deadzone_plus = (double)VALVE_DEADZONE_PLUS; |
Lightvalve | 57:f4819de54e7a | 1194 | temp_valve_deadzone_minus = (double)VALVE_DEADZONE_MINUS; |
Lightvalve | 57:f4819de54e7a | 1195 | temp_ddv_center = (double)VALVE_CENTER; |
Lightvalve | 11:82d8768d7351 | 1196 | |
Lightvalve | 11:82d8768d7351 | 1197 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1198 | temp_msg.len = 7; |
Lightvalve | 12:6f2531038ea4 | 1199 | temp_msg.data[0] = (uint8_t) CTX_SEND_DDV_VALVE_DEADZONE; |
Lightvalve | 48:889798ff9329 | 1200 | temp_msg.data[1] = (uint8_t) temp_valve_deadzone_minus; |
Lightvalve | 48:889798ff9329 | 1201 | temp_msg.data[2] = (uint8_t) ((int) (temp_valve_deadzone_minus) >> 8); |
Lightvalve | 48:889798ff9329 | 1202 | temp_msg.data[3] = (uint8_t) (temp_valve_deadzone_plus); |
Lightvalve | 48:889798ff9329 | 1203 | temp_msg.data[4] = (uint8_t) ((int) (temp_valve_deadzone_plus) >> 8); |
Lightvalve | 48:889798ff9329 | 1204 | temp_msg.data[5] = (uint8_t) (temp_ddv_center); |
Lightvalve | 48:889798ff9329 | 1205 | temp_msg.data[6] = (uint8_t) ((int) (temp_ddv_center) >> 8); |
Lightvalve | 11:82d8768d7351 | 1206 | |
Lightvalve | 11:82d8768d7351 | 1207 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1208 | } |
Lightvalve | 11:82d8768d7351 | 1209 | |
Lightvalve | 11:82d8768d7351 | 1210 | void CAN_TX_VALVE_GAIN_MINUS(void) { |
Lightvalve | 11:82d8768d7351 | 1211 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1212 | |
Lightvalve | 11:82d8768d7351 | 1213 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1214 | temp_msg.len = 6; |
Lightvalve | 12:6f2531038ea4 | 1215 | temp_msg.data[0] = (uint8_t) CTX_SEND_VALVE_GAIN_MINUS; |
Lightvalve | 30:8d561f16383b | 1216 | temp_msg.data[1] = (uint8_t) (VALVE_GAIN_LPM_PER_V[1] * 50.0f); |
Lightvalve | 30:8d561f16383b | 1217 | temp_msg.data[2] = (uint8_t) (VALVE_GAIN_LPM_PER_V[3] * 50.0f); |
Lightvalve | 30:8d561f16383b | 1218 | temp_msg.data[3] = (uint8_t) (VALVE_GAIN_LPM_PER_V[5] * 50.0f); |
Lightvalve | 30:8d561f16383b | 1219 | temp_msg.data[4] = (uint8_t) (VALVE_GAIN_LPM_PER_V[7] * 50.0f); |
Lightvalve | 30:8d561f16383b | 1220 | temp_msg.data[5] = (uint8_t) (VALVE_GAIN_LPM_PER_V[9] * 50.0f); |
Lightvalve | 11:82d8768d7351 | 1221 | |
Lightvalve | 11:82d8768d7351 | 1222 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1223 | } |
Lightvalve | 11:82d8768d7351 | 1224 | |
Lightvalve | 11:82d8768d7351 | 1225 | void CAN_TX_REFENCE_MODE(void) { |
Lightvalve | 11:82d8768d7351 | 1226 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1227 | |
Lightvalve | 11:82d8768d7351 | 1228 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1229 | temp_msg.len = 6; |
Lightvalve | 12:6f2531038ea4 | 1230 | temp_msg.data[0] = (uint8_t) CTX_SEND_REFENCE_MODE; |
Lightvalve | 12:6f2531038ea4 | 1231 | temp_msg.data[1] = (uint8_t) REFERENCE_MODE; |
Lightvalve | 30:8d561f16383b | 1232 | temp_msg.data[2] = (uint8_t) (int) (REFERENCE_FREQ * 100.0f); |
Lightvalve | 30:8d561f16383b | 1233 | temp_msg.data[3] = (uint8_t) ((int) (REFERENCE_FREQ * 100.0f) >> 8); |
Lightvalve | 30:8d561f16383b | 1234 | temp_msg.data[4] = (uint8_t) (int) (REFERENCE_MAG * 100.0f); |
Lightvalve | 30:8d561f16383b | 1235 | temp_msg.data[5] = (uint8_t) ((int) (REFERENCE_MAG * 100.0f) >> 8); |
Lightvalve | 11:82d8768d7351 | 1236 | |
Lightvalve | 11:82d8768d7351 | 1237 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1238 | } |
Lightvalve | 11:82d8768d7351 | 1239 | |
Lightvalve | 11:82d8768d7351 | 1240 | void CAN_TX_HOMEPOS_OFFSET(void) { |
Lightvalve | 11:82d8768d7351 | 1241 | CANMessage temp_msg; |
Lightvalve | 12:6f2531038ea4 | 1242 | int16_t send_homepos_offset; |
Lightvalve | 12:6f2531038ea4 | 1243 | send_homepos_offset = (int16_t) (HOMEPOS_OFFSET); |
Lightvalve | 11:82d8768d7351 | 1244 | |
jobuuu | 2:a1c0a37df760 | 1245 | temp_msg.id = CID_TX_INFO; |
jobuuu | 2:a1c0a37df760 | 1246 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 1247 | temp_msg.data[0] = (uint8_t) CTX_SEND_HOMEPOS_OFFSET; |
Lightvalve | 12:6f2531038ea4 | 1248 | temp_msg.data[1] = (uint8_t) send_homepos_offset; |
Lightvalve | 12:6f2531038ea4 | 1249 | temp_msg.data[2] = (uint8_t) (send_homepos_offset >> 8); |
jobuuu | 2:a1c0a37df760 | 1250 | |
jobuuu | 2:a1c0a37df760 | 1251 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 1252 | } |
Lightvalve | 11:82d8768d7351 | 1253 | |
Lightvalve | 11:82d8768d7351 | 1254 | void CAN_TX_HOMPOS_VALVE_OPENING(void) { |
Lightvalve | 11:82d8768d7351 | 1255 | CANMessage temp_msg; |
Lightvalve | 12:6f2531038ea4 | 1256 | int16_t send_homepos_valve_opening; |
Lightvalve | 12:6f2531038ea4 | 1257 | send_homepos_valve_opening = (int16_t) (HOMEPOS_VALVE_OPENING); |
Lightvalve | 11:82d8768d7351 | 1258 | |
Lightvalve | 11:82d8768d7351 | 1259 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1260 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 1261 | temp_msg.data[0] = (uint8_t) CTX_SEND_HOMEPOS_VALVE_OPENING; |
Lightvalve | 12:6f2531038ea4 | 1262 | temp_msg.data[1] = (uint8_t) send_homepos_valve_opening; |
Lightvalve | 12:6f2531038ea4 | 1263 | temp_msg.data[2] = (uint8_t) (send_homepos_valve_opening >> 8); |
Lightvalve | 11:82d8768d7351 | 1264 | |
Lightvalve | 11:82d8768d7351 | 1265 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1266 | } |
Lightvalve | 11:82d8768d7351 | 1267 | |
Lightvalve | 12:6f2531038ea4 | 1268 | void CAN_TX_VALVE_PWM_VS_VALVE_POS(int8_t canindex) { |
Lightvalve | 11:82d8768d7351 | 1269 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1270 | int16_t valve_pos_vs_pwm; |
Lightvalve | 49:e7bcfc244d40 | 1271 | // valve_pos_vs_pwm = (int16_t) (VALVE_POS_VS_PWM[canindex]); |
Lightvalve | 49:e7bcfc244d40 | 1272 | |
Lightvalve | 57:f4819de54e7a | 1273 | if(VALVE_POS_VS_PWM[canindex]>= (float) VALVE_CENTER) { |
Lightvalve | 57:f4819de54e7a | 1274 | valve_pos_vs_pwm = 10000.0f*((double)VALVE_POS_VS_PWM[canindex]-(double)VALVE_CENTER)/((double)VALVE_MAX_POS-(double)VALVE_CENTER); |
Lightvalve | 49:e7bcfc244d40 | 1275 | } else { |
Lightvalve | 57:f4819de54e7a | 1276 | valve_pos_vs_pwm = -10000.0f*((double)VALVE_POS_VS_PWM[canindex]-(double)VALVE_CENTER)/((double)VALVE_MIN_POS-(double)VALVE_CENTER); |
Lightvalve | 49:e7bcfc244d40 | 1277 | } |
Lightvalve | 11:82d8768d7351 | 1278 | |
Lightvalve | 12:6f2531038ea4 | 1279 | int16_t PWM_VALVE_ID; |
Lightvalve | 12:6f2531038ea4 | 1280 | PWM_VALVE_ID = ID_index_array[canindex] * 1000; |
Lightvalve | 11:82d8768d7351 | 1281 | |
Lightvalve | 11:82d8768d7351 | 1282 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1283 | temp_msg.len = 5; |
Lightvalve | 12:6f2531038ea4 | 1284 | temp_msg.data[0] = (uint8_t) CTX_VALVE_PWM_VS_VALVE_POS; |
Lightvalve | 12:6f2531038ea4 | 1285 | temp_msg.data[1] = (uint8_t) PWM_VALVE_ID; |
Lightvalve | 12:6f2531038ea4 | 1286 | temp_msg.data[2] = (uint8_t) (PWM_VALVE_ID >> 8); |
Lightvalve | 12:6f2531038ea4 | 1287 | temp_msg.data[3] = (uint8_t) valve_pos_vs_pwm; |
Lightvalve | 12:6f2531038ea4 | 1288 | temp_msg.data[4] = (uint8_t) (valve_pos_vs_pwm >> 8); |
Lightvalve | 11:82d8768d7351 | 1289 | |
Lightvalve | 11:82d8768d7351 | 1290 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1291 | } |
Lightvalve | 11:82d8768d7351 | 1292 | |
Lightvalve | 12:6f2531038ea4 | 1293 | void CAN_TX_VALVE_POS_VS_FLOWRATE(int8_t canindex) { |
Lightvalve | 11:82d8768d7351 | 1294 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1295 | int32_t valve_pos_vs_flowrate; |
Lightvalve | 11:82d8768d7351 | 1296 | valve_pos_vs_flowrate = (int32_t) (JOINT_VEL[canindex]); |
Lightvalve | 11:82d8768d7351 | 1297 | |
Lightvalve | 57:f4819de54e7a | 1298 | int16_t VALVE_POS_VALVE_ID = ID_index_array[canindex] * 10 + VALVE_CENTER; |
Lightvalve | 49:e7bcfc244d40 | 1299 | int16_t temp_valve_pos = 0; |
Lightvalve | 57:f4819de54e7a | 1300 | if(VALVE_POS_VALVE_ID>=VALVE_CENTER) { |
Lightvalve | 57:f4819de54e7a | 1301 | temp_valve_pos = (int16_t) (10000.0f*((double)VALVE_POS_VALVE_ID-(double)VALVE_CENTER)/((double)VALVE_MAX_POS-(double)VALVE_CENTER)); |
Lightvalve | 49:e7bcfc244d40 | 1302 | } else { |
Lightvalve | 57:f4819de54e7a | 1303 | temp_valve_pos = (int16_t) (-10000.0f*((double)VALVE_POS_VALVE_ID-(double)VALVE_CENTER)/((double)VALVE_MIN_POS-(double)VALVE_CENTER)); |
Lightvalve | 49:e7bcfc244d40 | 1304 | } |
Lightvalve | 11:82d8768d7351 | 1305 | |
Lightvalve | 11:82d8768d7351 | 1306 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 49:e7bcfc244d40 | 1307 | temp_msg.len = 8; |
Lightvalve | 12:6f2531038ea4 | 1308 | temp_msg.data[0] = (uint8_t) CTX_VALVE_POS_VS_FLOWRATE; |
Lightvalve | 49:e7bcfc244d40 | 1309 | temp_msg.data[1] = (uint8_t) temp_valve_pos; |
Lightvalve | 49:e7bcfc244d40 | 1310 | temp_msg.data[2] = (uint8_t) (temp_valve_pos >> 8); |
Lightvalve | 49:e7bcfc244d40 | 1311 | temp_msg.data[5] = (uint8_t) valve_pos_vs_flowrate; |
Lightvalve | 49:e7bcfc244d40 | 1312 | temp_msg.data[6] = (uint8_t) (valve_pos_vs_flowrate >> 8); |
Lightvalve | 49:e7bcfc244d40 | 1313 | temp_msg.data[7] = (uint8_t) (valve_pos_vs_flowrate >> 16); |
Lightvalve | 49:e7bcfc244d40 | 1314 | temp_msg.data[7] = (uint8_t) (valve_pos_vs_flowrate >> 24); |
Lightvalve | 11:82d8768d7351 | 1315 | |
Lightvalve | 11:82d8768d7351 | 1316 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1317 | } |
Lightvalve | 11:82d8768d7351 | 1318 | |
Lightvalve | 11:82d8768d7351 | 1319 | void CAN_TX_VALVE_POS_NUM(void) { |
Lightvalve | 11:82d8768d7351 | 1320 | CANMessage temp_msg; |
Lightvalve | 11:82d8768d7351 | 1321 | int32_t valve_pos_num; |
Lightvalve | 11:82d8768d7351 | 1322 | valve_pos_num = (int16_t) VALVE_POS_NUM; |
Lightvalve | 11:82d8768d7351 | 1323 | |
Lightvalve | 11:82d8768d7351 | 1324 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 11:82d8768d7351 | 1325 | temp_msg.len = 3; |
Lightvalve | 12:6f2531038ea4 | 1326 | temp_msg.data[0] = (uint8_t) CTX_VALVE_POS_NUM; |
Lightvalve | 12:6f2531038ea4 | 1327 | temp_msg.data[1] = (uint8_t) valve_pos_num; |
Lightvalve | 12:6f2531038ea4 | 1328 | temp_msg.data[2] = (uint8_t) (valve_pos_num >> 8); |
Lightvalve | 11:82d8768d7351 | 1329 | |
Lightvalve | 11:82d8768d7351 | 1330 | can.write(temp_msg); |
Lightvalve | 11:82d8768d7351 | 1331 | } |
Lightvalve | 11:82d8768d7351 | 1332 | |
Lightvalve | 38:118df027d851 | 1333 | void CAN_TX_DDV_VALVE_MAX_MIN_POS(void) { |
Lightvalve | 38:118df027d851 | 1334 | CANMessage temp_msg; |
Lightvalve | 38:118df027d851 | 1335 | |
Lightvalve | 48:889798ff9329 | 1336 | float temp_valve_max_pos = 0.0f; |
Lightvalve | 48:889798ff9329 | 1337 | float temp_valve_min_pos = 0.0f; |
Lightvalve | 48:889798ff9329 | 1338 | float temp_ddv_center = 0.0f; |
Lightvalve | 48:889798ff9329 | 1339 | |
Lightvalve | 57:f4819de54e7a | 1340 | temp_valve_max_pos = VALVE_MAX_POS; |
Lightvalve | 57:f4819de54e7a | 1341 | temp_valve_min_pos = VALVE_MIN_POS; |
Lightvalve | 57:f4819de54e7a | 1342 | temp_ddv_center = VALVE_CENTER; |
Lightvalve | 48:889798ff9329 | 1343 | |
Lightvalve | 38:118df027d851 | 1344 | temp_msg.id = CID_TX_INFO; |
Lightvalve | 38:118df027d851 | 1345 | temp_msg.len = 7; |
Lightvalve | 38:118df027d851 | 1346 | temp_msg.data[0] = (uint8_t) CTX_VALVE_MAX_MIN_POS; |
Lightvalve | 48:889798ff9329 | 1347 | temp_msg.data[1] = (uint8_t) temp_valve_max_pos; |
Lightvalve | 48:889798ff9329 | 1348 | temp_msg.data[2] = (uint8_t) ((int) (temp_valve_max_pos) >> 8); |
Lightvalve | 48:889798ff9329 | 1349 | temp_msg.data[3] = (uint8_t) (temp_valve_min_pos); |
Lightvalve | 48:889798ff9329 | 1350 | temp_msg.data[4] = (uint8_t) ((int) (temp_valve_min_pos) >> 8); |
Lightvalve | 48:889798ff9329 | 1351 | temp_msg.data[5] = (uint8_t) (temp_ddv_center); |
Lightvalve | 48:889798ff9329 | 1352 | temp_msg.data[6] = (uint8_t) ((int) (temp_ddv_center) >> 8); |
Lightvalve | 38:118df027d851 | 1353 | |
Lightvalve | 38:118df027d851 | 1354 | can.write(temp_msg); |
Lightvalve | 38:118df027d851 | 1355 | } |
Lightvalve | 38:118df027d851 | 1356 | |
jobuuu | 2:a1c0a37df760 | 1357 | /****************************************************************************** |
jobuuu | 2:a1c0a37df760 | 1358 | Sensor & State Transmission Functions |
jobuuu | 2:a1c0a37df760 | 1359 | *******************************************************************************/ |
jobuuu | 2:a1c0a37df760 | 1360 | |
Lightvalve | 52:8ea76864368a | 1361 | void CAN_TX_POSITION_FT(int16_t t_pos, int16_t t_vel, int16_t t_torq) { |
Lightvalve | 52:8ea76864368a | 1362 | CANMessage temp_msg; |
Lightvalve | 52:8ea76864368a | 1363 | |
Lightvalve | 52:8ea76864368a | 1364 | temp_msg.id = CID_TX_POSITION; |
Lightvalve | 52:8ea76864368a | 1365 | temp_msg.len = 6; |
Lightvalve | 52:8ea76864368a | 1366 | temp_msg.data[0] = (uint8_t) t_pos; |
Lightvalve | 52:8ea76864368a | 1367 | temp_msg.data[1] = (uint8_t) (t_pos >> 8); |
Lightvalve | 52:8ea76864368a | 1368 | temp_msg.data[2] = (uint8_t) t_vel; |
Lightvalve | 52:8ea76864368a | 1369 | temp_msg.data[3] = (uint8_t) (t_vel >> 8); |
Lightvalve | 52:8ea76864368a | 1370 | temp_msg.data[4] = (uint8_t) t_torq; |
Lightvalve | 52:8ea76864368a | 1371 | temp_msg.data[5] = (uint8_t) (t_torq >> 8); |
Lightvalve | 52:8ea76864368a | 1372 | |
Lightvalve | 52:8ea76864368a | 1373 | can.write(temp_msg); |
Lightvalve | 52:8ea76864368a | 1374 | } |
Lightvalve | 52:8ea76864368a | 1375 | |
Lightvalve | 52:8ea76864368a | 1376 | void CAN_TX_POSITION_PRESSURE(int16_t t_pos, int16_t t_vel, int16_t t_pa, int16_t t_pb) { |
Lightvalve | 52:8ea76864368a | 1377 | |
jobuuu | 2:a1c0a37df760 | 1378 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 1379 | |
jobuuu | 2:a1c0a37df760 | 1380 | temp_msg.id = CID_TX_POSITION; |
jobuuu | 2:a1c0a37df760 | 1381 | temp_msg.len = 8; |
Lightvalve | 12:6f2531038ea4 | 1382 | temp_msg.data[0] = (uint8_t) t_pos; |
Lightvalve | 12:6f2531038ea4 | 1383 | temp_msg.data[1] = (uint8_t) (t_pos >> 8); |
Lightvalve | 41:abbd4e2af68b | 1384 | temp_msg.data[2] = (uint8_t) t_vel; |
Lightvalve | 41:abbd4e2af68b | 1385 | temp_msg.data[3] = (uint8_t) (t_vel >> 8); |
Lightvalve | 52:8ea76864368a | 1386 | temp_msg.data[4] = (uint8_t) t_pa; |
Lightvalve | 52:8ea76864368a | 1387 | temp_msg.data[5] = (uint8_t) (t_pa >> 8); |
Lightvalve | 52:8ea76864368a | 1388 | temp_msg.data[6] = (uint8_t) t_pb; |
Lightvalve | 52:8ea76864368a | 1389 | temp_msg.data[7] = (uint8_t) (t_pb >> 8); |
jobuuu | 2:a1c0a37df760 | 1390 | |
jobuuu | 2:a1c0a37df760 | 1391 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 1392 | } |
jobuuu | 2:a1c0a37df760 | 1393 | |
Lightvalve | 67:c2812cf26c38 | 1394 | //void CAN_TX_TORQUE(int16_t t_valve_pos, int16_t t_vout) { |
Lightvalve | 67:c2812cf26c38 | 1395 | // CANMessage temp_msg; |
Lightvalve | 67:c2812cf26c38 | 1396 | // |
Lightvalve | 67:c2812cf26c38 | 1397 | // temp_msg.id = CID_TX_TORQUE; |
Lightvalve | 67:c2812cf26c38 | 1398 | // temp_msg.len = 4; |
Lightvalve | 67:c2812cf26c38 | 1399 | // temp_msg.data[0] = (uint8_t) t_valve_pos; |
Lightvalve | 67:c2812cf26c38 | 1400 | // temp_msg.data[1] = (uint8_t) (t_valve_pos >> 8); |
Lightvalve | 67:c2812cf26c38 | 1401 | // temp_msg.data[2] = (uint8_t) t_vout; |
Lightvalve | 67:c2812cf26c38 | 1402 | // temp_msg.data[3] = (uint8_t) (t_vout >> 8); |
Lightvalve | 67:c2812cf26c38 | 1403 | // |
Lightvalve | 67:c2812cf26c38 | 1404 | // can.write(temp_msg); |
Lightvalve | 67:c2812cf26c38 | 1405 | //} |
Lightvalve | 67:c2812cf26c38 | 1406 | |
Lightvalve | 67:c2812cf26c38 | 1407 | void CAN_TX_TORQUE(int16_t t_valve_pos) { |
jobuuu | 2:a1c0a37df760 | 1408 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 1409 | |
jobuuu | 2:a1c0a37df760 | 1410 | temp_msg.id = CID_TX_TORQUE; |
Lightvalve | 67:c2812cf26c38 | 1411 | temp_msg.len = 2; |
Lightvalve | 48:889798ff9329 | 1412 | temp_msg.data[0] = (uint8_t) t_valve_pos; |
Lightvalve | 48:889798ff9329 | 1413 | temp_msg.data[1] = (uint8_t) (t_valve_pos >> 8); |
jobuuu | 2:a1c0a37df760 | 1414 | |
jobuuu | 2:a1c0a37df760 | 1415 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 1416 | } |
jobuuu | 2:a1c0a37df760 | 1417 | |
Lightvalve | 11:82d8768d7351 | 1418 | void CAN_TX_PRES(int16_t t_pres_a, int16_t t_pres_b) { |
jobuuu | 2:a1c0a37df760 | 1419 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 1420 | |
jobuuu | 2:a1c0a37df760 | 1421 | temp_msg.id = CID_TX_PRES; |
Lightvalve | 57:f4819de54e7a | 1422 | temp_msg.len = 4; |
Lightvalve | 12:6f2531038ea4 | 1423 | temp_msg.data[0] = (uint8_t) t_pres_a; |
Lightvalve | 12:6f2531038ea4 | 1424 | temp_msg.data[1] = (uint8_t) (t_pres_a >> 8); |
Lightvalve | 12:6f2531038ea4 | 1425 | temp_msg.data[2] = (uint8_t) t_pres_b; |
Lightvalve | 12:6f2531038ea4 | 1426 | temp_msg.data[3] = (uint8_t) (t_pres_b >> 8); |
jobuuu | 2:a1c0a37df760 | 1427 | |
jobuuu | 2:a1c0a37df760 | 1428 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 1429 | } |
jobuuu | 2:a1c0a37df760 | 1430 | |
Lightvalve | 11:82d8768d7351 | 1431 | void CAN_TX_PWM(int16_t t_pwm) { |
jobuuu | 2:a1c0a37df760 | 1432 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 1433 | |
Lightvalve | 57:f4819de54e7a | 1434 | temp_msg.id = CID_TX_VOUT; |
Lightvalve | 57:f4819de54e7a | 1435 | temp_msg.len = 2; |
Lightvalve | 12:6f2531038ea4 | 1436 | temp_msg.data[0] = (uint8_t) t_pwm; |
Lightvalve | 12:6f2531038ea4 | 1437 | temp_msg.data[1] = (uint8_t) (t_pwm >> 8); |
jobuuu | 2:a1c0a37df760 | 1438 | |
jobuuu | 2:a1c0a37df760 | 1439 | can.write(temp_msg); |
jobuuu | 2:a1c0a37df760 | 1440 | } |
jobuuu | 2:a1c0a37df760 | 1441 | |
Lightvalve | 73:f80dc3970c99 | 1442 | void CAN_TX_VALVE_POSITION(int16_t t_valve_pos_1, int16_t t_valve_pos_2, int16_t t_ref_valve_pos, int16_t t_pwm) |
Lightvalve | 27:a2254a485f23 | 1443 | { |
jobuuu | 2:a1c0a37df760 | 1444 | CANMessage temp_msg; |
jobuuu | 2:a1c0a37df760 | 1445 | |
jobuuu | 2:a1c0a37df760 | 1446 | temp_msg.id = CID_TX_VALVE_POSITION; |
Lightvalve | 73:f80dc3970c99 | 1447 | temp_msg.len = 8; |
Lightvalve | 73:f80dc3970c99 | 1448 | temp_msg.data[0] = (uint8_t) t_valve_pos_1; |
Lightvalve | 73:f80dc3970c99 | 1449 | temp_msg.data[1] = (uint8_t) (t_valve_pos_1 >> 8); |
Lightvalve | 73:f80dc3970c99 | 1450 | temp_msg.data[2] = (uint8_t) t_valve_pos_2; |
Lightvalve | 73:f80dc3970c99 | 1451 | temp_msg.data[3] = (uint8_t) (t_valve_pos_2 >> 8); |
Lightvalve | 73:f80dc3970c99 | 1452 | temp_msg.data[4] = (uint8_t) t_ref_valve_pos; |
Lightvalve | 73:f80dc3970c99 | 1453 | temp_msg.data[5] = (uint8_t) (t_ref_valve_pos >> 8); |
Lightvalve | 73:f80dc3970c99 | 1454 | temp_msg.data[6] = (uint8_t) t_pwm; |
Lightvalve | 73:f80dc3970c99 | 1455 | temp_msg.data[7] = (uint8_t) (t_pwm >> 8); |
Lightvalve | 27:a2254a485f23 | 1456 | |
jobuuu | 2:a1c0a37df760 | 1457 | |
jobuuu | 2:a1c0a37df760 | 1458 | can.write(temp_msg); |
Lightvalve | 67:c2812cf26c38 | 1459 | } |