Hello - I'm creating a pan/tilt camera system that has an option for recording user input and playing it back (a motion-control setup). I've finally realized that I can't get a computer to do the recording as computer sleep is not accurate enough.
I am looking into using a programmable interval timer that sends an interrupt pulse every millisecond in order to have a precisely accurate record and playback mechanism. Any suggestions?
Can you handle any jitter in the signal?
How wide a pulse? High or Low?
What voltage levels?
What rise/fall times?
How much current needs to sourced/sinked?
How much variability?
I suppose I was not clear enough with my question. I'm not worried about recording values from my input devices. I can do that much.
I'm worried about getting a precisely timed alarm with very little variance. I need SOMETHING to interrupt the arduino to record a value. I would like this interrupt to happen every millisecond. Perhaps precise to +/- 10 microseconds? Drift is not preferable.
An Arduino with a crystal should have an accuracy of a few seconds over the course of the day. You need more accuracy than that?
Why mess with timers? Why not just poll your inputs constantly and record input changes (with time deltas) when they occur? An interrupt or timer library isn't going to give you any better accuracy than that.
As for not using the timers, that's a fair idea but I actually need it to be sampled at a set interval of 1ms so that I have the ability to be pulse-synced with a shutter on a camera.
Just avoid taking readings when millis() hasn't incremented.
unsigned long lastmillis = 0;
void loop() {
if (millis() > lastmillis) {
lastmillis = millis();
} else {
return; // goes back to start of loop()
}
// take readings here
}