Pin Change vs. External Interrupt Overhead

I have created a bunch of circuit boards that use Nano 3.0 and don't have access to pin 2 and 3 anymore. The board has access to Analog Input 0 and 1 for generic inputs, and I'd like to use Analog 0 for a interrupt. The application is triggering of an LED light source. A TTL low signal is sent simultaneously to a digital camera and to my circuit board for synchronized camera-LED shuttering, so I need to respond as quickly as possible to stay in sync with the camera.

1) Does it take longer to execute a pin-change interrupt compared to an external interrupt on pin 2 or 3?

2) Can you create a conditional interrupt when the pin input goes low on a pin-change interrupt like you can with external interrupts? The Arduino site says no, but I've seen a post that describes code to do it. What is the best way to achieve this, and how much clock time would I loose?

Thanks for your response.

First question you should answer is why you need interrupts at all. What else is the Arduino doing that polling is not adequate?

Can you create a conditional interrupt when the pin input goes low on a pin-change interrupt like you can with external interrupts? The Arduino site says no, but I've seen a post that describes code to do it.

The pin change interrupt fires when the pin changes state. It is up to you, in the ISR, to determine what change caused the interrupt. If the pin is now HIGH, the interrupt was a RISING one. If it is now LOW, it was a FALLING interrupt.

Thanks PaulS.

The Arduino has an ethernet interface and must be free to respond to host requests, even when it is busy. I assumed that continuous polling would shut the Arduino down for communication. I also guessed that polling might be slower than using interrupts.

Thanks for the info on the state-change preferences in the ISR.

Do you know if the pin-change interrupt works as quickly as the external interrupt?

The Arduino has an ethernet interface and must be free to respond to host requests, even when it is busy.

I think that you really need to decide which is the priority here. Is responding to client requests more important than dealing with sensors, or is dealing with sensors more important.

Most clients can't tell the difference between an immediate response and one that took 0.25 seconds. Most cameras can.

I also guessed that polling might be slower than using interrupts.

Slower in terms of knowing when the event occurred. Depending on what needs to be done in response to the event, the ISR may, or may not, be able to fully service the interrupt. If not, all it can do is set a flag that needs to be polled anyway. In which case, the ISR will actually slow things down.

Do you know if the pin-change interrupt works as quickly as the external interrupt?

No, I don't. But, I doubt it. Whether the slower response is important, or not, I couldn't tell you.

However, since you seem to think that servicing clients is more important than servicing sensors, I doubt that the slower reaction will be significant.

You are correct, the response to the camera is way more important than the ethernet response. In fact, I can tell you that it is unlikely that the ethernet interface would be used at all during the interrupt routine execution, except for a user abort operation.

The response time to the eternal pulse on the pin input is critical and must be the same response time on every iteration of the interrupt. I'm scanning motion picture film and get one pulse every frame. The film runs continuously, so the LED's must shutter at the same time each frame, or I'll get vertical jitter.

Based on these criteria, do you think I'm better to do continuous polling? Or should I redesign my hardware to use pin2/3?

Still a little confused.

Stupid question, but if you need to respond as quickly as possible why use the Arduino at all ?

Duane B

rcarduino.blogspot.com

Stupid question, but if you need to respond as quickly as possible why use the Arduino at all ?

I don't think it's a stupid question. I wonder, though, why run a web server on a mission/time critical device. Surely you would be better off with another Arduino as web server, sending only "Whoa, stop" messages to the film processing Arduino.