nthallen / keutsch-PlantHub

Instrument software for plant chamber experiment
1 stars 0 forks source link

Issues with Optimizing PI Controller for CO2 Feedback System #5

Open jdshutter opened 5 years ago

jdshutter commented 5 years ago

Hi Norton,

Is there a way to go about optimizing a PI controller? Josh and I have been changing the coefficients for both P and I for the past few hours, but the controller either sends out 0 V or 5 V, which implies that one of the terms is blowing up and reaching our MFC limits. Is there a way to save what the values of rate_adj, the error term, or even the CO2_integral term in the output? We thought we've been understanding the math correctly, so it's perplexing why the controller only sends out 0 or 5 V and nothing in-between.

Thanks! Josh and Josh

nthallen commented 5 years ago

One thing I notice right off is that you still don't have an initialization for CO2_integral. We talked about adding a CO2_control_init state to do that. I doubt that's the whole problem, but it's probably something you should have.

It would be possible to save the derived values, but in order to do so, you'd need to move the calculations our of the algo and into a .tmc file. However, it is possible to run the algorithm under the debugger (gdb) while playing back a troublesome run. Then you can examine any and all values as you step through. This process is not well documented, and it would probably be quickest if we did it together, at least the first time. (I'll need to double-check a step or two...)

If you're in a hurry, you could always add msg() statements to add log messages with the values. You'd want something like:

msg(0, "err_term=%.5lg CO2_integral=%.5lg rate_adj=%.5lf", err_term, CO2_integral, rate_adj);

jdshutter commented 5 years ago

We originally had the initialization for CO2_integral in the code (commit d4d2e03d7d541f02ffcdbbe7543c92a2e0f6923f) but then we removed it as a troubleshooting step. Having it present or not had no effect on running the code or the PI controller's behavior.

I guess it might be best to sit down with you to discuss the debugger and see if we can glean some information from past runs.