I'm trying to output a pulse after receiving the rising edge of an external trigger (from an encoder). There is a time interval of several microseconds between the pulse and the trigger,which could be changed through the program. But we found the pulse is jittering, for about 5us.
For example, most of time, the time interval between the pulse and the trigger is 8us, but frequently, it jitters from 8 to 14us.
If we inspect with OSC, we could see the pulse jitters back accidentally without obviously period and
it could last 5 us at most.
The peripheral hardware is simple. There is a signal generator hooked up to the external interrupt of the Arduino Uno, and we observed the output pin with an oscilloscope.
The yellow line represents the trigger pulse, and the blue line represents the output pulse.The oscilloscope is triggered by the yellow line.
The following pictures show the jittering of the output pulse .
The program is as follows:
- int trigger = 4;
void setup() {
pinMode(trigger, OUTPUT);
attachInterrupt(1, blink, RISING);//trigger by TTL rising.
}
void loop() {
}
void blink()
{
digitalWrite(trigger,HIGH); // output input trigger
delayMicroseconds(100); // High TTL level laststriggers for 100us
digitalWrite(trigger,LOW);
}
What I have tried are these:
1,Use another signal generator or another Arduino board. The pulse jitter remains.
2,Alter the trigger frequence.The pulse jitter appears if only the frequence higher than 40Hz.
So,I myself think it doesn't matter with the signal generator.
3,Modify the program to achieve the similar function through capturing the HIGH level of the trigger rather than its rising edge. The pulse jitter remains, while it appears not so frequently as before.
4,Add noInterrupts() and interrupts() to avoid ISR being interrupted accidently.The pulse jitter remains.
We know that the interrupt starts only after the current running instruction finishes, the clock cycles of the different instrcutions vary a lot, which may cause the output pluse jitter a little bit. But this variation is much less than 5us.
I was frustrated.Is it's the residual accumulation between crystal oscillator period and the external trigger's period that leads to the pulse jitter? But,could it reach a 5us long jitter?
Please help me!


