Go Down

Topic: What is the reaction time of the Arduino interrupt? (Read 8925 times) previous topic - next topic

-horn-

Hi there,

I couldn't find an answer to my question on the internet, so I would like to ask heere.

What is the reaction time of the interrupt, if programmed with the arduion code?

I ask, because I want to trigger it with a 1 pulse per second GPS chip with a +-10 nanoseconds jitter and it must trigger faster than 250 nano seconds and then pulling up a pin from low to high.

I hope you have an answer for me :).

Best regards,


Andreas

DrAzzy

Check the interrupts section of the datasheet, it tells you how many clock cycles that takes - but with 250ns, you have only 4 clock cycles to do it in, which I don't think is enough, no matter how you do it.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

jboyton

It may be possible to just barely do it using timer 1, assuming you're using an Atmega328 or something similar. What I think might work is to feed the PPS signal into the timer 1 external clock pin and configure the timer so that a single clock pulse will cause it to generate an output compare, thus setting the OC1A pin. According to the data sheet, the external clock pin is sampled each system clock cycle and then there is a delay of up to 3.5 clock cycles before the timer is clocked. So it might just get you under that 250ns requirement. Maybe. :-)

It would probably be easier to add some external logic.

MarkT

I think you are looking for a flip-flop, not a microcontroller...
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

arduinoaleman

I love Arduino, so it hurts me when i have to recommend you a Raspberry Pi when it comes to higher speed or higher level programming.

If your questions are not precise, nobody can help you.

DrAzzy

I agree with MarkT - what you need is a discrete part with the necessary speed to do the converting of the pulse to a pin transition - since presumably you need to do more than that, you could then use an Arduino alongside it, to do the other stuff (and enable/disable that part, etcetera).

I don't think this calls for a Pi, since you don't need fast processing, just fast reaction to a pulse, which is easy to do with a separate IC or two.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Coding Badly

I love Arduino, so it hurts me when i have to recommend you a Raspberry Pi when it comes to higher speed or higher level programming.
Don't think it is up to the task either...
https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=9207


Grumpy_Mike

The Raspberry Pi is very poor at responding to interrupts due to Linux constantly interrupting any code. If you did want to use a Pi then you would have to run it as a Bair Metal system.

JoeN

I can't see why you don't want to use a T-flip flop like the other poster suggested.  That part is just about as cheap as you can get and can be had in pretty much any package.
I will never ask you to do anything that I wouldn't do myself.

MarkT

The Propeller microcontroller can respond to input changes with a granularity of 12.5ns and a delay
or about 100ns if you dedicate an entire cog to watching that pin.  Since the design philosophy of
that machine is about guaranteed cycle-accurate timing and uses multiple cores in place of interrupts,
it is a good match to a problem that would normally require special hardware.

Interrupt handling in most chips has jitter (it depends on the timing of the instructions being
interrupted - a divide instruction typically takes more clocks than an add for instance, so delays
the interrupt longer).  Also in most architectures a new stack frame is started (so a couple
of registers are written to stack and stack pointer altered) before your ISR code even starts running,
so there is a definite delay involved.  ISRs that react within 10 machine cycles would normally be
thought "ultra-fast".  In a full-blown CPU you'd expect the interrupt latency to be measured in
hundreds/thousands of cycles and timing completely at the mercy of the cache and memory
subsystem.  It doesn't matter what the OS policy is, you do not get +/-10ns repeatability from
an interrupt handler in a modern CPU...

I suspect you need some specialised hardware and an ISR to accomplish your task - though its
not impossible that one of the timer units can be pressed into service if you can clock it
externally and route one of its output compares to a pin too.

Some more information about what you are trying to do would help...
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

AWOL

I love Arduino, so it hurts me when i have to recommend you a Raspberry Pi when it comes to higher speed or higher level programming.


Unfortunately, the Pi comes with a lot of other baggage, and I suspect it is also incapable of the sort of timings required by the OP.

Grumpy_Mike

I ask, because I want to trigger it with a 1 pulse per second GPS chip with a +-10 nanoseconds jitter and it must trigger faster than 250 nano seconds and then pulling up a pin from low to high.
From what I can gather this signal is pulsing at the rate of one per second with a +-10 nanoseconds jitter. That means that the pulse can be 10 nanoseconds early or 10 nanoseconds late. Given that I am not sure what you want to do or why you want to do it.

Quote
it must trigger faster than 250 nano seconds and then pulling up a pin from low to high.
What and when does this pin go from a high to a low?

polymorph

In ignorance, the Due or Teensy 3.1? Both use an ARM Cortex running at a clock speed considerably faster than a 16MHz Arduino without the baggage of Linux on a Pi.

A flip flop does seem simpler, depending on what you intend on doing with this time-sensitive information.
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

polymorph

High Resolution PulsePosition library on the Teensy 3.1

Quote
PulsePosition Library

PulsePosition can transmit and receive PPM (Pulse Position Modulated) signals commonly used to control RC aircraft and servo motors. Up to 8 simultaneous input and/or output PPM streams may be used, with each stream conveying up to 16 signals.
PulsePosition is in beta testing. Please get the latest code from GitHub:
https://github.com/PaulStoffregen/PulsePosition

PulsePosition is designed for 0.02 ┬Ás accuracy (approx 24X better than most Arduino implementations using AVR Timer1) with tolerance for significant interrupt latency caused by other libraries. All output waveforms are generated by hardware timer compare and all input waveforms are read using hardware timer input capture, for extremely precise timing. Pin change interrupts, which add error due to interrupt latency, are never used.
So, 20ns accuracy.
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

MarkT

In ignorance, the Due or Teensy 3.1? Both use an ARM Cortex running at a clock speed considerably faster than a 16MHz Arduino without the baggage of Linux on a Pi.

Doesn't mean it will respond to interrupts any faster...  It has a lot more hardware baggage (an
instruction cache I think, as well as lots of registers).
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up