# Servo: PID process

I would like to set speed, direction and number of revolutions of the motor shaft based on the PID algoritm. I can read actual number of revolutions and direction of rotation based on hardware encoder readings. After achieving desired value (number of rotations, angle of shaft) serwo will stop the rotation of the shaft. Or, if value is behind or above desired, shaft will rotate in specified direction.

Does anybody have an idea how to implement PID algoritm based on vvvv?

this is an interesting and desirable topic http://en.wikipedia.org/wiki/PID_controller

it looks quite plausible to implement the algorithm shown on the wikipedia page with a FrameDelay loop.

Note that much of the beauty of the Damper and Oscillator nodes (which internally do probably 99% of the PID mechanics anyway) is that they do not require a constant frame rate. so using a Oscillator + Basic Math + FrameDelay loop might give superior results.

## BTW: How to do math like this: I = I + Ki * error * dt ? How can I add an I to itself, thru FrameDelay?

Oscillator (Animation) Advanced looks interesting. It is Position In for use as actual position.