-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add automatic support for 1/8th PWM pulse length aliases ("oneshot125").
Why so complicated? This implementation works almost as if we just added a conditional multiply by 8 in the PWM RX interrupt, except without doing that. This means that no additional cycles are used that would increase software PWM jitter. Also, switching between aliased and non-aliased inputs is like switching between any other input type in that invalid pulses are rejected until the armed session times out, at which point other options (such as the opposite alias state) become available again. This avoids the possibility that a wire falling off looks like full power in another input alias. With some other tricks (such as MIN_RC_PULS * CPU_MHZ & 0xff == 0), the RC processing path has only 4 cycles of overhead for length checking that isn't part of the interrupt checking, or 1 cycle less than before for the non-alias case. Calibration is supported when aliased or not, and is carried across. So, one can calibrate with long pulses and arm with short pulses, and the calibration will line up exactly. This should help with comparing modes without introducing any other changes. Note to flight controller software people: "oneshot" should really be separated into two options such as "syncpwm" (synchronous PWM, which is where the "one shot" name comes from), and something like "8xpwm" (1/8th PWM pulse lengths), since they really are totally separate things. This would also help with actually producing fair test results, and "syncpwm" could be used on all ESCs (KK1 says hello). Note that boards with PWM input on the ICP1 pin (USE_ICP set in the .inc file) such as all Afro ESCs and Team BlackSheep (TBS) ESCs have hardware capture of the pulse edges. This means they can measure pulse lengths with no jitter, which becomes more important at shorter lengths. Other ESCs will incur some PWM input jitter due to multi-cycle instructions, areas of code which block interrupts, and when other interrupts are already executing. Finally, note that we still report out of range PWM pulses by beeping rapidly once the motor stops. The purpose of reporting this is that pulses being corrupted by power noise or ground offset or some other electrical problem could cause other problems in flight. Twisted wires, proper grounding, or opto-isolation may be required for reliable operation. Please report any abnormal cases.
- Loading branch information
Showing
1 changed file
with
91 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters