I need help with all of the above. Never programmed anything before like this.
I am controlling a hydraulic cylinder using relays. The relays control Solenoids. In this example:
Let’s call it 0 (closed) and 100 (Open)
Two relays 1 for open and 1 for close. Each controls a solenoid on either end of the hydraulic cylinder.
Starting point is 0.
I change the set point to say…30. The feedback shows that the current point is 0 therefore 30 is a positive integer and it needs to “open” so it fires the open solenoid. As it settles at 30 the relay switches to 0 the hydraulic actuator is now at the position desired.
If I ask it to open further to say 80 from 30 by changing the set point, it would fire the same open relay as before but what if I want to go the other way?
I am currently at 30 and change the set point to 10. 10 is below 30 meaning it has to move the opposite way therefore it has to fire the “close” solenoid also adhering to the same PID.
I could get fancy and say I want to have controls to move faster one way or the other but the basic premise is as described.
This does not work exactly like a simple PID heater or AC system which just stays on till it gets to the temp and them turn off. It has to know the current setpoint and relative position based on the sensor feedback and know which direction to go.
I think it might also require a deadband to control the overshoot and correction factor to keep it from hunting back and forth forever.