kopia lustrzana https://github.com/OpenRTX/OpenRTX
Implement voltage to dBm conversion in MDx
MDx radios get an RSSI voltage in mV, to be converted into dBm, we used and empirically derived linear relation to compute the dBm value.replace/2eebd6a124e378c3ef1f604cda4ffaad69285583
rodzic
f61c269270
commit
90445e29a7
|
@ -110,8 +110,8 @@ rtxStatus_t rtx_getCurrentStatus();
|
|||
void rtx_taskFunc();
|
||||
|
||||
/**
|
||||
* Get current RSSI voltage.
|
||||
* @return RSSI voltage.
|
||||
* Get current RSSI in dBm.
|
||||
* @return RSSI value in dBm.
|
||||
*/
|
||||
float rtx_getRssi();
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ typedef struct
|
|||
curTime_t time;
|
||||
float v_bat;
|
||||
float charge;
|
||||
float rssi;
|
||||
|
||||
uint8_t ui_screen;
|
||||
uint8_t backlight_level;
|
||||
|
|
|
@ -37,6 +37,7 @@ void state_init()
|
|||
#endif
|
||||
state.v_bat = platform_getVbat();
|
||||
state.charge = battery_getCharge(state.v_bat);
|
||||
state.rssi = rtx_getRssi();
|
||||
|
||||
state.backlight_level = 255;
|
||||
state.channelInfoUpdated = true;
|
||||
|
|
|
@ -251,6 +251,7 @@ static void dev_task(void *arg)
|
|||
#endif
|
||||
state.v_bat = platform_getVbat();
|
||||
state.charge = battery_getCharge(state.v_bat);
|
||||
state.rssi = rtx_getRssi();
|
||||
|
||||
OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err);
|
||||
|
||||
|
|
|
@ -44,6 +44,13 @@ rtxStatus_t rtxStatus; /* RTX driver status */
|
|||
uint8_t sqlOpenTsh; /* Squelch opening threshold */
|
||||
uint8_t sqlCloseTsh; /* Squelch closing threshold */
|
||||
|
||||
// RSSI mV to dBm conversion function, gain is constant, while offset values
|
||||
// are aligned to calibration frequency test points
|
||||
float rssi_gain = 22.0f;
|
||||
float rssi_offset[] = {3277.618f, 3654.755f, 3808.191f,
|
||||
3811.318f, 3804.936f, 3806.591f,
|
||||
3723.882f, 3621.373f, 3559.782f};
|
||||
|
||||
/*
|
||||
* Helper functions to reduce code mess. They all access 'rtxStatus'
|
||||
* internally.
|
||||
|
@ -443,5 +450,17 @@ void rtx_taskFunc()
|
|||
|
||||
float rtx_getRssi()
|
||||
{
|
||||
return adc1_getMeasurement(1);
|
||||
// ADC1 returns the RSSI value in mV, we convert it to dBm trough
|
||||
// their derived linear relation
|
||||
float rssi_mv = adc1_getMeasurement(1);
|
||||
float freq = rtxStatus.rxFrequency;
|
||||
int index = 0;
|
||||
if (freq < 401035000.0f)
|
||||
index = 0;
|
||||
else if (freq > 479995000.0f)
|
||||
index = 8;
|
||||
else
|
||||
index = (int)(freq - 400035000.0f)/10000000;
|
||||
float rssi_dbm = (rssi_mv - rssi_offset[index]) / rssi_gain;
|
||||
return rssi_dbm;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue