Controlling distance travel of a hydraulic cylinder

I’m wondering if anyone can point me in a direction where I might be able to get some help with a real world problem I’d like to resolve, and think an Arduino board (not sure whether there’s a preferred board on this occasion) may be the basis of a solution. The project centers around controlling the extension distance of a hydraulic cylinder. The plan is to have a limit switch detecting when the cylinder is fully retracted to signal a ‘home’ position. Then extend it the required distance (this will vary from job to job) and set that extension distance for the duration of the job. The piston rod currently has an arm clamped to its far end that extends out at a right angle to the rod by around 18cm. The arm is quite ridged so I would like to fix a length of steel plate at right angles to the arm and parallel to the rod meaning that the steel then runs up and down parallel to the cyinder rod as it extends and retracts. To this steel plate I’d attach a length of timing belt, and from the belt drive a timing pulley attached to a rotary encoder that fed back to an Arduino. So far so good, that bit is quite straightforward. The electrical aspects and hydraulic valve control side aren’t a problem. Now to the (for me) tricky bit. What I’d like to do, when the hydraulics are turned on, is first to home the cylinder via the fixed limit switch, then, when the cylinder is extended stop it at a desired position (this will vary from from time to time) press a button to have that distance ‘set’ in the Arduino program, so that with each successive retraction and extension it always extends to the same point until a new position is required, and at that point I would go through the homing/setting procedure again. The distance units e.g. millimeters, inches whatever aren’t really important, it’s about repetitive movement to a fixed point. I did think about using a multi turn potentiometer rather than encoder, but felt the accuracy and lifespan might be an issue. Although I’ve played around with an Arduino Uno for a while, including a little with an encoder and many of the book-based projects, I’m having trouble getting to grips with the various program requirements here – struggling is the word. Has anyone any experience of this sort of problem, or able to point me to somewhere on the web that might help me get underway? A forum search has so far not come to my rescue. I’ve tried to be as clear as I can here but if any clarification is required please say. Any help would be much appreciated. Phil

Given that your timing belt / encoder is accurate and repeatable, it's just a matter of counting pulses....

The programme breaks down to several parts.

1/ the homing part - operate the cylinder till the switch operates, then turn off the hydraulics .

2/ the running part - operate the cylinder and count pulses - when they reach the preset value, stop.

3/the setting process - display number of pulses /inches/mm on eg a 16x2 LCD display, and use up/down buttons to get the value you want. Save this in eprom.

The best way might be to have a little state machine, and perhaps 4 buttons....

start/stop, set, up and down.

There are several states : AtResetPoint - hydraulics off : Moving In " reverse : MovingOut " forward : AtSetPoint " off

then : SettingLimit - use up/down buttons, then start/stop to save.

well it's a start.



Many thanks for you prompt reply Allan. This was my general plan:

Extension and retraction of the cylinder would be via a foot pedal, which when pressed extended the cylinder, and when released the cylinder would automatically retract until it met the home switch. At which point a three position hydraulic solenoid valve (extend/retract/dump to tank) de-energised and circulated oil to tank. There would be a ‘Jog’ switch which would disable automatic retraction to allow for setting the extension distance.

My plan for the sequence from start up would be as follows:

Power up hydraulic system > retract cylinder to home position (in reality this would happen automatically if the cylinder were not already home) > engage the jog switch for setting > press foot pedal to extend to desired position > press a button to store position in Arduino > disengage jog switch > cylinder retracts to home position > press foot pedal > cylinder extends to preprogrammed position > release foot pedal > cylinder retracts etc.

The hard wired side for the hydraulic valve and pump control isn’t an issue. That sort of relay/contactor/solenoid valve system I’m ok with. From my limited experience with the Uno and encoder I’m aware that if I don’t use an efficient program positional loss is a real issue, which would be a very significant problem. And this, coupled with the storing and retrieval of information ‘on the fly’ as it were is where my main problems lie (I'm sure I'll have many others). Having a LCD would be a nice addition, though, for me at least, it would complicate programming and may not be an absolute requirement – for the moment at least.

Couonting pulses from an optical encoder shouldn't be a big problem.

Your foot pedals, I take it, work the switches.

Good luck.



Is your hydraulic cylinder a balanced system? In other words, is there pressure on both sides of the piston and it will move only when there is a difference in pressure? If it is not, the piston will drift when pressure is released.


Hi Paul. Yes the cylinder is pressurised on both sides. Though with this sort of setup a small amount of drift when power is removed is always a possibility, hence the importance of homing prior to use. Phil

there is a device called a tracer or hydraulic tracer. it is used in machine shops to move the table for teh part and follows a contour for the cutter.

in that aspect, accuracies of 4 and 5 decimal places are possible.

Bridgeport, the maker or milling machines has had hydraulic controls for decades. I used to use one back in the 1980's .

in home machine shops, it is common to use a DRO. this is an electronic scale that reads out in 4,5 or 6 decimal places.

what this means is that the measuring technology is available. and that the postional control is already in existinace.

all that said, I would not expect the cost of the valves of technology to cheap.

BTW, the old hydraulic Bridgeport mills were all completely computer controlled ( CNC) and if you can find one, will sell for less than it costs to move it from that site to your shop.