We are spending the day trying to hack an AC motor for use at a trade show. We do not need to control the speed of the motor, just direction.
We are running into trouble today controlling both directions. We were able to control just one direction before with two relays. This time, we added two more relays and the motor stops working on either direction. The problem we’re trying to solve today is to control both directions at its full speed.
Here are some steps that we took and image reference:
————————————————————————->
We were able to control the SSRs with arduino and the code below,
You can see from the video
We are using this motor:
http://www.harborfreight.com/880-lb-electric-hoist-44006.html
which has a 25% duty cycle.
It has a built-in motor controller, and the motor comes with a pendent switch to control the direction.
We are using four of these
Amico 250V 25A SSR-25DA Temperature Control Solid State Relay
to hack the motor pendent switch.
We are using the datasheet from the motor’s manufacturer.
Marcela and Eric Rosenthal colored it and drew the connections from the pendent switch to Solid State Relays and an Arduino:
The wiring look like this:
Here's the code that we're using:
————————————————————————->
//Another experimental code that we’re working on add a equation for the 25% duty cycle, still it’s not working with the motors but it can controls the solid state relays
int SSRPin1 = 5; // motor forward
int SSRPin2 = 6; // motor backward
//int val = 200; // variable to store the read value
void motorForward();
void motorBackward();
int secondsForLift; // how long should the lift be in seconds
float pctLiftToTotalTime; // duty cycle — how much one cycle is lift = 25% = 2.5 second lifting, 7.5 seconds waiting
int totalCycle; // lift + rest = one full cycle.
// pctLiftToTotalTime = pct of x’s per total: xxxx—— = 50%
// totalCycle = how long is the whole sequence: xxxx—— = 8…
//————————————————————————————————-
void setup() {
Serial.begin(9600);
pinMode(SSRPin1, OUTPUT);
pinMode(SSRPin2, OUTPUT);
secondsForLift = 5; // one second
pctLiftToTotalTime = 0.25; // 25% duty cycle
totalCycle = secondsForLift * (1 / pctLiftToTotalTime);
// 0.25X = 60 (sec) X = 60 (second) /25%
}
//————————————————————————————————-
void motorStop(){
digitalWrite (SSRPin1, LOW);
digitalWrite (SSRPin2, LOW);
Serial.println(“stopped”);
}
//————————————————————————————————-
void motorForward() {
analogWrite (SSRPin1, 253);
digitalWrite (SSRPin1, HIGH);
digitalWrite (SSRPin2, LOW);
Serial.println(“forward”);
}
//————————————————————————————————-
void motorBackward() {
analogWrite(SSRPin2, 253);
digitalWrite(SSRPin1, LOW);
digitalWrite(SSRPin2, HIGH);
Serial.println(“backward”);
}
//————————————————————————————————-
void loop(){
unsigned long millisecond = millis(); // todo: check if this wraps over
Serial.println(millisecond);
unsigned long totalCycleInMillis = totalCycle * 1000;
unsigned long whichCycle = millisecond / totalCycleInMillis; // which cycle is a counter that keeps increading (0,1,2,3…)
boolean bForward = whichCycle % 2 == 0 ? true : false; // we are going forward if the counter is even….
boolean bMoving = (millisecond % totalCycleInMillis < secondsForLift*1000) ? true : false;
// bMoving = are we in or out of duty cycle
// bForward = are we going forwards or backwards
if (bForward && bMoving) motorForward();
if (!bForward && bMoving) motorBackward();
if (!bMoving) motorStop();
}
}other links:
The code we were using were based on Computergeek’s instructables: