R/C Receiver, Interrupts, and Classes

Hi guys, I'm building a quadcopter :roll_eyes:

I'm eagerly awaiting the arrival my transmitter and receiver from ebay... :wink:

I'm looking at ways to interpret the pulses coming from the receiver into the arduino, and it turns out that a simple analogRead or pulseIn won't cut it.

I fully understand why and how to use interrupts to measure the change in pulse width as I change things on the transmitter, and I've been looking at the pin change interrupt library for use with my Uno, but I still had a couple of questions in regards to making the code a bit simpler, and perhaps safer...

Would it be appropriate to create class objects for each of the receiver channels? That way they can each have their own private time counters and it could make for simpler analysis/interpretation into ESC pwn signals i'm thinking. Would the variables that are used inside the methods as well as the ISRs need be declared volatile as well?

Also, when the something on the transmitter changes (e.g. the throttle is increased) are the pulses repeatedly sent from the receiver to the arduino? Or is it a single pulse? The reason I ask is that I have 6 channels and don't much like the idea of pinging 6 interrupts continuously.

Any other advice/links you can offer are also greatly appreciated.

Cheers.

In old analog systems the pulses were sent in groups, each channel having one pulse in the
group, so this limited the max rate of pulses as there needed to be an inter-group gap.

Modern digital Tx/Rx pairs can be more flexible, but the Rx output is still standard pulses,
typically 30 a second or something like that (look up the specs of your system).

If you are wanting to read in one channel, set an interrupt for CHANGE and record starting
and end micros() values, recording the difference everytime a pulse ends.

You will see timing jitter if other interrupts are flying about as occasionally one will delay
one of your ISRs - this is problematic as the Servo library is interrupt driven...

MarkT:
the Servo library is interrupt driven...

Interrupt driven? Not quite sure what you mean by that. I'm using the Servo library to control the 3 ESCs, but this is just a matter of setting the output no? The interrupts will interfere with the reading of the receiver channels?

Thanks.

I've also read that it is possible to tap into the demultiplexed stream and use a single high speed interrupt to read all of the channels, is this easily achievable with any kind of receiver unit? Or does it require a more unique, specialised one?

is this easily achievable with any kind of receiver unit? Or does it require a more unique, specialised one?

If your receiver can output a PPM signal or you can hack it to get access to such a signal then this page leads to a library will do what you need to extract the individual channel pulse widths.

Out of interest which Tx/Rx will you be using ?

I bought the cheapo 6 channel fly sky:
http://www.ebay.co.uk/itm/231482811761?ru=http%3A%2F%2Fwww.ebay.co.uk%2Fsch%2Fi.html%3F_from%3DR40%26_sacat%3D0%26_nkw%3D231482811761%26_rdc%3D1

I have read this article and I'm confident I'll be able find and bypass the timer. The code to separate the channels is pretty straight forward to me. Use a high speed interrupt detecting the rising signals, log time, count the channels, then reset the channel count when you detect the end of the frame. Would you still recommend constructing a class to handle each individual channel? I foresee this being useful for error checking and debugging.

I've also got an MPU6050 and a ultrasonic ranger that I'll be using as well. Could this possibly task load the arduino?

Thanks again.