# hydraulic cylinder speed function

## 6 posts in this topic

Posted (edited)

Hello,

How I can simple do function to measure the speed of hydraulic cylinder. I have a position encoder. I would like to have a actual speed not a average speed. Speed in mm/s.

Edited by marcinmrag

##### Share on other sites

What about looking at the  current velocity.

You can then use the  ScaleTrans instruction to scale the output to mm/s.

Regard,
Garry

##### Share on other sites

But i read position by the analog input. I have a baluff encoder. So i have position value scaled from input. I create some function but im not sure if is working correct. I store position when i start movement than i calculate distance during the moment and i div this with the time. Time is very short is like 0,3-0,4 s. Cylinder speed should be 150mm/s for move up and 54mm/s for move down. working stroke of cylinder is really short like 40-45mm. When i move cylinder all the way up and down i get 200mm for up and 70 for down. It's possible that 40-45mm stroke is to short to rich the full speed? On this short distance i get 80mm/s for up and around 50 for down. Time reaction of cpu should be enough fast to make the calculation. I run this task i 2ms period time.

##### Share on other sites

Posted (edited)

But how I can check velocity? I have analog enckoder 0-10V. I can do some virtual axis for this or what? I have value from analog input which give me actual position. I would like to do function to show actual speed of cylinder.

Edited by marcinmrag

##### Share on other sites

Then you need to measure the rate of change of the said encoder reading. Put a constant timer which run every 100 ms for example. Or better, create a secondary Periodic Task that run for every 100 ms just to read this analog value periodically (from the Task Settings menu)

On each cycle, read the analog value of the said encoder. Subtract with its previous reading. Divide the remainder with 100 ms.
The result might get jumpy though. You can reduce the jumps by doing an moving-average of subsequent subtraction results (you can find that algorithm in the internet easily)

Now for the question whether the result displayed stands correct, that'll depends. Your encoder rated on 0 - 10 V, but for what distance?

Let's say 0 - 10 V equals 0 - 1000 mm, which means you'll have a precision of 1000 mm / 10 V = 100 mm/V
If your analog input card rate at 4000 for its resolution, the smallest voltage you can measure is 10 V /4000 = 2.5 mV
So that means the smallest unit of distance you can measure is (100 mm / V) x (2.5 mV) = 0.25 mm
Divide that by 100 ms sampling time, then the smallest change of speed that you can measure is (0.25 mm) / (100 ms) = 2.5 mm/s

That's the concept I can offer. Happy coding

##### Share on other sites

Thank you so much!

Distance of encoder is 220mm

## Create an account

Register a new account