Quick advice on PIC choice?

Thread Starter

urb-nurd

Joined Jul 9, 2014
269
Hey guys. i am trying to control a small DC heater with some Soft Pid control using a PIC and PWM via a mosfet.

I understand the theory behind all this, however this will be my first physical attempt at this project.

I was wondering if anyone could help me pick some parts here, first off. I use Mikroc at university and will be using it this year - therefore i would like to be able to use mikroc with my PIC and Board.

I also am not sure what type of mofset to use as a switch for the PWM control of my heater.
I was thinking something like this http://www.hobbytronics.co.uk/irf1405-mosfet
However, i have no real solid idea.

I also would like to measure the temperature of my heater and so considered a thermistor or RTD.

Any advice on the following is greatly appreciated:

What Pic and Board can i use with mikroc (funds are very low, so cheap as possible! hence why im not looking at the microelectronica boards)

What mosfet is best used a a switch for PWM a heater vis soft PID.

What would be better for accurate PID control of a heater that would get in excess of 300 Celcius - RTD, thermistor or other?

thanks alot guys!

Edit: for clarification, the heater will be cooled frequently with air flow. possibly loosing it's set point about once every ten seconds.
 
Last edited:

joeyd999

Joined Jun 6, 2011
5,283
My guess, off the top of my head, is that you are going to be better off with an RTD or thermocouple at 300C. I use thermistors for temperature measurement, but only close to room temperature.

RTDs are easier to drive accurately than thermocouples. Pay attention to the resistance curve vs. temperature and design appropriately.

Remember that a physical heater has a significantly large thermal mass. It doesn't change temperature all that quickly, so you don't really need a fast pid or pwm. In fact, I assume you will be driving considerable power into the heater, so switching it at a much longer period would help to eliminate noise. A one second PWM period, or longer, should be acceptable.

Also, the switching transients may couple into the small temperature signal. Syncronize your A/D conversions with the transients to eliminate this as a noise source.

There will be more good advice to come from others, I am sure.
 

Thread Starter

urb-nurd

Joined Jul 9, 2014
269
My guess, off the top of my head, is that you are going to be better off with an RTD or thermocouple at 300C. I use thermistors for temperature measurement, but only close to room temperature.

RTDs are easier to drive accurately than thermocouples. Pay attention to the resistance curve vs. temperature and design appropriately.

Remember that a physical heater has a significantly large thermal mass. It doesn't change temperature all that quickly, so you don't really need a fast pid or pwm. In fact, I assume you will be driving considerable power into the heater, so switching it at a much longer period would help to eliminate noise. A one second PWM period, or longer, should be acceptable.

Also, the switching transients may couple into the small temperature signal. Syncronize your A/D conversions with the transients to eliminate this as a noise source.

There will be more good advice to come from others, I am sure.
Wow, more in depth than i imagined! thanks!

I meant to say thermocouple not thermistor haha! thanks for the recommendation.

could you elaborate on the switching of the mosfets effect on the RTD's sensitivity?
 

NorthGuy

Joined Jun 28, 2014
611
Heaters are very slow. Electric range, for example, switches only few times a minute. Therefore, you probably do not need PWM. You simply measure the temperature once a second. If it gets too cold, you switch it on. If it gets too hot, you switch if off.
 

Thread Starter

urb-nurd

Joined Jul 9, 2014
269
Heaters are very slow. Electric range, for example, switches only few times a minute. Therefore, you probably do not need PWM. You simply measure the temperature once a second. If it gets too cold, you switch it on. If it gets too hot, you switch if off.
thanks for the input!

The heater will be cooled frequently by rapid air flow, the aim of the temperature control is to try maintain this temperature as soon as cooling begins.

As air is drawn past the heater i would like the air to be a consistent temperature through out.
 

joeyd999

Joined Jun 6, 2011
5,283
...Could you elaborate on the switching of the mosfets effect on the RTD's sensitivity?
I have an application very close to what you are trying to do, albeit at much lower temperatures. Here is a thread I made about it, there might be some useful information for you:

http://forum.allaboutcircuits.com/showthread.php?t=64095&highlight=thermistor

You said you want DC control of the heater. I assume this means that the heater is going to operate off the same supply as the controller. Every time the heater switches on or off, a significant transient will be produced that may (probably will) perturb your low-level, high-impedance temperature signal. This will introduce synchronous (i.e. correlated) noise into your measurement.

Even if you use separate supplies for the controller and the heater, synchronous noise can be inductively coupled into your low-level analog signal.

Synchronous noise is different than asynchronous (uncorrelated) noise in that, a) it is predictable and b) no amount of filtering will remove it. Worse, if you sample at a rate different than the noise signal, your samples will acquire an additional beat frequency that, under some conditions will start to look like a bad, variable DC error.

OTH, synchronous noise is *easy* to eliminate entirely, if you know its source, and if you can align your a/d conversions with the transients.

I would approach your case like this:

Pick a PWM period, say 1 second.
Pick a PWM frequency, say 1024 hz -- therefore, your minimum time slice is just less than a millisecond, and your PWM resolution is 1024 counts.

Each millisecond, start (and complete) an a/d conversion just prior to the switching of power (which may, or may not, happen, depending on the PWM duty).

In this way, the a/d has had a full 1ms to settle prior to the conversion, and any transients occur only after the conversion is complete.

Clear as mud, I know.
 

NorthGuy

Joined Jun 28, 2014
611
The heater will be cooled frequently by rapid air flow, the aim of the temperature control is to try maintain this temperature as soon as cooling begins.
Should still be very slow. Remembering how it works with soldering station, it takes nearly a minute for it to cool down (about 5°C/sec). At any rate, if you measure once per 100ms, and then switch according to the last measurement (if higher than Ton then switch on, if lower than Toff switch off), it is still very slow for a PIC. You may get some overshoot (which you can control by manipulating Ton and Toff), but overall this type of control works much better than PID over PWM.
 

joeyd999

Joined Jun 6, 2011
5,283
Should still be very slow. Remembering how it works with soldering station, it takes nearly a minute for it to cool down (about 5°C/sec). At any rate, if you measure once per 100ms, and then switch according to the last measurement (if higher than Ton then switch on, if lower than Toff switch off), it is still very slow for a PIC. You may get some overshoot (which you can control by manipulating Ton and Toff), but overall this type of control works much better than PID over PWM.
The problem is, a bang-bang controller, as you are proposing, will not compensate for the thermal lag between when the power is applied and when the air/RTD is heated. Therefore, there *will* be overshoot and undershoot.

A properly tuned pid will predict power requirements in advance, eliminating the over/undershoot.
 

Thread Starter

urb-nurd

Joined Jul 9, 2014
269
I have an application very close to what you are trying to do, albeit at much lower temperatures. Here is a thread I made about it, there might be some useful information for you:

http://forum.allaboutcircuits.com/showthread.php?t=64095&highlight=thermistor

You said you want DC control of the heater. I assume this means that the heater is going to operate off the same supply as the controller. Every time the heater switches on or off, a significant transient will be produced that may (probably will) perturb your low-level, high-impedance temperature signal. This will introduce synchronous (i.e. correlated) noise into your measurement.

Even if you use separate supplies for the controller and the heater, synchronous noise can be inductively coupled into your low-level analog signal.

Synchronous noise is different than asynchronous (uncorrelated) noise in that, a) it is predictable and b) no amount of filtering will remove it. Worse, if you sample at a rate different than the noise signal, your samples will acquire an additional beat frequency that, under some conditions will start to look like a bad, variable DC error.

OTH, synchronous noise is *easy* to eliminate entirely, if you know its source, and if you can align your a/d conversions with the transients.

I would approach your case like this:

Pick a PWM period, say 1 second.
Pick a PWM frequency, say 1024 hz -- therefore, your minimum time slice is just less than a millisecond, and your PWM resolution is 1024 counts.

Each millisecond, start (and complete) an a/d conversion just prior to the switching of power (which may, or may not, happen, depending on the PWM duty).

In this way, the a/d has had a full 1ms to settle prior to the conversion, and any transients occur only after the conversion is complete.

Clear as mud, I know.
Thank you for that, i really do appreciate the time spent!
 

Thread Starter

urb-nurd

Joined Jul 9, 2014
269
The problem is, a bang-bang controller, as you are proposing, will not compensate for the thermal lag between when the power is applied and when the air/RTD is heated. Therefore, there *will* be overshoot and undershoot.

A properly tuned pid will predict power requirements in advance, eliminating the over/undershoot.
i have used PID controllers in conjunction with PLC's before.
I (wrongly) assumed i could implement a similar algorithm using code only.
What would you recommend to control the temperature?
 

NorthGuy

Joined Jun 28, 2014
611
The problem is, a bang-bang controller, as you are proposing, will not compensate for the thermal lag between when the power is applied and when the air/RTD is heated. Therefore, there *will* be overshoot and undershoot.
It depends on how much of an overshoot you get. If you want your temperature to vary between Tl and Th, and overshoot is O then you set your switch points to Ton=Tl+O anf Toff=Th-O. Overshoot will be a problem only if O > (Th-Tl)/2, although by introducing a waiting period you can make it work well with O close to (Th-Tl).

The problem might be of two sorts:

Too big of an overshoot. If you put a heater at one end of a long corridor and measure temperature at the other end, you get enormous overshoot, so PID will do better.

Too strict requirements - too narrow (Th-Tl) - in which case PID won't do any better.
 

joeyd999

Joined Jun 6, 2011
5,283
i have used PID controllers in conjunction with PLC's before.
I (wrongly) assumed i could implement a similar algorithm using code only.
What would you recommend to control the temperature?
Wrongly? I have said nothing to the contrary with respect to your original post. You may approach the problem with a PID controller. And the PID controller may be implemented as a mcu/software solution. I even referred to a thread where I did the exact same thing, but at a lower temperature.
 

NorthGuy

Joined Jun 28, 2014
611
And if you desire no overshoot/undershoot at all???
Every switching system has some sort of ripple. Then there are measurement errors, noise etc. So, if you desire absolute accuracy, you're not going to get it in the real world.

Every design should start from defining the acceptable range of parameters, then designing a method to meet the goal.
 

Thread Starter

urb-nurd

Joined Jul 9, 2014
269
Every switching system has some sort of ripple. Then there are measurement errors, noise etc. So, if you desire absolute accuracy, you're not going to get it in the real world.

Every design should start from defining the acceptable range of parameters, then designing a method to meet the goal.
To clarify, my RTD would be fixed to the heater.

The accuracy im looking for will be around 4-5 Celsius either way.

Im afraid i have been lost in the discussions of this thread.
What is the general consensus?
I can use a PIC with a mosfet to PWM the heater? However there are caveats that will need to be addressed?

I am still looking for advice on the Mosfet and PIC programmer that i can use with Mikroc if anyone has an idea.

Thanks again to everyone for their input
 

Thread Starter

urb-nurd

Joined Jul 9, 2014
269
Yes. Since your switching frequency is low, going with bigger mosfet with low Rds(on) will help to conserve power and possibly eliminate the need for a heatsink. What is your voltage and current?
Fantastic!
My voltage will be 7.4V (peak at 8.4) and the curent will be 1.5 amps from the heater.
 
Top