Hello, in Arduino 0011 I've been successful in reading multiple channels from an RC receiver by doing the following:
// Setup interrupt to trigger on pin D2
attachInterrupt(0, interruptHandler, RISING);
The in another sketch I do:
void interruptHandler() {
// Read Receiver
// This has been tested with AR6100 and AR6200 Spektrum receivers
roll = pulseIn(ROLLPIN, HIGH, TIMEOUT);
aux = pulseIn(AUXPIN, HIGH, TIMEOUT);
mode = pulseIn(MODEPIN, HIGH, TIMEOUT);
pitch = pulseIn(PITCHPIN, HIGH, TIMEOUT);
throttle = pulseIn(THROTTLEPIN, HIGH, TIMEOUT);
yaw = pulseIn(YAWPIN, HIGH, TIMEOUT);
}
I know the order that the PWM signals come out of my receiver, so I attach an interrupt to the first channel being output from my receiver, then use pulseIn to read the remaining channels. It takes about 14ms to read in 6 channels using this method.
My main problem is that this worked fine in Arduino 0011, but when I try it in 0012 or 0013 it hangs when I do the attachInterrupt function call. I don't see any compile error messages under 0012 or 0013. I'd like to use Mem's ServoDecode library, but I don't have access to a PPM signal with the Spektrum receiver's I use.
If this is hopless in 0012 or 0013, is there an alternative approach to read multiple RC channels in the background if the order of channels to read is known (like I'm doing for the pulseIn approach)? Maybe somehow attach a timer to each digital pin in a known order to measure each PWM pulse length? I'm not knowledgeable enough to do it on my own, but if someone could help point the way (maybe some pseudocode) I'd be very appreciative.
Thanks!