Save money on your purchases by earning redeemable points with Progressive Rewards!
The world of linear motion is fast paced, and constantly evolving. Progressive Automations is determined to remain at the forefront of these technological changes. Remote controlled actuators have 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. This is indeed possible. Thus, this article will provide a step-by-step on how it can be achieved. It also includes a code example and the tools one would need to establish a successful connection and ultimately control the actuator(s) online.
The PA-14 Mini Linear Actuator is 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 would not require any modifications should one choose a different actuator, but the current and voltage rating of the power supply would need to be checked before proceeding.
The experiment details provided will provide an explanation on how 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 Raspberry Pi is a single-board computer, roughly the size of a credit card. This micro-computer was developed in the UK for use in teaching basic computer knowledge.
The Raspberry Pi has all the attributes of a real computer including a dedicated processor, memory, and graphics driver for HDMI output. It even runs a special version of the Linux operating system. This makes it easy to install most Linux programs and connect linear actuators to Raspberry Pi. This allows the Raspberry Pi to be used for actuators, as a full-fledged media server, or as a videogame emulator.
There is no internal data storage on the Pi, but one can use a smart card as a flash memory serving the entire system. This allows one to quickly download different versions of the operating system or software updates for debugging. As this device provides independent connectivity over the network, it can also be configured for SSH access or FTP file transfer.
The following demonstrates the exact steps taken by Jake when testing this setup, from initial set-up to the linear actuator’s wireless remote control.
As the Raspberry Pi board can be assigned an IP address and have GPIO pins, along with its aforementioned functions, it acts as the best device for such an experiment.
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()
For clear instructions on the wiring for this project, a diagram is provided at the following link: 4-Channel Digital Relay + Arduino Wiring of a Linear Actuator.
Once your Pi is connected to your Wi-Fi and has a static IP that you configured in the previous step, you can begin in setting up 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.
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.
We would advise setting up IP filtering at this point for security purposes. IP filtering allows you to specify the IP addresses of devices that are allowed to access and send commands to your Pi device over the 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()
As stated at the beginning of the article, it is possible to make use an Arduino board instead of a Raspberry Pi. Firstly, it is important to note what the Arduino boards are. These microcontrollers execute codes interpreted by the firmware. They are not fully-featured computers thus do not have an operating system per se. One may not have the basic tools provided by the operating system, but it does make the direct execution of simple code easier.
There are also no costs associated with this operating system. The main purpose of the Arduino Board is to interact with sensors and devices, making Arduino great for hardware projects aimed at evoking a response to different sensor signals and manual input. It is perfectly suited for the articulation of other devices and actuators, where a full-featured operating system is simply not required.
Choosing between the Raspberry Pi and the Arduino would greatly depend on the project it is required for.
It would be better to choose the Arduino if one’s main task is to read data from sensors or change values on the engine and other devices. Given the requirements of Arduino power supply and ease of maintenance of this system, the device can be operated without turning off with close to no interfering with its operation.
The Raspberry Pi on the other hand would be more practical when solving tasks that would be performed on a personal computer. Raspberry Pi simplifies workflow management in various scenarios like if one needed to connect to the Internet to read or write data, play any media, or connect to an external display.
Given that Arduino and Raspberry Pi solve different tasks, in certain situations it is convenient to use these devices together. When connecting these two devices one would be able to get client access to settings and code through the Pi, while the Arduino controls the actuators and collects information from the sensors. One can connect these two devices via USB, LAN or connecting Arduino I/O ports to Raspberry Pi.
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!
We have detected your location to be from outside of the US, would you like to go to our Canadian Store?