Modification of a timelapse program

Hello,
I use very successfully the program MiniEngine1 by Eiric Lenz ( GitHub - airiclenz/miniEngine1: An Arduino based single-axis motion-control system for time-lapse photography (the legacy version) ) to control a camera (focus and shutter triggering) and the stepper motor of a slider.
I would like now to also control a studio light installation that would turn on slightly before each camera shutter triggering.
Since I don't really use the focus fonction, I used the focus pin to control a relay board.
It works fine BUT it turns "on" the light at the same time than triggering, despite the setting, "focus time" and "focus behavior" in the menu.
I am about to try to add delay() in the camera_shoot() function (mE_camera.ino file, line 55).
What do you think of it ?
Surely the most "elegant" thing would be to add a new pin attribution, a "light_on" function and more line in the setting menu to set the delay between "light on", "camera focus" and "camera shoot".
I hope that subject could find some competent and helpfull mind.

The easier you make it to read and copy your code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

If the git was less than two years old, I’d say you’d get further faster opening an issue or asking the author…

At a glance, it looks more like line 69 to me. After the focus bit is adjusted, but before the shutter is open.

But just plopping delay into what is quite an elaborate program might mess up all kindsa timing of critical and less critical nature.

How long a short bit of time do you need? It seems like you could go ahead and try, what’s the worst that could happen?

If it appears to work, carefully check that all the other time based operations have not been compromised… you might get lucky.

If it doesn’t work at all or screws with the time lapsing accuracy, there is little choice but to take a longer route which will involve learning way more about the entire program than, well let’s just say you might want to open alternate channels of inquiry about the program or how to do what you want.

Can you get faster lights? Can you exploit a delay until camera actually takes a picture in the camera itself? And so forth, up to and including switching careers. :wink:

a7

Thank you for your answer. I should have start the previous message, by explaining that my coding skills are close to zero. I have a vague and intuitive comprehension.
As you say, I will go ahead by next week and let you know. I need between 1000 ms and 500 ms delay, and since it's to shoot plants growth the shooting cycle will be very long, the delay shouldn't make a big difference.
What do you mean by "switching careers" ? I hope I am a better photographer than coder...

I am sorry to not have add the code in my message, but the whole program is constituted of 9 files , and the zip is to heavy to be upload. That 's why I give the github adress of the program :

With something so large and spread over tabs like it is, I personally don't have a problem looking at it on github. Others might.

But add the fact that it is built for an earlier IDE version and you might find few takers for diving into the code - we usually see relatively simple programs, or problems exposed through small examples... not a large program from a non-programmer.

I have a vague and intuitive comprehension.

That's a good start for setting out on a long journey. I still find common sense, intuition and sometimes extra-sensory things entering into my own progress. And I am pretty vague most of the time.

As for switching careers, it was an attmept at humor, which like so many I try apparently did not land.

a7

I got it , and my answer was an attempt too for humor. I suppose my english is not good enough for too much subtility.
Anyway thank you very much for your help. No doubt that project would be a good brain exercice for me, but I have first to learn the very basics and as an impatient piano learner, I would dream to be able to play a Bach invention after a week, a Mozart sonata after two weeks and a Beethoven concerto after a month...
and finally put a Rubinstein recording in my CD player.

Me again,

I tried very empirically to add a " delay(500) ; " line and did a test also with
"delayMicroseconds(500) ;" line in the code of the mE_camera.ino file with no success

// ===================================================================================
void camera_shoot() {

  // close or open the focus line while shooting (relevant for shootimg behavior of different camera brands)
  if (camera_status & B10000000) {
    digitalWrite(FOCUS_PIN, HIGH);
  } else {
    digitalWrite(FOCUS_PIN, LOW);
  }

  // enpower the camera pin
  **delay(500);**
  digitalWrite(CAMERA_PIN, HIGH);
  // remember the starting time
  action_start_time = millis();

  // set the "i am exposing" flag to on
  action_status |= B00010000;

}

is there some possible modification in this part of the code of the mini_E file in the "S H O O T - M O V E - S H O O T m o d e " part ?

// ===================================================================================
// Arduinos eternal loop procedure
// ===================================================================================
void loop() {
  
  // do the screen stuff
  do_screen();
     
  // programm is running
  if (action_status & B00001000) {
    
    
    // =================================================
    // C O N T I N U O U S   m o d e
    // =================================================
    if (action_status & B10000000) {
      
      // do some continuous steps    
      doMotorContinuous();

      // if it is time or the "start a new cycle immediately" flag is set
      if ((action_status & B00100000) ||
          ((program_start_time + ((unsigned long) cycle_length * 500UL * (unsigned long) camera_shoot_count)) <= millis())) {
             
        // if not exposing right now and not in camera post delay (makes this sense in continuous??)        
        if (!(action_status & B01000000) && 
            !(action_status & B00010000) && 
            !(action_status & B00000100))  { 
          
          // do some continuous steps    
          doMotorContinuous();    
              
          // should we do focussing?    
          if (camera_focus_time > 0) {
            camera_focus();
          } else {
            // shoot camera 
            camera_shoot();
          }
          
        }
        
        // do some continuous steps    
        doMotorContinuous();
        
         // delete the start immediately flag if set
        if (action_status & B00100000) {
          
          // delete the start immediately flag
          bitClear(action_status, 5); // B11011111
        }
      }
      
      // do some continuous steps    
      doMotorContinuous();
      
      
      // is camera focussing right now?
      if (action_status &  B01000000) {
        
        // did we focus the time we wanted to focus?
        if((action_start_time + (unsigned long) camera_focus_time) <= millis()) {
                   
          // stop focussing (this function automatically starts the exposure)
          camera_stop_focus();
        
        } 
      }
      
      // do some continuous steps    
      doMotorContinuous();
            
      // is camera exposing right now?
      if (action_status &  B00010000) {
       
        // did we exposed the time we wanted to expose?
        if((action_start_time + (unsigned long)camera_exp_time) <= millis()) {
                    
          // stop shooting
          camera_stop_shoot();

        } 
      }
      
      // do some continuous steps    
      doMotorContinuous();
      
      // now check the limit switches if we need to stop the program
      // this function is called as late as possible after the key reading because
      // analogRead needs some pre delay time to deliver accurate measurements...
      check_limit_switches();
      
    }
    
    // =================================================
    // S H O O T - M O V E - S H O O T   m o d e
    // =================================================
    else {
    
      // if it is time or the "start a new cycle immediately" flag is set
      if ((action_status & B00100000) ||
          ((program_start_time + ((unsigned long) cycle_length * 500UL * (unsigned long) camera_shoot_count)) <= millis())) {
        
            
        // if not focussing or exposing right now and not in camera or motor post delay        
        if (!(action_status & B01000000) && 
            !(action_status & B00010000) && 
            !(action_status & B00000100) && 
            !(action_status & B00000001) )  { 
          
          // should we do focussing?    
          if (camera_focus_time > 0) {
            camera_focus();
          } else {
            
            // shoot camera 
            camera_shoot();
          }
        }
        
         
        // delete the start immediately flag if set
        if (action_status & B00100000) {
          
          // toggle the start immediately flag to off
          bitClear(action_status, 5);
        }
      }

      
      // is camera focussing right now?
      if (action_status &  B01000000) {
        
        // did we focus the time we wanted to focus?
        if((action_start_time + (unsigned long) camera_focus_time) <= millis()) {
                   
          // stop focussing (this function automatically starts the exposure)
          camera_stop_focus();
        
        } 
      }

      
      // is camera exposing right now?
      if (action_status &  B00010000) {
       
        // did we exposed the time we wanted to expose?
        if((action_start_time + camera_exp_time) <= millis()) {
          
          // stop shooting
          camera_stop_shoot();
          
        } 
      }
     
     
      // post exposure delay
      if (action_status & B00000100) {
      
        // did we exposed the time we wanted to expose?
        if((action_start_time + (unsigned long) camera_exp_time + (unsigned long) camera_exp_post) <= millis()) {
  
          camera_stop_post();
          
        }
        
      }
     
     // time for the engines
     if (action_status & B00000010) {
      
        // do the blocking motor phase with error check
        doMotorPhase(true);
        
        motor_stop();
        
        // now check the limit switches if we need to stop the program
        // this function is called after the blocking motor phase because
        // analogRead needs some pre delay time to deliver accurate
        // measurements...
        check_limit_switches();
        
     } 
     
     
     // motor post delay
     if (action_status & B00000001) {
     
       // did we waited the time we wanted to wait?
        if((action_start_time + (unsigned long) motor_post) <= millis()) {
  
          // clear the waintg flag...
          bitClear(action_status, 0); // B11111110
          
        }
     
     }
   
    } // operation mode
   
         
    // if the programm is running and we are in contiuous mode
    continuous_check();
            
  }  // program is running
  
  // read the time from the RTC (valid for the next loop)
  time = RTC.now(); 
   
  // if the programm is running and we are in contiuous mode
  continuous_check(); 
   
  // the function that checks if we need to start or stop a program
  check_programs();
  
  // if the programm is running and we are in contiuous mode
  continuous_check(); 
  
  // check if there are programs that will be triggered in the future
  // this is done for being able to display this information ("smart P")
  check_programFuture();
  
}

:cold_sweat: :cold_sweat: :cold_sweat: :cold_sweat: :cold_sweat: :cold_sweat:
Help !!!!

the code is old, requires a very old version of the IDE etc...

why don't you bite the bullet and go to the author's "newest" version (6 year old) you might get better luck (although seems this is all abandoned)

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.