# How do I convert this analog PID to a digital one?

I want to transform a type III analog PID into a discrete-time one so I can implement it on a PIC18F. The controller is for a buck converter.

When I apply the bilinear transformation to the analog transfer function

$s =\dfrac{2}{T}\cdot \dfrac{z-1}{z+1}$

how much should T be when my switching frequency is 500 kHz and loop bandwidth is 60 kHz?

• I'm not sure about a type III PID controller? I wasn't convinced that the internet was definitive about what "type III" means. Can you provide detail of the circuit you are trying to make digital. Include the switching regulator part please. – Andy aka Apr 9 '13 at 11:02
• As pointed out in the answer below by CAGT: T is time between successive calculations in your filter loop. If all you are after is T then this answer is correct. If you want more details on designing your loop we need more information about the analogue controller you are trying to make digital. – Warren Hill Feb 3 '14 at 11:55
• Are you sure about that loop bandwidth of 60kHz? That would mean your PID loop must run with at least 120kHz! – EvertW Apr 25 '14 at 11:57
• Can you add some code and show how your schematics look? Probably many people are interested in microcontroller doing PID regulation. – Kamil Apr 26 '14 at 22:47
• Here is a link that should help! biricha.com/converter/type/4 – user74867 May 5 '15 at 16:08

4. In other hand, a very high Fs can lead to precision errors in a fixed point implementation: Remember that, with a very small T, the poles in z domain tend to unity, since $$z = e^{Ts}$$ resulting in very similar values, such as 0.999 and 0.99.