Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "PID.h"
- void PID_Cyclic (int goal, int current, struct PID_Einstellung& PID)
- {
- int AS = 15; //akzeptierer Fehler
- PID.e = goal - current; // aktuelle Regelabweichung bestimmen
- if ((PID.e >= AS)||(PID.e) >= (AS * (-1))) // Schwelle
- {
- if ((PID.u < 1023)&&(PID.u > 0)) // (Anti-Windup)
- PID.esum = PID.esum + PID.e;
- PID.u = PID.Kp* (PID.e + PID.I*PID.esum)+ PID.Tv*(PID.e-PID.ealt);
- PID.ealt = PID.e;
- }
- if (PID.u > 1023) // Stellgröße auf (10 bit PWM)
- {
- PID.u = 1023;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement