PWM'ing a 250W heater. - Page 1
Forum section: electronics / general

author: paulca
author_rank: Super Contributor
timestamp: February 25, 2021, 12:11:57 pm
content: I am trying to heat a plant incubator for getting ahead with some seedlings before summer.It's a pretty small space and a 250W desktop heater is able to heat it as long as the extractor fan is very low. As the temperature rises however the thermostat on the heater cuts it out around 26*C, it sits idle for many minutes while the temp falls right down to 14*C when it clicks back on and rises pretty rapidly back up to 20+C and then slowly to 26*C when it cuts out again.So the mechanical bi-metalic strip in the heater is way too slow.I got the bizarre idea to automate the heater using a "smart" switch and instead of choosing a basic target temp, current temp feedback loop, I considered instead using a PWM cycle and a tracker algorithm to adjust the duty cycle to acheive and maintain the target temp. Maybe a 1/60th Hz frequency, meaning the heater will switch ON, OFF, ON every minute with the ON time varied by the algorithm.Is this even slightly sane?EDIT: 1/60th Hz might be a bit rapid and wear the relay out. Maybe a 3 or 4 minute cycle.

author: paulca
author_rank: Super Contributor
timestamp: February 25, 2021, 12:16:25 pm
content: Just to add the competing technique suggested to me is to place a barrel of 20 litres of water in there, preheated to around 22*C. The idea being the thermal mass will soften the saw toothing of the temperature. Additionally that barrel of water could be heated with a 250W fish tank heater and the only heat in the incubator would be passive heat from the water barrel.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: February 25, 2021, 12:22:01 pm
content: plenty of triac-based temperature controllers out there - why reinvent the wheel

author: Gyro
author_rank: Super Contributor
timestamp: February 25, 2021, 12:23:14 pm
content: The idea of skipping complete (or multiple mains cycles) is common for high thermal mass items like heaters. It is commonly known as burst fire control. It's usually done with a Triac or SSR rather than a relay though, and at mains zero crossings.

author: Ian.M
author_rank: Super Contributor
timestamp: February 25, 2021, 12:25:04 pm
content: I assume the heater is fan assisted. First hack the heater so the fan stays on when the thermostat contacts open. As-is, the residual heat from the element holds the thermostat off until the rest of the enclosure cools significantly. If you maintain airflow so its thermostat is sampling the general air temperature, not the locally elevated temperature inside the heater, you'll get far smaller temperature swings.If that's not good enough, you'll need to add a temperature controller, that uses cycle skipping to control a mains load, preferably running a PID algorithm, and hack the heater so the controller feeds the element not the fan, which should stay on continuously, as it wont like cycle skipping or frequent stop/starts.

author: beanflying
author_rank: Super Contributor
timestamp: February 25, 2021, 12:35:34 pm
content: Unless you are 'desperate' to make it then these and the countless clones (this is a clone) work great. You can adjust the hysteresis and set points etc.https://inkbird.shop/products/itc-1000Or a Sonoff POW is an option with a Temperature Sensor which lets you monitor it or even send an alarm to your phone if it goes wrong.I have used both of these options on a number of commercial fridges but both will do low temperature heater control too.The other options is an SSR Arduino or ESP32 the correct SSR can be driven directly from either with DC from the controllers. This will get you PWM if you really need it.

author: paulca
author_rank: Super Contributor
timestamp: February 25, 2021, 12:39:26 pm
content: Quote from: mikeselectricstuff on February 25, 2021, 12:22:01 pmActually I have a Triac controller but it's a manual knob. I'd need to hack that and produce a voltage in lieu of the potentiometer so I can automate control of it.I think you had something like this in mind though.https://www.amazon.co.uk/Inkbird-Temperature-Controller-Thermostat-Thermocouple/dp/B01N2XZ4HV/On reinventing the wheel, I always find that sentiment a little ironic, considering how many different types of wheel have been invented.

author: paulca
author_rank: Super Contributor
timestamp: February 25, 2021, 12:42:56 pm
content: Quote from: Ian.M on February 25, 2021, 12:25:04 pmInteresting. My kind of gruella style setupI don't want to spent too much money on this as I'm kinda hoping that by end of March the 100W of LED lights will be sufficient heat and the heater will no longer be needed. 100W of light lifts the temp to about ambient +8*C and by end of march it "usually" doesn't fall much below 10*C. So I just need to run the LED lights at night time to maintain temps and only cut the lights for 4-6 hours during the warmest part of the day.

author: Ian.M
author_rank: Super Contributor
timestamp: February 25, 2021, 01:06:53 pm
content: If you really want to do a hack job, get an AC SSR with zero crossing switching, (and make sure its a decent one, not a fake) and wire it in series with the heater and the existing thermostat., which becomes the over-temperature cutout). Now you've got something that can be controlled by a safe low voltage logic level signal e.g. from an Arduino. Program the Arduino with your desired control algorithm, but only update the output every 1/50 of a second so that ON AVERAGE it only switches for full mains cycles to avoid DC imbalance (though that probably doesn't matter for only a 250W load.) You *may* want another SSR in series with the fan so you can switch it off if the temperature is over the setpoint for an extended period. You probably cant mount the SSRs inside a compact heater as you'll have difficulty finding a space where they will be cool enough. If you want to be able to use the heater normally with your add-on control box disconnected, you'll need a min. 4 pole (if the fan isn't switched or 5 pole if it is) mains rated female connector on the fan to connect to your control box, bringing out Line Neutral and Earth and Live feed to the element and optionally the fan, and make up a bypass plug that simply reconnects to the ekement (and fan) feeds.An isolated AC current sensor in series with the element circuit in your control box would be useful as you could then sound an alarm if the SSR fails, or the thermostat fails open, It could be as crude as a beefy mains rated bridge rectifier AC terminals connected to the element circuit with a 20 turn coil round a reed switch to sense if current is flowing or not!OTOH I'm too lazy nowadays to tackle a project like this as a rush job so would probably order an off-the-shelf controller.

author: Siwastaja
author_rank: Super Contributor
timestamp: February 26, 2021, 08:10:02 am
content: Easiest: Off-the-shelf PID temperature controller module. Run the autotune cycle. Set the temperature. You are good to go.If you want to develop your own algorithm, then a standard simple opto-isolated Solid State Relay module.Even a mechanical relay is widely used solution in older generation PID temperature controllers, if the relay is of suitable quality, it will last years switching thousands of times a day.PWM frequency can be like 5Hz for SSR or like 0.1Hz for a mechnical relay.

author: Terry Bites
author_rank: Super Contributor
timestamp: February 28, 2021, 01:49:34 pm
content: A bit over complex for an incubator heater. Make your own or buy a bang-bang contoller with a narrower hysterisis band.Home heating thermostats eg BYC07HE can be set to 0.5'C hysterisis. Cheap as chips. Nice green glow as well!

author: Medved
author_rank: Contributor
timestamp: March 10, 2021, 12:51:09 am
content: The problem is the long response delay of the bimetal switch vs the temperature in the chamber changing rather fast, making the simple hysteretic cintrol to over- and under-shoot a lot.Quite nice trick: Add some extra small heater directly onto the bimetal and set it so, its heating power is barely able to overcome the bimetal hysteresis That way you will essentially form an electro-thermo-mechanical PWM proportional regulator, generating rather nice PWM with few minutes period. The gain of this is then dictated by how muc the auxiliary resistor warms up the strip beyond the hysteresis. This trick was often used in room heating thermostats in the past...But for your case the ready made PID controller should be the best choice. It has its advantage to display the actual temperature there, so you will see it is off (e.g. due to heater fault,...) and be able to rectify the problem before it causes consequent damage.But don't use any of the hysteretic ones, even with the hysteresis adjustable to zero. Those will over-/under-shoot the same as the bimetallic does, so you will end up the same as you already are.

author: paulca
author_rank: Super Contributor
timestamp: March 10, 2021, 09:45:29 pm
content: Was just coming back to say I bought a smart 4 plug power bar. With individual Wifi control over the plugs, so I can control the heater and the extractor fan from software.I just stuck in 1*C natural hysteresis and it toggles every few minutes. Saw tooths with an amplitude of almost exactly 1*C.It don't get more simple.if temp < 19:self.extractor("OFF") # if it gets really cold and heater can't keep upif temp > 20:self.extractor("ON")if temp < 20:self.heater("ON")if temp > 21:self.heater("OFF")The plants on the other hand may be beyond saving at this stage. When I sort of found the extractor and the heater on 100% of the time would balance out around 24-26*C I left it there. The humidity was 40-70%... it didn't twig that once I stabilsed the temp at 25'ish the humidity would go down and stay down... and keep going down.I added a humidifier to keep it at 75% and ... well, it rained in the propagator, thankfully just down the walls, so I dropped it back to 65% and 20-21*C.Maybe they will recover, they have got fresh green growth nodes currently being protected by the seedling leaves, but, they aren't meant to be curled up like that and they are very, very slow.I knew it would turn into another "hobby" and explode. The propogator now includes:A 240V desk fan, on 24/7A 250W heater, switched automaticallyA 5 litre humidifier set to 65% on 24/7A 12W heat mat for the base, to warm it against the cold floor below (switched manually but remotely)Extractor fan, switch automatically, on most times, off if the heater can't keep up.

author: paulca
author_rank: Super Contributor
timestamp: March 10, 2021, 09:49:33 pm
content: The Smart Power bar did valiantly defend it's self from a few hacks, but it was game over when I soldered the serial lines to the board. Bye bye, Chinese firmware

author: beanflying
author_rank: Super Contributor
timestamp: March 10, 2021, 10:51:56 pm
content: Nice life hackGenerally most environmental heating applications don't need the fast switching/pwm control. My coffee Roasters run in the order of seconds for switching even though they are following a fairly tight temperature ramp, moving the both the thermal mass of them and the air inside significantly takes 20-60 seconds not matter what you do even with gross airflow changes.

author: Circlotron
author_rank: Super Contributor
timestamp: March 10, 2021, 11:01:55 pm
content: You may like to use a transformer to run the heater at reduced voltage when it is operating to slow the rate of rise of temperature. Put the tranny upstream of the heater fan so any wasted energy gets fed into the controlled environment.

author: paulca
author_rank: Super Contributor
timestamp: March 11, 2021, 09:30:06 am
content: Well, I would say this 6 hour graph shows it's working as intended. I'd call that pretty tight temp control.

author: paulca
author_rank: Super Contributor
timestamp: March 11, 2021, 10:36:10 am
content: Quote from: Circlotron on March 10, 2021, 11:01:55 pmThis was an idea I considered, although using a triac to cut the wave rather than a transformer. The fiddly part is making a software controller one... which led to using an STC-1000 or similar. What put me off that, is it's last generation tech. Yes it works, yes it will be reliable, but it's so "offline" and I'm sure a "Smart" one which can be hooked up to a network data logger and accept parameters remotely... would cost $$$$ and probably force me to sign up to a cloud service.In fact the 4 plug bar I bought tried that too. They even closed the loop hole where you could pretend to be their update server because they used a PSK (pre-shared key) which had become "leaked" to the community. That no longer allows you to inject your own firmware. I had to open the thing up to flash it over serial. Even then, they had switched the orientation of the module to make it very difficult to get to the GPIO 0 test pad on the back of the board to put it into flash mode. Still didn't stop me.As an aside, the commercial spyware industry is trying to make it illegal for you to modify any software installed on a device you own if the company declare it so. We should fight against this while we fight for the "right to repair" clause. Allowing companies free run as to what software runs in our homes when the regulations and bodies overseeing "Smart home" gadgets is pretty much non-existent. The average consumer is completely unaware and completely unprepared for the level of tracking, profiling and behavioural analysis that is happening to them everyday. The REAL worry however is what happens when these devices get hacked, taken over en-mass, just like 150,000 security cameras this week did.

author: paulca
author_rank: Super Contributor
timestamp: March 14, 2021, 10:29:16 am
content: Whoops!After a few beers I decided to see how far I could push it on "Tropical conditions", so I bumped the humidity up to 75% and the temp up to 25*C... Deciding it was a bad idea to leave it over night like that I dropped the temp back to 22*C.So what happens if you take air at 25*C and 75% humidity and quickly drop it to 22*C. It rains or at least dew forms... first lesson. Humidity sensors stop working when dew is present, the first one to get hit was mine which rose rapidly to 100% and stuck there, but the one in the humidifier failed the other way and that sent it into full throttle, max humidifying mode.The project camera still functioned and you can just watch the water level drop in the humidifier on the time lapse and the water running down the walls, dripping off cables.Around 5am the temperature sensors on one sensor board dropped out, then the pressure sensor.I found the damage at 8:30. It's not hard to fix the humidity, open the door. Drying everything out is the other story. The heaters and fan still work, so I'm closing the extractor, letting it heat up, the cycling the air out with the extractor and repeating. I also need to be extremely careful in there, in regards touching things as there is a 240V heater sitting in a puddle of dew on the floor of a propagator lined with metalized reflective fabric.I'm hoping the sensors and humidifier recover when I get rid of the dew. At least it's basically distilled water anyway.EDIT: I have one free socket on the wifi power bar. The humidifier is going on it. I can't change the panel settings remotely, but I can kill it's power if the humidity goes out of spec again.

author: Ian.M
author_rank: Super Contributor
timestamp: March 14, 2021, 02:31:52 pm
content: It would appear you need a more robust humidity sensor that can cope with 100% humidity and condensing conditions. There are various options, including heated humidity sensors, where as the humidity approaches 100%, the sensor is heated to maintain a lower target readout, and the actual humidity calculated from the readout, sensor and ambient temperatures, however a much simpler to implement one would be to add a wet bulb thermometer (actually a wet bulb temperature sensor) consisting of a glass, epoxy or stainless steel encapsulated temperature probe, covered in cotton lamp-wick, with the tail of the wick immersed in a reservoir of distilled water.Seehttps://en.wikipedia.org/wiki/Wet-bulb_temperatureAs to recovering your current 'swamp chamber', I'd isolate power, mop everything off to remove gross condensation, then if I didn't have a dehumidifier handy, proceed as you are doing. If I had a dehumidifier, Id simply run it and program the chamber temperature to drop slowly from say 27 deg C to the desired target temperature, at a rate calculated so that the volume of water that can be expected to condense from that volume of air at 100% RH cooled over that temperature range is significantly less than the specified max. extraction rate of the dehumidifier.

author: paulca
author_rank: Super Contributor
timestamp: March 14, 2021, 03:18:31 pm
content: It's recovering. Turning the heater to point the sensor for an hour fixed it. Humidifier seems to have recovered too.Managed not to get shocked even moving the heater around.Fixing the ambient humidity was just a matter of opening the door, the trickier part is drying everything out, but it looks like it's working. I increased the extractor fan rpm to where the heater can't keep up and runs constantly, but when the temp drops too far the extractor shuts off, it warms up, absorbs moisture and then gets vented when the extractor comes back on. I can see on the graphs the heater struggling less and less as the thermal mass goes down as things dry out. The current measured humidity (with compromised reliability) is 78% and falling.Time lapse:https://youtu.be/i9Rja644X0M

author: Ian.M
author_rank: Super Contributor
timestamp: March 14, 2021, 03:23:53 pm
content: Good. I still think adding a backup wet-bulb sensor would be worthwhile. It would let you detect failure of your integrated humidity sensor, and also script recovery from a similar situation, which could occur as a result of any significant power outage or a sudden and severe drop in external ambient temperature such that your heater is insufficient to maintain the target temperature.

author: paulca
author_rank: Super Contributor
timestamp: March 16, 2021, 12:00:09 pm
content: Second fault. Caught this one fairly quickly. A software bug! Shame on me.The power bar publishes it's state on a message topic. However to get a snapshot of it's state you need to send it a message on another topic. I had added this of course. So when my controller was run it would send a status request for each of the sockets and that would bring it into consistent state with the device and I don't need to spam, "ON", "ON", "ON", "ON" everytime the temperature changes 0.01 degree. If I "know" it's already ON, just leave it.The first issue is that I sent the status request before the client connected and it got dropped. So my view of the socket state showed them all "OFF" and so it "left the heater off" as it should be off.The temperature sored to 30*C.The second issue is MQTT. It's great, but, like most asynchronous message buses it has it's downsides. Message loss is an issue. Not "over the wire" as TCP should correct packet loss, but in many corner cases messages get dropped, over written in caches, dropped on disconnect etc.I have been trying to avoid having to wrap my own layer of transactional context on top of MQTT, but this project makes me reconsider that.I am thinking of using the Promise style pattern. Instead of chucking the command message over the fence with just a "publish( topic, message )" and hoping I get an appropriate action, I should send a request() and get a Promise in return. A Promise is a contract that the component you requested something from WILL give you a response. Not now, but later. It might be a success or an error, but you will get called back. (For old-school folks, it's a async-callback).The code behind it would publish the command message, but wait for the status topic to reply back with the same state as requested for a short timeout, maybe retry a few times and finally return success or failure in the promise assigned call back.The end-device does not implement request IDs, so no way to track request-response 1 for 1. Just need to wing it.In the mean time, I added a timer to republish status requests every minute, just in case.

author: paulca
author_rank: Super Contributor
timestamp: March 16, 2021, 12:11:43 pm
content: Next challenge, asides checking the calibration on the humidity sensor is to automate the extractor fan speed.It has a knob controller already. I imagine as it's a 240V 50W fan it will probably be a triac? So all I really need to do is measure the control voltage it produces and mimic that from an analogue MCU pin.... unless it's not a DC controlled Triac of course.Could I just use a normal 240V dimmer circuit on a mains motor?

author: Alti
author_rank: Frequent Contributor
timestamp: March 16, 2021, 01:06:51 pm
content: Do not focus too much on heating, loosing main objective.And main objective is to not to burn your house down. Make sure that in case of any controller failure the losses are contained. If the failure of some component (fan) brings fire hazard - this is not what you want. If you still need that controller, use some safety rated components, like thermal cut-offs. So peak mains voltage, lowest tolerance heater element, triac dead short and seized fan should not cause havoc there.

author: paulca
author_rank: Super Contributor
timestamp: March 16, 2021, 05:34:42 pm
content: Quote from: Alti on March 16, 2021, 01:06:51 pmObvious risk is a 240V heater in a humid environment with water around, in a sealed plastic tent. That said, it is a reputable domestic brand and has it's own thermostat (set to half way), an normal overload thermal cut out on the element and a "fall over" switch which means it has to be sitting upright and if it falls over it auto shuts off. It's cover proof and knock-over proof.There is spill risk against the electricals at the bottom of the tent. Mitigation there would be to put the electrics up off the floor, hung or on risers at least.Anything that can be outside the tent is outside the tent, only things that have to be in there are contained in it. Heater, Fan, Humidifier, Heat mat... sensors. The extractor is currently inside, but I am moving it outside to save space and risk.The tent itself is in the garage and the mitigation there is to move the junk boxes away from it. If there is a fire, the tent will quickly shrink and drip into a burning mass of plastic. Unless it can reach the wooden 2.5 meter ceiling beams before it burns out... the afore mentioned junk boxes are the biggest risk for spread.I should have a smoke alarm in there anyway. A good smart one would be nice as I'm not sure I would hear a smoke alarm in the garage from bed, but if I can repeat the sounded inside bonus points.

author: paulca
author_rank: Super Contributor
timestamp: March 16, 2021, 05:48:58 pm
content: The way I have implemented these control systems for temperature and my home heating in the past has been more strict that this project.In my heating control I do not rely on anything, or any device to turn something OFF. OFF is just the default state and if nothing demands otherwise it turns off an stays off. That extends down to the firmware on the boiler controller noting the expiry on the control message to turn it ON and if that time expires and nobody has updated it, the firmware switches the relay off. (I confess this code is still not deployed on the relay device... shame.. it is contained in the HTTP controller for it)They way this works is, something sends an update to a temp, that results in a need for heating. A "demand" is raised with a time stamp and an expiry of 5 minutes. The heating will now be on for 5 minutes unless something specifically turns it off. The system will constantly strive to maintain that it stays ON, even if you try and manual turn it off or reboot something. It will not give up. However, if the Gods strike the house and the server goes on fire, that demand will expire and the heating will turn off. However, assuming the world is normal and nice, the demand will be continually refreshed until it's no longer necessary, when it will be left to expire.It's fault tolerant is most cases as it defaults back to safe. The only component that could fail and leave the heating on is the MCU controlling the relay locking up with the relay closed. Not yet, but I have plans for that also, certainly in terms of monitoring the health of my sheep (wifi devices) to keep tabs on them and raise alarm if one of them is offline.... especially if it's in a dangerous state when it did so, such as "ON".

author: paulca
author_rank: Super Contributor
timestamp: April 15, 2021, 10:17:56 am
content: Seems to be functioning as expected these days. The attachment is 24 hour period. The lights are OFF between 10am and 5pm.You can see the heater "accordian" showing the coolest part of the night and also when the light is out, the total heat drops by 100W, so the heater kicks back in.It's odd though. When it gets warm enough to not need a heater, I will be done with the propagator for the year.... Unless I use it to play with fully automated, electronic controlled hydro! More hobby, more $$$. It's always the same.EDIT: The "garage temp" in the graph is recorded by a sensor a little close to the south facing wall, it reads artificially high. If the garage ambient was actually above the propagator temp, I would just flip the ventilation to high

author: Microdoser
author_rank: Frequent Contributor
timestamp: April 15, 2021, 11:56:11 am
content: Quote from: paulca on February 25, 2021, 12:39:26 pmI have one of those I bought from Ebay for £11.99, although the price has since gone up to £15.99. Very similar controller, uses a thermocouple (included) and a 40 amp SSR (included). The SSR states 40 amp but BigClive dot com recently did a teardown of one and found the internals only rated to half the stated amps, but that is still 20 amps.Works fine. Starts full on then reduces the pulse width to maintain a set temperature to within 1 degree C.I use it to control a toaster oven for SMD reflow, copes fine with the ~800W heater in there so 250W would be fine.https://www.ebay.co.uk/itm/Digital-LCD-PID-REX-C100-Temperature-Controller-Set-K-Thermocouple-Max-40A-SSR/313203913699