Este es el pid que estoy implementando en mi lab
DValue VAR WORD
SetPoint VAR WORD
Direction var PortB.7
Setpoint = 512
INCLUDE "incPID.pbp" 'Include the PID routine.
,asignar valores
pid_Kp = $0700 'Set Kp to 7.0
pid_Ki = $0080 'Set Ki to 0.5
pid_Kd = $0225 'Set Kd to 2.14
pid_Ti = 8 'Update I-term every 8th call to PID
pid_I_Clamp = 100 'Clamp I-term to max ±100
pid_Out_Clamp = 511 'Clamp the final output to ±511
Start:
Gosub GetAD 'Get position from AD - NOT SHOWN HERE.
pid_Error = Setpoint - ADValue 'Calculate the error
Gosub PID 'Result returned in pid_Drive
Direction = pid_Out.15 'Set direction pin accordning to sign
pid_Out = ABS pid_Out 'Convert from two's comp. to absolute
HPWM 1, pid_Out, 10000 'Set PWM output
Pause 10 'Wait....
Goto Start '...and do it again.
como ven esta re simple lo estoy simulando en proteus aplicado a otro proseco
aki la web
pid pic basic