I would like to discuss whether there are different ways to approach this project. I have 4 hydraulic valves (prop valves) that control four hydraulic cylinders. They have to move at the same speed, which requires some tuning and control due to the hydraulic system.
Each height of the cylinder is measured with absolute encoders.
What would be the best solution to program this project? The setpoint for the speed is given and should not be changed, only all four cylinders must move at the same speed.
I have thought about a PID control, but is this possible with four instances comparing their values? Maybe there are already libraries for this, but I have not found anything for two or in this case 4 values.
i thought PID was more for dealing with things that weren't controlled directly (you control the speed of a motor, not it's position) and have inertia
wouldn't you need to know the relationship between the change in position vs the controlling input. You could consider this a gain value. once you know what it is you would have a better estimate of the target input is to achieve the desired position.
initially, the input to each valve is changed by some amount and a gain calculated, another input change is made using the initial gain estimate and the gain recalculated.
presumably with each iteration, inputs to each valve are determined so that the position of each value is the same as the others and the the positions are more equal as the gains values for each valve become more accurate.
it's unclear if different gain values are needed over different ranges of each valve
the gains are stored in EEPROM and used during subsequent operation of the valves.
I don't see that PID helps you, especially if you're going to have variable weights in variable positions on the platform - hard to get the tuning parameters right.
I would start with something simple and make it more clever if simple doesn't cut it.
So at startup crack the valves minimally open and drive to a home position checking all the encoders as fast as makes sense (5Hz maybe?) adjusting the corresponding valves according to what the encoders say.
Once you're stable at home, read the set point and drive to there, reading encoders and tweaking the valves. It might make sense to calculate intermediate set points and make sure the encoders all make it to each intermediate point before any can move on.
I think you are looking at your problem the wrong way....
you said it yourself:
Jan_B:
when weight is loaded on the platform, one valve may need to open a little more to compensate for the load.
so, if I understood this correctly, its the PLATFORM that you want to be level and for that yes, your cylinders would have to be at the same height.
so IMHO the approach you should take is to have a level sensor as an input to your PID system to control the hydraulic values so that that the platform remains level at all time.
the purpose of the encoder(s) would only be to check that the target height is achieved or not. (I think using them as inputs for a PID system may be possible but probably much more complicated to implement!)
and maybe check out some typical PID examples like the 'self-balancing robot' to get some ideas on how you might go about implementing your PID system.