GeorgeEllwood
Mechanical
- Aug 22, 2006
- 134
Hello,
I'm hoping someone can help me, I'm trying to recreate a PID controlled generator output using a in Fortran.
Here's the code:
error = setpoint - measured_value
integral = integral + (error*dt)
derivative = (error - previous_error)/dt
Output = ((KP * error) + (KI * integral) + (KD *derivative))
previous_error=error
The output from the generator can vary between 0 & 4000Nm. I'm trying to get something to hold at 1.0.
The output from the PID loop is very small ~ 10Nm unless I make the KP term very high ~ 20000000. I seem to have made a fundamental error somewhere but I don't know where.
Can anyone advise?
Thanks
George
I'm hoping someone can help me, I'm trying to recreate a PID controlled generator output using a in Fortran.
Here's the code:
error = setpoint - measured_value
integral = integral + (error*dt)
derivative = (error - previous_error)/dt
Output = ((KP * error) + (KI * integral) + (KD *derivative))
previous_error=error
The output from the generator can vary between 0 & 4000Nm. I'm trying to get something to hold at 1.0.
The output from the PID loop is very small ~ 10Nm unless I make the KP term very high ~ 20000000. I seem to have made a fundamental error somewhere but I don't know where.
Can anyone advise?
Thanks
George