Shop OBEX P1 Docs P2 Docs Learn Events
PWM Echo - autonomous quadcopter — Parallax Forums

PWM Echo - autonomous quadcopter

ypapelisypapelis Posts: 99
edited 2012-01-02 12:29 in Propeller 1
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.

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-12-31 20:42
    I should think you would not have to monitor all eight channels simultaneously, since they're transmitted (and demultiplexed upon reception) sequentially. Just figure out what their order of transmission is and sample them in turn.

    -Phil
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-01-01 02:05
    ypapelis: If you look over on the Quadcopter thread in the build forum, Jason has posted his code. I tidied up some objects and documented them and wrote some with help from others, etc. IIRC my code is posted there too.
    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 ;)
  • ypapelisypapelis Posts: 99
    edited 2012-01-01 08:07
    I should think you would not have to monitor all eight channels simultaneously, since they're transmitted (and demultiplexed upon reception) sequentially. Just figure out what their order of transmission is and sample them in turn.

    -Phil

    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.
  • ypapelisypapelis Posts: 99
    edited 2012-01-01 08:11
    Cluso99 wrote: »
    ypapelis: If you look over on the Quadcopter thread in the build forum, Jason has posted his code. I tidied up some objects and documented them and wrote some with help from others, etc. IIRC my code is posted there too.
    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 ;)

    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.
  • TharkunTharkun Posts: 67
    edited 2012-01-01 12:07
    Hi ypapelis,

    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.
  • ypapelisypapelis Posts: 99
    edited 2012-01-01 16:30
    Tharkun wrote: »
    Hi ypapelis,

    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 ?
  • TharkunTharkun Posts: 67
    edited 2012-01-02 00:25
    ypapelis wrote: »
    Tharkun,

    I am not sure what you mean by the sum-pwm-signal, could you explain ?
    Compared to a normal servo PPM signal the sum signal contains all the channels sent by the R/C transmitter before they are decoded by the receiver. This signal is available in every receiver and there are many of them where this signal is directly accessible from outside. (at the 3rd Battery Pin)
    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
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-01-02 02:35
    Tharkun: That is very interesting. I have a Spektrum DX6i with the AR6200 & slave receivers. I know that it is possible to get the data (IIRC its straight serial) from the slave but I couldn't find anywhere where they said the serial data was available on the main receiver. Do you have a link as this would be fantastic?
  • TharkunTharkun Posts: 67
    edited 2012-01-02 04:44
    Cluso99 wrote: »
    Tharkun: That is very interesting. I have a Spektrum DX6i with the AR6200 & slave receivers. I know that it is possible to get the data (IIRC its straight serial) from the slave but I couldn't find anywhere where they said the serial data was available on the main receiver. Do you have a link as this would be fantastic?

    @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
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-01-02 12:29
    Tharkun: Thanks for the link. Interesting that they have hacked the Spektrum DX7 to add another 5 channels. Wonder if the DX6i could also be hacked that way - there was mention of it there but no specific results that I saw so I guess I need to google it (later). I didn't see anything specific about getting to the serial stream other than by just using slave receivers though, and this shortens the range.
Sign In or Register to comment.