Need More Interrupts For More RC Channels

Hi,
I recently needed more interrupts to be able to read more RC Receiver channels that can be read with the two Arduino interrupts INT0 and INT1. I was aware of the ATMega pin change interrupt facility and intended to write something using this, however -

Duane B

rcarduino.blogspot.com

I was aware of the ATMega pin change interrupt facility and intended to write something using this, however -

however, what?

Conclusion

The minimal impact of the pinChangeInt library is a very reasonable trade off for access to more than 20 external interrupts.

Update: In subsequent tests, the performance impact of attaching an interrupt with PCintPort::attachInterrupt has been measured to be near negligible. In the worst case test there was a 5% overhead (over INT0,INT1 ), in the best case it was actually 15% faster.

So now you don't need to write something? You will just use the new library instead?
Looks like a good find.

So how do we use this library ?

Part 1) Installation

  1. Download the zip file from the google code group Google Code Archive - Long-term storage for Google Code Project Hosting.
  2. Copy the three directories cppfix, MemoryFree and PinChangeInt into the libraries folder of your Arduino directory, mine is here - 'C:\arduino-1.0-windows\arduino-1.0\libraries\PinChangeIn'

Part 2) Adding the library to a project

  1. To add the library to a project, open the project in the IDE
  2. In the 'Sketch' menu you should see a menu item 'Import Library'
  3. Select import library and you should see a drop down list of the libraries you have installed, from this list select 'pinChangeInt'
  4. You should now see the line #include <PinChangeInt.h> added near the start of you sketch

The library is now installed and included in your project ready for use.

Also the arduino mega boards have five user interrupt pins avalible.

Yes, but 5 <8 still 8)
Little bit of software seems more cost beneficial vs a more expensive uC and/or board

'2560, $12.86

'328, $3.85

other packages & options available as well.

Yea, I wasn't making a value jugement, just throwing out that mega has 5 in case OP didn't know that. I did quickly look at that library and the code sure was hard to read, dense style, not enough white space for my taste. I think it would take a while for me to get a feel for how easy it might be to use. Even his example sketches seemed difficult to read/understand on first browes through, at least for me. Also his comments seem to say that it only supports the 328 chip and not the 1280/2560 chips where it would be just as useful for very large number of interrupts might be useful?

Lefty

Hi,
Just to be clear, while I would be happy to claim responsibility for the library, it isn't mine, nor have I contributed anything to its development.

The coding style is a mater of taste but I can agree that the examples are pretty horrible !

I will rectify that in a day or two with a post showing how I am using the library to read four RPM sensors and three RC Channels in one of my projects.

As for usability, its use is identical to attachInterrupt and its performance is so close as to make no difference - if my maths is right !

Duane B

rcarduino.blogspot.com

rcarduino.blogspot.com