The world of linear motion is fast paced and constantly evolving, and Progressive Automations is determined to remain at the forefront of these technological changes. Remote controlled actuators are become more diverse and dynamic. With this in mind, one of our engineers, Jake, decided to undertake an experiment to determine whether our linear actuators could be controlled from alternative networks.
We’re very excited to say that yes – you can! This article will provide a step-by-step on how you can achieve this, including a code example and the tools you will needed to establish a successful connection and ultimately control your actuator(s) online.
In the following example, we will explain how to control a linear actuator with a Raspberry Pi. the Raspberry Pi 4 is used to run the server software and receive commands for control of the actuator. Alternatively, a desktop and Arduino board can be used instead. If this is the route you choose, your PC would need to receive commands and communicate them to the Arduino board through a serial port.
The final control element is the PA-14 Mini Linear Actuator - one of the most popular models offered by Progressive Automations and the example we used for this experiment. Any model provided by Progressive Automations with a 12VDC/24VDC/36VDC/48VDC rating and brushed DC motor can be used instead of the PA-14 actuator. The provided code which is demonstrated below wouldn’t need any modifications should you choose a different actuator, but the current and voltage rating of the power supply would need to be checked before proceeding.
Here we will take you through exactly what Jake did when testing this setup, from initial set-up to the linear actuator’s wireless remote control.
The Raspberry Pi board is probably one of the best choices for this project. It is a microcomputer which runs the operation system, can be assigned an IP address and have GPIO pins as well.
To set up your Raspberry Pi with a linear actuator for this project:
import socket import sys # Create a TCP/IP socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Bind the socket to the port server_address = ('', 6166) print ('starting up on port ', server_address) sock.bind(server_address) # Listen for incoming connections sock.listen(True) GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.OUT) GPIO.setup(27, GPIO.OUT) while (True): # Wait for a connection print ('waiting for a connection') connection, client_address = sock.accept() print ('connection from', client_address) # Receive the data in small chunks and retransmit it data = connection.recv(16) print ("received:", data) # Output signal on GPIO depending on received command if data == b"ext": GPIO.output(18, GPIO.HIGH) if data == b"ret": GPIO.output(27, GPIO.HIGH) if data == b"close connection": break # Closing up the connection connection.close()
We have made wiring for this project as simple to follow as possible! Just refer to the wiring diagram on our site for the 4-Channel Digital Relay + Arduino Wiring of a Linear Actuator.
When your Pi is connected to your WiFi and has a static IP that you configured in the previous step, its time to setup port forwarding and IP filtering in your router! Port forwarding enables you to set up a router to transfer data which comes to a specific port on a certain device in your LAN. Let’s assume that your Pi server has a static IP address 192.168.1.69 and listens for commands on port 6166. You would need to set up your router to transfer data which comes on port 6166 to a device with the IP address 192.168.1.69.
The following steps show you how to do this:
Note: The interface of your router might look different to this example. In that case, please find instructions on how to perform this step for your router model.
For security reasons set up IP filtering. IP filtering allows you to specify the IP addresses of devices that are allowed to access and send commands to your Pi device over internet. Find the inbound filters setting and set IP addresses of devices that are allowed to access actuator(s) in this setting.
import socket import sys # Create a TCP/IP socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Connect the socket to the port where the server is listening server_address = ('Enter IP address of router in your pi’s LAN', 6166) print ('connecting to %s port', server_address) sock.connect(server_address) try: # Send data message = b'ret' print ('sending "%s"',message) sock.sendall(message) # Look for the response amount_received = 0 amount_expected = len(message) while amount_received < amount_expected: data = sock.recv(16) amount_received += len(data) print ('received: ', data) finally: print ('closing socket') sock.close()
At this point everything is set up to control any actuator within the mentioned criteria from Progressive Automations using the internet! By running the code, it gives you the ultimate convenience of controlling your actuators remotely, or as we like to call them ‘WiFi controlled actuators’. Thanks for reading this article – if you have any queries or if you want to see something experimented by one of our engineers, contact us and we’ll be happy to get in touch with you!