PID control of pressure in hydraulic cylinders with Python and LinuxCNC

More
08 Jul 2023 21:25 #275044 by santy
Hey guys

My goal is to drive an hydraulic cylinder with a directional valve.
The cylinder is to push an object, by opening the valve, and closing it when it reaches a given pressure.

For this, i have built a test python script to obtain the pressure of a dial, and my goal is to send the current pressure as a variable to linuxcnc, so that i can control it.

The idea is that the operator could choose a certain pressure in the control panel, and linuxcnc would work in parallel with the python script to check if it has reached it or not yet.
I can accept an error of 2-5 % so there is no problem!

please check the picture. the test was done with a compressor dial, not yet the hydraulic manometer.. but its similar.

What approach would you suggest to get the PID control working? where can i start? 
Any examples for communicating variables within linuxcnc to other apps?

Thank you!
Attachments:

Please Log in or Create an account to join the conversation.

More
08 Jul 2023 22:08 #275050 by andypugh
Using image recognition to measure the pressure is fairly cunning, but is presumably not providing results in real-time?
If at all possible it would be better to get the pressure into HAL as a realtime signal. (for example, by using a pressure gauge with an analogue voltage output.
Maybe something like a diesel fuel rail pressure sensor? What pressure do you need to measure?

Anyway, to answer the question, rather than say "No, don't do it that way"
Import the linuxcnc HAL module into python and create a HAL pin to present the pressure on.

Then connect that to a HAL PID component as the feedback.

That's pretty much it.

linuxcnc.org/docs/2.9/html/hal/halmodule.html
import hal
...
h = hal.component("hydraulics")
h.newpin("pressure", hal.HAL_FLOAT, hal.HAL_OUT)
h.ready()
...
h.pressure = measured_pressure

Please Log in or Create an account to join the conversation.

More
09 Jul 2023 14:24 #275077 by santy
i want to measure hydraulic pressure. So that type of sensor is hard to find and fairly expensive. 

Pneumatic sensors can be cheaper as they handle max 10 bar but for hydraulics i haven't had much luck with something that won't break the bank. yes i would rather get something exactly like you said and use a 7i87 or similar for analogue input but this way i can play with open cv!

Please Log in or Create an account to join the conversation.

More
09 Jul 2023 14:47 #275079 by tommylight

Maybe something like a diesel fuel rail pressure sensor?

That is a very good idea, those sensors measure up to 2000 BAR of pressure.
And are cheap as they are mass produced.
Search for "common rail pressure sensor".

Please Log in or Create an account to join the conversation.

Time to create page: 0.120 seconds
Powered by Kunena Forum