I'm using millis() to sequence dslr camera shutter events, avoiding delay because PWM is running a heater and/or cooler simultaneously.
Timing of the shutter declares timer = millis() at the beginning of the loop and adds the previous action time to the next and so on. Psuedo code below.
void integrate(){
// capture images here
if(shutter == LOW) // must be declared or Timer routine will not work
Timer = millis();
if(millis() - Timer >= 3000)
digitalWrite(shutter, HIGH); // lock up the dslr mirror
if(millis() - Timer >= 3500) // wait a while for vibrations to settle
digitalWrite(shutter, LOW);
if(millis() - Timer >= 6500)
digitalWrite(shutter, HIGH); // fire the shutter again to start image capture
if(millis() - Timer >= (6500 + integration)) // that done, now dither - point camera a little off from last image
digitalWrite(shutter, LOW);
dither();
}
void dither(){
Timer = millis(); // must declare here or wont work
dither routine here then return to shutter sequence for next exposure
integrate();
}
This works fine except for missing the occasional mirror lock up, which is not ideal but tolerable. Unless Timer = millis(); is declared in void dither() no further action takes place.
When I attempt the same routine in a different loop (where it takes calibration frames) the same routine will not work and ignores the shutter timing, basically bringing everything to a halt. Same code as above, different loop location, does not work.
This is odd because Timer is just taking on the value of millis - when it is called, shouldn't matter.
What am I missing here?