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

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.

There is a pseudocode of PID algorithm:
previous_error = error or 0 if undefined
error = setpoint - actual_position
P = Kp * error
I = I + Ki * error * dt
D = Kd * (error - previous_error) / dt
output = P + I + D
goto start^

I was try to build something based on Oscillator (Animation) node, but it has not an input for the actual position feedback. So Oscillator cannot react onto changes of shaft in time when motor goes to achieve goal position. In short - Oscillator is a “self made man”.

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.