Number of Interrupt routines

How many independent interrupt routines can be called. I thought I could use attachInterrupt on D0-D6, but in reading the documentation, I found:

All pins with the exception of D0 and A5 (since at present Mode Button external interrupt(EXTI) line is shared with D0, A5). Also please note following are the pins for which EXTI lines are shared so only one can work at a time:
D1, A4
D2, A0, A3
D4, A1

You can put an interrupt handler on D1-D6.

Since you can’t use D0, you can use one of the other pins that’s not on the list. That would include A2, A6, D7, TX, and RX.

In other words, you can’t use A4 because it shares an interrupt with D1, which you are already using, and so on.

So, if I understand you, there are only 4 at a time that can have an interrup attached.

No, you can attach an interrupt to all of these, just pick one out of each line:

D1 (or A4)
D2 (or A0 or A3)
D3 (or DAC)
D4 (or A1)


I’m building a race timer that has 7 IR beams. To function, each IR beam is run at a 50% cycle of PWM. To better discriminate a beam break, only one eye at a time is turned on (duty cycle set to 0). My question is this… is it best to use D1-D7 or a sequence of D5, D6, D7, A0, A2, WKP, Rx, Tx since I believe these are non-shared PWM timers?

Hmm, I seem to completely miss the point.
Can you provide a schematic drawing of what you intend to do?
Why the combination of PWM and interrupt?

If you know at any given time which beam is active, why do you need more than one interrupt.
Or if you are using a dedicated interrupt for each beam, why the PWM?

Sorry… Senior moment. This question has nothing to do with PWM. I’m going to try to include the schematic. I would prefer attaching the receivers to D1-D7. This shows the other alternative.

@harley, what part number are those IR receivers?

Vishay TSSP4038.

If PWM is out of the picture I’d not see any issue in using D1…D7

PWM is only for the IR carrier. The IR detector outputs a logic level so no issue. As for interrupts, since only one sensor is active at a time, multiple interrupts will work just fine.

OK, I messed up. This has nothing to do with PWM… This has to do with the receivers. All of the 7 receivers need to actively attach an ISR all of the time. Will this work with D1-D7 each having an independent ISR?

@harley, if each sensor is mutually exclusive, you don’t need an ISR per sensor. You just need your ISR to read the D1-D7 pins to figure out which pin caused the interrupt.

1 Like

According to the manufacturer’s application note, each emitter should be turned on for a minimum of 10 cycles and then turned off for a period 5 cycles. This should be done successively for all emitters. That helps cross-talk between emitters and it’s equilevent receiver.

Therefore, the receivers are constantly toggling. A beam break isn’t declared because the receiver transitions from low-to-high, but rather, if the time between pulses is longer than what would occur with the transmitter toggling. 10 cycles is about 300 uSec and 150 uSec is needed for quiescence. With 7 LEDs, a complete cycle is 3,100.

This is a dog timer for dog agility trials. The fastest dog runs at such a rate that they cross the plane of the emitter/receiver in about 5 mSec. The receiving timing pole must send a keep-alive every 1 second and periodically check the battery level and send break messages.

The reason I’m explaining this is to say that the timing is very close and I don’t want to do any extra reads at the interrupt level. I’d rather have independent ISE’s

@harley, the first question that begs to be asked is, how long will the wires going to each IR sensor be?

Your explanation of the hardware is still not clear. Am I correct in assuming that you have a single “pole” that a dog is expected to run in front of so his speed can be measured? The pole has 7 LEDS for what reason - to make sure that the regardless of dog size and jump height, one or more IR receiver is affected?

Can you explain what the detector output will look like during “unbroken” and “broken” operation. If I understand correctly, you are looking for a “missing pulse” detector. And you want to use individual ISRs to measure each pulse “train” looking for missing pulses on each pin. Correct?

IA set is 4 poles, two transmitters and two receivers. To start the time, the dog (from Chicuacua to St. Bernard) goes between the poles (a transmitter and a receiver) to start the run and timer and at the end of the run goes between second set (a transmitter and receiver).

Often, the timer is place in front of a jump. Small dogs jump as low as 4” and depending upon the dog’s size the dogs can jump up to 24” with just about every 2” between 4” & 24”. Also, sometimes large dogs jump especially high, such as 30”.

Therefore my design has a beam at 7”, 11”, 15”, 19”, 25”, 30”, & 35” which I’ve calculated should break a beam based upon the size of the dog. The Photon in the design sits at about 22” in the middle so the wires extend from the Pohron 20”, 15”, & 10” in each direction.

National dog trials have prize pools of $10,000 with the placements decided in the 100ths of a second. There currently are timers such as these which sell for $2200 per set. I decided to make a replacement using an iPhone/iPad as the logic and timer and the poles only sending keep-Alives and beam breaks.

I have a model working pretty dependably with three “eyes” (beams). The receiver circuits with resistor, capacitors and receiver are on small circuit boards at the opening in the pole. The wires for power extend from a power booster at the bottom of the pole to the top and the wire carrying that detected signal extends from the eye to the Photon. The wires are twisted to avoid cross-talk. The circuit for the emitter is on a small board with resistors, capacitor, MOSFET, and IR LED. Again, the power wires are as described above and the PWM pins are connected to the remote MOSFET with a control wire from Photon.

The IR LEDs are toggled off and on rapidly so that near LEDs will not effect the receiver. To this end, the LEDs are turned on 1, 4, 2, 5, 3, 6. Currently, I plan on only 6 LEDs for 7 receivers.

I am including a picture of the prototype with 3 eyes, first one of the front and then one with the back open so you can see the wiring

1 Like

I should have mentioned that in the pictures, you’ll see the Photon on the outside of the prototype, that was done because the IR LED light bounces off of everything so the circuits need to be sealed from extraneous light, but, to develop the firmware, I need to use the USB port and press buttons to get the Photon into receiving mode (the WiFi is used for communications between poles and iPhone/iPad so can’t be used in the network that connects to

Interesting application.

It leaves me wondering if there is a better sensor for the Job or not?

What is the distance between the 2 poles usually?

The minimum required distance is 6’ since jumps are required to e 5’ apart. Sometimes the timers are used before or after a tunnel so they are only 2.5’ apart.

I’m going to include a picture of my first prototype that was a single beam that could slide up and down a pole to match the size of dog required. Since there is a single eye, it doesn’t need to be toggled, but rather runs at a constant 50% duty cycle

Would this type fo sensor have any benefits for your application?