How To Control The Timing Of A Linear Actuators Motion

How to Control the Timing of a Linear Actuators Motion?

Guest Writer
Guest Writer
PA Engineer

In our latest "How To" post, we will be going over how to control the timing of a linear actuator's motion using a microcontroller. Microcontrollers give a lot of freedom in motion control and this is just one example of an almost endless amount of motion control options available. Depending on your application, the example project in this article can be adjusted to suit your requirements, whether you add another timed actuator or beef up the power supply to handle a stronger linear actuator, it is all up to you.

 

Motion Control Using a Microcontroller

An Arduino microcontroller will be used to control the motion timing of a linear actuator, but any microcontroller will work. However, since we are using a shield, the microcontroller needs to be compatible. We are going to walk you through the various parameters that you can adjust to change the speed of a linear actuator.

 

What You Will Need

For this example, we will be using the following components for controlling a linear actuator:

 

Connecting Components

Now that we have our supplies, we will need to connect everything. Thankfully, connections are simple by using a shield as opposed to a separate board that requires additional wiring and soldering.

First, let's connect our actuator to our LC-80 MegaMoto Plus shield by attaching the two wire leads from the actuator to the A/B screw terminals on the LC-80. Then, we need to connect the LC-80 to our power supply, in this case, the PS-20-12. We do this by attaching positive and negative wires from the power supply to the BAT +/- terminals of the LC-80.

Finally, we need to connect the LC-80 to the LC-066, which is as simple as sticking it on top of one another as shown in the image below.

 

Photo of microcontrollers by Progressive Automations


Adjusting the Code

For us to get full control over our actuator's motion, we will need to do some linear actuator programming with our Arduino unit. We've prepared an example code that has our actuator extending and then retracting for 10 seconds each way for a 300-second cycle.

//Use the jumpers on the board to select which pins will be used

int EnablePin1 = 13;

int PWMPinA1 = 11;

int PWMPinB1 = 3;

int extendtime = 10 * 1000;  // 10 seconds, times 1000 to convert to milliseconds

int retracttime = 10 * 1000; // 10 seconds, times 1000 to convert to milliseconds

int timetorun = 300 * 1000; // 300 seconds, times 1000 to convert to milliseconds

int duty;

int elapsedTime;

boolean keepMoving;

void setup() {

  Serial.begin(9600);

  pinMode(EnablePin1, OUTPUT);//Enable the board

  pinMode(PWMPinA1, OUTPUT);

  pinMode(PWMPinB1, OUTPUT);//Set motor outputs

  elapsedTime = 0; // Set time to 0

  keepMoving = true; //The system will move

}//end setup

void loop() {

  if (keepMoving) 

  {

    digitalWrite(EnablePin1, HIGH); // enable the motor

    pushActuator();

    delay(extendtime);

    stopActuator();

    delay(10);//small delay before retracting

    pullActuator();

    delay(retracttime);

    stopActuator();

    elapsedTime = millis();//how long has it been?

    if (elapsedTime > timetorun) {//if it's been 300 seconds, stop

      Serial.print("Elapsed time is over max run time. Max run time: ");

      Serial.println(timetorun);

      keepMoving = false;  

    }

  }//end if

}//end main loop

void stopActuator() {

  analogWrite(PWMPinA1, 0);

  analogWrite(PWMPinB1, 0); // speed 0-255

}

void pushActuator() {

  analogWrite(PWMPinA1, 255);

  analogWrite(PWMPinB1, 0); // speed 0-255

}

void pullActuator() {

  analogWrite(PWMPinA1, 0);

  analogWrite(PWMPinB1, 255);//speed 0-255

}

 

It is important to walk through the code, line-by-line to try and understand what is going on. By doing so, you can customize the code to do a whole host of other tasks. However, for now, the most important part is the first section and the setup loop, which that focuses on assigning pins and setting the cycle speed.

You need to configure the pins on our LC-80 to match what is in the first section of the code by setting the jumpers on the LC-80 or adjusting the code. In this case, set the "Enable" pin to D13, the "PWMA" pin to D11, and the "PWMB" pin to D3. The “Enable” pin is what controls and powers the motor and without it, the actuator will stop moving and will not be able to be controlled. The “PWMA” and “PWMB” pins control the extension and retraction of the actuator. We don't need the "Sensor" pins in this example so don't worry about selecting anything there.

The timer control of a linear actuator is now complete. You can upload the code to the Arduino by using their IDE (download from the Arduino website). Once you have your linear actuator extending and retracting, why not play around with the code a bit? Try and adjust the extend/retract time within the code, re-upload it to the Arduino, and see how the linear actuator responds. By adjusting these numbers in the code, you can control the speed and total motion cycle time based on your desired application.


Conclusion

Below we have included a video of a timing actuator in action. For the video example, we wanted to show off another way you can alter the timing, so we made it extend and retract for 5 seconds at a time over a 20-second cycle.

As stated earlier, this is just one example of a way you can alter the motion of an actuator with the help of our microcontrollers. If you have your own custom control method in mind, you can have a control system built specifically to your custom requirements with the help of our talented engineering staff. They will guide you through the process and make sure you have full control over your units. If you'd like to learn more about the custom order process take a look at our custom order page.

Please wait...

...