Tuesday, 31 October 2017

How To Use A Linear Actuator Control Board With Arduino

Arduino linear actuator control


Over the past few years, our support department has been receiving more and more questions about how to use a linear actuator with Arduino. We have never officially offered Arduino support. We have a couple of resources on our website and we've directed many people to Robot Geek and a couple of other Arduino pros.

The problem with this is that none of those resources cover how to drive a -P series linear actuator via Arduino and a Linear Actuator Control (LAC) board.

I thought it was time that I did a basic tutorial on how to accomplish this. I'm going to show you how to make the physical connection between the two boards, as well as cover a couple of common issues that our customers have. This will serve as the basis for any additional learning you may want to do with Arduino and linear actuators.

We'll start by going through the things that you will need to operate an actuator via Arduino.

1. -P Series Micro Linear Actuator

Our -P series micro linear actuators are designed to be operated via our LAC board. Using the board's RC input mode, you can effectively control your -P series actuator as you would an RC linear servo.

You can only use -P series feedback actuators with the LAC board. -R, -S and -I actuators will not work.

2. LAC board

As mentioned above, our LAC board was developed parallel to our -P series actuators, and the two are meant to be used together. The LAC board will also work with some larger actuators that offer position feedback. We do not sell such actuators however and can not offer support for this usage.

3. Arduino Board

We often use an Arduino Mega or an UNO around here for various experimentation and testing.

3. Source of Power

You will need either a battery or a power supply to power both your Arduino board and your LAC board. The power supply for your LAC must match the voltage of the actuator and the power supply for your Arduino must be appropriate for the board.

4. Potentiometer Or Another Way To Drive The Actuator

You will need a control mechanism of some type if you want to drive the actuator manually. You can also cycle the actuator using code, which is what we have done here. The code used to drive the actuator in our example is a modified version of the 'servo-sweep' example found in the Arduino library.

Why use an LAC board with Arduino

Using an -R series linear actuator is the simplest way to drive a linear actuator via Arduino. The -R actuators use the same 3-wire connector as a standard hobby servo. The LAC board however, offers a couple of advantages over just using Arduino and an -R series micro linear servo.

The first is that the LAC board allows you to monitor the position of the actuator using the position feedback signal. This is ideal for situations where you can't see the actuator, but want to monitor where it is along it's stroke.

Another reason to use an LAC and -P series device is that the LAC board offers you direct control over certain aspects of how the actuator functions. The LAC has 4 pots on it that allow you to control speed, sensitivity, and both extended and retracted end-of-stroke limits.

Of course, this setup might just happen to be what you have on-hand. If that's the case, keep reading and I'll show you how to get your setup working via arduino.

Wiring The LAC To The Arduino

There are a few things to understand when you're trying to use an LAC via Arduino:

  • First, as mentioned above, you are going to need an external power supply. You can use the same power supply to power both your Arduino board and your LAC board provided the input voltage of your Actuator and your Arduino is the same, but each board must be powered directly.
  • Second, the Arduino and LAC must share a common ground to function correctly. This is the most common issue our customers have when trying to drive their actuators this way.

Below is a wiring diagram showing how we've connected the  LAC board to our Arduino Uno.

linear actuator control board via arduino


The actuator is plugged into the board as usual. We're using the RC output on the LAC to connect the Arduino board via standard RC cable (red/black/white). The red wire has been cut at the LAC as it's not used. The black wire runs from the RC plug on the LAC to gnd on the arduino board. This is the common ground we mentioned before. The white RC wire runs from the RC output on the LAC to pin-9 on the Arduino.

That's it for interfacing the LAC and arduino, but now you need power. We have powered the LAC with a 12V power supply (this matches the 12V actuator) into the + and - terminals on the X6 block, as per the LAC datasheet.The Arduino board is powered by it's own 6V power supply with positive plugged into the -vin terminal, and - plugged into -gnd.

As for code, we used a slightly modified version of the Servo-Sweep example found the Arduino software.

As you can see, this is a relatively basic way to cycle the actuator in and out.

If you are so inclined, you can use your own code and a switch of your choosing to actuate the device another way. This could be via a push button, proximity sensor or any other Arduino-compatible sensor you choose


Below is the code that we used for this example. It is the basic Servo-Sweep example code from within the Arduino software. The only part we modified is the delay.

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(30);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(30);                       // waits 15ms for the servo to reach the position
  }
}


No comments:
Post a Comment