AC Motor, 2 Solid State Relays - Defining Oscillation

I'm interested in trying to describe an oscillation by using an AC motor that does clockwise and counterclockwise. There are three wires. 2 of the wires control the direction.

I'm thinking of having each wire connected to a separate solid state relay for an arduino uno that would essentially power the related SSR on a direction, off, then the other SSR on and then off as a flicker. Would the following work?

My lack of understanding is the having the motor power on between 0-255. How does that relate to the duration? Or should I stick with HIGH and LOW?

For the code:

const int relayPinCC = 9; // set pin 8 for relay output counter clockwise
const int relayPinC = 10; // set pin 7 for relay output clockwise
int onDuration
int offDuration

void setup()
{
Serial.begin(9600); 
pinMode(relayPinCC, OUTPUT); 
pinMode(relayPinC, OUTPUT); 
randomSeed(analogRead(0));
}

void loop()
{
onDuration = random (3000, 60000);
offDuration = random (3000,60000);

analogWrite (relayPinCC, random(0, 255));
analogWrite (relayPinCC, LOW);
analogWrite (relayPinC, random(0, 255));
analogWrite (relayPinC, LOW);
delay(onDuration);
analogWrite (relayPinCC, LOW);
analogWrite (relayPinC, LOW);
delay(offDuration);
}

}

Thank you

The solid state relay can either be triggered on or off so using analog value doesn't make sense.

Since it takes some time for the motor to react (inertia) you can probably control it simply by switching it on & off. But if you need precise position-control you'll need something to sense the position and use that as feedback to the software.

That probably won't work with most AC SSRs.

analogWrite() is PWM which switches on & off quickly to "simulate" analog. It can be used to control the speed of a DC motor, to dim a DC light bulb, or to make an LED appear dim.

But most AC SSRs are made with a TRIAC. Once a TRIAC is switched on, it latches-on until current drops to zero, which with AC is the next zero crossing. (If you use that type of SSR in a DC circuit it won't shut off until you remove power.)

A standard light dimmer uses a TRAIC by synchronizing to the AC cycle and switching it on part-way through each half-cycle and it remains latched-on until the end of the half-cycle (the next zero crossing). That's "similar" to PWM.

1 Like

Thank you.

So it's better to just stick using HIGH and LOW?

And digitalWrite instead?

Thank you

I really don't know precise controls.

I'm trying to randomize flickering of clockwise and counterclockwise to look like it's vibration.

My intention is to hang something to the motor and simulate movement/wind.

You should post the motor model and specs. Are you absolutely certain that you don't swap the two wires to change direction? If so, you need an H bridge, not separate relays to disconnect one lead or the other.

on/offDuration don't seem to be related to time and it looks like you're enabling both directions simultaneously

if you're trying to move the motor randomly in either direction for a random amount of time as well as stopping the motor for a random amount of time, shouldn't there also be a random variable that determines the direction?

shouldn't the appropriate relay depending on the direction be enabled for the onDuration, then disabled (motor off) for the offDuration?

consider

#define MyHW
#ifdef MyHW
# include "sim.hh"
const int relayPinCC = 13;
const int relayPinC  = 12;

#else
const int relayPinCC = 9; // set pin 8 for relay output counter clockwise
const int relayPinC = 10; // set pin 7 for relay output clockwise
#endif


#define MinOnOff    1000
#define MaxOn       3000 
#define MaxOff      3000 

// -----------------------------------------------------------------------------
void setup()
{
    Serial.begin(9600);
    pinMode(relayPinCC, OUTPUT);
    pinMode(relayPinC, OUTPUT);
    randomSeed(analogRead(0));
}

void loop()
{
    if (0 == random (0, 2))
        digitalWrite (relayPinCC, HIGH);
    else
        digitalWrite (relayPinC,  HIGH);

    delay (random (MinOnOff, MaxOn));

    digitalWrite (relayPinCC, LOW);
    digitalWrite (relayPinC,  LOW);

    delay (random (MinOnOff, MaxOff));
}

It's an old motor.

Janette Gear Motors and Speed Reducers
Model A11
Output RPM 160
Output Torque 6 lbs in
HP: 1/50
Duty: Cont
PH: 1
Current: 9A
Volt: 115V
Frame: KL16
60hz

Thanks GCJR.

I'm trying to have the motor flicker a clockwise, stop then counterclockwise stop that'll cause short burst of movement, then be delayed for a random amount of time.

If not, maybe I'm limited to only having it run one direction at time for a random duration.

The goal is have an indoor hanging art mobile that turns on its own by the wind or so.

I guess it's simliar to baby's hanging crib mobile.

I just imagined a 5 pound motor hanging above a babies crib. What's the worst that could happen? :smiley:

1 Like

so it would just alternate directions.

#define MyHW
#ifdef MyHW
# include "sim.hh"
const int relayPinCC = 13;
const int relayPinC  = 12;

#else
const int relayPinCC = 9; // set pin 8 for relay output counter clockwise
const int relayPinC = 10; // set pin 7 for relay output clockwise
#endif

bool dir;

#define MinOnOff    1000
#define MaxOn       3000 
#define MaxOff      3000 

// -----------------------------------------------------------------------------
void setup()
{
    Serial.begin(9600);
    pinMode(relayPinCC, OUTPUT);
    pinMode(relayPinC, OUTPUT);
    randomSeed(analogRead(0));
}

void loop()
{
    dir = ! dir;
    if (dir)
        digitalWrite (relayPinCC, HIGH);
    else
        digitalWrite (relayPinC,  HIGH);

    delay (random (MinOnOff, MaxOn));

    digitalWrite (relayPinCC, LOW);
    digitalWrite (relayPinC,  LOW);

    delay (random (MinOnOff, MaxOff));
}
1 Like

Thanks GCJR. It looks like I'll be limited to a Solid State Relay. H Bridges wouldn't work with this motor that I'm limited to using.

I had hooked up the motor as a test and the reduction gear kept it slow so I won't need might to worry about turning off one relay to and turning the other one on to have it simulate a stutte. I decided to just control one rotational direction at time based on a random duration to keep it simple.


#include <Arduino.h>

const int relay1 = 10; // Solid State Relay 1 - Clockwise
const int relay2 = 9; // Solid State Relay 2 - Counter Clockwise

void setup() {
  pinMode(relay1, OUTPUT); 
  pinMode(relay2, OUTPUT);
}

void loop() {
  int duration1 = random (1000, 15000); // Random duration between 1 - 15 seconds
  int duration2 = random (1000, 30000); // Random duration between 1 - 30 seconds

  int option = random(0, 3); // runs an option - 0, 1, 2, or 3
  switch (option) {
    case 0:
    digitalWrite(relay1, HIGH);
  if (digitalRead(relay1) == HIGH) {
    // If the first relay is running, don't run the second relay
     digitalWrite(relay2, LOW);
     delay(duration1);
     break;
  }
    case 1:
    digitalWrite(relay2, HIGH);
  if (digitalRead(relay2) == HIGH) {
    // If the second relay is running, don't run the first relay
    digitalWrite(relay1, LOW);
    delay(duration1);
    break;
  }
    case 2:
      digitalWrite(relay2, LOW);
      digitalWrite(relay1, LOW);
      delay(duration2);
      break;

    case 3:
      digitalWrite(relay2, LOW);
      digitalWrite(relay1, LOW);
      delay(duration1);
      break;
  }
}

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