Support for walkera telemetry.

More
14 Apr 2015 15:47 #31178 by linux-user
Replied by linux-user on topic Support for walkera telemetry.

Indigo wrote: Ok, I made function CYRF_RxPacketIsGood() similar to the code used in db5dcb3.
New version 3123e28 is available in Test Builds.


Spontaneous reboot of 3123e28 without even touching it on my Devo10
Attachments:

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

More
14 Apr 2015 16:20 #31179 by PhracturedBlue
Replied by PhracturedBlue on topic Support for walkera telemetry.
I don't know if anyone knows how to use the errors.log besides me. I should probably write up some instructions.

From your log, the stack trace was:
spi_xfer()
CYRF_ReadRegister(0x0f)
CYRF_SetTxRxMode()
devo_cb()

It is a software fault which means that too much time has elapsed since the watchdog timer was updated. This usually means the code is stuck in a loop.

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

More
14 Apr 2015 16:27 #31180 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
It is while loop
// Wait for the FRC_END_STATE bit in the XACT_CFG register to clear 
while(CYRF_ReadRegister(CYRF_0F_XACT_CFG) & 0x20) {};

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

More
15 Apr 2015 05:21 - 15 Apr 2015 06:11 #31192 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
Indigo, probably you have a problem in next place -> CYRF_WriteRegister(CYRF_0F_XACT_CFG, 0x10); // receive mode

void CYRF_SetTxRxMode(enum TXRX_State mode)
 {
     //Set the post tx/rx state
    if (mode == RX_EN)
        CYRF_WriteRegister(CYRF_0F_XACT_CFG, 0x10); // receive mode
    else {
        if (mode == TXRX_OFF)
            CYRF_WriteRegister(CYRF_0F_XACT_CFG, 0x24); // force idle mode
        else
            CYRF_WriteRegister(CYRF_0F_XACT_CFG, 0x28); // force Synth(TX) mode

        // Wait for the FRC_END_STATE bit in the XACT_CFG register to clear
        while(CYRF_ReadRegister(CYRF_0F_XACT_CFG) & 0x20) { ; }
    }

For "RX Mode" you do not set FRC END bit, RX mode will be active after next transaction only (receiving or transmitting a packet). Will be better change to:
CYRF_WriteRegister(CYRF_0F_XACT_CFG, 0x30); // force Receive mode

For my opinion we have not any need to change TX and RX mode, for "Fast Turn Mode" and TX_OFFSET = 1MHz TX and RX mode synthesizer frequency is equal. We can always use Force End State "Synth Mode (TX)":
CYRF_WriteRegister(CYRF_0F_XACT_CFG, 0x28);

"Fast Turn Mode" and TX_OFFSET = 1MHz have place for all CYRF6936 protocols: Devo, DSM, J6Pro.
Last edit: 15 Apr 2015 06:11 by vlad_vy.

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

More
15 Apr 2015 09:49 - 24 Apr 2015 06:25 #31200 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
Successfully tested build (based on nightly build) with RX abort before enabling TX mode, without any while() loops. Implemented for Devo protocol only.

RX abort tested by inserting CYRF_StartReceive() after CYRF_ReadDataPacket(packet) in devo_telemetry_cb().

void CYRF_SetTxRxMode(enum TXRX_State mode)
{
//Set the post tx/rx state
CYRF_WriteRegister(CYRF_0F_XACT_CFG, 0x28);

int CYRF_RxPacketIsGood(u8 len)
{
    unsigned 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);
        }
        CYRF_WriteRegister(CYRF_07_RX_IRQ_STATUS, 0x80);    // need to set RXOW before data read.
        u8 length = CYRF_ReadRegister(CYRF_09_RX_COUNT);
        if (((rx_state & 0x25) == 0x20) && length == len) {
            // good data (complete with no errors)
            return 1;
        }
        // else bad data, empty buffer
        while (length) {
            CYRF_ReadRegister(CYRF_21_RX_BUFFER);
            length--;
        }
    }
    return 0;
}
    txState++;
    if(txState == 16) { //2.3msec have passed
        if (CYRF_ReadRegister(CYRF_05_RX_CTRL) & 0x80) { // We're still in receive mode    
            // Disrupt any pending receive by enabling abort    
            // Force End State should not be used to abort a receive if a SOP has already happened.    
            CYRF_WriteRegister(CYRF_29_RX_ABORT, 0x20);
        
            CYRF_RxPacketIsGood(0x00);
        
            // Abort by writing the FRC_END_STATE bit in the XACT_CFG register.    
            CYRF_SetTxRxMode(TX_EN); //Write mode
        
            // Disable abort
            CYRF_WriteRegister(CYRF_29_RX_ABORT, 0x00);    
        } 
        else 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:
Last edit: 24 Apr 2015 06:25 by vlad_vy.

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

More
15 Apr 2015 10:34 #31202 by Indigo
Replied by Indigo on topic Support for walkera telemetry.
Well done. Thanks for helping. :)

New version 84cc0db (incorporating your changes) has been uploaded to Test Builds. :woohoo:

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

More
15 Apr 2015 13:42 - 15 Apr 2015 14:05 #31204 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
Just for clarity of the time interval
int delay = 100;
    if (txState == 1) {
        int i = 0;
        while (! (CYRF_ReadRegister(0x04) & 0x02)) {
            if(++i > NUM_WAIT_LOOPS) {
                delay = 1500 - i*5;
                txState = 15;
                break;
            }
        }
        delay = 100 - i*5;
Last edit: 15 Apr 2015 14:05 by vlad_vy.

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

More
15 Apr 2015 18:11 #31212 by PhracturedBlue
Replied by PhracturedBlue on topic Support for walkera telemetry.
That delay code shouldn't work.
delay is calculated based on the time the callback is entered, so you don't ever want to adjust it for the time you spent in the callback. Unless I'm missing the point of the compensation.

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

More
15 Apr 2015 18:29 #31214 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
I thinking about:

900 + 1500 = 2400
900 + while(up to 100) + 1500 = 2500???

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

More
15 Apr 2015 18:34 - 15 Apr 2015 18:35 #31217 by PhracturedBlue
Replied by PhracturedBlue on topic Support for walkera telemetry.
the code doesn't work that way.
the timer is referenced from when the devo_cb is entered NOT from when it exits. so if you want a callback every 1000usec, you always return 1000 regardless of whether you use 10us or 990usec inside of the devo_cb function. If devo_cb takes more time than what you return, you are screwed though (so if the maximum runtime of devo_cb is 1100us, you cannot return 1000). So I don't recommend changing the delay values in the code unless you think they are wrong for some reason.
Last edit: 15 Apr 2015 18:35 by PhracturedBlue.

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

More
16 Apr 2015 04:25 #31230 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
Thanks, PB, I realized my mistake. I'm not a programmer and only exercising my brain.

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

More
16 Apr 2015 06:23 #31235 by linux-user
Replied by linux-user on topic Support for walkera telemetry.

vlad_vy wrote: I'm not a programmer and only exercising my brain.

But you are very good at that :cheer:

My Devo10 MiniCP test has been running for 17h successfully with Indigo's test build 84cc0db.
Checked again at 18h and got loss of connection.

This was definitely the longest time I've observed it running successfully.
Are we now closer to a solution or still lost? :unsure:

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

More
16 Apr 2015 06:38 - 20 Apr 2015 18:46 #31236 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
The more and more I think it is a hardware problem. Now I run long time test for Devo protocol with telemetry enabled:

Hardware: Devo 12s without any mods, RX1202, WK-CTL01-D telemetry module, Walkera GPS sensor, elevator servo. All powered permanently.
Software: nightly build with some changes: www.deviationtx.com/forum/protocol-devel...etry?start=240#30974 or PB test build www.deviationtx.com/downloads-new/catego...o-fixes-for-devo-dsm

Test results:
Day 1, 24 hours = still connected
Day 2, 48 hours = still connected
Day 3, 72 hours = still connected
Day 4, 96 hours = still connected
Day 5, 120 hours = still connected
Tx as usual powered, Rx powered off
Day 6, 144 hours = Rx still connect without problems
Day 6, 149 hours = Rx can't connect...
Test ended with connection lost.
Last edit: 20 Apr 2015 18:46 by vlad_vy.

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

More
16 Apr 2015 06:48 - 16 Apr 2015 06:56 #31237 by linux-user
Replied by linux-user on topic Support for walkera telemetry.

vlad_vy wrote: Hardware: Devo 12s without any mods, RX1202, WK-CTL01-D telemetry module, Walkera GPS sensor, elevator servo. All powered permanently.

Well, there is one significant difference to my test:
My RX is powered off most of the time. Just reconnect it from time to time.
Only my TX is running all the time.

So my TX is receiving invalid telemetry data i.e. no valid telemetry data most of the time.
Last edit: 16 Apr 2015 06:56 by linux-user.

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

More
16 Apr 2015 06:59 - 16 Apr 2015 07:00 #31238 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
First, it's not real life test. We want to fly without disconnection.
Second, I've tried such metod with Devo 8s, Ladybird and Fixed ID, 24 hours = still connect without problems.
Last edit: 16 Apr 2015 07:00 by vlad_vy.

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

More
16 Apr 2015 08:31 - 16 Apr 2015 08:52 #31239 by linux-user
Replied by linux-user on topic Support for walkera telemetry.

vlad_vy wrote: First, it's not real life test. We want to fly without disconnection..

Well, my original motivation to test this was real v120d02s-v2-lost-binding-mid-flight
Because of this I have changed the CYRF module, which seems to have solved my issue.
This post from cmpang made me rethink about it.

Since then the code has changed a lot, so you may be right, it is different now.
IMHO if we can't fix it, we should at least disable telemetry as a default.

vlad_vy wrote: Second, I've tried such metod with Devo 8s, Ladybird and Fixed ID, 24 hours = still connect without problems.

Statistically 17h is not too far away from 24h.
The incident is definitely very rare

Edit: Hmm :unsure:
#30562

PhracturedBlue wrote: ...
I have evidence that the official firmware actually has CYRF lockup detection that will send a Reset() and Init() if the chip gets into an illegal state. We could actually code that into the protocol if certain errors are found. It would be better to pay the few msec to reinitialize the chip than to lose contact for a longtime. Just need to find a reliable flag for when to do it.

Last edit: 16 Apr 2015 08:52 by linux-user.

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

More
16 Apr 2015 10:47 - 16 Apr 2015 10:59 #31240 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
PB, how we can detect abnormal state of the CYRF6936 on the fly? And how we can reset CYRF6936 to working state? By protocol initialize()?

Probaly, if we get stuck in while() loop:
if (txState == 1) {
        int i = 0;
        while (! (CYRF_ReadRegister(0x04) & 0x02)) {
            if(++i > NUM_WAIT_LOOPS) {
                if(CYRF_ReadRegister(0x02) & 0x80) //TX_GO still active
                    RESET_CYRF(); ???
                delay = 1500;
                txState = 15;
                break;
            }
Last edit: 16 Apr 2015 10:59 by vlad_vy.

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

More
16 Apr 2015 13:20 #31241 by PhracturedBlue
Replied by PhracturedBlue on topic Support for walkera telemetry.
I think something like:
if (txState == 1) {
        int i = 0;
        u8 reg;
        while (++i <= NUM_WAIT_LOOPS)
            reg =  CYRF_ReadRegister(0x04);
            if (reg & 0x02) {
                break;
            }
        }
        if (i == NUM_WAIT_LOOPS || (reg & 0x22) || (CYRF_ReadRegister(0x02) & 0x80)) {
            CYRF_Reset();
            CYRF_Init();
            txState = 15;
            return 1500;
       }
}
That is untested, and I'm not sure we can actually do a CYRF_Reset() quickly enough, so we might need to go to 2700 and increase the counter by one. Also, I'm not sure if that will initialize the state completely, there may be a be more CYRF commands needed.

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

More
16 Apr 2015 14:50 - 16 Apr 2015 14:59 #31243 by vlad_vy
Replied by vlad_vy on topic Support for walkera telemetry.
More CYRF commands will need. After reset the connection was lost.
static u16 test_reset = 25000;
...
...
    if (txState == 1) {
        int i = 0;
        while (! (CYRF_ReadRegister(0x04) & 0x02)) {
            if(++i >= NUM_WAIT_LOOPS) {
                delay = 1500;
                txState = 15;
                break;
            }
        }     
        test_reset--;
        if(!test_reset) {
            test_reset = 25000;
     	    CYRF_Reset();
            cyrf_init();
            delay = 1500;
            txState = 15;
        }
Last edit: 16 Apr 2015 14:59 by vlad_vy.

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

More
16 Apr 2015 15:46 #31244 by PhracturedBlue
Replied by PhracturedBlue on topic Support for walkera telemetry.
How about this? I added cyrf_set_bound_sop_code(). I also ensure that we don't enter Rx mode if an error occurs. When I get access to my equipment, I'll work on it some more if you are unable to test further.
static u16 test_reset = 25000;
...
...
    if (txState == 1) {
        int i = 0;
        while (! (CYRF_ReadRegister(0x04) & 0x02)) {
            if(++i >= NUM_WAIT_LOOPS) {
                delay = 1500;
                txState = 15;
                break;
            }
        }     
        test_reset--;
        if(!test_reset) {
            test_reset = 25000;
     	    CYRF_Reset();
            cyrf_init();
            cyrf_set_bound_sop_code();
            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_07_RX_IRQ_STATUS, 0x80); //Prepare to receive
            CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x80); //Prepare to receive (do not enable any IRQ)
        }
        }

FYI: Regardless of whether it is a 'real' test or not, I think linux-user's test is fine. It indicates instability in the protocol in telemetry mode. I also cannot duplicate it on my equipment, but that doesn't mean there isn't an issue. I don't trust the '17 hr' number though. My guess is the issue is inherently random, and that 17hr is no different than 1hr in reproducibility

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

Time to create page: 0.099 seconds
Powered by Kunena Forum