Asked — Edited

Linear Actuator Ezb Script

I have looked on the community and don't seem to be able to find a simple answer on how to control a Linear actuator.

What I am doing is making my Tin Man robot upper body rise up or down on command. I have a 12" actuator. It has two wires. To change directions you reverse the two wires. I would like to use one half of a Hbridge motor control. The motor control I have is a two in one Hbridge. I thought of using a movement control but I already have one controlling the wheels.

The linear actuator is moved by a 12v dc motor. I will power the actuator with 12v from my two twelve volt lead acid batteries. Do I just control the Hbridge with servo code. My linear actuator has limits up and down.


Upgrade to ARC Pro

Unlock the true power of automation and robotics by becoming a proud subscriber of Synthiam ARC Pro.


A servo is not a motor. A servo consists of a motor, gears, circuit board with intelligent logic AND a positioning sensor.

An hbridge merely moves a motor in one of two directions with stop

Find out more about a servo here, in ezrobot’s fantastic learn section:

Once you’ve become knowledgeable about what components make up a servo, and why’re they’re necessary for positioning, you can begin to understand how to apply that to your custom linear motor actuator. Compare a servo’s features to your linear actuator to understand what is missing...

What your application is missing are:

  • an hbridge to move the motor
  • a feedback system to know the position

Perhaps look into one of two solutions:

  1. use the pcb of a servo and it’s potentiometer mounted on the actuator to control an hbridge that moves the motor
  2. use a solution provided by dimension engineering which combines their sabertooth hbridge with kangaroo positioning

Thanks DJ. I have an hbridge I do understand the difference and how a servo works. I do not really need a feedback system as I will probably send an up command or a down command and let the limit switch on the actuator stop the motor.

I know this sounds crazy but I am trying to make this easy. If I connect one side of my Hbridge with two servo ports and connect the two wires from my actuator to motor one output what code would I need. Is it possible to use the limit switches to stop motor or will I have to add a potentiometer to make it work.

What would the script look like.


Script would just be digital on and off commands. See this excellent tutorial by @Rich for how to wire and control an H-Bridge. You could just use half of it for one motor/actuator.

You can certainly use the limit switches, but you will also want timers in your script to turn off the digital port some time after the movement stops if you are not going to provide position feedback.



Would it be difficult to add positioning feedback to the mechanism - since you're considering adding TWO limit switches?

Because what I recommend is taking the guts out of a servo and use its potentiometer and electronics connected to your HBridge - then you can use it as a servo.

See, if you take a servo apart and look at the PCB, it'll have two wires going to the motor. If you connect those two wires to an HBridge input with the potentiometer connected to the actuator, you just made a servo :D

Seriously - it'll be WAY easier and more robust to do it that way. The servo electronics are real tiny and won't occupy much space. The whole contraption will plug directly into the EZ-B and be controlled the same way a servo is.

An HBridge takes the logic voltage of two input pins to determine what direction to spin the motor - including braking. So, if you connect the two motor wires from a servo PCB to the HBridge inputs, the servo PCB can now control a motor based on the HBridge's power specifications.

As TechGuru said, if you depend on limit switches, you'll need a timer running. If you were to perform a swat analysis on these two scenarios, the servo PCB would win by a landslide.

So, if you're going through the effort of installing TWO (2) limit switches, that's twice the amount of work than installing a single potentiometer. servo method is half the work :D

And think of the dances and animations that you will have control of by using a servo control in ARC! Really bring your tin man to life


Sorry DJ. I must not have said that the Linear actuator that I purchased has already two limit switches. I like your idea about the servo mod.

Let me get this straight. The Ezb controller would send digital signals to the modified servo with the servo motor wires running to the servo motor and to the digital ports on the Hbridge in parallel. That would work? How will the dc output of the modified servo work through the Hbridge. If this will work it is a great idea. This would give a lot of control for the linear actuator.



Not a modified servo, a real Servo. A standard servo.

A modified servo does not have a positioning.

By adding the positioning potentiometer to your actuator, you can use the hbridge and servo pcb as a real regular servo in ARC.


Do you know about servo City linear actuators with PWM command ? They can be operated directly by EZB digital ports. They're real Servos. They're costly, but solve all problems.


I guess I used the wrong word. I meant the servo that I am going to hack the servo motor output. I called it modified as I modified it. Also I was have another question. Will the potentiometer be run long enough to allow the 1’ rise of my actuator. Actuators are run somewhat long to reach their height.

I also thought about coding the time the motor runs to adjust height. Would that be accurate enough. I imagine that the time wouldn’t be consistent and I would loose indexing.

Thanks for the heads up on the servo City actuator. I don’t know if they mill meet my needed specifications. I also know they are around 2 1/2 more expensive. I will check. Thanks Leonardo.



For a 12" stroke linear actuator:

Limit switches only: $104.95

Potentiometer & limit switches: $129.99

Linear Servo 299.99

for less than $25 you have a potentiometer.

maybe i'm wrong, but, it's not an easy task to add a potentiometer.


Servo City has a wide range for any requirements, 2" to 12" stroke, speed and strength as you want. No extra electronics needed. They cost 300 $.


While you guys are pouncing - find out if he has the actuator because it was free? It’s a 12volt one, so I assume it’s quite heavy duty. Might be worthwhile to ask some questions and explore what he’s got and why?

I do agree, if there’s an option to purchase a correct actuator for the application... if that’s part of the plan. But, if you came across this actuator currently in your possession for much less than a new $299 purchase, it’s going to be more cost effective to retrofit.

If 1 height is all you need, be potentiometer will do that, it’ll simply need a larger diameter wheel on the end. Or, you can look into getting a multi turn potentiometer from digikey - that’s the easiest and most robust solution.


I use to use a cable potentiometer on machines I built. Think of a retractable tape measure and how it works. Put a multi turn potentiometer in the middle of the drum and you have the concept.

Use a couple of pulleys to go around corners.

They work great for position feedback.


You can check this out.


will - those are great videos but they don't have positioning feedback so it doesn't work like a servo - a servo knows the position. This example you've provided only allows controlling the speed of a motor by means of an r/c servo input.

By having a potentiometer added to the actuator, the example i provided throughout this conversation would allow a servo control actually act as a servo - not control speed.

The conversation was never about controlling speed using a servo control. The conversation was about controlling output position like a servo does.

While there's been a bunch of input, no one read my posts with the intent of understanding the content. The purpose of my contribution was to provide a very simple and elegant solution that allows a linear actuator to act as a servo with precise control of positioning.

I recommend revisiting my previous posts in this thread. If I find time, i can draw a sketch for you - because i know this approach will be beneficial to many of you who create custom robots.


For long travel actuators a string pot works great. You can buy or build one. Pull the board out of a servo, hook the string pot to the where the old servo pot connected, connect the servo motor wires to an h bridge, connect the actuator motor wires to the h bridge out wires and you have a linear servo.

For short travel actuators, connect a spring loaded lever to the pot shaft, and connect a string to the end of the actuator or part you are moving. Wire this up the same as listed above.

I have used this in the past and it does work. You will need to mess with the pot values to get it to match the travel you want.

With the actuator Will mentioned, ( @$ 67.00) you can build a low cost servo for less than $150.00 with controller.


Hello everyone! Thank you all for the information in the thread! I am attempting to control a home made actuator with the hacked micro servo POT (following DJ’s suggestion for turning my actuator essentially into a servo) and am wondering where exactly the two wires (that would normally connect to the servo motor) plug into the H bridge. I’m using a an standard L298 bridge and a Pololu 12v motor.

Any help is appreciated!

  • Douglas :)

They connect to one of the Hbridge channel dual inputs.