Pages: [1]   Go Down
Author Topic: Need More Interrupts For More RC Channels  (Read 540 times)
0 Members and 1 Guest are viewing this topic.
Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 517
Posts: 26291
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17259
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 517
Posts: 26291
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, but 5 <8 still smiley-cool
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.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17259
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

« Last Edit: March 24, 2012, 12:52:51 am by retrolefty » Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Pages: [1]   Go Up
Jump to: