Hi everyone, I have a project where I'm controlling flow of water. I have flowmeter with impulse output which gives me current flow value and manometer. I have to control proportional valve to get some value of flow (it can change). Proportional valve can be controlled only with +12V, 0V and -12V. If I want to open it a little, I have to set +12V for a while and then change value to 0V. Total open of valve lasts about 10 seconds. Here is my algorithm but it's too simple because flow is non linear. It has to work with different configurations, which means I will need some calibration method.
Measure how fast flow changes from pressure 6bar to 12 bar (max pressure is about 15bar) and get value of how much time you need to pass +12V to change flow of 1 litre/minute. Example: started with 6bar and 15l/min. After 3 seconds i get 12bar and 25l/min which means that increasing 10l/min lasts 3 seconds, so increasing 1l/min took 0.33s.
Measure current flow
Count difference between current flow and flow set
Calculate time of signal: multiply difference with value from calibration and set +12V if current flow is too low or -12V if current flow is too high
Set 0V when time of signal passed.
Repeat Example: I want to set 20l/min, current flow is 12l/min. Difference is 8l/min so +12V signal should lasts 8*0.33 = 2.66s
It is very simple algorithm and it should consider non linearity of proportional valve - in first two seconds of open flow changes from 10 l/min to 11.5 l/min (it can't be completely closed) but in last two seconds it's change is from 18 to 30 l/min. How can I control it? I can't add any additional hardware. I was thinking about PID controller where I will pass current flow, flow to set and output will be time of +12v signal or -12V in case of negative output but configuration of my valve and many other things may change and adjusting all PID parameters manually is not a solution. Any ideas?