Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple PIDs on one Photon #7

Open
chixxi opened this issue Aug 11, 2018 · 0 comments
Open

Multiple PIDs on one Photon #7

chixxi opened this issue Aug 11, 2018 · 0 comments

Comments

@chixxi
Copy link

chixxi commented Aug 11, 2018

Thanks a lot for the library you adapted. I am using the PID to control the cooling of conical beer fermenters. I have now gotten a second one, so I want to have two separate PIDs running on a single Particle Photon.

How would I set this up? Is this the right approach:

double Setpoint1, Input1, Output1;
double Setpoint2, Input2, Output2;

double Kp=6, Ki=2600, Kd=1200;
PID myPID1(&Input1, &Output1, &Setpoint1,Kp,Ki,Kd, PID::REVERSE);
PID myPID2(&Input2, &Output2, &Setpoint2,Kp,Ki,Kd, PID::REVERSE);

int WindowSize1 = 600000;
unsigned long windowStartTime1;
int WindowSize2 = 600000;
unsigned long windowStartTime2;

windowStartTime1 = millis();
windowStartTime2 = millis();

myPID1.SetOutputLimits(10000, WindowSize1);
myPID2.SetOutputLimits(10000, WindowSize2);
  
myPID1.SetSampleTime(10000);
myPID2.SetSampleTime(10000);

myPID1.SetMode(PID::AUTOMATIC);
Input1 = temp1;
Setpoint1 = target1;
Output1 = myPID1.Compute();

myPID2.SetMode(PID::AUTOMATIC);
Input2 = temp2;
Setpoint2 = target2;
Output2 = myPID2.Compute();

For some reason this is not calculating and always returning 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant