M

I have developed a relatively simple PID loop in a ucontroller. However I am a bit unsure about a few details:

1. In a lot of the standard equations I have seen they contain Ts/Td for example. What does it mean to divide your sampling period by the derivative time?

2. If I specify a derivative time Td, does this mean I should take a sample (error sample i.e SP-PV) at say t(0) then another sample at t(0+Td) and subtract from each other? In any of the equations I have seen or code I have looked at there doesn't appear to be a timer that is set to sample the error difference for Td, all I see is Ts/Td. This is where the confusion comes in. If the code is not sampling for Td then why bother setting a Td? How does Ts/Td effect the loop?

The same above applies for the integral.

My current understanding leads me to the following:

Use Interrupt to sample Analogue (PV) every say...

* 1ms (faster then any real possible changes in measured value), once the sample is taken then evaluate P, I and D and output to PWM.

or

* Sample every 1ms evaluate P output to PWM, sample every Ti for integral and evaluate I output to PWM, sample every Td for derivative and evaluate D output to PWM.

Any suggestions would be appreciated.

Mike