In this post, we will be going over how to use relay boards to control the motion of linear actuators. We have 2-channel, 4-channel and 8-channel relay boards available and each one does the same thing, the only difference is how many channels are being used. We will be combining the relay boards with our LC-066 Arduino Uno to show off their control capabilities. The relays control the direction in which the actuator moves. They work by using current from the input source to activate an electromagnet, which pulls a switch that allows higher currents on the opposite side of the relay to flow.
On the control side of our relays you will find a GND pin, IN pins numbered from 1 to 8 depending on the relay model, and a VCC pin. Our relays require a fair amount of power to stay activated so we'll need at least a stable 5V power supply. Otherwise, the Arduino will have trouble powering the higher channel relay modules. Usually, they can produce a few hundred milliamps which are more than enough to power a 2 channel relay module like our LC-200 but nowhere near enough for an 8 channel relay module like our LC-202. For this example, we'll be using the 2 channel relay. As for wiring the relay modules you'll need to follow some simple steps.
On the control side of the relay, first, we need to connect our 5V power supply to the VCC and GND pins. Next, we'll need to connect the IN pin to the corresponding Arduino pin, then the relays will activate once the IN pins are connected to the GND pins. On the relay side, there are three main parts of each relay, three screw terminals.
These terminals are referred to as the Normally Closed (NC) connection, the top one, the Common (COM) connection, the middle one, and the Normally Open (NO) connection on the bottom. If there are no connections to the IN pin then the relay will connect between the NC and COM terminals. If the 5V power source is connected to the IN pin then the relay will connect between the NC and COM terminals as well. Finally, if you connect the IN pin to the GND pin the relay will connect between the NO and COM terminals.
Now that everything is wired up its time for some basic coding with the Arduino Uno. Below is an example showing how the programming works.
const int forwards = 7;
const int backwards = 6;//assign relay INx pin to arduino pin
void setup() {
pinMode(forwards, OUTPUT);//set relay as an output
pinMode(backwards, OUTPUT);//set relay as an output
}
void loop() {
digitalWrite(forwards, LOW);
digitalWrite(backwards, HIGH);//Activate the relay one direction, they must be different to move the motor
delay(2000); // wait 2 seconds
digitalWrite(forwards, HIGH);
digitalWrite(backwards, HIGH);//Deactivate both relays to brake the motor
delay(2000);// wait 2 seconds
digitalWrite(forwards, HIGH);
digitalWrite(backwards, LOW);//Activate the relay the other direction, they must be different to move the motor
delay(2000);// wait 2 seconds
digitalWrite(forwards, HIGH);
digitalWrite(backwards, HIGH);//Deactivate both relays to brake the motor
delay(2000);// wait 2 seconds
}
We've included a video showing off what we talked about in this article, be sure to check it out and stay tuned for more videos like it in the coming weeks. In conclusion, using relays to control linear actuators allows for some creative control options like the one we went over above and combining them with other motion control devices provides even more capabilities. If you want to learn more about our linear actuators and motion control devices check out our blog for a variety of different articles like this. You can also contact us and talk to one of our on-staff expert engineers to answer some of your more specific questions.