Go Down

Topic: Need More Interrupts For More RC Channels (Read 624 times) previous topic - next topic

DuaneB

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 -

http://rcarduino.blogspot.com/2012/03/need-more-interrupts-to-read-more.html

Duane B

rcarduino.blogspot.com
Read this
http://rcarduino.blogspot.com/2012/04/servo-problems-with-arduino-part-1.html
then watch this
http://rcarduino.blogspot.com/2012/04/servo-problems-part-2-demonstration.html

Rcarduino.blogspot.com

CrossRoads

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


however, what?
Quote

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.
Quote

So how do we use this library ?

Part 1) Installation

1) Download the zip file from the google code group http://code.google.com/p/arduino-pinchangeint/
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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

retrolefty

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


CrossRoads

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
http://www.mouser.com/ProductDetail/Atmel/ATmega2560-16AU/?qs=sGAEpiMZZMtkfMPOFRTOl4TPj%252bk4h3O1

'328, $3.85
http://www.mouser.com/ProductDetail/Atmel/ATMEGA328P-AU/?qs=sGAEpiMZZMtVoztFdqDXO3RbBx7FKCmV

other packages & options available as well.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

retrolefty

#4
Mar 24, 2012, 06:50 am Last Edit: Mar 24, 2012, 06:52 am by retrolefty Reason: 1
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


DuaneB

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
Read this
http://rcarduino.blogspot.com/2012/04/servo-problems-with-arduino-part-1.html
then watch this
http://rcarduino.blogspot.com/2012/04/servo-problems-part-2-demonstration.html

Rcarduino.blogspot.com

Go Up