Implementing PID control using a microcontroller

THE_RB

Joined Feb 11, 2008
5,438
A more elaborate feedback controller could be needed if there is a large thermal lag in the system, which could cause significant overshoot in the system temperature.
That's a good point about thermal lag and I agree with you.

However I have built a few industrial incubators/ovens etc, and in a closed environment (which loses heat slowly) a setpoint controller with a fine setpoint (and no hysteresis) works just fine, keeping the temp within about 1 degree C or so at the sensor.

Large thermal lag can get you into trouble but as I said if the sensor is reasonably close to the heater element the thermal lag is small and it will cycle every few seconds with very little heat ripple (maybe 1'C heat ripple at the sensor, but fas less than 1'C heat ripple through the majority of the heated volume).
 

Thread Starter

Mitchy190

Joined Apr 23, 2012
33
If my heat source requires a voltage higher than what my chip can output, which i think this will be likely, would a viable solution be to use a transistor on the output of the pwm pin so a higher supply to the heater can be used?
 

tracecom

Joined Apr 16, 2010
3,944
If my heat source requires a voltage higher than what my chip can output, which i think this will be likely, would a viable solution be to use a transistor on the output of the pwm pin so a higher supply to the heater can be used?
Generally, that situation uses an N-channel MOSFET in a low-side switching arrangement.
 

Thread Starter

Mitchy190

Joined Apr 23, 2012
33
Also if this is a solution, could I use lets the 12v suply to the heater and reduce the voltage using a potential divider or voltage regulator, and then use this as my supply to the chip?
 

tracecom

Joined Apr 16, 2010
3,944
Also if this is a solution, could I use lets the 12v suply to the heater and reduce the voltage using a potential divider or voltage regulator, and then use this as my supply to the chip?
Sure, that's standard procedure. Here's a schematic for another project that might give you some help. Note that whatever MOSFET you use must be able to be controlled by a logic level input to the gate. Also note that, depending on the quality of your 12VDC input, you may need a 10uf cap on the output of the 78L05.
 

Attachments

Thread Starter

Mitchy190

Joined Apr 23, 2012
33
Alex you mentioned an Opto triac? It turns out to get the heat I require I will need to use a ceramic heater which requires mains voltage.

I have never used an opto triac? Do you have any suggestions on how to set the correct circuit up?
 

BobTPH

Joined Jun 5, 2013
8,938
An opto triac is simple to use. The input side is just and LED and is driven via a voltage + series resistor. The output side is wired just like an AC switch.


Bob
 

Thread Starter

Mitchy190

Joined Apr 23, 2012
33
Haha, its a 4ft long tank for a ball python, my temp in my thread is wrong as I was going to make a temp control for a corn snake, but I have changed my mind.

The temp now needs to be around 35 degrees and as its a larger tank a more suitable heater is required.

And to answer your question probably a 100-150watt ceramic heat bulb.

I'm still slightly confused with this opto triac. So my source is the mains AC voltage, does this opto triac sit on the output of the PWM pin of the micro, then the output of the opto then in turn controls the power to the heat source?

I also need to tap into the my source voltage to use for my micros supply, are some rectifiers and step down transformers needed? Or is there some other magical way :)

Thanks for you help by the way guys, really is helping me.
 

alexfreed

Joined Oct 8, 2012
72
Yes, that's the right schematics. The LED is only needed for visual indication of when the heater is powered. You need a resistor between the control input and the PIC. Assuming a voltage drop of about 4 volts across the LED and the optocoupler there is an extra volt to drop. At say 10 mA (good for the LED but need to check the spec for the optocoupler) a 100 ohm resistor will be good.
 

Thread Starter

Mitchy190

Joined Apr 23, 2012
33
Brilliant thank you! And another thing, to use the mains supply as my chips source voltage I guess I will need use a step down transformer and then a full wave rectifier (with a smoothing cap) ?
 

alexfreed

Joined Oct 8, 2012
72
The old school call for a transformer, rectifier, cap and probably a voltage regulator like 7805.
The new school says get a $2 5V cell phone charger on ebay.
 

Thread Starter

Mitchy190

Joined Apr 23, 2012
33
I see, but that raises yet another question on my behalf! Haha. If I was going to use a phone charger how would I then get the mains ac voltage to my heat source, I would ideally like one power cable into the system, however running the mains voltage along a cable beside my lovely filtered dc signal suggest I will get mains hum along it? I am right in thinking this? And is there any solution to which my ideal scenario can be used?
 
Last edited:

alexfreed

Joined Oct 8, 2012
72
A power cord with at least 2 outputs comes to mind.
As for the "mains hum", you are not building an audio system with high-Z low level input. Definitely not an issue.
 

Thread Starter

Mitchy190

Joined Apr 23, 2012
33
That what I like to here! Thank you :)

I found this schematic which is similar to what I want to do, Im in the process of creating my own now. I will post it once finished.

Thanks for all of your help.

Practical-Temperature-Controller-Circuit-Diagram.jpg
 

tracecom

Joined Apr 16, 2010
3,944
That what I like to here! Thank you :)

I found this schematic which is similar to what I want to do, Im in the process of creating my own now. I will post it once finished.

Thanks for all of your help.

View attachment 60640
At a glance, I can see that the 7805 circuit does not follow the datasheet guidelines. When I see such an obvious omission, it makes me suspicious of the entire drawing.
 

THE_RB

Joined Feb 11, 2008
5,438
Tracecom, what's wrong with the 7805 circuit?

1000uF on Vin and 10uF on Vout is not at all unusual for commercial designs.
 
Top