Linear Actuator control with Arduino Uno

Hi there,

I have recently bought a cheap linear actuator from ebay see link to model and specs here: http://www.ebay.co.uk/itm/390595957552?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

I am afraid I am new to controlling motors with an arduino and so need help with pretty much everything, as there does not seem to be a tutorial which I can find online for wiring up an arduino uno with a linear actuator.

Please see what I would like to know below:

  1. How do I wire up my linear actuator to my arduino uno? (Do I need any extra components for the circuit? resistors etc...)

  2. How do I control my actuator, what code do I use? I need to be able to turn off for a certain amount of time then turn on for a certain amount of time, extending and retracting fully each time.

  3. Eventually I need to control around 8 of these motors with the arduino, is this possible and what would I need circuit-wise in order for this to work?

Sorry for the total novice status here, any help would be much appreciated and if someone would like to write a tutorial on the topic I would be much obliged!

Aphra

A linear actuator is a motor. It moves something in a straight line instead of moving in a circle. Use all code and hardware like a motor or stepper motor. Study the written text and diagrams for your linear actuator and connect wires, transistors and diodes, resistors, and Arduino pins like for a motor. The Arduino is not powerful enough to drive the actuator directly.

Well you do know that radio control aircraft use standard rotary servos to control flight using linear movement by using servo arms and push rods thereby converting to linear motion actuators?

Depending on the actuator stroke length and force requirements your require, you might find that R/C servos are your best choice from a price/performance basis. Servos are available in about any size/torque requirement you might have and the rest is just mechanical design to convert to linear motion.

Lefty

Aphra:
I am afraid I am new to controlling motors with an arduino and so need help with pretty much everything, as there does not seem to be a tutorial which I can find online for wiring up an arduino uno with a linear actuator.

Most linear actuators are simply DC motors connected mechanically (via a gear train) to move a shaft in some linear manner. In your case, it is fairly apparent how this is being accomplished, via probably a simple spur-gear drive to a rack gear that is the linear motion part you see sticking out of the case of the actuator. Fairly straightforward. I won't go any further on this or other linear actuators or how they work; plenty can be found online.

This particular actuator you have, though, was likely meant for an automotive application - so keep that in mind. Generally, this may mean that the current the motor draws could be quite substantial at startup and during running. So, in order to move forward properly, you -must- know what that current need is (especially if you plan to drive 8 of them later - so you can size your power supply).

The best way to do that on this actuator to avoid damaging it would be to open the actuator up, locate the motor, and attempt to disconnect the motor from the geartrain (additionally, this will also allow you to assess the geartrain and its construction, and also whether the grease and such in it needs to be cleaned and replaced - remember, these are likely used and/or surplus devices, and as such may need a bit of TLC to get them into best running). Basically - you just want the motor to be free spinning, so you can move the rotor by hand.

Once you can do that, hook a multi-meter set to measure resistance to the yellow and orange wires (according to the ebay writeup, these are supposed to be the wires that control the motor - in fact, they should almost directly lead to the motor's terminals). Slowly rotate the shaft of the motor, noting the resistance on the meter. Mark down every value you can read; make sure you rotate the shaft a least one full turn - you may want to rotate it a few turns, noting the common values. Once you know these values, take an average of them - that will give you the overall rotor coil resistance. You know the voltage of the motor (12 volts), so, apply Ohm's law to get the current. This will be the stall current of the motor, the maximum it can pull.

After you have done this, re-assemble the gearbox with the motor, etc (do any cleaning and re-lubing of the mechanism if you think it needs it - be sure that if you do this, that you use an appropriate grease for the job - automotive wheel bearing grease will probably work fine).

Aphra:

  1. How do I wire up my linear actuator to my arduino uno? (Do I need any extra components for the circuit? resistors etc...)

Ok - once you know the stall current (and you already know the voltage) of the actuator, you can then move forward. What you need to purchase or construct, in order to control the motor of the actuator, is called an h-bridge driver circuit. These can be constructed in a variety of ways, from simple relays to transistors to integrated circuits. Which you use will be up to what your skill levels are, as well as what you measured. There do exist for the Arduino various shields and modules (so-called DC motor control shields/modules) that incorporate parts to create an h-bridge and make it easy to control the motor.

You will find that most of these use one of two kinds of IC devices, either an L293 (or a variant, the SN754410) or the L298. The L293 is good up to 1 amp of current draw per channel (with a heatsink), the L298 is good for up to 2 amps of current draw per channel (with heatsink). Both of these ICs have 2 channels (to allow control of two motors - which makes them nice for differential drive robot usage, but I digress). In the case of the L298, you can also bridge the two channels together to provide up to 4 amps of current.

You may find people claiming to have done the same with the L293; another popular thing to do with the L293 is to "stack" chips together to gain more current output. I must caution against doing either of these things, as there is nothing in the datasheet of the L293 or SN754410 that mentions being able to do this as a means of supplying more current to a device under control. Nor does the datasheet of the L298 mention anything about bridging multiple units of that part to do the same (it only mentions the bridging of the internal bridges - something the datasheet for the L293 does -not- mention). Do your research, and read/follow the datasheet recommendations.

Also, regarding the L298 - if you decide to go with this IC, realize that it -does not- have a standard DIP pin layout, and cannot be plugged into a standard breadboard or piece of veroboard/stripboard - one row of pins is offset by .05 in. to the other row, thus both rows will not plug into a standard 0.1 in hole spacing board without either an adaptor, or bending of pins. I don't recommend the latter approach, but people have done it. There is a guy online (http://www.jrhackett.net/) that supplies a PCB adaptor for the L298; he also supplies a "bare" PCB for an entire L298 motor control board, if you want to populate it with your own parts. I am a satisfied customer of his, just to note (see my writeup here on the adapter - http://www.phoenixgarage.org/show_article/123).

Lastly, I want to mention that for proper use of the L293 or L298 - especially when anywhere near the current limits of the devices - you will need a properly sized heatsink! Neither of these devices are very efficient - they use bipolar transistor outputs, and were designed and used in the 1970s and 1980s - they are a very venerable device, and both were mainly designed for automotive applications. As such, there are tons of them out there, and they are very well documented, plus they have a TTL interface for the logic - all of which is why you see them often used in Arduino applications. That said, there are other and better (more efficient, smaller, etc) h-bridge designs out there today that use mosfets and the like if you need something with better specs (check out Pololu's offerings, for instance - http://www.pololu.com/).

Aphra:
2. How do I control my actuator, what code do I use? I need to be able to turn off for a certain amount of time then turn on for a certain amount of time, extending and retracting fully each time.

Well - to control your actuator - you need to control your h-bridge, and you also need to control one other part on that actuator - the electro-mechanical clutch on it. The inclusion of this clutch likely means that the actuator is "back-drivable" - meaning that, with enough force applied to the linear output "shaft", the internal parts (including the motor) can be rotated, changing the overall position of the actuator. The clutch is there to prevent that.

So - your control system would need to be able to activate that clutch (via the blue and green wires, according to the ebay listing), then activate the h-bridge to cause the motor to rotate and move the linear output shaft in or out.

Control of the clutch should be done with a circuit similar to that used to control a relay or solenoid (look this up - it's a common circuit described in the Arduino playground examples); when activated, you can command the motor to move and move the shaft in or out of the actuator. When de-activated, the clutch will hold the shaft in position. If you don't need this kind of control (that is, whatever you are using the actuator to move doesn't have the mass or power to back-drive the actuator and change it's position) it might be possible to remove the clutch from the gearbox (only you can determine this, though - take a look when you do the current measurement procedure I outlined at the beginning). Removing it can simplify the control and code somewhat, but you will lose some functionality that, depending on your needs, may be needed.

--- Part 2 to follow ---

--- Part 2 ---

As you control the actuator, you may also want to know the position of the output shaft. There is, apparently, some kind of built in potentiometer on the actuator, that can be accessed (at least the ends) via the red and white wires; this is where the description on the listing is vague. They mention that these wires are the "ends" of the "resistance wiper circuit" - I can't tell whether that means the potentiometer inside is wired as a rheostat, or if there is some other wire involved (like the green ground wire if this is true) that is connected to one end of the potentiometer track, and one of the wires - the red or white - is the "wiper" contact, to allow you to use it as a potentiometer (ie - variable voltage divider). Ultimately, you need to figure this out (by visual inspection when you take apart the actuator to get to the motor, if you must).

Once you know this - and with further help here or elsewhere - you can then figure out a method to read this variable resistance and use it (via an analog input on the Arduino) to know the position of the output shaft of the actuator, and use that in your code to know where the position of the shaft is, and to drive the shaft in the direction needed such that the difference between where it is and where you want it to be ends up being zero (that is the basic "naive" algorithm of a servomechanism - it's actually much more complex than that if you want to avoid oscillation and other issues - there are various ways to approach the problem, the most common, though somewhat difficult to understand being a complete PID control system).

Aphra:
3. Eventually I need to control around 8 of these motors with the arduino, is this possible and what would I need circuit-wise in order for this to work?

Well - once you get one of these working as I have outlined above - you obviously need to repeat this process 8 times. The main problem you will ultimately encounter at this point is the fact that the Arduino doesn't have enough pins to accommodate 8 of these devices (you would need 2 digital pins for each h-bridge, which already puts you out of the regular Arduino - plus 1 digital pin per each clutch, plus one analog input per each potentiometer to measure position - that means 24 digital pins and 8 analog input pins - which is 4 more pins than the ATMega328 even has!). One method would be to split it over two Arduinos (12 digital pins for control, 4 analog pins for position) - so four actuators per each Arduino. Another method would be to use an Arduino Mega (plenty of pins for everything and then some). You could also look into using a couple of external control chips on the SPI bus (something like an SPI digital I/O expander chip or two, plus an SPI ADC for the position sensing).

Finally - you would need a power supply to run the whole thing; take the current need you measured at the beginning, multiply it by 8, tack on 20-30 percent more current to account for everything else, and use that number to find an appropriate power supply.

Aphra:
Sorry for the total novice status here, any help would be much appreciated and if someone would like to write a tutorial on the topic I would be much obliged!

Not really a tutorial, but I hope it does answer at least a few of your questions, and gives you an idea of where to go with this project. Good luck on it!

Thank you very much for such a detailed response. I think that I am beginning to understand everything better now, however I still have afew questions if you would be so kind to answer them that would be great.

  1. I have an SN75441ONE (4 channel Half-H bridge driver) at home, is this ok to use to make the circuit? can be found here: SN754410NE Datasheet(PDF) - Texas Instruments

  2. I am confused as to what the circuit should look like, would it be similar to this image (see image attached) of a unipolar steeper circuit with a h-bridge? Please can you explain to me in complete lamens terms exactly how the circuit goes together? It would be mega useful to have a Fritzig diagram if at all possible because I am very new to all this and am finding most things quite tricky!

  3. How do you decide on a 'properly sized heatsink'? can you point me to a place that sells these and the kinds which I may want to buy?

  4. As I am struggling with the very basics I think I will be at a complete loss as to how the code works, can you point me in the direction of a code which I can use to control the motor, so that it extends fully and retracts fully, how would this work? Is it similar to the stepper commands to change the devices direction? Would something like the cods on this page work? http://www.tigoe.net/pcomp/code/circuits/motors/stepper-motors/ Or something like the code here? http://arduino.cc/en/Tutorial/MotorKnob

Thanks so much for your help, I really hope I can create this circuit and get everything going, it would be such a great achievement! Hopefully with your help, I will be able too!

A

Aphra:

  1. I have an SN75441ONE (4 channel Half-H bridge driver) at home, is this ok to use to make the circuit? can be found here: SN754410NE Datasheet(PDF) - Texas Instruments

I don't know. I have no idea what the current needs of your motor are. You need to find out those needs FIRST.

The SN75441 may very well work - but only if your motor draws less than 1 Amp of current - which is possible, but without knowing anything about the motor other than its voltage, you may end up trying it and burning out the IC.

Aphra:
2. I am confused as to what the circuit should look like, would it be similar to this image (see image attached) of a unipolar steeper circuit with a h-bridge? Please can you explain to me in complete lamens terms exactly how the circuit goes together? It would be mega useful to have a Fritzig diagram if at all possible because I am very new to all this and am finding most things quite tricky!

I don't see any "attached image", nor do I make fritzing diagrams. Learn to read a schematic (the language of electronics, my friend) and study what an h-bridge is and how it works.

Also - don't just go by a single datasheet; for these kinds of common and legacy components, there are an absolute ton of manufacturers of the parts, and as many datasheets covering each version as well. Study all of those datasheets; the only time you should adhere to any particular datasheet is when you want to know the electrical specs for your particular part - but the other information in other manufacturers datasheets (application examples and such) - you will often find out how to do things that the others don't tell you (this is particularly true with the L298 - one manufacturer has a datasheet that only shows how to hook it up as a stepper driver, whereas another manufacturer's datasheet shows both a stepper driver and DC motor implementation).

Aphra:
3. How do you decide on a 'properly sized heatsink'? can you point me to a place that sells these and the kinds which I may want to buy?

Well - there are ways - with various calculation and understanding of both the heatsink (which will have it's own datasheet or specifications! I bet you thought electronics was going to be easy - HAH!); but a rule of thumb is "bigger is better" (to a point). There is plenty of information out there on how to size a heatsink (but you have to know various information about the part in question, as well as the heatsink). Do your research.

That said - here is the issue with the L293/SN75441 and the L298: Heatsinks are difficult to get for either.

In the case of the L293/SN75441, it's a DIP component; at one time they made "clip-on" IC heatsinks for DIP components, but you can't easily find them any more. What you can find, though, are small heatsinks meant for gluing onto PC motherboard chipsets - you can use these, and a small bit of heatsink glue to attach them to the chip.

For the L298, most of these (if you DIY such a device) will be the Multiwatt-15 packaging (with it's odd pin spacing) - some will have straight leads, sometimes you find them with bent leads (meant lay flat on the PCB and to use a copper "ground pour" to act as the heatsink, and/or with an actual heatsink). Regardless, you need to find a heatsink that will fit such a device. I've looked - I have yet to find such a heatsink (as a separate part, or as an "extrusion profile" - you can purchase aluminium heatsink extrusions from various companies). I know they exist, because you see such things on the various Chinese L298 motor controller boards - but where to buy them, I haven't found yet.

I'd say just get a small VGA cooling heatsink (or something similar), and do a bit of light machining on it, drill it for the bolt, and bolt it on with some heatsink compound.

Aphra:
4. As I am struggling with the very basics I think I will be at a complete loss as to how the code works, can you point me in the direction of a code which I can use to control the motor, so that it extends fully and retracts fully, how would this work? Is it similar to the stepper commands to change the devices direction? Would something like the cods on this page work?

You're not at the point of needing to code anything, yet - you don't even understand the basics of what an h-bridge is and how it works. Study up on h-bridges, and you will see how you can easily control them (in general, you only need two digital output pins to control an h-bridge).

Now, controlling them in such a manner as to be able to stop the motion when the feedback potentiometer is in the proper location takes a bit more work, but really, you just set the pins to control the h-bridge (ie - one pin HIGH and one pin LOW to move it in a given direction; or one pin LOW and PWM the other pin HIGH to control speed in a given direction), then monitor the analog input pin for the value you expect (this is a very rough idea - in practice, this doesn't work), and then put both pins for the h-bridge LOW to stop the motion.

This is nothing like controlling a stepper. Also, I am not going to write the code for you (besides which, there are a ton of examples of it out there - again, do your own research).

But long before all of this - you need to find out the specs of your motor, and you need to use those specs to decide what h-bridge system to use, then you need to get that built and working with basic controls before you can even think about actual control of the system as a whole.