4 ms·
So here's an awfully uninformed question that will probably get me laughed at by actual engineers (as in, not 'software engineers' like myself - and yes Canadia
by roel_v 9y ago
So here's an awfully uninformed question that will probably get me laughed at by actual engineers (as in, not 'software engineers' like myself - and yes Canadians please bite your tongues, I've heard your shpiel by now): when you have a more powerful computer to work with, isn't it much easier to just derive some regression parameters and call it a day?
My use case: I have this home-build growhouse that I use to start my seedlings in at the end of winter (and as a fermentation chamber for wine). It's controlled by a Raspberry Pi and as inputs I have 4 groups of LED grow lights, a 30w heating element, a fan that draws warm air out of the box and thus brings the temperature within the box towards ambient temperature, and DHT22 sensors that measure temperature and humidity inside and outside the box. The goal is to keep temperature as close to a certain target temperature as possible, keeping in mind that I want the lights to be on for a certain nr of hours per day and the lights give off so much heat that they will pretty much always make the temperature go over the target (so the fan then needs to bring it down again). It's easy to get this working the naive way with an hysteresis of say +/- 2 degrees (which is fine for my purposes), but the nerd inside me sees it as a game to make that band smaller. So I've been reading up on PID controllers and dear baby jesus I can't even work out how I'd get started. So the pragmatic part of my brain goes 'just run it for a few weeks with incremental inputs between 15 and 35 degrees (C, of course), measure the responses, toss all measurements into R and derive some regression parameters'.
Does anyone do this in industry? Probably not because everywhere I've asked, everybody's who's ever done real work on this uses PID controllers - but is that because they're easier to build on microprocessors (i.e., need less number crunching)?
- deleted 9y ago[deleted]
- Tepix 9y agoThere will almost always be external influences that change the behaviour over time. If you have a vehicle, going up the hill will require more energy to keep the speed constant. For your growhouse, if it's hot outside of the box it may requires less heating, etc. Or the LEDs that you use get less efficient over time. You really want to have a dynamic algorithm such as PID that can deal with these changes in a near optimal fashion.
- donquichotte 9y agoWhat you are describing is called "system identification". If you have a simple mathematical model, it is possible (and in the case of your fermentation chamber, it should be) to measure a couple of step responses and estimate the parameters to design a control system. Finding good Kp, Ki, Kd gains by just sampling the [Kp, Ki, Kd]- space at random and trying it out on the real system is often not recommended. Firstly, because the state space is relatively large. Secondly, many systems can fail catastrophically if they become unstable, causing potential harm to man and machine. The second objection does not apply to a wine fermentation chamber, as far as I can see.
- Gibbon1 9y ago> It's easy to get this working the naive way with an hysteresis of say +/- 2 degrees Yeah that's a bang bang controller. Those actually work really well as long as you don't mind the temp swing. It mostly sounds like your temperature control is via the fan and the heating element. The heating element is the simplest to control with a PID loop. Just use a PWM output to control the heater power. Use a solid state relay to switch the power to the heater. Once you have that you need someway to record and plot the setpoint and temperature. Once you have that simplest way to get started is just play around with straight proportional control. Then add integral control with some sort of anti-windup. You don't actually need much theory to implement and tune a PI controller. Three bits. For your case you likely only have to run the control algorithm at 10Hz. Second when tuning don't adjust your tuning constants linearly, instead double or halve them. On a Raspberry Pi use double precision floating point.