Multiwii 2.2 hangs when using FrSKY serialsum receiver

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
User avatar
JayBee
Posts: 12
Joined: Tue Mar 13, 2012 9:33 pm
Location: Bremerhaven (Germany)

Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by JayBee »

Hello,

when a FRSKY serial sum receiver (D4FR) get no transmit signal (for example you have forgot to switch on the transmitter :roll:) it connects the serial sum output to zero.
In this case an ATmega32U4 based board hangs up (it can be still tested by connecting the serial sum input to ground). The controller hangs (also if the transmitter was switch on in the meantime) until you switch off the board.
Normally no problem but sometimes the controller activates one or more motor outputs with full throttle, a dangerous situation !!!
I have no idea for the reason but the problem is the serial sum interrupt routine rxInt().
In revision r1101, the interrupt was (re)enable inside the interrupt routine:

Code: Select all

    now = micros();
    sei();   // <= new line
    diff = now - last;

The new sei(); line is the reason for the crash.
If the line was deleted, there's no more hanging up.


JayBee

Goetz
Posts: 82
Joined: Sun Mar 04, 2012 3:40 pm

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by Goetz »

I have FrSky Rx on Crius SE and on Crius AIO V1, both with PPM-SUM - no Probs

mmattila
Posts: 5
Joined: Fri Jun 08, 2012 11:33 pm

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by mmattila »

I have exactly same setup as JayBee and I experience same issues if I power up MW when transmitter is off. Also configuration gets erased occasionally.

Have you Goetz set failsafes in Frsky. If failsafes are set then I think Frsky RX will output the failsafe PPM:s if there is no signal.

-Markus

Goetz
Posts: 82
Joined: Sun Mar 04, 2012 3:40 pm

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by Goetz »

MY FrSky-RX always have an output. without failsave set they repeat the last known command, with fs set the fs-values. (I would like to know a possibility to let them output "nothing" in case of signalloss).

Powering Motors at full Throttle is serious. Do I understand it right: It happans when you connect Lipo and Tx is off?

Peter
Posts: 82
Joined: Mon Jun 11, 2012 2:09 pm

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by Peter »

@Goetz: you can set the failsafe on the FrSky RX when the transmitter is off. Then the flight controller can detect the failsafe situation.

Goetz
Posts: 82
Joined: Sun Mar 04, 2012 3:40 pm

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by Goetz »

Thank you Peter, i read this somewhere. I tried it on my D8R-XP, but it didn't work, Rx was still sending last known command when switching TX off.... haven't tested with D4R-II... anything I could have made wrong? Does it only work immediately after binding (but I tested this too)...

What I did is:
RX and TX off, power up rx, set fs (now there is no output of rx...fine). power of rx. power to rx and tx, lok at rx-signal in MW-Gui, power off tx..... ....rx still sending last signal :-((

Peter
Posts: 82
Joined: Mon Jun 11, 2012 2:09 pm

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by Peter »

I don't remember the exact sequence, I had to try a couple of times too. Maybe tx and rx on, txoff, press rx button.
It is not that it doesn't give a signal, but it gives a very low signal, something like 985us. That is what I got.

Sebbi
Posts: 478
Joined: Sun Jul 08, 2012 1:08 am
Location: Germany
Contact:

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by Sebbi »

Hmm ... I always thought this was because my NanoWii boards isn't providing enough power to the receiver. When I connect it to a battery instead of USB only it works (maybe because the receiver is powered before the board boots up?), but when USB (to the NanoWii board) is the only power source, it hangs at initialisation. Same problem?

scrat
Posts: 925
Joined: Mon Oct 15, 2012 9:47 am
Location: Slovenia

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by scrat »

Try this. Rebind Rx with Tx. Then turn off both. Then turn on both in put throttle stick all the way down in then press FS button on RX. Then again power off and on tx and rx. Then try. I have made like this and if I turn off my Tx, rx sends no throttle command and quad turns off.

User avatar
JayBee
Posts: 12
Joined: Tue Mar 13, 2012 9:33 pm
Location: Bremerhaven (Germany)

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by JayBee »

@Goetz
Goetz wrote:Powering Motors at full Throttle is serious. Do I understand it right: It happans when you connect Lipo and Tx is off?

-Powering Motors at full Throttle is serious, but what I mean is the motors runs with full throttle(max. power), the stick was at low throttle position.
-Yes, your understanding it right: It happens when you connect Lipo and Tx is off, means the receiver never binds.


If the receiver has bind and then lost his bind the receiver acts as you describes :
without failsave set they repeat the last known command, with fs set the fs-values.

I have tested the following receivers: D4FR, D4R-II and D8R-II, all acts equal, when they never bind (means they where powered with no TX signal) their outputs are driven low (measured with an oscilloscope)


But this is the secondary problem, the major problem is the hanging up of the controller if the serial sum input is driven low (for whatever reason).

@Sebbi
Perhaps, you can test it by deleting the sei(); line.

-JayBee

SergioC
Posts: 19
Joined: Sat Dec 22, 2012 11:33 pm

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by SergioC »

same to me. d4r-ii

scared.

kataventos
Posts: 702
Joined: Sun Aug 28, 2011 8:14 pm
Contact:

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by kataventos »

Hi,

The FS will only memorize sticks and aux´s positions, no need to arm motors and other stuff to set it up ;) I use D8R-II Plus:

1-TX and RX on (motors disarmed);
2-throttle stick to desired position (e.g my settings for FPV);
a) middle to hover.
3- GPS return home Aux´s selected with stable, baro and mag;
4- press the fail safe on RX (hear the beep on TX);
5- done.

This is actually not the best fail safe situation, but normally when you fly far to have a signal loss situation you are also flying high so this is the better way for the job using the FRSky FS.
The best FS situation is to get a dedicated fail safe check box on MW GUI and use an aux for the advanced fail safe. (e.g) It will first gain some altitude to given value (e.g) 40 meters and then face home, when reached it will PH.

In both situations, as soon as it got signal again, it will assume your current stick and aux´s positions (they should not be moved during the FS process or they should be like in fail safe situation).
Cheers,
KV

scanman
Posts: 74
Joined: Thu Jun 21, 2012 9:26 am
Location: Durban, South Africa
Contact:

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by scanman »

turn your tx off then look in the GUI, you should see channels 1 to 4 drop to very low values. if they dont drop then you must repeat the frysky settings as mentioned above.

If they drop then make a note of those values and then change the following setting in the multiwii code, you can find it in the RX file not in the config.h file:

#define FAILSAFE_DETECT_TRESHOLD 995

this setting should be just above the setting that the frysky transmits. i had to increase mine to 995 from the default

GMSonic
Posts: 2
Joined: Mon Apr 01, 2013 8:38 pm

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by GMSonic »

Hi all,

i have the same behaviour with the frsky d4r-ii. Connecting the lipo without tx powered, nanowii does not initialize correctly and one motor spin up to full speed!!
If i comment out the "sei()" line in RX.ino, the board initialize correctly and no motor starts.

Is it safe to comment this out? Does anybody fly with this modification?

I think this is really dangerous, cost me only one propeller, but what if it hits you in your face?

SergioC
Posts: 19
Joined: Sat Dec 22, 2012 11:33 pm

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by SergioC »

I also confirm that removing the sei() call seems to fix the issue.

But I had two software freeze when armed and connected to the PC via the USB port. It freeze the motor speed, no more corrections. I was holding it by hand during some PID tuning. One time it freezed during an hard correction... it flipped.... several damages around. The second time it was flat, I barely recognized the freeze just because the motor noise was no more varying.

I still have not understood the usb serial interrupt handling, so I cannot say about the sei(), but may be related.

Is it recommended to fly with the USB plugged and the GUI running? May it be better with bluethoot on serial1?

Ciao,
Sergio.

Peter
Posts: 82
Joined: Mon Jun 11, 2012 2:09 pm

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by Peter »

Do you all run the 27ms firmware of FrSky? The default firmware can give problems with 8 channel cppm.
Test if you have the same problem if you change your transmitter ppm to 6 channels. I do this in my 9x with open9x.

GMSonic
Posts: 2
Joined: Mon Apr 01, 2013 8:38 pm

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by GMSonic »

Hi Peter,
i run the stock firmware fo d4r-ii. have not tried the 27ms beta firmware.

Changing PPM Channels in openTx to 6 has the same problem.

I use the following settings in openTx
Proto: PPM 6CH
PPM frame: 18.5ms 300u

What settings are you using? Do you have the beta receiver firmware installed? Can you startup your fc without transmitter powered?

Stars112
Posts: 36
Joined: Wed Jan 30, 2013 9:29 pm

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by Stars112 »

I have the same Problem.
With my PPM JETI RX (12x) and comment "sei()" the 32u4 dosent boot any time.
with uncomment "//sei()" is everthing OK!

Marc

SergioC
Posts: 19
Joined: Sat Dec 22, 2012 11:33 pm

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by SergioC »

Is there any developer confirming that removing sei() is the solution?
Did someone understood why it happens?
I had two software freeze midflight (my prev post) and I'm going to go back to 2.1

Sergio

gompf-2
Posts: 136
Joined: Sun Jun 05, 2011 11:46 am

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by gompf-2 »

I´m not a proffesional developer either, but it´s quite strange that

Code: Select all

uint16_t readRawRC(uint8_t chan) {
...
    uint8_t oldSREG;
    oldSREG = SREG; cli(); // Let's disable interrupts
    data = rcValue[rcChannel[chan]]; // Let's copy the data Atomically
    SREG = oldSREG;        // Let's restore interrupt state
  #endif
  return data; // We return the value correctly copied when the IRQ's where disabled
}

disables the interrupts and they are reenabled during rxInt()? Shoudn´t the sei() happen after restoreing SREG like in 2.1?

Mis
Posts: 203
Joined: Fri Apr 01, 2011 12:23 am

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by Mis »

Interrupts state is stored in SREG register. If the interrupts are enabled before cli(), the SREG = oldSREG line enable the interrupts back. If the inrerrupts are disabled before cli(), after SREG = oldSREG line stays disabled too.

kataventos
Posts: 702
Joined: Sun Aug 28, 2011 8:14 pm
Contact:

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by kataventos »

Hi,

correct me if I am wrong but, should´t this topic be changed to (Multiwii 2.2 hangs when using FrSKY serialsum receiver (on Baseflight)) ?

I say this because I keep seeing post´s about this matter and never experienced this issue.
First of all we should never turn on our TX after, that is the most old rule but I tried it some times just to see if I have the same issue and I must say that no problem was found, it just behaves normally.

I use D8RII-Plus flashed with 27ms CPPM on AIO Pro v1 using the throttle pin, I am using full 8ch and not even changed my end points since I used normal PPM channel´s setup.

Cheers,
KV

gompf-2
Posts: 136
Joined: Sun Jun 05, 2011 11:46 am

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by gompf-2 »

Hi,

Baseflight is not using 2.2 code jet and won´t run on a 32u4.
Problem seems to be isolated to 32u4 (but I didn´t look up everyones hardware here), maybe one should check the errata for issues with irq handling.

Mis wrote:Interrupts state is stored in SREG register. If the interrupts are enabled before cli(), the SREG = oldSREG line enable the interrupts back. If the inrerrupts are disabled before cli(), after SREG = oldSREG line stays disabled too.
Ok, I had in mind that SREG just sets/reads the trigger event, thanks.

Regards,
gompf

User avatar
JayBee
Posts: 12
Joined: Tue Mar 13, 2012 9:33 pm
Location: Bremerhaven (Germany)

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by JayBee »

Hello kataventos

kataventos wrote:Hi,

correct me if I am wrong but, should´t this topic be changed to (Multiwii 2.2 hangs when using FrSKY serialsum receiver (on Baseflight)) ?

KV


If, the topic must be changed to (Multiwii 2.2 hangs when using FrSKY serialsum receiver (on ATmega32U4 based boards))
but it still has reached the allowed length.

Like I wrote at the begin of this topic, the ATmega32U4 based board hangs up if their serial sum input port is zero (constant low level signal).


JayBee

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by Alexinparis »

JayBee wrote:Hello,

when a FRSKY serial sum receiver (D4FR) get no transmit signal (for example you have forgot to switch on the transmitter :roll:) it connects the serial sum output to zero.
In this case an ATmega32U4 based board hangs up (it can be still tested by connecting the serial sum input to ground). The controller hangs (also if the transmitter was switch on in the meantime) until you switch off the board.
Normally no problem but sometimes the controller activates one or more motor outputs with full throttle, a dangerous situation !!!
I have no idea for the reason but the problem is the serial sum interrupt routine rxInt().
In revision r1101, the interrupt was (re)enable inside the interrupt routine:

Code: Select all

    now = micros();
    sei();   // <= new line
    diff = now - last;

The new sei(); line is the reason for the crash.
If the line was deleted, there's no more hanging up.


JayBee


sei() is here to reactivate as soon as possible interrupts once the main value is calculated (now)
reactivate interrupts is important to avoid overall code jitter.

So it apparently is a good choice for promini&mega but wrong for promicro ?
On promicro, the PPM interrupt is triggered a little bit differently than promini&mega:
#define PPM_PIN_INTERRUPT DDRE &= ~(1 << 6);PORTE |= (1 << 6);EIMSK |= (1 << INT6);EICRB |= (1 << ISC61)|(1 << ISC60);
ISR(INT6_vect){rxInt();}

Probably something to dig in instead of sei() removal.

User avatar
JayBee
Posts: 12
Joined: Tue Mar 13, 2012 9:33 pm
Location: Bremerhaven (Germany)

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by JayBee »

Hello Alex

Alexinparis wrote:On promicro, the PPM interrupt is triggered a little bit differently than promini&mega:
#define PPM_PIN_INTERRUPT DDRE &= ~(1 << 6);PORTE |= (1 << 6);EIMSK |= (1 << INT6);EICRB |= (1 << ISC61)|(1 << ISC60);
ISR(INT6_vect){rxInt();}

Probably something to dig in instead of sei() removal.


Now, I have digged deeper and found the problem.
Weeks ago I looked at the wrong init part (the definition for STANDARD_RX and not for PPM_PIN_INTERRUPT definition) :oops:.
For the ATmega32U4 external interrupts the default interrupt sense is low level. In our special case (the constant low level signal at the serial sum input) if the interrupt will enable before changing the interrupt sense, the interrupt routine will be called recursive.
Enabling an interrupt should be always done as the last step:
#define PPM_PIN_INTERRUPT DDRE &= ~(1 << 6);PORTE |= (1 << 6);EICRB |= (1 << ISC61)|(1 << ISC60);EIMSK |= (1 << INT6);


JayBee

SergioC
Posts: 19
Joined: Sat Dec 22, 2012 11:33 pm

Re: Multiwii 2.2 hangs when using FrSKY serialsum receiver

Post by SergioC »

JayBee wrote:Now, I have digged deeper and found the problem.
Weeks ago I looked at the wrong init part (the definition for STANDARD_RX and not for PPM_PIN_INTERRUPT definition) :oops:.
For the ATmega32U4 external interrupts the default interrupt sense is low level. In our special case (the constant low level signal at the serial sum input) if the interrupt will enable before changing the interrupt sense, the interrupt routine will be called recursive.
Enabling an interrupt should be always done as the last step:
#define PPM_PIN_INTERRUPT DDRE &= ~(1 << 6);PORTE |= (1 << 6);EICRB |= (1 << ISC61)|(1 << ISC60);EIMSK |= (1 << INT6);


is this confirmed? It is still not integrated.
I tried and it seems to works, even if I had a few software freeze hot-plugging the receiver.

I hope it worths to note that the same error is made configuring the interrupts for standard RX with a 32u4, in RX.ino EIMSK is setted before EICRA or EICRB

Sergio

Post Reply