Hi,I am studying Brett Beauregard's website's PID control tutorial. It said "If this PID is going into a microcontroller, a very good argument can be made for using an interrupt. SetSampleTime sets the interrupt frequency, then Compute() gets called when it’s time."
I don't know which method is right :using running time of the loop() to be the sample time or each interrupt interval time to be the sample time as he mentioned?
If I choose running time of the loop() to be the sample time , it probably get so many PID outputs already than interrupt method dose once.
Interrupt time as samle time:the wheel's speed decreases before reaching the target position, the interrupt freq also decreases by the time. So I need to change SetSampleTime in process,right? I guess the interrupt time interval is decided by wheel rotation, and I need to know the rough time interval between each interrupt.
Hope someone can correct me if I am wrong. But don,t correct my grammar , because English is not my native language, please.