From 046a3a35ccc3adddc23cf4eddd1c378c04b77cb6 Mon Sep 17 00:00:00 2001 From: 771-8bit Date: Sun, 24 Mar 2024 17:09:24 +0900 Subject: [PATCH 1/9] Update Main.ino --- Main/Main.ino | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Main/Main.ino b/Main/Main.ino index 19edb2f..15cda00 100644 --- a/Main/Main.ino +++ b/Main/Main.ino @@ -65,6 +65,9 @@ String response = ""; bool need_response_usb = false; bool need_response_es920 = false; +// E220 +SerialPIO Serial_E220(E220_TX, E220_RX, 256); + // W25Q128 // Opener @@ -130,6 +133,7 @@ void setup() { Serial_GNSS.begin(9600); Serial_Valve.begin(115200); Serial_MIF.begin(921600); + Serial_E220.begin(115200); opener.init(); } @@ -252,6 +256,10 @@ void loop() { valve_mode = Serial_Valve.read(); } + // E220パススルー + while(Serial_MIF.available()){ + Serial_E220.write(Serial_MIF.read()); + } // テレメトリ生成 downlink = ""; From 611d5d191e015ce269275ab5092c950b3cf16446 Mon Sep 17 00:00:00 2001 From: 771-8bit Date: Sun, 24 Mar 2024 17:33:03 +0900 Subject: [PATCH 2/9] add E220-900T22S-JP to CI --- .github/workflows/arduino_ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/arduino_ci.yml b/.github/workflows/arduino_ci.yml index a2bbca7..dc983da 100644 --- a/.github/workflows/arduino_ci.yml +++ b/.github/workflows/arduino_ci.yml @@ -113,6 +113,8 @@ jobs: version: latest - name: Adafruit LPS35HW version: latest + - name: E220-900T22S-JP + version: 2.0.2 - source-url: https://github.com/uChip/MCP342X.git - source-url: https://github.com/core-rocket/CCP.git - source-url: https://github.com/core-rocket/Opener.git From 6f3781b21c1e4832a0f0f2c085da689425e9bdda Mon Sep 17 00:00:00 2001 From: 771-8bit Date: Sun, 24 Mar 2024 17:33:16 +0900 Subject: [PATCH 3/9] e220 integrate --- MissionInterface/MissionInterface.ino | 166 ++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) diff --git a/MissionInterface/MissionInterface.ino b/MissionInterface/MissionInterface.ino index c197213..2ceabfd 100644 --- a/MissionInterface/MissionInterface.ino +++ b/MissionInterface/MissionInterface.ino @@ -10,6 +10,31 @@ #define LED_G 16 #define LED_B 25 +// E220 +#include +#define PAYLOAD_SIZE 55 +E220 e220(Serial1, 0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A +/*E220configuration +- UARTbaudrate:115200bps +- bandwith: 250kHz//審査書の値なので運営からの指示以外変更禁止 +- channel: 0x0A(ARIB 34-35)//審査書の値なので運営からの指示以外変更禁止 +- target address: 0xFFFF(broradcast) +- power: 13dBm +- SF: 11 +*/ +union unionfloat { + float f; + byte b[4]; +}; +union unionuint32 { + uint32_t i; + byte b[4]; +}; +unionuint32 mcutime_ms; +unionfloat buf; +uint8_t status_byte = 0x00; +uint8_t tx_payload[199] = { 0 }; + // CAN CCP_MCP2515 CCP(CAN_CS, CAN_INT); @@ -42,6 +67,7 @@ void setup() { pinMode(MISSION_POWER, OUTPUT); digitalWrite(MISSION_POWER, LOW); + Serial1.setFIFOSize(512); //E220のサブパケ200byteより大きいサイズにする Serial1.begin(921600); while (Serial1.available()) { Serial1.read(); @@ -52,6 +78,8 @@ void setup() { flash.begin(); + reset_tx_payload(); + pinMode(LED_R, OUTPUT); pinMode(LED_G, OUTPUT); pinMode(LED_B, OUTPUT); @@ -175,5 +203,143 @@ void loop() { snprintf(msgString, sizeof(msgString), "%d,ID,%03x,time,%d000,fp16_0,%8.2f,fp16_1,%8.2f,fp16_2,%8.2f", millis(), CCP.id, CCP.time16(), CCP.data_fp16_0(), CCP.data_fp16_1(), CCP.data_fp16_2()); } Serial.println(msgString); + + + switch (CCP.id) { + case CCP_nose_status: + if (CCP.str_match("OK", 2)) { + status_byte |= 0b10000000; + } + break; + case CCP_surface_pressure1_status: + if (CCP.str_match("OK", 2)) { + status_byte |= 0b01000000; + } + break; + case CCP_surface_pressure2_status: + if (CCP.str_match("OK", 2)) { + status_byte |= 0b00100000; + } + break; + case CCP_surface_pressure3_status: + if (CCP.str_match("OK", 2)) { + status_byte |= 0b00010000; + } + break; + case CCP_surface_pressure4_status: + if (CCP.str_match("OK", 2)) { + status_byte |= 0b00001000; + } + break; + case CCP_surface_pressure5_status: + if (CCP.str_match("OK", 2)) { + status_byte |= 0b00000100; + } + break; + case CCP_surface_pressure6_status: + if (CCP.str_match("OK", 2)) { + status_byte |= 0b00000010; + } + break; + case CCP_nose_adc: //自信ない + //adcの生データを16進数表示の文字列で送信 + for (int i = 0; i < 6; i++) { + tx_payload[i + 5] = CCP.msg.string_msg.string[i]; + } + break; + case CCP_nose_temperature: + buf.f = CCP.data_float(); + for (int i = 0; i < 4; i++) { + tx_payload[i + 11] = buf.b[i]; + } + break; + case CCP_nose_barometic_pressure: + buf.f = CCP.data_float(); + for (int i = 0; i < 4; i++) { + tx_payload[i + 15] = buf.b[i]; + } + break; + case CCP_nose_voltage: + buf.f = CCP.data_float(); + for (int i = 0; i < 4; i++) { + tx_payload[i + 19] = buf.b[i]; + } + break; + case CCP_surface_pressure1_pressure_pa: + buf.f = CCP.data_float(); + for (int i = 0; i < 4; i++) { + tx_payload[i + 23] = buf.b[i]; + } + break; + case CCP_surface_pressure2_pressure_pa: + buf.f = CCP.data_float(); + for (int i = 0; i < 4; i++) { + tx_payload[i + 27] = buf.b[i]; + } + break; + case CCP_surface_pressure3_pressure_pa: + buf.f = CCP.data_float(); + for (int i = 0; i < 4; i++) { + tx_payload[i + 31] = buf.b[i]; + } + break; + case CCP_surface_pressure4_pressure_pa: + buf.f = CCP.data_float(); + for (int i = 0; i < 4; i++) { + tx_payload[i + 35] = buf.b[i]; + } + break; + case CCP_surface_pressure5_pressure_pa: + buf.f = CCP.data_float(); + for (int i = 0; i < 4; i++) { + tx_payload[i + 39] = buf.b[i]; + } + break; + case CCP_surface_pressure6_pressure_pa: + buf.f = CCP.data_float(); + for (int i = 0; i < 4; i++) { + tx_payload[i + 43] = buf.b[i]; + } + break; + case CCP_surface_pressure7_pressure_pa: + buf.f = CCP.data_float(); + for (int i = 0; i < 4; i++) { + tx_payload[i + 47] = buf.b[i]; + } + break; + case CCP_surface_pressure8_pressure_pa: + buf.f = CCP.data_float(); + for (int i = 0; i < 4; i++) { + tx_payload[i + 51] = buf.b[i]; + } + break; + default: + break; + } + } + + mcutime_ms.i = millis(); + for (int i = 0; i < 4; i++) { + tx_payload[i] = mcutime_ms.b[i]; + } + status_byte = 0x00; + tx_payload[4] = status_byte; + + static uint32_t last_send_time = 0; + if (millis() - last_send_time >= 1000) { + last_send_time = millis(); + e220.TransmissionDataVariebleLength(tx_payload, PAYLOAD_SIZE); } } + +void reset_tx_payload() { + for (int i = 0; i < 11; i++) { + tx_payload[i] = 0; + } + buf.f = 0; + for (int data = 0; data < 11; data++) { + for (int i = 0; i < 4; i++) { + tx_payload[i + 11 + (4 * data)] = buf.b[i]; + } + } +} \ No newline at end of file From 148e56a8a605d0ef00c3efcb6cc5f98d7a02aa7e Mon Sep 17 00:00:00 2001 From: 771-8bit Date: Sun, 24 Mar 2024 17:41:33 +0900 Subject: [PATCH 4/9] Create Ground_E220.ino --- Ground_E220/Ground_E220.ino | 140 ++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 Ground_E220/Ground_E220.ino diff --git a/Ground_E220/Ground_E220.ino b/Ground_E220/Ground_E220.ino new file mode 100644 index 0000000..97584be --- /dev/null +++ b/Ground_E220/Ground_E220.ino @@ -0,0 +1,140 @@ +#include + +#define SEND_PERIOD_MS 1000 + +E220 e220(Serial1, 0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A=10ch=ARIB 34-35 + +/*E220configuration +- UARTbaudrate:115200bps +- bandwith: 250kHz//審査書の値なので運営からの指示以外変更禁止 +- channel: 0x0A(ARIB 34-35)//審査書の値なので運営からの指示以外変更禁止 +- target address: 0xFFFF(broradcast) +- power: 13dBm +- SF: TBD +*/ + +/* +------configuration------ +Address(HEX):00 +UARTBaudrate:115200bps +SF:11 +BW:250kHz +SubpacketLength:200bytes +RSSINoise:Not Available +TxPower:0dBm +Channel:10 +RSSIByte:Available +TxMethod:Transparent mode +WORCycle:500ms +------------------------- +*/ + +union unionfloat { + float f; + byte b[4]; +}; +union unionuint32 { + uint32_t i; + byte b[4]; +}; + + +void setup() { + Serial1.setFIFOSize(512); //E220のサブパケ200byteより大きいサイズにする + Serial.begin(115200); + Serial1.begin(115200); //E220のUART +} + +void loop() { + static byte rx_payload[199] = { 0 }; + int rssi = 0; + int Rxlength = 0; + Rxlength = e220.ReceiveDataVariebleLength(rx_payload, 47, &rssi); //surface6_pressureまでの長さ + unionuint32 mcutime_ms; + byte nose_adc_raw[6] = { 0x00 }; + unionfloat nose_temperature; + unionfloat nose_barometic_presure; + unionfloat nose_voltage; + unionfloat surface1_pressure; + unionfloat surface2_pressure; + unionfloat surface3_pressure; + unionfloat surface4_pressure; + unionfloat surface5_pressure; + unionfloat surface6_pressure; + byte status = 0x00; + for (int i = 0; i < 4; i++) { + mcutime_ms.b[i] = rx_payload[i]; + } + status = rx_payload[4]; + for (int i = 0; i < 6; i++) { + nose_adc_raw[i] = rx_payload[i + 5]; + } + for (int i = 0; i < 4; i++) { + nose_temperature.b[i] = rx_payload[i + 11]; + } + for (int i = 0; i < 4; i++) { + nose_barometic_presure.b[i] = rx_payload[i + 15]; + } + for (int i = 0; i < 4; i++) { + nose_voltage.b[i] = rx_payload[i + 19]; + } + for (int i = 0; i < 4; i++) { + surface1_pressure.b[i] = rx_payload[i + 23]; + } + for (int i = 0; i < 4; i++) { + surface2_pressure.b[i] = rx_payload[i + 27]; + } + for (int i = 0; i < 4; i++) { + surface3_pressure.b[i] = rx_payload[i + 31]; + } + for (int i = 0; i < 4; i++) { + surface4_pressure.b[i] = rx_payload[i + 35]; + } + for (int i = 0; i < 4; i++) { + surface5_pressure.b[i] = rx_payload[i + 39]; + } + for (int i = 0; i < 4; i++) { + surface6_pressure.b[i] = rx_payload[i + 43]; + } + + if (Rxlength > 0) { + Serial.print("RSSI[dBm]:"); + Serial.print(rssi); + Serial.print(",rocket_time_ms:"); + Serial.print(mcutime_ms.i); + Serial.print(",status:"); + StatusSerialPrint(status); + Serial.print(","); + for (int i = 0; i < 6; i++) { + Serial.print(nose_adc_raw[i]); + Serial.print(","); + } + Serial.print(nose_temperature.f, 6); + Serial.print(","); + Serial.print(nose_barometic_presure.f, 6); + Serial.print(","); + Serial.print(nose_voltage.f, 6); + Serial.print(","); + Serial.print(surface1_pressure.f, 6); + Serial.print(","); + Serial.print(surface2_pressure.f, 6); + Serial.print(","); + Serial.print(surface3_pressure.f, 6); + Serial.print(","); + Serial.print(surface4_pressure.f, 6); + Serial.print(","); + Serial.print(surface5_pressure.f, 6); + Serial.print(","); + Serial.println(surface6_pressure.f, 6); + } +} + +void StatusSerialPrint(byte _status) { + for (int i = 0; i < 8; i++) { + if ((_status >> 7 - i) & 0x01) { + Serial.print("1"); + } else { + Serial.print("0"); + } + } +} From 25fc68cd2b8181e4d2cc03e649296c6f29ce8679 Mon Sep 17 00:00:00 2001 From: 771-8bit Date: Sun, 24 Mar 2024 17:49:29 +0900 Subject: [PATCH 5/9] Update Pressure.ino --- Pressure/Pressure.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pressure/Pressure.ino b/Pressure/Pressure.ino index 34322e5..256d38f 100644 --- a/Pressure/Pressure.ino +++ b/Pressure/Pressure.ino @@ -37,7 +37,7 @@ void loop() { static uint32_t time = 0; if (millis() - time >= 10) { time = millis(); - CCP.float_to_device(CCP_surface_pressure1_pressure_pa, lps35hw.readPressure()); + CCP.float_to_device(CCP_surface_pressure1_pressure_hPa, lps35hw.readPressure()); } if (!digitalRead(CAN_INT)) // データ受信確認 From 77b46282518bcd3b7a38ea1ee158fdcbb8a02d14 Mon Sep 17 00:00:00 2001 From: 771-8bit Date: Sun, 24 Mar 2024 17:49:32 +0900 Subject: [PATCH 6/9] Update MissionInterface.ino --- MissionInterface/MissionInterface.ino | 53 ++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/MissionInterface/MissionInterface.ino b/MissionInterface/MissionInterface.ino index 2ceabfd..5d843a8 100644 --- a/MissionInterface/MissionInterface.ino +++ b/MissionInterface/MissionInterface.ino @@ -57,6 +57,18 @@ Flash_Mode flash_mode = SLEEP; char msgString[128]; char str_buf[7]; // 6+\0 +float nose_temperature = 0; +float nose_barometic_presure = 0; +float nose_voltage = 0; +float surface1_pressure = 0; +float surface2_pressure = 0; +float surface3_pressure = 0; +float surface4_pressure = 0; +float surface5_pressure = 0; +float surface6_pressure = 0; +float surface7_pressure = 0; +float surface8_pressure = 0; + void setup() { delay(500); Serial.begin(115200); @@ -164,7 +176,28 @@ void loop() { flash_index = 0; flash_addr = 0; } else { - data_str += "\n"; + data_str += String(nose_temperature, 2); + data_str += ","; + data_str += String(nose_barometic_presure, 2); + data_str += ","; + data_str += String(nose_voltage, 2); + data_str += ","; + data_str += String(surface1_pressure, 2); + data_str += ","; + data_str += String(surface2_pressure, 2); + data_str += ","; + data_str += String(surface3_pressure, 2); + data_str += ","; + data_str += String(surface4_pressure, 2); + data_str += ","; + data_str += String(surface5_pressure, 2); + data_str += ","; + data_str += String(surface6_pressure, 2); + data_str += ","; + data_str += String(surface7_pressure, 2); + data_str += ","; + data_str += String(surface8_pressure, 2); + data_str += ","; data_str.toCharArray(data_char, 256); flash_print(data_char); } @@ -265,49 +298,49 @@ void loop() { tx_payload[i + 19] = buf.b[i]; } break; - case CCP_surface_pressure1_pressure_pa: + case CCP_surface_pressure1_pressure_hPa: buf.f = CCP.data_float(); for (int i = 0; i < 4; i++) { tx_payload[i + 23] = buf.b[i]; } break; - case CCP_surface_pressure2_pressure_pa: + case CCP_surface_pressure2_pressure_hPa: buf.f = CCP.data_float(); for (int i = 0; i < 4; i++) { tx_payload[i + 27] = buf.b[i]; } break; - case CCP_surface_pressure3_pressure_pa: + case CCP_surface_pressure3_pressure_hPa: buf.f = CCP.data_float(); for (int i = 0; i < 4; i++) { tx_payload[i + 31] = buf.b[i]; } break; - case CCP_surface_pressure4_pressure_pa: + case CCP_surface_pressure4_pressure_hPa: buf.f = CCP.data_float(); for (int i = 0; i < 4; i++) { tx_payload[i + 35] = buf.b[i]; } break; - case CCP_surface_pressure5_pressure_pa: + case CCP_surface_pressure5_pressure_hPa: buf.f = CCP.data_float(); for (int i = 0; i < 4; i++) { tx_payload[i + 39] = buf.b[i]; } break; - case CCP_surface_pressure6_pressure_pa: + case CCP_surface_pressure6_pressure_hPa: buf.f = CCP.data_float(); for (int i = 0; i < 4; i++) { tx_payload[i + 43] = buf.b[i]; } break; - case CCP_surface_pressure7_pressure_pa: + case CCP_surface_pressure7_pressure_hPa: buf.f = CCP.data_float(); for (int i = 0; i < 4; i++) { tx_payload[i + 47] = buf.b[i]; } break; - case CCP_surface_pressure8_pressure_pa: + case CCP_surface_pressure8_pressure_hPa: buf.f = CCP.data_float(); for (int i = 0; i < 4; i++) { tx_payload[i + 51] = buf.b[i]; @@ -342,4 +375,4 @@ void reset_tx_payload() { tx_payload[i + 11 + (4 * data)] = buf.b[i]; } } -} \ No newline at end of file +} From 17ebbe60ab08cf1829d14752e20cf1b56a07287e Mon Sep 17 00:00:00 2001 From: 771-8bit Date: Sun, 24 Mar 2024 17:53:12 +0900 Subject: [PATCH 7/9] Update MissionInterface.ino --- MissionInterface/MissionInterface.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MissionInterface/MissionInterface.ino b/MissionInterface/MissionInterface.ino index 5d843a8..f819ac4 100644 --- a/MissionInterface/MissionInterface.ino +++ b/MissionInterface/MissionInterface.ino @@ -180,7 +180,7 @@ void loop() { data_str += ","; data_str += String(nose_barometic_presure, 2); data_str += ","; - data_str += String(nose_voltage, 2); + data_str += String(nose_voltage, 4); data_str += ","; data_str += String(surface1_pressure, 2); data_str += ","; From 8a7fba43c24de15972124005075bbdbea1e92b2f Mon Sep 17 00:00:00 2001 From: 771-8bit Date: Mon, 25 Mar 2024 01:22:34 +0900 Subject: [PATCH 8/9] Update Main.ino --- Main/Main.ino | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Main/Main.ino b/Main/Main.ino index 15cda00..a1d00a6 100644 --- a/Main/Main.ino +++ b/Main/Main.ino @@ -258,7 +258,8 @@ void loop() { // E220パススルー while(Serial_MIF.available()){ - Serial_E220.write(Serial_MIF.read()); + //Serial_E220.write(Serial_MIF.read()); + Serial_MIF.read(); } // テレメトリ生成 @@ -370,25 +371,34 @@ void loop() { if (uplink == "mif-on") { Serial_MIF.print("mif-on\n"); + set_response("on"); } if (uplink == "mif-off") { Serial_MIF.print("mif-off\n"); + set_response("off"); } if (uplink == "flash-start") { Serial_MIF.print("flash-start\n"); + set_response("start"); } if (uplink == "flash-stop") { Serial_MIF.print("flash-stop\n"); + set_response("stop"); } if (uplink == "flash-clear") { Serial_MIF.print("flash-clear\n"); + set_response("clear"); } float uplink_float = uplink.toFloat(); if (uplink_float != 0) { opener.set_open_threshold_time_ms(uplink_float * 1000); - response = "open:" + String(static_cast(opener.get_open_threshold_time_ms()) / 1000.0, 2); - need_response_usb = true; - need_response_es920 = true; + set_response("open:" + String(static_cast(opener.get_open_threshold_time_ms()) / 1000.0, 2)); } } + +void set_response(String str) { + response = str; + need_response_usb = true; + need_response_es920 = true; +} \ No newline at end of file From 49c0e9ca2bc5dac15d8e47d874a2e1ca41b91771 Mon Sep 17 00:00:00 2001 From: 771-8bit Date: Mon, 25 Mar 2024 01:22:37 +0900 Subject: [PATCH 9/9] Update MissionInterface.ino --- MissionInterface/MissionInterface.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MissionInterface/MissionInterface.ino b/MissionInterface/MissionInterface.ino index f819ac4..74a4ba9 100644 --- a/MissionInterface/MissionInterface.ino +++ b/MissionInterface/MissionInterface.ino @@ -197,7 +197,7 @@ void loop() { data_str += String(surface7_pressure, 2); data_str += ","; data_str += String(surface8_pressure, 2); - data_str += ","; + data_str += ",\n"; data_str.toCharArray(data_char, 256); flash_print(data_char); }