multi-channel capture w/ one capture unit?

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm making a small mega8-based system for controlling stuff through I2C. The input is 3 signals from an RC receiver. Those signals are, as you might know, pulses repeated at approximately 30-50 Hz. The pulse width is between 1000 and 2000 microseconds. Now, I have to capture all 3 pulses with the mega8. The microcontroller has ONE input capture unit.

So I guess you figured out the question... what is the best way of doing this?

The resolution/accuracy is not critical, but I'm aiming at 1 microsecond or better. I'd prefer interrupt-driven capture - it's much nicer to use in C. I have an idea of XORing all 3 signals and connecting the result to the capture unit, but of course in the event of 2 signals changing state at the same time, this it wouldn't work. Any other ideas?

BTW I'm not sure how RC receivers in general emit signals - in sync or interchanged?

/Jakob Selbing

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jaksel wrote:

BTW I'm not sure how RC receivers in general emit signals - in sync or interchanged?

Standard (often called PPM, but is really PWM) systems pack up to eight** channels in a 20ms frame. Each channel is a pulse of between 1 and 2ms. The scheme was designed to enable easy decoding with simple logic in the reciever. This means the servo outputs from a basic receiver will always emit pulses in a fixed order.

For the newer PCM systems, I don't know, it's entirely possible that the servo pulses could overlap.

FWIW, 1us resolution is almost certainly overkill. Most standard servos would struggle to get much better than an 8 bit resolution.

** Some newer PPM systems can pack 12 channels in by shortening the servo pulse width before encoding at the TX and then the RX expands them again.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have seen a PCM system outputting the pulses on all channels simultaneously, so it is a situation that can happen.
And if used with a PCM system, then a 1us resolution is very realistic.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you really need a number of capture inputs - then choose a micro with the hardware you need. Some of the 8051 derivatives have a PCA timer unit with 5 capture/compares. Certainly, its not an AVR but I tend to choose the device I find most suited to the task. If you write in 'c', most micros look much the same from the programmer's point of view.

I also back up the other respondent's point of view - with most of the servos, 1uS is way overkill. Try it yourself - see if the servo even moves on a 1uS change. They have a built in 'dead band' which is greater than 1uS (the exact value I'm not sure - do a Google).

You can use some software and you PC's sound card as an oscilloscope to measure the output of your receiver and answer your questions regarding them being in sync or sequential. Again, do a Google.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Svuppe wrote:
I have seen a PCM system outputting the pulses on all channels simultaneously, so it is a situation that can happen.
And if used with a PCM system, then a 1us resolution is very realistic.

The point I was making is that whilst the TX/RX might be able to resolve a 1us change, the servo's (unless they are some very precision/expensive units) will not.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jaksel, if your receiver is PPM (and cheap enough that you are ok with some soldering on it) it might be better to decode the whole PPM signal. You can use the input capture pin. As a bonus you get all channels.

Here is some info on GWS recivers, i.e., where to find the PPM pulse:
http://homepages.paradise.net.nz/bhabbott/decoder.html
Just ignore the stuff about decoding with PIC:s :) .

/Lars

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why not just poll on all channels, while running a single timer/counter with a known prescaler at a known clock speed? When a pin changes, you compare it to the timer.counter to know how long it has been?

Andy Out!