PROJECT:
Hello, I am doing a project that involves a extending a boom from a metal housing, once it extends it dwells, then retracts back into the metal housing and the linear actuator extends (closes the door to housing). There are also cameras recording the whole time.
PROBLEM:
The linear actuator doesn't extend even though it is getting 24V (We measured with a Voltmeter and we tried switching polarity). The relay is also working and the lights turn on when we set the pins LOW signifying that it was triggered. We also measured continuity on the relay pins and the wiring was fine.
The odd thing is, if we set the linear actuator pin (actPin = 6) LOW in the setup, it closes properly. But, if we set it LOW after the code for our motor has run, it doesn't close, even though it seems to be getting 24V.
If anyone could help with this problem, thank you in advance! The parts are listed below, along with the code. Let me know if you need more information to help solve my problem. Again, thanks!
PARTS:
Cameras: GoPro Hero 3 (x 2)
Linear Actuator: https://www.amazon.com/gp/product/B01N9BUOSN?pf_rd_p=019ad97c-f176-43be-96b9-991a6dc65763&pf_rd_r=FH183YDP61JMC9JW4FSQ&th=1
Motor: 24Y - High Torque Stepper Motor (MODEL 24Y-308D-LW8)
int pulsePin = 3;
int dirPin = 5;
int enablePin = 4;
int cameraPin = 7;
int actPin = 6;
int fullIn = 9;
int fullOut = 8;
int timerEvent = 13;
int timerEventCam = 11;
int camOn = 0;
int motorSpeed = 600; //PWM pulse width in microseconds
//int stepsTen = 500; //(10/(motorSpeed*10^(-3)))/1; //number of steps for the for loop to go through to last for 10 secs
void setup() {
//setting up all output pins
pinMode(pulsePin, OUTPUT);
pinMode(dirPin, OUTPUT);
pinMode(enablePin, OUTPUT);
pinMode(cameraPin, OUTPUT);
pinMode(actPin, OUTPUT);
//Setting up all input pins
pinMode(fullIn, INPUT);
pinMode(fullOut, INPUT);
pinMode(timerEvent, INPUT);
//The relay is low logic activated so I initialize all of the relay pins to be high to prevent the relays for being tripped on from the start
//Also disable the motor so it's not taking any current.
digitalWrite(cameraPin, HIGH);
digitalWrite(actPin, HIGH);
digitalWrite(enablePin, HIGH);
// Serial.begin(9600);
}
void loop() {
//Statement triggers at .01s after launch to turn on the gopro right away
if (digitalRead(timerEventCam) == HIGH && camOn == 0 ){
//Triggering the GoPro to turn on and start recording
digitalWrite(cameraPin, LOW);
delay (500);
digitalWrite(cameraPin, HIGH);
//By writing this variable to something other than 0 this insures that this conditional is only true once and doesn't attempt to turn the camera on again
camOn = 1;
}
//If statement is checking the timer event line to see if it's time to start
//If timerEvent is LOW it skips the main code to the end and waits 100 mS before checking again
if (digitalRead(timerEvent) == HIGH) {
//Delay is to allow the main arduino to start collecting data before anything else happens
delay (5000);
//Enabling the motor and setting the direction
digitalWrite(enablePin, LOW);
digitalWrite(dirPin, HIGH);
//While loop will continure to pulse the motor until it recives a signal from the main arduino that the boom has fully deployed
while (digitalRead(fullOut) == LOW){
digitalWrite(pulsePin, HIGH);
delayMicroseconds(motorSpeed);
digitalWrite(pulsePin, LOW);
delayMicroseconds(motorSpeed);
}
Serial.println("out");
//Disable the motor and let the boom dwell for a period of time before briging it back in.
digitalWrite(enablePin, HIGH);
delay(5000);
digitalWrite(enablePin, LOW);
digitalWrite(dirPin, LOW);
while (digitalRead(fullIn) == LOW){
digitalWrite(pulsePin, HIGH);
delayMicroseconds(motorSpeed);
digitalWrite(pulsePin, LOW);
delayMicroseconds(motorSpeed);
}
Serial.println("in");
digitalWrite(enablePin, HIGH);
delay(500);
//Closes Actuator
digitalWrite(actPin, LOW);
delay(5000);
digitalWrite(actPin, HIGH);
//Turns camera off
digitalWrite(cameraPin,LOW);
delay(3000);
digitalWrite(cameraPin,HIGH);
//5 sec delay to allow the camera to save the previous video and save the file
delay(5000);
//Turns on cameras to record indefinintely
digitalWrite(cameraPin, LOW);
delay (500);
digitalWrite(cameraPin, HIGH);
//End the code
while(1);
}
}