Support for walkera telemetry.

More
30 Apr 2015 05:18 - 30 Apr 2015 05:35 #31833 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
By the way, my code also working fine with buffer overwrite disabled, it's a good way to detect any problems with receiving. If any data get stuck in the RX buffer, telemetry stop working.

devo_cyrf6936.c
CYRF_WriteRegister(CYRF_06_RX_CFG, 0x48);

dsm2_cyrf6936.c
{CYRF_06_RX_CFG, 0x48},
Last edit: 30 Apr 2015 05:35 by vlad_vy.

Please Log in or Create an account to join the conversation.

More
30 Apr 2015 07:43 #31835 by linux-user
Replied by linux-user on topic Support for walkera telemetry.
vlad-deviation-devo10-v4.0.1-f628e56 has been running now for 18h without any problems.
- 4x 'RST CYRF' message what is expected on my TX
- connection still possible
- telemetry working prefect
- control working prefect

OT:
- when telemetry alarm is triggered it jumps to telemetry page (maybe debatable).
- data logging is not working since a long time ago.

Please Log in or Create an account to join the conversation.

More
30 Apr 2015 08:06 - 30 Apr 2015 08:14 #31836 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
I also don't like switching to Telemetry monitor screen in case any telemetry alarm. At least we need option to select if we want to switch or not. By default, definitely I don't want switch to any other screen from main screen.
Last edit: 30 Apr 2015 08:14 by vlad_vy.

Please Log in or Create an account to join the conversation.

More
30 Apr 2015 09:31 - 01 May 2015 03:47 #31838 by Gyrfalcon
Replied by Gyrfalcon on topic Support for walkera telemetry.
With additional testing ([PhracturedBlue]Vlad's Devo/DSM test #31794, deviation-devo12-v4.0.1-f628e56) has had a few Rst CYRF messages.

For the new tests, I separated the receiver and transmitter to about 3 meters and setup a parallel test system. Both systems are powered at 100uW and have had good telemetry and control reception. I think the Rst CYRF message occurs sometimes when I bind or re-bind one of the systems, or when I turn on an additional transmitter (Devo8S, 100mW). But I can not get a consistent response, so it may be something else.

I also noted that I can jam the telemetry signal with the addition transmitter (most of the time), once it is moved away or turned off, the telemetry is restored. The receivers do not seam to be affected by a third transmitter and I still see smooth servo functionality.

At the end my torcher testing, I did have a LOC to the RX2637. The RX1202, which was dual bound to the same transmitter was still connected, so I don't think it was caused by a transmitter problem.

BTW, I tested Indigo's latest build, deviation-devo12-v4.0.1-ee1b869 and it seams to perform about the same. Telemetry and receiver connections were good. Unfortunately, it also generates a few Rst CYRF messages, similar to Vlad's code. I had both versions running at the same time, and sometimes it appeared that they generated Rst CYRF messages at the same time, but other times they were independent. Wish I could get consistent, results.

I was happy to see that Indigo changed the alarm page jump code as I suggested, Thanks!
Last edit: 01 May 2015 03:47 by Gyrfalcon. Reason: updated build version

Please Log in or Create an account to join the conversation.

More
30 Apr 2015 09:43 - 30 Apr 2015 10:01 #31839 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
PB, probably will be better change code to version without reduced polling and test again? I don't like occasionally "Rst CYRF" messages.
            } 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;                
            }

or at least decrease delay
            } else {
                CYRF_SetTxRxMode(RX_EN); //Receive mode
                CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x80); //Prepare to receive (do not enable any IRQ)
                delay = 800;
                txState = 8;                
            }
Last edit: 30 Apr 2015 10:01 by vlad_vy.

Please Log in or Create an account to join the conversation.

More
30 Apr 2015 10:08 #31842 by linux-user
Replied by linux-user on topic Support for walkera telemetry.
I like occasionally "Rst CYRF" messages :P
Every ~4h one "Rst CYRF" messages means to me a prevented LOC

Please Log in or Create an account to join the conversation.

More
30 Apr 2015 10:14 #31843 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
You still will have prevented LOC, but may be less occasionally "Rst CYRF" messages.

Please Log in or Create an account to join the conversation.

More
30 Apr 2015 17:08 #31854 by Gyrfalcon
Replied by Gyrfalcon on topic Support for walkera telemetry.
Restarted the test with ([PhracturedBlue]Vlad's Devo/DSM test #31794, deviation-devo12-v4.0.1-f628e56) and let it run over night, by itself with no other interference (at least by me).

So far, after 9 Hrs, the Debug log is clean, with no "Rst CYRF' messages.

Telemetry looks good and no LOC to either the RX2637 or the RX1202. (Note, the Devo12S was set to 100uW, with about 3 meters distance between TX and RX, same as before.)

Please Log in or Create an account to join the conversation.

More
01 May 2015 02:39 - 01 May 2015 03:33 #31877 by Gyrfalcon
Replied by Gyrfalcon on topic Support for walkera telemetry.
Repeated the same bench tests today with Indigo's latest build, deviation-devo12-v4.0.1-ee1b869 and all is good after 9 hrs of running. No "Rst CYRF" messages, both receivers are still connected and Telemetry is working well.
Last edit: 01 May 2015 03:33 by Gyrfalcon. Reason: updated build version

Please Log in or Create an account to join the conversation.

More
01 May 2015 08:44 - 05 May 2015 09:52 #31883 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
New version of devo_telemetry_cb() without excessive poll. I have not "Rst CYRF" messages. So, probably this version be worth more extensive testing. For testing purpose I disabled buffer overwrite mode for both DEVO and DSM protocols. But it works with both buffer overwrite modes.

CYRF_WriteRegister(CYRF_06_RX_CFG, 0x48);
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 1200;
            }
        }
    }
    if(txState == 2) {  // this won't be true in emulator so we need to simulate it somehow
        //Read telemetry if needed
        if(CYRF_ReadDataPacketLen(packet) == 1) {
            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 = 300;
        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;
}

Changed files (printf(" Rst CYRF\n") commented out):
Last edit: 05 May 2015 09:52 by vlad_vy.

Please Log in or Create an account to join the conversation.

More
01 May 2015 12:44 - 01 May 2015 12:48 #31886 by linux-user
Replied by linux-user on topic Support for walkera telemetry.
indigo-deviation-devo10-v4.0.1-ee1b869 is now running for 18.5h without any problems this test
- 1x 'RST CYRF' message what is expected on my TX
- connection still possible
- telemetry working prefect
- control working prefect
- telemetry alarm working as "advertised" (Gyrfalcon's hybrid)

So far with my limited test capabilities both versions are working
vlad-deviation-devo10-v4.0.1-f628e56
indigo-deviation-devo10-v4.0.1-ee1b869
Last edit: 01 May 2015 12:48 by linux-user.

Please Log in or Create an account to join the conversation.

More
01 May 2015 15:55 #31889 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
So far I have not "Rst CYRF" messages, 4 hours of testing the new version of devo_telemetry_cb() without excessive poll.

Please Log in or Create an account to join the conversation.

More
02 May 2015 07:30 - 05 May 2015 09:53 #31922 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
I added CRC16 check for received packet. I don't know if CRC16 check will work with other CYRF protocols. Tested with DEVO and DSMX protocols only.

First time I see rock solid "Flight Log" values for DSMX protocol, without any sporadical erroneous values. But it can be illusion.

int CYRF_ReadDataPacketLen(u8 dpbuffer[])
{
    u8 rx_state;
    u8 length;
    
    rx_state = CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
    if (rx_state & 0x02) {              // receive complete
        if (!(rx_state & 0x01)) {       // RXC=1, RXE=0 then 2nd check is required (debouncing)
            rx_state |= CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
        }
        length = CYRF_ReadRegister(CYRF_09_RX_COUNT);
        if ((rx_state & 0x05) || (CYRF_ReadRegister(CYRF_08_RX_STATUS) & 0x08)) {  //if any error or CRC error
            if( !(CYRF_ReadRegister(CYRF_06_RX_CFG) & 0x02)) { //if buffer overwrite disabled (RXOW bit = 0)
                // bad data, empty buffer
                CYRF_WriteRegister(CYRF_07_RX_IRQ_STATUS, 0x80);  // need to set RXOW before data read
                while (length) {
                    CYRF_ReadRegister(CYRF_21_RX_BUFFER);
                    length--;
                }
            }
            return 2;  //bad data
        } else {
            // good data (complete with no errors)
            CYRF_WriteRegister(CYRF_07_RX_IRQ_STATUS, 0x80);  // need to set RXOW before data read
            ReadRegisterMulti(CYRF_21_RX_BUFFER, dpbuffer, length);
            return 1;  //good data
        }
    }
    return 0;  //receive not complete
}

Changed files (printf(" Rst CYRF\n") commented out):
Last edit: 05 May 2015 09:53 by vlad_vy.

Please Log in or Create an account to join the conversation.

More
02 May 2015 17:19 #31967 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
With the help of next test code I can say that timing 900+1200+300 is quite good. With timing 900+1180+320 I can sometimes get "Delay:1" messages. With any higher timing I don't see these messages.

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 1180;
            }
        }
    }
    if(txState == 2) {  // this won't be true in emulator so we need to simulate it somehow
        //Read telemetry if needed
        int i = 0;
        u8 rx_status;
        while ( !((rx_status = CYRF_ReadRegister(0x07)) & 0x20)) {
            if (++i > NUM_WAIT_LOOPS)
                break;
        }
        if((rx_status & 0x03) == 0x02) { // RXC=1, RXE=0 then 2nd check is required (debouncing)
            rx_status |= CYRF_ReadRegister(0x07);
        }
        if ((rx_status & 0x27) == 0x22) { // 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(i) printf(" Delay: %d\n", i);
        }
#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 = 320;
        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;
}

Please Log in or Create an account to join the conversation.

More
02 May 2015 18:50 #31974 by PhracturedBlue
Replied by PhracturedBlue on topic Support for walkera telemetry.
20 micreoseconds is not very much. I think you are right on the edge, and it is unlikely to be the same for all receivers

Please Log in or Create an account to join the conversation.

More
02 May 2015 19:28 #31976 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
Most of telemetry packets ended with timing 900+1140+360, with timing 900+1180+320 I can get only one "Delay: 1" message in 1-2 minutes. I will test it with all my Devo receivers.

Please Log in or Create an account to join the conversation.

More
02 May 2015 22:27 #31990 by Indigo
Replied by Indigo on topic Support for walkera telemetry.
Try checking RXGO,

devo_cyrf6936.c
        //Read telemetry if needed
        if (!(CYRF_ReadRegister(CYRF_05_RX_CTRL) & 0x80)) {
            // RXGO has cleared so "something" has been received
            if (CYRF_ReadDataPacket(packet) == 1) {
                ...

Please Log in or Create an account to join the conversation.

More
02 May 2015 22:42 #31991 by Indigo
Replied by Indigo on topic Support for walkera telemetry.

vlad_vy wrote: I added CRC16 check for received packet. I don't know if CRC16 check will work with other CYRF protocols. Tested with DEVO and DSMX protocols only.
...


CRC16 check is already included in error bit of RX_IRQ_STATUS but only after receive is complete.

So if RXC=1 and RXE=0, we check RX_IRQ_STATUS again to get final value of RXE which includes CRC16 error.
    rx_state = CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
    if (rx_state & 0x02) {              // receive complete
        if (!(rx_state & 0x01)) {       // RXC=1, RXE=0 then 2nd check is required (debouncing)
            rx_state |= CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
        }

Please Log in or Create an account to join the conversation.

More
03 May 2015 03:40 - 03 May 2015 03:42 #31996 by Indigo
Replied by Indigo on topic Support for walkera telemetry.
I've created a simplified version of ReadDataPacket() that also supports buffer emptying required for DSM protocol.

This new version only checks 2 bits: RXE receive data error, and RXC receive complete.

cyrf6936.c
int CYRF_ReadDataPacket(int force, u8 dpbuffer[]) // use "force" if not set RXOW EN in RX_CFG
{
    int ok = 0;
    u8 rx_state = CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
    if (rx_state & 0x01)    // RXE=1 bad data
        ok = -1;
    else if (rx_state & 0x02)    // receive complete
        // RXC=1, RXE=0 then 2nd check is required (debouncing)
        ok = (CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS) & 0x01) ? -1 : 1;

    if (ok == 1 || (ok && force)) {
        CYRF_WriteRegister(CYRF_07_RX_IRQ_STATUS, 0x80);    // set RXOW before data read
        u8 length = CYRF_ReadRegister(CYRF_09_RX_COUNT);
        ReadRegisterMulti(CYRF_21_RX_BUFFER, dpbuffer, length);
    }
    return ok;
}

A new test version 5c9ff36 using the above is available in Test Builds . DSM protocol is using "force" buffer emptying.

Previous test version ee1b869 was all cyrf protocols (DSMx, Devo, J6pro) using buffer overwrite enabled.
Last edit: 03 May 2015 03:42 by Indigo.

Please Log in or Create an account to join the conversation.

More
03 May 2015 04:31 - 03 May 2015 04:32 #31998 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
If you use it with "force" option, you can read buffer while receive is not completed, but error rise. I have bad experience with such reading.
Last edit: 03 May 2015 04:32 by vlad_vy.

Please Log in or Create an account to join the conversation.

Time to create page: 0.097 seconds
Powered by Kunena Forum