Merge from main

payload-adc
sq2ips 2025-07-23 15:33:35 +02:00
commit 1dbae45749
5 zmienionych plików z 51 dodań i 15 usunięć

Wyświetl plik

@ -161,15 +161,15 @@ Before building the firmware you fist need to configure parameters located in th
Parameters list:
| parameter | type (and unit) | description |
|-----------|------|-------------|
| `PAYLOAD_ID` | uint16 | Payload ID transmitted in Horus Binary frame, in order to conduct a flight you need to request one for your callsign, more information in the [Protocol documentation](https://github.com/projecthorus/horusdemodlib/wiki#how-do-i-transmit-it). For testing ID 256 is used |
| `QRG_FSK4` | float[] (in Hz) | Transmitted frequencies array, switched in a loop, add new frequencies after a comma in braces. Refer to [Horus wiki](https://github.com/projecthorus/horusdemodlib/wiki#commonly-used-frequencies) for commonly used frequencies. |
| `PAYLOAD_ID` | uint16 | Payload ID transmitted in Horus Binary frame, in order to conduct a flight you need to request one for your callsign, more information in the [Protocol documentation](https://github.com/projecthorus/horusdemodlib/wiki#how-do-i-transmit-it). For testing ID 256 is used. |
| `TIME_PERIOD` | uint (in seconds) | Time between transmition of frames. Should not be lower than 4. |
| `GPS_TYPE` | uint | Type of GPS module, eather 1 for u-blox MAX-M10M, 2 for XM1110 module. For identifying the module see [GPS](#gps) section. |
| `QRG_FSK4` | uint (in Hz) | Frequency of 4FSK Horus transmition. |
| `PA_FSK4` | uint | Number from 0 to 63. See the table bellow. |
| `RF_BOOST_ACTIVE` | bool | State of RF TX boost, amplifies signal by around 15dB. (In off state the boost cricut is attenuating the signal, when less output power is needed it's better to decrease `PA_FSK4` than turning it off.) |
| `ADF_FREQ_CORRECTION` | uint (multiples of 244Hz) | Frequency correction for transmitted signal |
| `LED_MODE` | uint | 0 - disabled, 1 - LED on while getting data before transmission, 2 - Fix type indication (1 flash for no fix, 2 flashes for 2D fix, 3 flashed 3D fix) |
| `LED_PERIOD` | uint | only for `LED_MODE` 3, time between fix indication |
| `ADF_FREQ_CORRECTION` | uint (multiples of 244Hz) | Frequency correction for transmitted signal. |
| `LED_MODE` | uint | 0 - disabled, 1 - LED on while getting data before transmission, 2 - Fix type indication (1 flash for no fix, 2 flashes for 2D fix, 3 flashed 3D fix). |
| `LED_PERIOD` | uint | only for `LED_MODE` 3, time between fix indication. |
| `LED_DISABLE_ALT` | uint (in meters) | only for `LED_MODE` 3, disables LED when prompted altitude is reached. |
## Power setting
@ -279,7 +279,7 @@ It will need some time to download an install the packages, after it finishes ru
```bash
docker run --rm -v .:/opt/m20 m20:latest
```
It will build the code and after finishing you should see a memory usage table, the compiled binaries should be in the `build/` directory.
It will build the code and after finishing you should see a memory usage table, the compiled binaries should be in the `build/` directory.
# Flashing the firmware
## Connecting

Wyświetl plik

@ -3,23 +3,27 @@
#ifndef INC_CONFIG_H_
#define INC_CONFIG_H_
#include <stdint.h>
//#define DEBUG
/*-----------------------------------------------------------------*/
// Sonde configuration, parameters that should be changed
const static float QRG_FSK4[] = {435100000}; // Transmitted frequencies array, switched in a loop, add new frequencies (in Hz) after a comma in braces.
#define PAYLOAD_ID 256 // Sonde payload ID 256 - for 4FSKTEST-V2
#define TIME_PERIOD 6 // Time betwen starts of transmissions (in seconds) (must be more than 3)
#define GPS_TYPE 1 // Type of GPS module: 1 - u-blox | 2 - XM1110
#define QRG_FSK4 435100000 // Frequency fo horus modulation (in Hz)
#define GPS_WATCHDOG 3 // number of frames without gps fix to trigger restart
#define PA_FSK4 10 // RF power setting for horus transmission values 0-63
#define RF_BOOST_ACTIVE 1 // RF booster enabled for transmissions about 15dB gain, but more power consumed - normally should be ON(1).
#define ADF_FREQ_CORRECTION 19 // correction of frequency from crystal inaccuracy in 270Hz steps. To be individually set for each sonde.
#define ADF_FREQ_CORRECTION 19 // correction of frequency from crystal inaccuracy in 244Hz steps. To be individually set for each sonde.
#define LED_MODE 2 // 0 - disabled, 1 - flashes when prepairing tx data before transmit, 2 - GPS fix indication
#define LED_PERIOD 5 // time between LED lighting

Wyświetl plik

@ -313,8 +313,8 @@ void adf_setup(void) {
adf_reset_config();
adf_set_r_divider(
1); // We will be using whole 9(or 8)MHz for freq reference for adf7012
adf_set_frequency(QRG_FSK4); // Temporarily set freq for CW - it is going to
// be changed later when turning on TX
adf_set_frequency(QRG_FSK4[0]); // Temporarily set freq for CW - it is going
// to be changed later when turning on TX
adf_set_pll_enable(ADF_ON);
adf_write_config();
}

Wyświetl plik

@ -25,6 +25,7 @@ static uint16_t current_2_bit = 0;
static bool FSK_Active = false;
static char *buffer;
static uint8_t buffer_len;
static uint8_t QRGCounter = 0;
void FSK4_stop_TX() {
TIM2->DIER &= ~(TIM_DIER_UIE); /* Disable the interrupt */
@ -85,7 +86,9 @@ void FSK4_start_TX(char *buff, uint8_t len) {
buffer_len = len;
// adf_setup();
current_2_bit = 0; // reset counter of current position of bit address
adf_RF_on(QRG_FSK4, PA_FSK4); // turn on radio TX
adf_RF_on(QRG_FSK4[QRGCounter++], PA_FSK4); // turn on radio TX
if (QRGCounter >= sizeof(QRG_FSK4) / sizeof(QRG_FSK4[0]))
QRGCounter = 0;
FSK_Active = true; // change status
TIM2->CR1 &= (uint16_t)(~((uint16_t)TIM_CR1_CEN)); // Disable the TIM Counter
uint16_t timer2StartValue =
@ -93,8 +96,8 @@ void FSK4_start_TX(char *buff, uint8_t len) {
1; // timer value calculated according to baud rate 999 for 100bd
TIM2->ARR = timer2StartValue; // set timer counter max value to pre-set value
// for baudrate (auto-reload register)
TIM2->CR1 |= TIM_CR1_CEN; // enable timer again
TIM2->DIER |= TIM_DIER_UIE; // Enable the interrupt
FSK4_timer_handler(); // force execution of procedure responsible for
// interrupt handling
TIM2->CR1 |= TIM_CR1_CEN; // enable timer again
TIM2->DIER |= TIM_DIER_UIE; // Enable the interrupt
FSK4_timer_handler(); // force execution of procedure responsible for
// interrupt handling
}

Wyświetl plik

@ -59,6 +59,11 @@ const static uint8_t GPS_airborne[44] = {
XMDATA GpsData;
#endif
#ifdef GPS_WATCHDOG
uint8_t GpsWatchdogCounter = 0;
bool PreviousFix = false;
#endif
uint8_t lps_init;
HorusBinaryPacket HorusPacket;
@ -112,6 +117,30 @@ PUTCHAR_PROTOTYPE {
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
void main_loop(void) {
#ifdef GPS_WATCHDOG
#if GPS_TYPE == 1
if (NmeaData.Fix > 1 && NmeaData.Sats > 0)
PreviousFix = true;
if (PreviousFix && (NmeaData.Fix <= 1 || NmeaData.Sats == 0)) {
GpsWatchdogCounter++;
} else {
GpsWatchdogCounter = 0;
}
#elif GPS_TYPE == 2
if (GpsData.Fix > 0 && GpsData.Sats > 0)
PreviousFix = true;
if (PreviousFix && (GpsData.Fix == 0 || GpsData.Sats == 0)) {
GpsWatchdogCounter++;
} else {
GpsWatchdogCounter = 0;
}
#endif
if (GpsWatchdogCounter >= GPS_WATCHDOG) {
LL_GPIO_ResetOutputPin(GPS_ON_GPIO_Port, GPS_ON_Pin); // disable GPS
while (1) {
} // trigger a restart with IWDG
}
#endif
// LED
#if LED_MODE == 1
LL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);