V761 telemetry

A1 (4.4V -> 2.2V), RSSI equal to 100 means that all telem packets are received and TQLY indicates the number of lost telem packets.
This commit is contained in:
pascallanger 2023-09-26 20:04:35 +02:00
parent 93a2cc8b7f
commit 2e1d763d54
6 changed files with 120 additions and 21 deletions

View File

@ -19,7 +19,7 @@
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 3 #define VERSION_MINOR 3
#define VERSION_REVISION 3 #define VERSION_REVISION 3
#define VERSION_PATCH_LEVEL 31 #define VERSION_PATCH_LEVEL 32
#define MODE_SERIAL 0 #define MODE_SERIAL 0

View File

@ -22,17 +22,23 @@ Multiprotocol is distributed in the hope that it will be useful,
#define V761_PACKET_PERIOD 7060 // Timeout for callback in uSec #define V761_PACKET_PERIOD 7060 // Timeout for callback in uSec
#define V761_INITIAL_WAIT 500 #define V761_INITIAL_WAIT 500
#define V761_PACKET_SIZE 8 #define V761_PACKET_SIZE 8
#define V761_RXPAYLOAD_SIZE 3
#define V761_BIND_COUNT 200 #define V761_BIND_COUNT 200
#define V761_BIND_FREQ 0x28 #define V761_BIND_FREQ 0x28
#define V761_RF_NUM_CHANNELS 3 #define V761_RF_NUM_CHANNELS 3
#define TOPRC_BIND_FREQ 0x2A #define TOPRC_BIND_FREQ 0x2A
#define TOPRC_PACKET_PERIOD 14120 // Timeout for callback in uSec #define TOPRC_PACKET_PERIOD 14120 // Timeout for callback in uSec
#define V761_WRITE_TIME 450
//#define V761_TELEM_DEBUG
enum enum
{ {
V761_BIND1 = 0, V761_BIND1 = 0,
V761_BIND2, V761_BIND2,
V761_DATA V761_RX_CHECK,
V761_DATA,
V761_RX
}; };
static void __attribute__((unused)) V761_set_checksum() static void __attribute__((unused)) V761_set_checksum()
@ -70,8 +76,8 @@ static void __attribute__((unused)) V761_send_packet()
if(hopping_frequency_no >= V761_RF_NUM_CHANNELS) if(hopping_frequency_no >= V761_RF_NUM_CHANNELS)
{ {
hopping_frequency_no = 0; hopping_frequency_no = 0;
packet_count++; packet_sent++;
packet_count &= 0x03; packet_sent &= 0x03;
} }
packet[0] = convert_channel_8b(THROTTLE); // Throttle packet[0] = convert_channel_8b(THROTTLE); // Throttle
@ -88,7 +94,7 @@ static void __attribute__((unused)) V761_send_packet()
packet[3] = convert_channel_8b(AILERON)>>1; // Aileron packet[3] = convert_channel_8b(AILERON)>>1; // Aileron
} }
packet[5] = packet_count<<6; // 0X, 4X, 8X, CX packet[5] = packet_sent<<6; // 0X, 4X, 8X, CX
packet[4] = 0x20; // Trims 00..20..40, 0X->20 4X->TrAil 8X->TrEle CX->TrRud packet[4] = 0x20; // Trims 00..20..40, 0X->20 4X->TrAil 8X->TrEle CX->TrRud
if(CH5_SW) // Mode Expert Gyro off if(CH5_SW) // Mode Expert Gyro off
@ -180,46 +186,125 @@ static void __attribute__((unused)) V761_initialize_txid()
uint16_t V761_callback() uint16_t V761_callback()
{ {
static bool rx = false;
static uint8_t packet_telem = 0;
switch(phase) switch(phase)
{ {
case V761_BIND1: case V761_BIND1:
if(bind_counter) if(bind_counter)
bind_counter--; bind_counter--;
packet_count ++; packet_sent ++;
XN297_RFChannel(sub_protocol == V761_TOPRC ? TOPRC_BIND_FREQ : V761_BIND_FREQ); XN297_RFChannel(sub_protocol == V761_TOPRC ? TOPRC_BIND_FREQ : V761_BIND_FREQ);
XN297_SetTXAddr(rx_id, 4); XN297_SetTXAddr(rx_id, 4);
V761_send_packet(); V761_send_packet();
if(packet_count >= 20) if(packet_sent >= 20)
{ {
packet_count = 0; packet_sent = 0;
phase = V761_BIND2; phase = V761_BIND2;
} }
return 15730; return 15730;
case V761_BIND2: case V761_BIND2:
if(bind_counter) if(bind_counter)
bind_counter--; bind_counter--;
packet_count ++; packet_sent ++;
XN297_Hopping(0); XN297_Hopping(0);
XN297_SetTXAddr(rx_tx_addr, 4); XN297_SetTXAddr(rx_tx_addr, 4);
V761_send_packet(); V761_send_packet();
if(bind_counter == 0) if(bind_counter == 0)
{ {
packet_count = 0; packet_sent = 0;
BIND_DONE; BIND_DONE;
phase = V761_DATA; phase = V761_DATA;
#ifdef V761_HUB_TELEMETRY
XN297_SetRXAddr(rx_tx_addr, V761_RXPAYLOAD_SIZE);
#endif
} }
else if(packet_count >= 20) else if(packet_sent >= 20)
{ {
packet_count = 0; packet_sent = 0;
phase = V761_BIND1; phase = V761_BIND1;
} }
return 15730; return 15730;
#ifdef V761_HUB_TELEMETRY
case V761_RX_CHECK:
rx = XN297_IsRX(); // Needed for the NRF24L01 since otherwise the bit gets cleared
packet_count++;
if(packet_count > 6*21) // About 1 sec with no telemetry
telemetry_lost = 1;
if(packet_telem++ >= 100)
TX_LQI = packet_telem = 0;
if(!telemetry_lost && !rx && (packet_count%22) == 0)
{// Should have received a telem packet but... Send telem to the radio to keep it alive
TX_LQI++;
RX_RSSI = 100 - TX_LQI;
telemetry_link = 1;
#ifdef V761_TELEM_DEBUG
debugln("Miss");
#endif
}
XN297_SetTxRxMode(TXRX_OFF);
phase++;
#endif
case V761_DATA: case V761_DATA:
#ifdef MULTI_SYNC #ifdef MULTI_SYNC
telemetry_set_input_sync(packet_period); telemetry_set_input_sync(packet_period);
#endif #endif
V761_send_packet(); V761_send_packet();
#ifdef V761_HUB_TELEMETRY
if(hopping_frequency_no == 1)
{ // Start RX on RF channel 0
phase++;
return V761_WRITE_TIME;
}
if(rx)
{ // Check if a packet has been received
#ifdef V761_TELEM_DEBUG
debug("RX ");
#endif
if(XN297_ReadPayload(packet_in, V761_RXPAYLOAD_SIZE))
{ // packet with good CRC and length
#ifdef V761_TELEM_DEBUG
debug("OK:");
for(uint8_t i=0;i<V761_RXPAYLOAD_SIZE;i++)
debug(" %02X",packet_in[i]);
#endif
// packet_in[] = AA 00 55 -> battery ok
// packet_in[] = 55 00 AA -> low battery
v_lipo1=packet_in[0] >> 1;
RX_RSSI = 100 - TX_LQI;
telemetry_link = 1;
telemetry_lost = 0;
packet_count = 0;
}
#ifdef V761_TELEM_DEBUG
else // Bad packet
debug("NOK");
debugln("");
#endif
rx = false;
}
break; break;
case V761_RX:
{ // Wait for packet to be sent before switching to receive mode
uint16_t start=(uint16_t)micros();
while ((uint16_t)((uint16_t)micros()-(uint16_t)start) < 500)
{
if(XN297_IsPacketSent())
break;
}
}
XN297_SetTxRxMode(RX_EN);
phase = V761_RX_CHECK;
if(!telemetry_lost && packet_count%20==0)
{ // Telemetry packets are sent every 21 packets but with a huge jitter from 4ms to 10+ms
hopping_frequency_no++; //don't send next packet to ensure we have enough time to receive the telemetry
return 2 * packet_period - V761_WRITE_TIME;
}
return packet_period - V761_WRITE_TIME;
#else
break;
#endif
} }
return packet_period; return packet_period;
} }
@ -227,6 +312,7 @@ uint16_t V761_callback()
void V761_init(void) void V761_init(void)
{ {
V761_initialize_txid(); V761_initialize_txid();
V761_RF_init();
if(sub_protocol == V761_TOPRC) if(sub_protocol == V761_TOPRC)
{ {
memcpy(rx_id,(uint8_t*)"\x20\x21\x05\x0A",4); memcpy(rx_id,(uint8_t*)"\x20\x21\x05\x0A",4);
@ -246,12 +332,19 @@ void V761_init(void)
else else
{ {
XN297_SetTXAddr(rx_tx_addr, 4); XN297_SetTXAddr(rx_tx_addr, 4);
#ifdef V761_HUB_TELEMETRY
XN297_SetRXAddr(rx_tx_addr, V761_RXPAYLOAD_SIZE);
#endif
phase = V761_DATA; phase = V761_DATA;
} }
V761_RF_init();
hopping_frequency_no = 0; hopping_frequency_no = 0;
packet_count = 0; packet_sent = 0;
#ifdef V761_HUB_TELEMETRY
packet_count = 0;
telemetry_lost = 1;
#endif
} }
#endif #endif

View File

@ -398,6 +398,7 @@
#undef DEVO_HUB_TELEMETRY #undef DEVO_HUB_TELEMETRY
#undef PROPEL_HUB_TELEMETRY #undef PROPEL_HUB_TELEMETRY
#undef OMP_HUB_TELEMETRY #undef OMP_HUB_TELEMETRY
#undef V761_HUB_TELEMETRY
#undef RLINK_HUB_TELEMETRY #undef RLINK_HUB_TELEMETRY
#undef DSM_RX_CYRF6936_INO #undef DSM_RX_CYRF6936_INO
#undef DSM_FWD_PGM #undef DSM_FWD_PGM
@ -433,6 +434,9 @@
#if not defined(OMP_CCNRF_INO) #if not defined(OMP_CCNRF_INO)
#undef OMP_HUB_TELEMETRY #undef OMP_HUB_TELEMETRY
#endif #endif
#if not defined(V761_NRF24L01_INO)
#undef V761_HUB_TELEMETRY
#endif
#if not defined(PROPEL_NRF24L01_INO) #if not defined(PROPEL_NRF24L01_INO)
#undef PROPEL_HUB_TELEMETRY #undef PROPEL_HUB_TELEMETRY
#endif #endif
@ -490,7 +494,7 @@
//protocols using FRSKYD user frames //protocols using FRSKYD user frames
#undef HUB_TELEMETRY #undef HUB_TELEMETRY
#endif #endif
#if not defined(HOTT_FW_TELEMETRY) && not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BUGS_HUB_TELEMETRY) && not defined(NCC1701_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(CABELL_HUB_TELEMETRY) && not defined(RLINK_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY) && not defined(MULTI_TELEMETRY) && not defined(MULTI_STATUS) && not defined(HITEC_HUB_TELEMETRY) && not defined(HITEC_FW_TELEMETRY) && not defined(SCANNER_TELEMETRY) && not defined(FRSKY_RX_TELEMETRY) && not defined(AFHDS2A_RX_TELEMETRY) && not defined(BAYANG_RX_TELEMETRY) && not defined(DEVO_HUB_TELEMETRY) && not defined(PROPEL_HUB_TELEMETRY) && not defined(OMP_HUB_TELEMETRY) && not defined(WFLY2_HUB_TELEMETRY) && not defined(LOLI_HUB_TELEMETRY) && not defined(MLINK_HUB_TELEMETRY) && not defined(MLINK_FW_TELEMETRY) && not defined(MT99XX_HUB_TELEMETRY) && not defined(MULTI_CONFIG_INO) #if not defined(HOTT_FW_TELEMETRY) && not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BUGS_HUB_TELEMETRY) && not defined(NCC1701_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(CABELL_HUB_TELEMETRY) && not defined(RLINK_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY) && not defined(MULTI_TELEMETRY) && not defined(MULTI_STATUS) && not defined(HITEC_HUB_TELEMETRY) && not defined(HITEC_FW_TELEMETRY) && not defined(SCANNER_TELEMETRY) && not defined(FRSKY_RX_TELEMETRY) && not defined(AFHDS2A_RX_TELEMETRY) && not defined(BAYANG_RX_TELEMETRY) && not defined(DEVO_HUB_TELEMETRY) && not defined(PROPEL_HUB_TELEMETRY) && not defined(OMP_HUB_TELEMETRY) && not defined(V761_HUB_TELEMETRY) && not defined(WFLY2_HUB_TELEMETRY) && not defined(LOLI_HUB_TELEMETRY) && not defined(MLINK_HUB_TELEMETRY) && not defined(MLINK_FW_TELEMETRY) && not defined(MT99XX_HUB_TELEMETRY) && not defined(MULTI_CONFIG_INO)
#undef TELEMETRY #undef TELEMETRY
#undef INVERT_TELEMETRY #undef INVERT_TELEMETRY
#undef MULTI_TELEMETRY #undef MULTI_TELEMETRY

View File

@ -133,10 +133,9 @@ static void __attribute__((unused)) XN297_SetRXAddr(const uint8_t* addr, uint8_t
if(xn297_rf == XN297_NRF) if(xn297_rf == XN297_NRF)
{ {
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, xn297_rx_addr, xn297_addr_len); NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, xn297_rx_addr, xn297_addr_len);
if(rx_packet_len >= 32) if(rx_packet_len > 32)
NRF24L01_WriteReg(NRF24L01_11_RX_PW_P0, 32); rx_packet_len = 32;
else NRF24L01_WriteReg(NRF24L01_11_RX_PW_P0, rx_packet_len);
NRF24L01_WriteReg(NRF24L01_11_RX_PW_P0, rx_packet_len);
} }
#endif #endif
#ifdef CC2500_INSTALLED #ifdef CC2500_INSTALLED

View File

@ -337,6 +337,7 @@
#define HUBSAN_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX #define HUBSAN_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
#define NCC1701_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX #define NCC1701_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
#define OMP_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX #define OMP_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
#define V761_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
#define PROPEL_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX #define PROPEL_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
#define CABELL_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX #define CABELL_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
#define RLINK_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX #define RLINK_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX

View File

@ -1991,6 +1991,8 @@ Flip: momentary switch: hold flip(+100%), indicate flip direction with Ele or Ai
RTN_ACT and RTN: -100% disable, +100% enable RTN_ACT and RTN: -100% disable, +100% enable
If the model (newest versions) sends telemetry then the battery status ok/empty is in A1 (4.4V -> 2.2V), RSSI equal to 100 means that all telem packets are received and TQLY indicates the number of lost telem packets.
### Sub_protocol 3CH - *0* ### Sub_protocol 3CH - *0*
Models: Volantex V761-1, V761-3 and may be others Models: Volantex V761-1, V761-3 and may be others