Go Down

Topic: How to calculate the Instruction Cycle time? (Read 611 times) previous topic - next topic

AK51

I need to make a delay of , for instance, 180ms with high accuracy. If I make a subroutine like this, how much micro second delay I have to subtract it? Thanks.

void delay_subroutine(long timedelay){
  while (timedelay > 16383){
    delayMicroseconds(16383);
    timedelay = timedelay-16383;
  }
  delayMicroseconds(timedelay);
}

AMPS-N

You can use timer library. It will be useful when you are trying to run call function exact time .
Else use MSTIMER liberay to get control over function.
AMPS

AK51

Thanks, I use micros() function and it is kind of ok.

Cheers

MarkT

If you have an Arduino with a ceramic resonator rather than a quartz crystal the
+/-0.3% accuracy of ceramic resonator itself will dwarf any fiddle factor in your
loop.

Having said that waiting for micros() is a reasonable approach - the largest source
of error is the jitter caused by the timer0 interrupt handler (assuming a perfect
crystal timebase).
[ I won't respond to messages, use the forum please ]

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy