Problem reading a hobby reciever

148 views
Skip to first unread message

André Franken

unread,
Nov 5, 2012, 8:55:38 PM11/5/12
to arduino-pincha...@googlegroups.com
Hi, I'm having a weird issue using the PinChangeInt library to read a 6 channel reciever.

I can only read up to two random channels reliably, I have tried different pins, tested the reciever with a servo.
I'm using a 5V/16MHz arduino pro mini and a hobbyking t6 rxtx combo. Using version 1.7 of the library

I have been using code from http://rcarduino.blogspot.co.uk/2012/04/how-to-read-multiple-rc-channels-draft.html and expanded it to read all 6 channels. 
When that didnt work I went back to the basics and used the example code for the pinchange library, changing only the pin numbers to the ones I was using and leaving the rest of the code intatct. I would expect to see 50 falling edge interrupts per second from the two connected channels. However I only get 50-51 from one channel and the occasional 1 interrupt from the second channel.

I just had a thought, is the library only capable of reading one interrupt per port rather than one interrupt per pin?

Thanks,
Andre
 

Michael Schwager

unread,
Nov 6, 2012, 2:36:44 PM11/6/12
to arduino-pincha...@googlegroups.com, andre.j...@gmail.com
The library can read as many pins as the Arduino has. My testbed has 6 pins on it.

Using my code as described below, what happens if you flip the wires to the pins?
--
-Mike Schwager

André Franken

unread,
Nov 7, 2012, 6:21:13 AM11/7/12
to arduino-pincha...@googlegroups.com, andre.j...@gmail.com
After swapping around the pins/channels as you suggested I discovered an interesting effect. The reciever channels are labelled 1 through 6, if any consecutive channels are attached to the same atmel port e.g. channels 1 and 2 are connected to pins 9 and 10 on portB, only one of the pins is properly handled. However, if channels 1 and 3 are connected to those pins both channels are handled correctly. This may be an issue with this particular receiver, in that the falling edge of channel 1 must trigger the rising edge on channel 2 to begin, somehow being too close to each other for the library to handle each separately as they both trigger the same interrupt vector. 

I've successfully been able to read all  channels from the receiver just by alternating the channel arrangement across 2 ports i.e. pins 5,6,7 attached to channels 1,3,5 and 8,9,10 to 2,4,6.  

Thanks again :)

Michael Schwager

unread,
Nov 12, 2012, 7:35:59 PM11/12/12
to arduino-pincha...@googlegroups.com
Andre',
Your post got my brain working... along with another upgrade I made, I uncovered a significant bug in the code. Please look for release 2.11beta to show up on the website soon.

Thanks for posting, it really helped. I had a small obscure problem, but with your post I could not avoid the feeling that something was really wrong. And I uncovered it!  Thanks again.
--
-Mike Schwager
Reply all
Reply to author
Forward
0 new messages