# PID algorithm Using pic16f877

23 Jan 14

Hello..
Can anyone guide me how implement a PID algorithm using PIC16F877..i wanna control a level of a tank using control valve..kindly help me..

23 Jan 14

Hi....
I can help you in designing the algorithm by giving some ideas.
You need a Level sensor which gives electrical value i.e. DC Voltage of maximum 5V.
you need a control valve being controlled using electrical units.

PID function is nothing but the values to the control valve.

Initially compare the water level to the corresponding output voltage.
This voltage is given as input Feed back (FB) to the PIC. This voltage verified by program continuously.
You need a set value (SV) in voltage to PIC.
P- proportional --- it means action takes place after the FB Value goes below SV and stops after it exeeds SV so it will settle exactly.
PI - Proportional Integral --- It means the settling time will be reached but takes long time.
PID - Proportional Integral Derivative --- This settling time will be fast.

Step 1: check SV
2: Check FB
3: Compare FB and SV (ER=SV-FB)
4: Increase the output of control valve by ER value then go to step 1 until ER=0.
end