Skip to content

Commit 2e1d763

Browse files
committed
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.
1 parent 93a2cc8 commit 2e1d763

6 files changed

Lines changed: 120 additions & 21 deletions

File tree

Multiprotocol/Multiprotocol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define VERSION_MAJOR 1
2020
#define VERSION_MINOR 3
2121
#define VERSION_REVISION 3
22-
#define VERSION_PATCH_LEVEL 31
22+
#define VERSION_PATCH_LEVEL 32
2323

2424
#define MODE_SERIAL 0
2525

Multiprotocol/V761_nrf24l01.ino

Lines changed: 108 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,23 @@ Multiprotocol is distributed in the hope that it will be useful,
2222
#define V761_PACKET_PERIOD 7060 // Timeout for callback in uSec
2323
#define V761_INITIAL_WAIT 500
2424
#define V761_PACKET_SIZE 8
25+
#define V761_RXPAYLOAD_SIZE 3
2526
#define V761_BIND_COUNT 200
2627
#define V761_BIND_FREQ 0x28
2728
#define V761_RF_NUM_CHANNELS 3
2829
#define TOPRC_BIND_FREQ 0x2A
2930
#define TOPRC_PACKET_PERIOD 14120 // Timeout for callback in uSec
3031

32+
#define V761_WRITE_TIME 450
33+
//#define V761_TELEM_DEBUG
34+
3135
enum
3236
{
33-
V761_BIND1 = 0,
34-
V761_BIND2,
35-
V761_DATA
37+
V761_BIND1 = 0,
38+
V761_BIND2,
39+
V761_RX_CHECK,
40+
V761_DATA,
41+
V761_RX
3642
};
3743

3844
static void __attribute__((unused)) V761_set_checksum()
@@ -70,8 +76,8 @@ static void __attribute__((unused)) V761_send_packet()
7076
if(hopping_frequency_no >= V761_RF_NUM_CHANNELS)
7177
{
7278
hopping_frequency_no = 0;
73-
packet_count++;
74-
packet_count &= 0x03;
79+
packet_sent++;
80+
packet_sent &= 0x03;
7581
}
7682

7783
packet[0] = convert_channel_8b(THROTTLE); // Throttle
@@ -88,7 +94,7 @@ static void __attribute__((unused)) V761_send_packet()
8894
packet[3] = convert_channel_8b(AILERON)>>1; // Aileron
8995
}
9096

91-
packet[5] = packet_count<<6; // 0X, 4X, 8X, CX
97+
packet[5] = packet_sent<<6; // 0X, 4X, 8X, CX
9298
packet[4] = 0x20; // Trims 00..20..40, 0X->20 4X->TrAil 8X->TrEle CX->TrRud
9399

94100
if(CH5_SW) // Mode Expert Gyro off
@@ -180,53 +186,133 @@ static void __attribute__((unused)) V761_initialize_txid()
180186

181187
uint16_t V761_callback()
182188
{
189+
static bool rx = false;
190+
static uint8_t packet_telem = 0;
191+
183192
switch(phase)
184193
{
185194
case V761_BIND1:
186195
if(bind_counter)
187196
bind_counter--;
188-
packet_count ++;
197+
packet_sent ++;
189198
XN297_RFChannel(sub_protocol == V761_TOPRC ? TOPRC_BIND_FREQ : V761_BIND_FREQ);
190199
XN297_SetTXAddr(rx_id, 4);
191200
V761_send_packet();
192-
if(packet_count >= 20)
201+
if(packet_sent >= 20)
193202
{
194-
packet_count = 0;
203+
packet_sent = 0;
195204
phase = V761_BIND2;
196205
}
197206
return 15730;
198207
case V761_BIND2:
199208
if(bind_counter)
200209
bind_counter--;
201-
packet_count ++;
210+
packet_sent ++;
202211
XN297_Hopping(0);
203212
XN297_SetTXAddr(rx_tx_addr, 4);
204213
V761_send_packet();
205214
if(bind_counter == 0)
206215
{
207-
packet_count = 0;
216+
packet_sent = 0;
208217
BIND_DONE;
209218
phase = V761_DATA;
219+
#ifdef V761_HUB_TELEMETRY
220+
XN297_SetRXAddr(rx_tx_addr, V761_RXPAYLOAD_SIZE);
221+
#endif
210222
}
211-
else if(packet_count >= 20)
223+
else if(packet_sent >= 20)
212224
{
213-
packet_count = 0;
225+
packet_sent = 0;
214226
phase = V761_BIND1;
215227
}
216228
return 15730;
229+
#ifdef V761_HUB_TELEMETRY
230+
case V761_RX_CHECK:
231+
rx = XN297_IsRX(); // Needed for the NRF24L01 since otherwise the bit gets cleared
232+
packet_count++;
233+
if(packet_count > 6*21) // About 1 sec with no telemetry
234+
telemetry_lost = 1;
235+
if(packet_telem++ >= 100)
236+
TX_LQI = packet_telem = 0;
237+
if(!telemetry_lost && !rx && (packet_count%22) == 0)
238+
{// Should have received a telem packet but... Send telem to the radio to keep it alive
239+
TX_LQI++;
240+
RX_RSSI = 100 - TX_LQI;
241+
telemetry_link = 1;
242+
#ifdef V761_TELEM_DEBUG
243+
debugln("Miss");
244+
#endif
245+
}
246+
XN297_SetTxRxMode(TXRX_OFF);
247+
phase++;
248+
#endif
217249
case V761_DATA:
218250
#ifdef MULTI_SYNC
219251
telemetry_set_input_sync(packet_period);
220252
#endif
221253
V761_send_packet();
254+
#ifdef V761_HUB_TELEMETRY
255+
if(hopping_frequency_no == 1)
256+
{ // Start RX on RF channel 0
257+
phase++;
258+
return V761_WRITE_TIME;
259+
}
260+
if(rx)
261+
{ // Check if a packet has been received
262+
#ifdef V761_TELEM_DEBUG
263+
debug("RX ");
264+
#endif
265+
if(XN297_ReadPayload(packet_in, V761_RXPAYLOAD_SIZE))
266+
{ // packet with good CRC and length
267+
#ifdef V761_TELEM_DEBUG
268+
debug("OK:");
269+
for(uint8_t i=0;i<V761_RXPAYLOAD_SIZE;i++)
270+
debug(" %02X",packet_in[i]);
271+
#endif
272+
// packet_in[] = AA 00 55 -> battery ok
273+
// packet_in[] = 55 00 AA -> low battery
274+
v_lipo1=packet_in[0] >> 1;
275+
RX_RSSI = 100 - TX_LQI;
276+
telemetry_link = 1;
277+
telemetry_lost = 0;
278+
packet_count = 0;
279+
}
280+
#ifdef V761_TELEM_DEBUG
281+
else // Bad packet
282+
debug("NOK");
283+
debugln("");
284+
#endif
285+
rx = false;
286+
}
222287
break;
288+
case V761_RX:
289+
{ // Wait for packet to be sent before switching to receive mode
290+
uint16_t start=(uint16_t)micros();
291+
while ((uint16_t)((uint16_t)micros()-(uint16_t)start) < 500)
292+
{
293+
if(XN297_IsPacketSent())
294+
break;
295+
}
296+
}
297+
XN297_SetTxRxMode(RX_EN);
298+
phase = V761_RX_CHECK;
299+
if(!telemetry_lost && packet_count%20==0)
300+
{ // Telemetry packets are sent every 21 packets but with a huge jitter from 4ms to 10+ms
301+
hopping_frequency_no++; //don't send next packet to ensure we have enough time to receive the telemetry
302+
return 2 * packet_period - V761_WRITE_TIME;
303+
}
304+
return packet_period - V761_WRITE_TIME;
305+
#else
306+
break;
307+
#endif
223308
}
224309
return packet_period;
225310
}
226311

227312
void V761_init(void)
228313
{
229314
V761_initialize_txid();
315+
V761_RF_init();
230316
if(sub_protocol == V761_TOPRC)
231317
{
232318
memcpy(rx_id,(uint8_t*)"\x20\x21\x05\x0A",4);
@@ -246,12 +332,19 @@ void V761_init(void)
246332
else
247333
{
248334
XN297_SetTXAddr(rx_tx_addr, 4);
335+
#ifdef V761_HUB_TELEMETRY
336+
XN297_SetRXAddr(rx_tx_addr, V761_RXPAYLOAD_SIZE);
337+
#endif
249338
phase = V761_DATA;
250339
}
251340

252-
V761_RF_init();
253341
hopping_frequency_no = 0;
254-
packet_count = 0;
342+
packet_sent = 0;
343+
#ifdef V761_HUB_TELEMETRY
344+
packet_count = 0;
345+
telemetry_lost = 1;
346+
#endif
347+
255348
}
256349

257350
#endif

Multiprotocol/Validate.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@
398398
#undef DEVO_HUB_TELEMETRY
399399
#undef PROPEL_HUB_TELEMETRY
400400
#undef OMP_HUB_TELEMETRY
401+
#undef V761_HUB_TELEMETRY
401402
#undef RLINK_HUB_TELEMETRY
402403
#undef DSM_RX_CYRF6936_INO
403404
#undef DSM_FWD_PGM
@@ -433,6 +434,9 @@
433434
#if not defined(OMP_CCNRF_INO)
434435
#undef OMP_HUB_TELEMETRY
435436
#endif
437+
#if not defined(V761_NRF24L01_INO)
438+
#undef V761_HUB_TELEMETRY
439+
#endif
436440
#if not defined(PROPEL_NRF24L01_INO)
437441
#undef PROPEL_HUB_TELEMETRY
438442
#endif
@@ -490,7 +494,7 @@
490494
//protocols using FRSKYD user frames
491495
#undef HUB_TELEMETRY
492496
#endif
493-
#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)
497+
#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)
494498
#undef TELEMETRY
495499
#undef INVERT_TELEMETRY
496500
#undef MULTI_TELEMETRY

Multiprotocol/XN297_EMU.ino

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,9 @@ static void __attribute__((unused)) XN297_SetRXAddr(const uint8_t* addr, uint8_t
133133
if(xn297_rf == XN297_NRF)
134134
{
135135
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, xn297_rx_addr, xn297_addr_len);
136-
if(rx_packet_len >= 32)
137-
NRF24L01_WriteReg(NRF24L01_11_RX_PW_P0, 32);
138-
else
139-
NRF24L01_WriteReg(NRF24L01_11_RX_PW_P0, rx_packet_len);
136+
if(rx_packet_len > 32)
137+
rx_packet_len = 32;
138+
NRF24L01_WriteReg(NRF24L01_11_RX_PW_P0, rx_packet_len);
140139
}
141140
#endif
142141
#ifdef CC2500_INSTALLED

Multiprotocol/_Config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@
337337
#define HUBSAN_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
338338
#define NCC1701_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
339339
#define OMP_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
340+
#define V761_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
340341
#define PROPEL_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
341342
#define CABELL_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
342343
#define RLINK_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX

Protocols_Details.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,6 +1991,8 @@ Flip: momentary switch: hold flip(+100%), indicate flip direction with Ele or Ai
19911991

19921992
RTN_ACT and RTN: -100% disable, +100% enable
19931993

1994+
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.
1995+
19941996
### Sub_protocol 3CH - *0*
19951997
Models: Volantex V761-1, V761-3 and may be others
19961998

0 commit comments

Comments
 (0)