New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix esc init #4322
Fix esc init #4322
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good finding and good fix!
src/main/fc/fc_init.c
Outdated
} | ||
LED0_OFF; | ||
LED1_OFF; | ||
|
||
#ifdef USE_SERVOS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikeller Yes,this spurious pulse will affect servos too, i moved it after ..
@jirif not working for FF_FORTINIF4 |
@adrianmiriuta: 'not working' as in still 2 sets of startup tones? If so, can you please confirm that this isn't already the case in RC5 or earlier? |
@mikeller |
@adrianmiriuta: That's awkward. I just tested with BLHeli_S 16.63, on a BEEROTORF4, and the double init was fixed with this patch. (I also tested with KISS and BLHeli32, but none of them showed the problem with 3.2.0, so there is nothing to fix.) But then since the problem seems to be a timing issue, and the fix is shifting the motor initialisation to an earlier point in the initialisation, different boards with different peripherals that need to be initialised, and different timings required by different ESCs might mean that this does not fix it for all possible combinations. The initialisation process is a complicated dance already, with different parts being dependent on each other, and some of them having timing requirements. This is just a 'cosmetic' issue, so users might have to live with it, in return for getting all the other components on their board initialised properly. |
@mikeller I have done 2 Traces to get a clue
they are quite different in the time the motor output is high after poweron. |
I guess the difference there is that the FF_FORTINIF4 has got a lot more on board peripherals that need to be initialised first, pushing the motor init farther back. There should be a difference in the output high time between without and with this patch, but possibly not enough to stop your ESCs from booting up before they get a valid signal. |
@jirif , well found. In terms of initialisation, the motor initialisation depends on little else and it seems it should be done as early as possible. So I think the whole block:
should be moved to just after the call to
|
@martinbudden |
@jirif , just checked your latest version, and it seems you have accidentally deleted that block entirely. |
@martinbudden here is one dependency left, ppmRxInit() need motors have initialized in ppmAvoidPWMTimerClash() so we should move it to its original location or whole
after latest revision moved led/beep block after servo init as @mikeller suggested |
@jirif , well spotted. Yes, move the block back to its original location. I'd also add a comment stating that the motor initialisation needs to occur at that point, so that someone doesn't move it again. |
Fixing betaflight#4257
Tested build 249 and this fix works on my Naze32. |
I just upgraded from a 3.2 RC to the full latest release of 3.2.1 on my Matek 405 AIO and am finding the double ESC init is happening. I didn't have this on the 3.2 RC. |
@TimothyGold: The problem causing the double ESC init is the delay between power being connected and the flight controller initialising the ESC outputs. A lot of peripherials (like OSD) are initialised before the ESC outputs, and in some cases this causes enough delay for the ESC to initialise on power up, and then again when they get a valid signal. This isn't a problem in itself, and there isn't really a fix for it (except to disable some of the peripherals), since a lot of the initialisation has to be done within a certain time frame after powering up. |
@mikeller Sounds good. Not a problem. Just thought I would mention this in case it indicated anything that was missed through the initial issues reported. Thanks for reply. |
This is workarround for issue #4257. It cannot be fixed by other way because during power up spurious pulse starting esc initialization (before any code is run, tested at OMNIBUS). Second initialization happen during motorDevInit call so the best way is initialize motors soon as posible what was done before db8698d whish showed/introduced this problem.