- Posts: 3333
Support for walkera telemetry.
- vlad_vy
- Offline
devo_cyrf6936.c
devo_telemetry_cb() without excessive poll:
static u16 devo_telemetry_cb()
{
int delay;
if (txState == 0) {
DEVO_BuildPacket();
CYRF_WriteDataPacket(packet);
txState = 1;
return 900;
}
if (txState == 1) {
int i = 0;
u8 reg;
while (! ((reg = CYRF_ReadRegister(0x04)) & 0x02)) {
if (++i >= NUM_WAIT_LOOPS)
break;
}
if (((reg & 0x22) == 0x20) || (CYRF_ReadRegister(0x02) & 0x80)) {
CYRF_Reset();
cyrf_init();
cyrf_set_bound_sop_code();
CYRF_ConfigRFChannel(*radio_ch_ptr);
//printf("Rst CYRF\n");
delay = 1500;
txState = 3;
} else {
if (state == DEVO_BOUND) {
/* exit binding state */
state = DEVO_BOUND_3;
cyrf_set_bound_sop_code();
}
if(pkt_num == 0 || bind_counter > 0) {
delay = 1500;
txState = 3;
} else {
CYRF_SetTxRxMode(RX_EN); //Receive mode
CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x80); //Prepare to receive (do not enable any IRQ)
txState = 2;
return 1100;
}
}
}
if(txState == 2) { // this won't be true in emulator so we need to simulate it somehow
u8 rx_status = CYRF_ReadRegister(0x07);
if((rx_status & 0x3) == 0x02) { // RXC=1, RXE=0 then 2nd check is required (debouncing)
rx_status |= CYRF_ReadRegister(0x07);
}
if ((rx_status & 0x07) == 0x02) { // good data (complete with no errors)
CYRF_WriteRegister(CYRF_07_RX_IRQ_STATUS, 0x80); //Prepare to read buffer
CYRF_ReadDataPacket(packet);
parse_telemetry_packet(packet);
}
#ifdef EMULATOR
u8 telem_bit = rand32() % 7; // random number in [0, 7)
packet[0] = TELEMETRY_ENABLE + telem_bit; // allow emulator to simulate telemetry parsing to prevent future bugs in the telemetry monitor
//printf("telem 1st packet: 0x%x\n", packet[0]);
for(int i = 1; i < 13; i++)
packet[i] = rand32() % 256;
parse_telemetry_packet(packet);
for(int i = 0; i < TELEM_UPDATE_SIZE; i++)
Telemetry.updated[i] = 0xff;
#endif
delay = 400;
txState = 3;
}
if(txState == 3) {
CYRF_SetTxRxMode(TX_EN); //Write mode
if(pkt_num == 0) {
//Keep tx power updated
CYRF_WriteRegister(CYRF_03_TX_CFG, 0x08 | Model.tx_power);
radio_ch_ptr = radio_ch_ptr == &radio_ch[2] ? radio_ch : radio_ch_ptr + 1;
CYRF_ConfigRFChannel(*radio_ch_ptr);
}
txState = 0;
}
return delay;
}
devo_cyrf6936.c
devo_telemetry_cb() without excessive poll and with while() loop: It is possible that it has a little more time for telemetry parsing. Telemetry packet ended in between 1900us and 2000us from cycle start.
static u16 devo_telemetry_cb()
{
int delay;
if (txState == 0) {
DEVO_BuildPacket();
CYRF_WriteDataPacket(packet);
txState = 1;
return 900;
}
if (txState == 1) {
int i = 0;
u8 reg;
while (! ((reg = CYRF_ReadRegister(0x04)) & 0x02)) {
if (++i >= NUM_WAIT_LOOPS)
break;
}
if (((reg & 0x22) == 0x20) || (CYRF_ReadRegister(0x02) & 0x80)) {
CYRF_Reset();
cyrf_init();
cyrf_set_bound_sop_code();
CYRF_ConfigRFChannel(*radio_ch_ptr);
//printf("Rst CYRF\n");
delay = 1500;
txState = 3;
} else {
if (state == DEVO_BOUND) {
/* exit binding state */
state = DEVO_BOUND_3;
cyrf_set_bound_sop_code();
}
if(pkt_num == 0 || bind_counter > 0) {
delay = 1500;
txState = 3;
} else {
CYRF_SetTxRxMode(RX_EN); //Receive mode
CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x80); //Prepare to receive (do not enable any IRQ)
txState = 2;
return 1000;
}
}
}
if(txState == 2) { // this won't be true in emulator so we need to simulate it somehow
int i = 0;
u8 rx_status;
while ( !((rx_status = CYRF_ReadRegister(0x07)) & 0x02)) {
if (++i > NUM_WAIT_LOOPS)
break;
}
if((rx_status & 0x3) == 0x02) { // RXC=1, RXE=0 then 2nd check is required (debouncing)
rx_status |= CYRF_ReadRegister(0x07);
}
if ((rx_status & 0x07) == 0x02) { // good data (complete with no errors)
CYRF_WriteRegister(CYRF_07_RX_IRQ_STATUS, 0x80); //Prepare to read buffer
CYRF_ReadDataPacket(packet);
parse_telemetry_packet(packet);
}
#ifdef EMULATOR
u8 telem_bit = rand32() % 7; // random number in [0, 7)
packet[0] = TELEMETRY_ENABLE + telem_bit; // allow emulator to simulate telemetry parsing to prevent future bugs in the telemetry monitor
//printf("telem 1st packet: 0x%x\n", packet[0]);
for(int i = 1; i < 13; i++)
packet[i] = rand32() % 256;
parse_telemetry_packet(packet);
for(int i = 0; i < TELEM_UPDATE_SIZE; i++)
Telemetry.updated[i] = 0xff;
#endif
delay = 500;
txState = 3;
}
if(txState == 3) {
CYRF_SetTxRxMode(TX_EN); //Write mode
if(pkt_num == 0) {
//Keep tx power updated
CYRF_WriteRegister(CYRF_03_TX_CFG, 0x08 | Model.tx_power);
radio_ch_ptr = radio_ch_ptr == &radio_ch[2] ? radio_ch : radio_ch_ptr + 1;
CYRF_ConfigRFChannel(*radio_ch_ptr);
}
txState = 0;
}
return delay;
}
dsm2_cyrf6936.c
{CYRF_06_RX_CFG, 0x4A},
#endif
{
state++;
CYRF_SetTxRxMode(RX_EN); //Receive mode
CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x87); //Prepare to receive
return 11000 - CH1_CH2_DELAY - WRITE_DELAY - READ_DELAY;
}
} else if(state == DSM2_CH2_READ_A || state == DSM2_CH2_READ_B) {
//Read telemetry if needed
int rx_status = CYRF_ReadRegister(0x07);
if((rx_status & 0x3) == 0x02) { // RXC=1, RXE=0 then 2nd check is required (debouncing)
rx_status |= CYRF_ReadRegister(0x07);
}
if ((rx_status & 0x07) == 0x02) { // good data (complete with no errors)
CYRF_WriteRegister(CYRF_07_RX_IRQ_STATUS, 0x80); //Prepare to read buffer
CYRF_ReadDataPacket(packet);
parse_telemetry_packet(packet);
}
if (state == DSM2_CH2_READ_A && num_channels < 8) {
Changed files:
Please Log in or Create an account to join the conversation.
- linux-user
- Offline
- Posts: 271
- Is this just statistics?
- Did you omit the 'RST CYRF' message in the code?
- Have we found a way to avoid LOS in the first place?
Please Log in or Create an account to join the conversation.
- vlad_vy
- Offline
- Posts: 3333
Do you have any problems with telemetry? Inverted values or anything else?
Please Log in or Create an account to join the conversation.
- linux-user
- Offline
- Posts: 271
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
If I'm going to do a new build anyway to enable debug(so we can see if issues are actually occurring) should I take Vald's latest code? I like reducing the polling and busy loops, so that is good.
Is this code otherwise ready to go?
Please Log in or Create an account to join the conversation.
- vlad_vy
- Offline
- Posts: 3333
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
www.deviationtx.com/downloads-new/catego...vlad-s-devo-dsm-test
I chose the _01 version. Not sure which is better, but telemetry parsing doesn't take much time.
Edit: I did enable the Reset printf so we can see if it is still occurring
Please Log in or Create an account to join the conversation.
- Gyrfalcon
- Offline
- Posts: 23
I just put together an ac powered test system using a Devo12S and a MCP receiver (RX2637H-D) that has telemetry enabled for receiver voltage, battery voltage and temp. I can also easily do fixed or auto binding tests.
Would you mind making a Devo12S release as well, or point me to the source that you are using? (As well as the make command used for consistency).
Also, what recommendations for the test environment do you have? Power level, distance between receiver and transmitter, other considerations?
I'll look forward to providing some feedback on the results
Thanks,
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
I have not published the repo, however it is just the trunk + the files from vlad's .zip file.
I then edit devo_cyrf6936.c to enable the printf in the 'Reset detector'
I run:
make TARGET=devo12 TYPE=dev zip
Note that I have never been able to reproduce the LOS that linux-user has on any of my transmitters, but I have been able to trigger the Reset condition. We have high confidence that the reset condition will resolve the LOS issue, so now it is more a question of optimizing the code and trying to prevent the Reset from happening in the 1st place (and fixing the telemetry glitches)
Anyhow, I'd like to see a significant amount of testing to gain confidence this can be pushed into the trunk.
Please Log in or Create an account to join the conversation.
- Gyrfalcon
- Offline
- Posts: 23
I'll let you know what I discover with my system.
Please Log in or Create an account to join the conversation.
- linux-user
- Offline
- Posts: 271
I see lots of 'RST CYRF" messages as soon as RX is connected.
TX alone (without connected RX) does not show 'RST CYRF" messages at first glance.
Besides that it seems to work good. Telemetry works perfect. No noticeable delay on control.
Please Log in or Create an account to join the conversation.
- Gyrfalcon
- Offline
- Posts: 23
Also, (this is probably obvious and expected) with Telemetry turned off no RST CYRF or any other messages are displayed.
I am also getting a lot of these messages - only with Telemetry on. (I'll check into this later.)
DEBUG: LCD_DrawWindowedImageFromFile (media/devo12.bmp) Dimensions asked for
size (480 x 272) bounds (464 x 275)
Hard to read at the beginning off line due to characters overlapping.
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
Please Log in or Create an account to join the conversation.
- Gyrfalcon
- Offline
- Posts: 23
As for the Devo Telemetry with an RX2637H-D, it seams to perform the best of any the builds I have tried so far. Unfortunately, there is a consistent flow of Rst CYRF messages on my system.
Please Log in or Create an account to join the conversation.
- vlad_vy
- Offline
- Posts: 3333
static u16 devo_telemetry_cb()
{
if (txState == 0) {
txState = 1;
DEVO_BuildPacket();
CYRF_WriteDataPacket(packet);
return 900;
}
int delay = 100;
if (txState == 1) {
int i = 0;
u8 reg;
while (! ((reg = CYRF_ReadRegister(0x04)) & 0x02)) {
if (++i >= NUM_WAIT_LOOPS)
break;
}
if (((reg & 0x22) == 0x20) || (CYRF_ReadRegister(0x02) & 0x80)) {
CYRF_Reset();
cyrf_init();
cyrf_set_bound_sop_code();
CYRF_ConfigRFChannel(*radio_ch_ptr);
//printf(" Rst CYRF\n");
delay = 1500;
txState = 15;
} else {
if (state == DEVO_BOUND) {
/* exit binding state */
state = DEVO_BOUND_3;
cyrf_set_bound_sop_code();
}
if(pkt_num == 0 || bind_counter > 0) {
delay = 1500;
txState = 15;
} else {
CYRF_SetTxRxMode(RX_EN); //Receive mode
CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x80); //Prepare to receive (do not enable any IRQ)
delay = 900;
txState = 9;
}
}
} else { // this won't be true in emulator so we need to simulate it somehow
u8 rx_status = CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
if ((rx_status & 0x03) == 0x02) { // RXC=1, RXE=0 then 2nd check is required (debouncing)
rx_status |= CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
if ((rx_status & 0x07) == 0x02) { // good data (complete with no errors)
CYRF_WriteRegister(CYRF_07_RX_IRQ_STATUS, 0x80); // need to set RXOW before data read
CYRF_ReadDataPacket(packet);
parse_telemetry_packet(packet);
delay = 100 * (16 - txState);
txState = 15;
}
}
#ifdef EMULATOR
u8 telem_bit = rand32() % 7; // random number in [0, 7)
packet[0] = TELEMETRY_ENABLE + telem_bit; // allow emulator to simulate telemetry parsing to prevent future bugs in the telemetry monitor
//printf("telem 1st packet: 0x%x\n", packet[0]);
for(int i = 1; i < 13; i++)
packet[i] = rand32() % 256;
parse_telemetry_packet(packet);
for(int i = 0; i < TELEM_UPDATE_SIZE; i++)
Telemetry.updated[i] = 0xff;
delay = 100 * (16 - txState);
txState = 15;
#endif
}
txState++;
if(txState == 16) { //2.3msec have passed
CYRF_SetTxRxMode(TX_EN); //Write mode
if(pkt_num == 0) {
//Keep tx power updated
CYRF_WriteRegister(CYRF_03_TX_CFG, 0x08 | Model.tx_power);
radio_ch_ptr = radio_ch_ptr == &radio_ch[2] ? radio_ch : radio_ch_ptr + 1;
CYRF_ConfigRFChannel(*radio_ch_ptr);
}
txState = 0;
}
return delay;
}
Changed files (printf(" Rst CYRF\n") commented out):
Please Log in or Create an account to join the conversation.
- vlad_vy
- Offline
- Posts: 3333
static u16 devo_telemetry_cb()
{
if (txState == 0) {
txState = 1;
DEVO_BuildPacket();
CYRF_WriteDataPacket(packet);
return 900;
}
int delay = 100;
if (txState == 1) {
int i = 0;
u8 reg;
while (! ((reg = CYRF_ReadRegister(0x04)) & 0x02)) {
if (++i >= NUM_WAIT_LOOPS)
break;
}
if (((reg & 0x22) == 0x20) || (CYRF_ReadRegister(0x02) & 0x80)) {
CYRF_Reset();
cyrf_init();
cyrf_set_bound_sop_code();
CYRF_ConfigRFChannel(*radio_ch_ptr);
//printf(" Rst CYRF\n");
delay = 1500;
txState = 15;
} else {
if (state == DEVO_BOUND) {
/* exit binding state */
state = DEVO_BOUND_3;
cyrf_set_bound_sop_code();
}
if(pkt_num == 0 || bind_counter > 0) {
delay = 1500;
txState = 15;
} else {
CYRF_SetTxRxMode(RX_EN); //Receive mode
CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x80); //Prepare to receive (do not enable any IRQ)
delay = 900;
txState = 9;
}
}
} else { // this won't be true in emulator so we need to simulate it somehow
u8 rx_status = CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
if ((rx_status & 0x03) == 0x02) { // RXC=1, RXE=0 then 2nd check is required (debouncing)
rx_status |= CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
if ((rx_status & 0x07) == 0x02) { // good data (complete with no errors)
CYRF_WriteRegister(CYRF_07_RX_IRQ_STATUS, 0x80); // need to set RXOW before data read
CYRF_ReadDataPacket(packet);
parse_telemetry_packet(packet);
}
delay = 100 * (16 - txState);
txState = 15;
}
#ifdef EMULATOR
u8 telem_bit = rand32() % 7; // random number in [0, 7)
packet[0] = TELEMETRY_ENABLE + telem_bit; // allow emulator to simulate telemetry parsing to prevent future bugs in the telemetry monitor
//printf("telem 1st packet: 0x%x\n", packet[0]);
for(int i = 1; i < 13; i++)
packet[i] = rand32() % 256;
parse_telemetry_packet(packet);
for(int i = 0; i < TELEM_UPDATE_SIZE; i++)
Telemetry.updated[i] = 0xff;
delay = 100 * (16 - txState);
txState = 15;
#endif
}
txState++;
if(txState == 16) { //2.3msec have passed
CYRF_SetTxRxMode(TX_EN); //Write mode
if(pkt_num == 0) {
//Keep tx power updated
CYRF_WriteRegister(CYRF_03_TX_CFG, 0x08 | Model.tx_power);
radio_ch_ptr = radio_ch_ptr == &radio_ch[2] ? radio_ch : radio_ch_ptr + 1;
CYRF_ConfigRFChannel(*radio_ch_ptr);
}
txState = 0;
}
return delay;
}
Changed files (printf(" Rst CYRF\n") commented out):
Please Log in or Create an account to join the conversation.
- Gyrfalcon
- Offline
- Posts: 23
Please Log in or Create an account to join the conversation.
- vlad_vy
- Offline
- Posts: 3333
Changed files (printf(" Rst CYRF\n") commented out):
Please Log in or Create an account to join the conversation.
- PhracturedBlue
- Offline
- Posts: 4402
www.deviationtx.com/downloads-new/catego...-devo-dsm-test-31794
Please Log in or Create an account to join the conversation.
- Gyrfalcon
- Offline
- Posts: 23
For this latest test, I am using the auto bind feature with two receivers (RX1202 and RX2637H-D w/Telemetry) and both connect and reconnect just fine. For reconnections I have removed the power and the reconnected it after a short time. Both receivers re-bind, although it would never be fast enough to prevent me from crashing.
I have also walked the transmitter (Devo12S @100uW) out of range for telemetry and both receivers, and returned. (I have a HK Discovery Buzzer connected on the gear channel of the RX1202 that I can hear when activated.) Once back within range everything reconnects and looks good. Again no debug messages.
Next I'll try my RX2648-D with the WK-CTL01-D Telemetry for a short test to see if it also looks good.
Later, I can also do some DSMX testing (SPMAR9020 system with a TM1000) if that code looks good to everyone. But we can discuss that on the DSM Telemetry Support thread if desired.
Everything is looking so good I am temped to get a Walkera and/or Spectrum GPS unit.
Feel free to ask any questions. Thanks
Please Log in or Create an account to join the conversation.
- Home
- Forum
- Development
- Protocol Development
- Support for walkera telemetry.