Hi brains trust,
I’ve got motorized camera slider project that I need help troubleshooting please. I am relatively inexperienced at Arduino builds so I’d appreciate some guidance. I've posted this in the code section but I'm not sure if it's a hardware or software issue.
Project brief: The project is designed to trigger a camera x number of times, then move a stepper y steps and then repeat. Within each stage there are various delays for shake etc. No great task I know.
My problem is that the system will run just fine, then at some random stage it will stop triggering the camera and only execute the stepper part of the loop. The old intermittent fault scenario. Being new to this I cant tell if it's a hardware or code issue.
I have a full set of replacement hardware components in various stages of delivery to make sure it isn’t a fried component.
Hardware:
Arduino nano (bought a while ago so not sure if it’s genuine or knockoff. Genuine Nano Every is in the mail).
EasyDriver v4.4 with a NEMA 17 stepper
Trigger pins for the camera are routed through 4N25 optoisolators with appropriate resistors on the Arduino side to manage the forward current of internal opto LEDs.
Camera is a Panasonic GH5s. The Panasonic trigger signal is an annoyingly non-standard one, relying on 2 pins only with changes in resistance triggering the shutter. I purchased a manual remote trigger unit including appropriate resistors so I didn't have to deal with the prospect of frying the inside of my camera with using the incorrect resistors. The manual unit triggers the shutter reliably simply by closing the shutter and focus contacts to ground with a pushbutton. My optoisolator outputs go to the manual contacts in the manual trigger unit with the same effect.
Code is below, parts I have constructed, other parts I have borrowed from various examples/tutorials. Comments are so I can bumble my way around my own code.
Any advice on which parts of the hardware or code to look at for the fault would be greatly appreciated. I'm banging my head on a wall here at the moment and will need this kit working soon or I'll miss my opportunity until next year.
Thanks, Mat
int smDirectionOut = 9; //Direction pin out
int smDirectionIn = 5; //Direction Pin in (switch)
int smStepPin = 11; //Stepper pin
int smEnablePin = 10; //Motor enable pin
int camFocusPin = 3; //optoisolated focus pin
int camShootPin = 2; //optoisolated shoot pin
int waitSwitch = 8; //wait switch pin
//SETUP STATE
void setup() {
pinMode(smDirectionOut, OUTPUT);
pinMode(smDirectionIn, INPUT_PULLUP);
pinMode(smStepPin, OUTPUT);
pinMode(smEnablePin, OUTPUT);
pinMode(camFocusPin, OUTPUT);
pinMode(camShootPin, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(waitSwitch, INPUT_PULLUP);
Serial.begin(9600);
}
//MAIN LOOP
void loop() {
int frames = 300; // how many frames are required?
Serial.println("waiting for go");
delay(100);
if (digitalRead(waitSwitch) == 0) {
digitalWrite(smEnablePin, LOW); //engage stepper
for (int f = 0; f < frames; f++) {
rotate(135, 0.1); //number of steps, speed between -1 and 1
Serial.println("move");
shoot (1000, 5, 3000); //shake delay Ms, number of stacked shots,intershot delay Ms *exposure plus rest*
Serial.println(f + 1);
}
}
}
//START OF FUNCTION DEFINITIONS
//Stepper function 'rotate'
//accepts 2 arguments : 'steps' and 'speed'
void rotate(int steps, float speed) {
// digitalWrite(smEnablePin, LOW); //Enabling the motor
int direction;
if (digitalRead(smDirectionIn) == HIGH) {
direction = HIGH;
} else {
direction = LOW;
}
speed = 1 / speed * 70; //Calculating speed
steps = abs(steps); //Stores the absolute value of the content in 'steps' back into the 'steps' variable
digitalWrite(smDirectionOut, direction); //Writes the direction (from the if statement above), to the EasyDriver DIR pin
//Actual stepping loop
for (int i = 0; i < steps; i++) {
digitalWrite(smStepPin, HIGH);
delayMicroseconds(speed);
digitalWrite(smStepPin, LOW);
delayMicroseconds(speed);
}
}
//Camera function 'shoot'
//accepts 3 arguments 'preshotDelay', 'stackNumber', 'intershotDelay',
int shoot(int preshotDelay, int stackNumber, int intershotDelay) {
delay(preshotDelay); // wait to minimise stepper shake.
for (int s = 0; s < stackNumber; s++) {
digitalWrite (camFocusPin, HIGH); //focus actuation
Serial.println("FocusPin");
delay(200); //focus duration
digitalWrite (camShootPin, HIGH); //shutter actuation
Serial.println("ShootPin");
delay(200); //shutter duration
digitalWrite (camFocusPin, LOW); //returning focus pin to low
digitalWrite (camShootPin, LOW); //returning shutter pin to low
delay(intershotDelay); // delay between shutter actuations
}
}
