PWM Echo - autonomous quadcopter
ypapelis
Posts: 99
I have been quietly monitoring all the quad-copter efforts and have been working on several quads myself, most of them flying at this point. Ultimately, my goal is to create quads that are partially and fully autonomous. One approach to doing this is to dig into the flight control code and expand it, but I am experiment with a different approach, namely, using a separate flight controller (or more appropriate, platform leveler) and then building the autonomy on a separate micro-controller which will selectively intercept the RC signals and either echo them back out (when in RC mode) or generate them based on a goal when in autonomous mode.
To do this, I need to be able to echo the pwm signals produced by the RC onto the flight board through the prop. The easy way to do this of course is by using the counters, but capturing 8 channels would consume 4 cogs which is too much. Furthermore, I need to be able to selectively pass specific RC signal to the flight board, so for example I may take over the throttle but pass through the rest of the channels.
With that in mind, i put together some PASM code that continuously polls all input pins and then selectively echos these pins to another set of output pins based on a mask. Problem is, i cannot find a way to poll 8 lines, detect down-up and up-down transitions and write the pulse widths to main memory, all within a single microsecond. I can make it work if I set the polling interval larger (up to 8 uSec, maybe more), but with the polling interval larger, I get quantization error and so the output waveform fluctuates a few micro seconds. Works, but not as well as if counters were in use.
Since I have done very little in PASM, I thought I would post the code and seek comments and/or suggestions on how to make it faster (or alternative approaches to achieving the same goal). The module I wrote is attached. As it is now, it appears to be working, in fact I have flown a couple of quads by using this code on a Propeller Proto-board which routes the PWM from the RC receiver to the flight board (a Hoverfly Sport). I am putting the final touches on an altitude hold functionality which uses the Parallax altimeter to intercept and adjust the throttle to maintain altitude, however, I am bothered by the fluctuation of the output pulse.
All comments/suggestions/recommendations/critiques are welcomed; if this is deemed useful, i can also post it on the Obex.
To do this, I need to be able to echo the pwm signals produced by the RC onto the flight board through the prop. The easy way to do this of course is by using the counters, but capturing 8 channels would consume 4 cogs which is too much. Furthermore, I need to be able to selectively pass specific RC signal to the flight board, so for example I may take over the throttle but pass through the rest of the channels.
With that in mind, i put together some PASM code that continuously polls all input pins and then selectively echos these pins to another set of output pins based on a mask. Problem is, i cannot find a way to poll 8 lines, detect down-up and up-down transitions and write the pulse widths to main memory, all within a single microsecond. I can make it work if I set the polling interval larger (up to 8 uSec, maybe more), but with the polling interval larger, I get quantization error and so the output waveform fluctuates a few micro seconds. Works, but not as well as if counters were in use.
Since I have done very little in PASM, I thought I would post the code and seek comments and/or suggestions on how to make it faster (or alternative approaches to achieving the same goal). The module I wrote is attached. As it is now, it appears to be working, in fact I have flown a couple of quads by using this code on a Propeller Proto-board which routes the PWM from the RC receiver to the flight board (a Hoverfly Sport). I am putting the final touches on an altitude hold functionality which uses the Parallax altimeter to intercept and adjust the throttle to maintain altitude, however, I am bothered by the fluctuation of the output pulse.
All comments/suggestions/recommendations/critiques are welcomed; if this is deemed useful, i can also post it on the Obex.
spin
13K
Comments
-Phil
http://forums.parallax.com/showthread.php?133372-Ken-Cluso99-W9GFO-JasonD-s-QuadCopter-Build-Log-(updated-info-ELEV-8-availability)&highlight=ken+jason+quadcopter
I am using a cog to read all 4 channels of the rc, and a cog to transmit the times to 4 escs. This can be expanded. In fact I want to later read 6 channels although my RC only has switch values for 5 & 6. IIRC Beau also wrote an 8 channel servo program for a single cog (see the obex). My files also contain references.
Great to have you using props
Phil,
I thought of that but wasn't sure how safe this assumption is. All the radio/receiver pairs I have (a Futaba, HobbyKing and some other no-name brand) seem to generate the pulses sequentially, starting with channel 1 till the end channel. At the same time, I wanted to avoid making any assumptions that would later break the code. For sure though, if we assume the channels arrive sequentially, this can be exploited; I may give it a try and have the old code as backup.
Cluso99 - Oh, I'm using props all right!
I'll look through the code(s) you are referring to, but I don't think any of them do exactly what I am trying to do. I can use a single cog to read the channels with no problem, but then I would need to use another cog to echo the signals out selectively. Also, I am not trying to drive the ESCs, I leave that to the flight board, but I do need to selectively echo the RC signals to the output pins.
Having said that, I will go ahead and check out the existing code, in particular Jason's which appears to provide the flight control. -- Thanks.
many quadcopter-projects uses only the sum-pwm-signal, it is much easier to handle in hard- and software !
Maybe this will make your solution easier.
I've seen an object somewhere for decoding it.
Tharkun,
I am not sure what you mean by the sum-pwm-signal, could you explain ?
Mikrokopter and Arm-O-Copter use this signal, also the Wii-Copter supports the pwm-sum.
The goal is that your only need one wire from the receiver to the flightcontrolboard and only one pin of the microcontroller, for the software it is only a few rows more of code.
Here is another explanation. (google translated):
http://translate.google.de/translate?hl=de&sl=de&tl=en&u=http%3A%2F%2Fwww.mikrokopter.de%2Fucwiki%2FSummenSignal%3Fhighlight%3D%28%28----%28-*%29%28%255Cr%29%253F%255Cn%29%28.*%29KategorieEmpf%25C3%25A4nger%29
@cluso99 : maybe this from german-mikrokopter-wiki could help you !?:
http://translate.google.de/translate?hl=de&sl=de&tl=en&u=http%3A%2F%2Fwww.mikrokopter.de%2Fucwiki%2FSpektrum%3Fhighlight%3D%2528%2528----%2528-*%2529%2528%5Cr%2529%253F%5Cn%2529%2528.*%2529KategorieEmpf%25C3%25A4nger%25295Cn%29%28.*%29KategorieEmpf%25C3%25A4nger%29