USA
Toll Free: 1-800-676-6123
How to Control Your Actuators from Alternative Networks

How to Control our Actuators from Alternative Networks

Guest Writer
Guest Writer
PA Engineer

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 used our PA-14 Mini Linear Actuator for this experiment as it is one of our most popular actuators!

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.

Product List

The LC-201 is a 4-channel relay board, perfect for this application!

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.

Mini linear actuator by Progressive Automations

 

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.

Step by Step Instructions

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.

All actuators need a dependable power supply - we used the PS-20-12 here!

Raspberry Pi (server) Setup

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:

  1. Make sure that the Raspbian OS is installed on your pi. Click here for a step-by-step instruction on how to install this operating system on your Pi - it is probably the easiest way to install Raspbian and Pi.
  2. Connect your board to your WiFi. Click here for instructions on how to do this.
  3. Assign a static IP to your Raspberry Pi. Click here for details on how to do this.
  4. Create a new .py file in your Raspberry Pi and copy the following code to this file. When you run this code, your Pi will become a server which listens for your commands on port “6166”.

 

 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() 

Wiring

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.

Router Setup

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.

  1. Enter your router’s IP address and login to access the interface of your router.
    IP address

     

  2. Find the Port Forwarding

     

    Find the Port Forwarding

     

  3. Enter the static IP address of your Pi server and Public Port range - make sure that port 6166 is in this range.

     

     Public Port range

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.

Client Setup

  • To run client software on your device, install the Python 3.8 from their official website.
  • You might also want to install PyCharm which is a great and a very easy to use IDE.
  • Copy the following code:
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()

Conclusion

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!


    
  

Please wait...

...