Jump to content

Banner.jpg.b83b14cd4142fe10848741bb2a14c66b.jpg

Arduino Interrupt Handling? (Thinking)


Macavity

Recommended Posts

I am able to follow how to handle interrupts on Arduinos.
But I have a more general (albeit vague?) question... :p

A standard Arduino has TWO interrupts pins? Most demo
programs handle only a couple of hardware devices! But 
what if I have (lots) more? Each needs one/two Arduino
input pins... Could I take an "OR"-ed signal from each to 
ONE interrupt? I could then identify a specific device in 
the interrupt routine, rather than in the main loop? ;)

Maybe I could just use simple Diodes to "OR" them?
Always seem to run out of PINS with Arduino projects!
Sometimes it's easier to use the Arduino MEGA too! :D

Details to be established. But does anyone "get me"? 
It would seem to be a general Processing problem...

Link to comment
Share on other sites

Whilst I don't know anything about Arduinos, I've written enough interrupt service routines to be able to answer your general question. Yes, you can OR together multiple interrupts to present to a processor's interrupt pin. A key thing to ensure is that all combinations of interrupt timing are supported. For example, using a level triggered processor interrupt (rather than edge triggered), allows a 2nd interrupt source to activate whist a 1st interrupt is being serviced. If the interrupt service routine does not see the 2nd interrupt whilst it is servicing the first interrupt, the 2nd interrupt will kick off the interrupt service routine again when the 1st interrupt is exited. Obviously the interrupt service routine must service and clear interrupts.

Link to comment
Share on other sites

Thank you ALL! Will indeed read more... HERE and elsewhere! :)
Nice to know the general idea is not too outlandish.

For what it's worth, the project is to build a MIDI "Control Surface"
for VST Virtual Synthesizers! Lots of potentiometers... switches and
*some* Rotary Encoders. It is these latter that seem candidates for
a more interrupt driven idea? One has to store "current values" etc.

The latter deliver "Edge" interrupts, so should be handle-able.
The typical interrupt rate is going to be limited by the speed of
human knob-twiddling anyway! <G> At most two at a time... :p

A lot of FUN stuff to learn... Might even try some of the ideas
for "high speed" reading of inputs etc. ;)

Link to comment
Share on other sites

Hi Chris,

I think I probably suggested this before but brain fade and all that..................

Have a look at this library: https://www.pjrc.com/teensy/td_libs_Encoder.html

Makes it very simple to use rotary encoders. And if you do want 'lots of switches, potentiometers' it means using a chip with lots of pins for inputs. Strongly recommend using either an Arduino Mega 2560 or - my favourite - a Teensy 3.5. The Teensy3.5, like the 3.1 and 3.2, has 'proper' interrupt handling on all digital inputs.

Regards, Hugh

PS - Thanks Dave_D - nice to see oneself in print!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.