I've been trying to tune the PID that controls the relay for the humidifier in my mushroom fruiting room, and have had some pretty consistent swings in humidity, often not unacceptably bad (+/-5%) but not great. I had a circulation fan in the fruiting room, but after a small increase in the KI constant earlier today, it started centering around my setpoint (90%) finally, and but later this afternoon I made the small change of adding a second oscillating fan at floor level, but pointed somewhat upwards, and despite losing some humidity when I had the door open, it stabilized to a much narrower oscillation.

Screenshot shows the difference a simple $15 fan can do!

]]>I am trying to set up an automated grow tent for plants but while I am enthusiastic and quick to pick things up, I have little coding knowledge. I am using a 1.2x1.2x2.2m tent. I am currently using MH-Z19 CO2 sensor and Seed studio's grove SHT35 for temp/humidity. I will be looking to incorporate a quantum PAR meter and soil moisture sensors next.

I have managed to get the SHT35 working with a bodged custom input file and manually installing grove.py. but something is wrong as it keeps spitting out "ERROR - mycodo. inputs. sht35_66f46a98 - InputModule. get_measurement() method raised IOError: Remote I/O error". Would you be able to help me write the correct input file?!

My current outputs are intake/outtake fans on one relay, a 1000w oil heater, ultrasonic humidifier and co2 regulator with solenoid.

Thanks in advance for any help you may be able to provide and thanks again for such an awesome controller.

Jamie

]]>First, let me thank you for you work, mycodo seems great!

i’m working on a modified fridge as meat curing chamber, but i can’t get the pid function to work???

My outputs (8 relays board) is working great on manual activations, but my tries of getting my pid function to work didn’t.

here are some screenshots of my setting.

Can you see where i did a mistake?

thanks

]]>

I have 3 relays:

- fridge (used for both cooling and de-humidifying)

- ceramic bulb (heater)

- humidifier

My basic PID knowledge comes from

another hobby of mine: flying RC helicopters.

With my helicopters the PID output adjustment (servo throw) is continuous and proportional which makes it rather simple to understand.

The PID period based relay control in Mycodo works rather different with 2 major differences: PID output is changed every PID period instead of continously and the output in case of a relay isn't proportional but either 0% or 100%.

The only way to proportionally regulate a relay would be to have it pulsating on/off but that's something that both the fridge and the ceramic bulb don't like.

I found your PID advise in another topic in which you talk about not setting Kp higher than P resulting in twice the PID period.

If I where to convert that advise to my temperature control situation with the default 30s PID period it would result in:

Max temp. in the summer: 30°C

Avg desired temp: 15° (+/-0,5° max)

Max. error: 15°

PID period * 2 = 60

P=Kp * e

60=Kp * 15

Kp=4

Based on this I can calculate the error at which time P will be equal to the PID period.

P=Kp * e

30=4 * e

e= 7,5°

Which would mean that the temperature would have to drop or raise 7,5°C in the current and following PID period or else the relay will start pulsating because P will become lower than the PID period. Which the fridge and heater won't like.

If I where to raise Kp in such way that the relays won't start pulsating this would most likely result in overshoot because the relay will remain 100% on until the desired temperature is just about reached.

I need to figure out a different approach for this situation which is giving me some headaches. So I hope you can help me out.

My thoughts so far:

I think I need to test run the fridge and heater to see how much °C they cool/heat over a period of time. As well as how much overshoot occurs when turning them off (and over which period this overshoot occurs).

Next I think I need to expand the PID period and raise Kp to achieve a situation where the relays won't pulsate and the overshoot is minimal.

If the differences between fridge and heater are too big maybe even use 2 PID controllers.

Or am I over thinking this and would 2 conditional controllers do the trick? Something like: fridge on above 15,5°C and heater on below 14,5°C

Hope you can give me some good advise on this.

]]>Would you please take a look at my PID setting as that may be the problem. I am trying to use set point sine wave tracking for humidity + or - 10% around a core value of 89%

PID settings:

Input: Humidity InputDirection: BothPeriod: 120Setpoint: 95Band: 1Kp: 100Ki: 0.5Kd: 0.5Integrator Min: -100Integrator Max: 100

Output Raise: Humidifier OutputMin On Duration: 300Max On Duration: 0Min Off Duration: 0

Output Lower: Dehumidifier OutputMin On Duration: 240Max On Duration: 0Min Off Duration: 0

Setpoint Tracking method: Sine Method

Let me first explain how the output value is calculated, then how the settings can be improved.

This equation is how the PID calculates the output value:

P + I + D = output value

Where,

P = Kp * e

I = Ki * ∫(e*dt)

D = Kd * d(e)/dt

e = error

It's usually good to turn the I and D gains off for initial testing to get an idea of how the output will be generated based solely on P, which would be the product of the Kp gain and the error (e).

P = output value

Kp * e = output value

If the desired humidity is 95 and the actual humidity is 55, the error, or difference, will be 40. If the I and D gains are turned off (set to 0), and Kp = 100, this is our output:

(100 * 40) + (0) + (0) = 4000

This would turn the output on for 4000 seconds.

Now let's analyze this tuning using a Period of 120 seconds. The Period is how long the duration between the PID controller acquiring a new measurement (to determine the error) and calculating the proper output value. Let's go through a few iterations to demonstrate how the PID controller will respond with these settings.

Period 1 (second 000): Humidity: 55, Error: 40, Output: 40 * 100 = 4000 seconds

Period 2 (second 120): Humidity: 60, Error: 35, Output: 35 * 100 = 3500 seconds

Period 3 (second 240): Humidity: 65, Error: 30, Output: 30 * 100 = 3000 seconds

Period 4 (second 360): Humidity: 70, Error: 25, Output: 25 * 100 = 2500 seconds

Period 5 (second 480): Humidity: 80, Error: 15, Output: 15 * 100 = 1500 seconds

Period 6 (second 600): Humidity: 90, Error: 5, Output: 5 * 100 = 500 seconds

Period 7 (second 720): Humidity: 95, Error: 0, Output: 0 * 100 = 0 seconds

Period 1 turned the output on for 4000 seconds. 120 seconds later, at Period 2, the output is instructed to turn on for 3500 seconds. Sine the output is still on from Period 1, it merely keeps the output on and updates the on time to 3500 seconds. This continues until the humidity reaches 95%, when the error is 0 and the output is instructed to turn on for 0 seconds (off).

The PID is essentially just on for the majority of the time. While this is common for some PIDs that are attempting to affect a large, slowly changing environmental condition, the durations the PID is outputting are incredibly larger than the period, which may make the system unstable or erratic when the measured value is near the setpoint. My suggestion is to reduce the Kp gain significantly in order to bring the output within a smaller range, closer to the 120 second Period. This will dampen erratic output changes by reducing the amount the output can change each period.

There are a few details I would need to now before being able to suggest a good initial tuning to start from. Most important is what type of humidification system is being used, however each system is different and there are other factors that should. Be considered. The best approach is to test your system. If there is a limitation to the output device (humidifier), we need to take that into consideration. For instance, I see the Min On Duration is set to 300. I'm not sure why, but perhaps the humidification system cannot tolerate switching at a period faster than this. My following tuning will be based on a humidification system that doesn't have this limitation. If it is the case that there is a limitation. , we can retune considering that limitation.

This is how I would generally create an initial tuning:

We want our maximum calculated output to be at least as high as our Period (120 seconds) but not much higher (less than twice as much), when our humidity is very low, we can calculate that with a low humidity (20%), our equation would be (Kp * error) = output, and substituting our known values, we get: P = Kp * e = 120; Kp * 75 = 120; Kp = 120/75 = 1.6. I would first run the PID controller with only Kp set to this value (Ki = 0 and Kd = 0) and see how the system responds.

We will probably want to reduce persistent error, so we will introduce the I value. The Ki gain typically is a small value, and incrementing it during tuning should be performed very conservatively. With a Integrator Max of 100, we can consider how much the I value can possibly be influencing the output value when there is no error (measured value = setpoint) with I = Ki * 100. Therefore, if Ki is 0.6, the maximum I value can be 60 when the measured value is near the setpoint. Therefore, if Ki is 0.6, the maximum I value can be is 60, half the period (a moderate initial Ki tuning). Let's now calculate the I value using this Ki gain, when the error is large. With a Ki = 0.6, if the error is 40, the first period I = 0.6 * 40 = 24 seconds output. This is a rather large amount the I value can potentially contribute to the final output, so reducing it some for the initial tuning could be beneficial. I would suggest reducing this at least by half. If we bring it down to 1/6th, we start with Ki = 0.1.

Using these values, our new tuning parameters are:

*Input: Humidity Input**Direction: Both**Period: 120**Setpoint: 95**Band: 0**Kp: 1.6**Ki: 0.1**Kd: 0**Integrator Min: -100**Integrator Max: 100*

*Output Raise: Humidifier Output**Min On Duration: 0**Max On Duration: 0**Min Off Duration: 0*

Using these parameters I would let the system run until stabilization occurs or a steady oscillation results. From there, depending how the system responds, further tuning can proceed. Very rarely does the first tuning produce exceptional results. Using the graphs, a lot of information can be determined about how to proceed with the second tuning. I would highly recommend creating a graph with these data series: Input measurement (for the humidity), Output humidification (increasing the humidity), PID Setpoint, and PID Output (duration). You could add PID P-Value and PID I-Value to see how these change as the PID controller progresses through cycles. If you can provide screenshots of how particular tunings affect the system starting from a calm state (low humidity), I can help further tune your PID to be more efficient.

Let me know if this helped and what other questions you may have or information you can provide about your system.

]]>