PID regulator output


Thread Starter

John Smith


I'm beginner in control systems area and I have a question regarding that. First let's take a look at the big picture of the control system and then I will state the actual problem.

There is a plastic tube, vertically placed in a space. At the bottom of the tube we have a fan (ventilator) and at the top, there is a ultrasound sensor. In the tube there is a light ball, which position is controlled by the fan and the position is measured by ultrasound sensor.

The task of control system is, to provide a control for controlling the position of a ball.

-Fan is controlled by pulse control (logical high turns it on, logical low turns it off)

-Sensor's output is in a range from 0 to 32643

The actual problem is that I have no idea how to set up the input parameters of PID controller that it output a number from 0 to 100 (%), which is a duty cycle needed for Signal gen input. I mean, PID controller operates with sensor output values (0 to 32643), so it's result will be also a sensor value and I can not see how to convert this to duty cycle. For instance, what value of PID output represents a 100% of duty cycle?

Control system:
Hi John Smith.

Yours is an interesting problem to start learning about our business. If the plastic tube has straight parallel sides, the process has no selfregulation. For any given air flow the position of the ball will hover anywhere in the tube and can only be driven to the set point by temporarily increasing or decreasing the air flow and then returning to the balanced value. You could liken your problem to the inverted pendulum challenge that is a feature of many advanced control system courses.

I have been planning to build a rig similar to yours for my amusement in retirement but I am having difficulties with sourcing a suitable ultrasonic sensor that has a realistic range and blocking distance. I would be most interested in learning more about your rig. You can contact me off list at [email protected].

Good luck
Peter Green
John Smith,

I'm assuming that you are using a pulse width modulation type control for the fan. The fan can be switched from 0 to V+ on a periodic interval, and you are controlling the duty cycle (ratio of time at V+ to time at 0 over the period). If that is the case, I would suggest using the magnitude of V+ as the 100% duty cycle reference. But, you can pick any value you want, since you are designing the control system. The error input to the control loop would be the difference between where you want the ball to be versus where the sensor tells you the ball is at. That error is fed into your controller, and the PID adjust its output (and therefore the duty cycle of the fan controller) to reduce the error to zero.

In theory everything sounds ok, but when I try to implement it in practice it simply doesn't work.

Current problem is that I'm getting slow oscillation with big magnitude - ball in the lift travels from zero level to above the setpoint. Of course I tried with all kind of values for proportional gain (the I and D are turned off), but it doesn't help. The ball doesn't move at all, it moves to the max. allowed height by the pipe or it slowly oscillates way off the setpoint.

Also take in note that PWM fan starts moving the ball when duty cycle is above 65%, so working range is between 65 and 100%. Because of this I introduced shift at the output of PID regulator, but it doesn't fix the problem.
You will never be able to stabilize the ball with just the proportional control. The ball will continue to oscillate up and down.

The integral control will allow you to the get the ball to the set-point position and keep it there. I don't think you need any differential control settings.

My suggestion is that you keep the proportional gain below x10 and implement the differential control over a reasonable period for the system, i.e 0.5 or 0.25 seconds.
>My suggestion is that you keep the
>proportional gain below x10 and
>implement the differential control over
>a reasonable period for the system, i.e
>0.5 or 0.25 seconds.


Sorry I mean implement the integral control and don't worry about the differential control. Perhaps 0.5 seconds is too long for this system - maybe 0.1 second intervals
Hi John Smith,

Thank you for posting the reference to the PDF that describes your system.

Great stuff.

In my original posting I said your system will have no self regulation. I should have elaborated on that; your system will not be able to be controlled manually. If you manually adjust the speed of the fan so that there is sufficient pressure to float your paper tube, it will continually rise but not hover anywhere. Then when the speed is reduced the paper tube will gently fall to the bottom.

This is why I have a plan to build a similar system and so that I can show friends and relatives what I used to do for a living. I would challenge people to drive the Ball or tube by hand. Then when they are completely frustrated I would show then how the automatic system could do the job.

Proportional only control with a high gain will allow the tube to hover somewhere near the set point but you will need an integral term with a small gain to drive the tube to your set point. Please make sure the integral term is small so that the time constant will be a long way from the resonant frequency of the proportional only system. With the integral term too large you could get oscillations.

This is what Bryan has suggested using different words.:)

There is also a possible cause of your instability coming you level measuring devices. There could be nasty echoes being reflected from your paper tube and bouncing from the sides of you "Lift shaft". You could investigate this by modifying your system so that it can be driven manually. Please attach a very light chain to the bottom of your paper tube. This chain should be as long as the top most position of your "Lift Shaft" and have a weight to match the maximum pressure that can be supplied from you fan at full speed. Jewelers sell suitable chains for necklaces.

With this chain attached the system will be self regulating and the fan speed will able to position the paper tube anywhere you like. You will then be able to check that the level measurement is working well with no unstable regions. If you find that you do have a measurement problem, you will need to discuss solutions with your instrument suppliers.

Good luck, you are developing a nice teaching rig. I wish I had your sort of resources 50 years ago when I was starting out in our business.

Peter Green