# Control valves, to control speed with limited feedback

#### MartinFO

Hi all
I am new to this forum. I am posting because, I have struggled with a problem for some time new and need some inputs. I hope will help me.
I have a water turbine (kind of) system that I need to control.
- The speed of the turbine is adjusted by a ball valve. The ball valve opening is controlled by a DC gear motor without any feedback.
- It takes approx 4 seconds to do a full opening (or closing) of the valve. I can easily power the motor for e.g. only 0.5s to open/close it a bit.
- I can detect fully open and fully closed but nothing in between.
- The turbine is connected to a gearbox that reduces the speed drastically.
- I measure the speed/RPM of the output shaft by a reed switch and an encode wheel with magnets.
- The system is very slow at operating speed, so I only receive a pulse every 20-40s.
- I am calculating the RPM in counts pr hour, 3600000/(delta_pulse[ms] )
My objective is to control the speed of the output shaft to a given speed (90 - 180 pr. hr), but setting a set point. The system will start from zero, closed valve = no feedback. The system can go quite fast (relatively), around 1000 pr. hr, so I prefer not to operate there to long.

I have tried with a PID (only the P so fare) and I am struggling with when to compute. I have tried:
1. Constant update time (e.g. every minute)
2. Variable update time, changing according to last feedback (e.g. change to 20s if last delta_pulse was 20s)
3. Compute only then the readings are steady (e.g. diff between the two last pulses of 5%)

The main problem is reducing the speed. With 3, I had the problem of closing the valve an awaiting inf for a new update (I have not used fully open / closed inputs in the control algorithm, perhaps this is the solution.). With 2. I risked using non-steady readings as input. Option 1. is just very slow and does not seem optimal.

I cannot change/add any hardware, but I have full control over the control software.

Any suggestions / comments or pointers some literature on similar system.
Bare in mind, I am a Mechanical Engineer, not a Control Engineer, so this might be trivial for some (I hope)

#### CSA

MartinFO,

Hmmm.... I'm not sure I really understand the set-up or the need to control the speed.

And I'm really not familiar with trying to measure speed with a reed switch and magnets.

But I think you need more pulses in a shorter period of time than you are getting, especially if you want to control speed without overshoot (opening too much, then closing too much, then opening too much, etc.).

You say you measure the speed of the "output shaft." Is that the output shaft of the turbine or the shaft of the gear box? If it's the gear box, can you change the speed sensing equipment to the output shaft of the turbine, which spins faster?

Have you tried calculating speed in RPS (Revolutions Per Second)? I don't quite understand why you are using delta_pulse/msec. Does it have to do with the "controller" you are using needing to see the reed switch pulse change state very quickly (in milliseconds) in order to record the pulse?

I suggest you provide some more detail about the controller and the PID you are using.

Are you trying to use various pieces of equipment from different applications to put together this system? Not all pieces will play well together under all conditions and operating configurations. That's part of engineering (mechanical or control)--picking pieces/components that work well together. You may not have a controller/PID that is capable of executing what you want in the time required.

Finally, are you able to "manually" control the control valve (using pulses from OPEN and CLOSE pushbuttons, for example) to achieve what you are trying to accomplish? How are you "powering" the motor for 0.5 seconds at a time? Some kind of electromechanical relay or solid-state relay? What kind of voltages are you talking about?

This doesn't sound difficult, but there's a lot we don't understand. The new and improved control.com allows pictures and drawings/sketches to be attached to/included with postings. A picture can be worth 10,000 characters

#### MartinFO

I have tried to draw the system. I need to control the reduced shaft of the gearbox by controlling the water flow. The sensor output is a square wave, so it is quite easy to calculate the speed. I have chosen counts per hour as the measure of speed, since it is possible to represent the speed as an integer with enough accuracy. But it could be something else.
Regarding the hardware. I cannot change anything. It is not possible to add additional sensor or increase the pulse rate.

I agree that the problem is a low pulse rate. So I think it comes down to the update/compute intervals of the PID.
The controller is a microcontroller. It controls the motor by switching relays for open and closing direction and stop. By sending short pulses I can slowly open and close the valve.
I write the microcontroller program myself, so I can modify the signals as I need.
I have got a working solution, where I change the PID-compute interval depending on the actual speed and the set point.

The PID computes if either one of the following conditions are fulfilled:

1. Steady readings: I compare the current pulse rate the last one (last time I got a count). If the difference is within 5% I flag the state as steady. This tells me that system has settled from last adjustment and ready again. The PID compute based on the current speed.

2. Timeout: If the readings never settle or takes too long time. This will happen if the controller closes the valve completely. No steady flag is set and the PID will never compute again.
So the timeout is the fallback. I base the timeout on the set point. So the time between pulses, if operated at the set point. Than times by 3, to allow for the steady state to occur (It would need at least 2 counts to settle).
The problem is then; what is the correct input to the PID? If I use the last known measurement, that might be above the set point, hence the PID would close the valve. If the valve is fully closed no new reading would ever occur.
To compensate for this I estimate the speed based on last count and current time. If the this value is below last speed reading I use this is input to the PID instead.

To control the motor valve, I convert the PID output to a motor direction and operate time, e.g. close for 2s.

The above solution works, but it seems like a hack, so I am thinking there must be a better method.