Most convenient/efficient/straight-forward method of producing 12-bit, 20 kHz PWM

Thread Starter

PaulEE

Joined Dec 23, 2011
474
And, in the event that this was what you were referring to, I haven't the slightest idea how to do that.

I suppose I'd have to come up with an expression that relates the specific heat and mass of the aluminum block, the ambient temperature, efficiency of the peltiers, etc.

It almost sounds more efficient to simply use 11-12 bits of PWM and look at results...

Right now the device is an analog power amplifier, so the resolution is *just* 11 bits in either heat/cool mode, which is why I thought I could simply sub. in PWM and call it done.

Thanks
 

MrChips

Joined Oct 2, 2009
30,720
I have no idea what you are talking about.

But as an example, suppose I have a control knob with 12-bit resolution but all I need is to dial up how dark I want my toast to be in the morning, with a choice of 4 settings, 1-2-3-4 levels of darkness. See what I am getting at?
 

Thread Starter

PaulEE

Joined Dec 23, 2011
474
I have no idea what you are talking about.

But as an example, suppose I have a control knob with 12-bit resolution but all I need is to dial up how dark I want my toast to be in the morning, with a choice of 4 settings, 1-2-3-4 levels of darkness. See what I am getting at?
We're saying the same thing.

My issue is that I do not know how to quantify how many steps my "toaster knob" needs. I am not sure what resolution I need.

I am working on a design that was created by someone else - and they never wrote down any rhyme or reason as to why they chose 12 bits; I was just continuing with this.

The goal is to temperature regulate an aluminum block to 25 +/- 0.001 *C (which ends up being +/- 0.01 *C, but in either case, pretty stable). Eventually, it'll be a large strip of copper metal that gets to be 60*C or so...which is why I'm using PWM to drive the peltier coolers instead of a linear power amplifier or similar setup.

So, instead of the 1-2-3-4 toaster setting, I need a 1 - 2 - ... - 2^11-step switch.

In either case, the PIC18F1330 is a chip that I can, at least, mimic the first design with.

As far as getting the analog value into the PIC18F1330, I figure I'll feed two ADC ports with one-half of the total DAC range and oversample to get 11-bit values from a 10-bit ADC (which I posted a separate thread about).

To be clearer:

-DAC yields 12-bit analog control signal. Range 0v to +5v.

-HALF of that range, with the reference point at +2.5v, would be responsible for HEAT on the TEC modules (-2.5v to 0). The other range, 0v to +2.5v, would be COOL.

-Splitting the original 12-bit DAC value in half yields two 11-bit analog ranges.

-Oversampling with 10-bit integrated ADCs on the PIC18F1330 will yield 11-bit analog values for each range (two separate ADCs used, one for HEAT range, one for COOL range)

-PIC18F1330's higher resolution (and faster) pulse-width modulation modules will yield the PWM output I am aiming for.

Thanks for the input
 

joeyd999

Joined Jun 6, 2011
5,237
I've implemented a 14 bit 20khz pwm on a PIC16C774 controlling a platinum wire within +/- 1C up to 800C about 10 years ago. It can be done.
 

MrChips

Joined Oct 2, 2009
30,720
Hmmm, it is not so simple.

You are heating an aluminum block that has a certain amount of thermal mass and a long time constant. You must be using some kind of PID control loop to regulate the temperature. To measure the temperature at 25C +/- 0.01C will need at least 12-bit temperature. At 60C you will need more than 12 bits.

12-bit PWM heater is probably overkill. I cannot quantify how many bits minimum you will need. People have done this with one bit!
 

Thread Starter

PaulEE

Joined Dec 23, 2011
474
I've implemented a 14 bit 20khz pwm on a PIC16C774 controlling a platinum wire within +/- 1C up to 800C about 10 years ago. It can be done.
From that chip's datasheet with a 20 MHz clock, I see this table (below).



How'd you get around this table to achieve 14-bit resolution at 20 kHz? Schemes like cycling the duty cycle configuration value as mentioned in prior responses?

Thanks
 

joeyd999

Joined Jun 6, 2011
5,237
How'd you get around this table to achieve 14-bit resolution at 20 kHz? Schemes like cycling the duty cycle configuration value as mentioned in prior responses?

Thanks
Yes, basically dithering the PWM counts each cycle to simulate the extra bits. Works really well! The PID operated on the same time base (actually, in the same interrupt routine). As a consequence, about 90% of the instruction cycles were consumed just in PID/PWM code. At 20Mhz, this left me 500,000 instructions/second to run the user interface. *Plenty* of time!
 

Thread Starter

PaulEE

Joined Dec 23, 2011
474
Yes, basically dithering the PWM counts each cycle to simulate the extra bits. Works really well! The PID operated on the same time base (actually, in the same interrupt routine). As a consequence, about 90% of the instruction cycles were consumed just in PID/PWM code. At 20Mhz, this left me 500,000 instructions/second to run the user interface. *Plenty* of time!
Nice! at 200nS/cycle, that left you just under an eternity for the user interface! Or serial I/O as is my case...very cool!

Thanks again to everyone that helped with this thread. Much appreciated.
 

joeyd999

Joined Jun 6, 2011
5,237
Nice! at 200nS/cycle, that left you just under an eternity for the user interface! Or serial I/O as is my case...very cool!

Thanks again to everyone that helped with this thread. Much appreciated.
As a matter of fact, the initial prototype pumped all the data out of the EUSART for analysis/fine tuning of the PID. I wrote a custom app for the PC to capture the data, process it through various transforms, graph it, and feed back PID constants to find the 'magic' numbers.
 

Ron H

Joined Apr 14, 2005
7,063
So - IS the cooler in a feedback loop, i.e., are you sensing the temperature and feeding it back, comparing it with a (adjustable) reference?
 

Thread Starter

PaulEE

Joined Dec 23, 2011
474
So - IS the cooler in a feedback loop, i.e., are you sensing the temperature and feeding it back, comparing it with a (adjustable) reference?
The order of operations is as follows:

-Unit powers on, block near room temp.
-Silicon NTC thermistor in a hole in the middle of block is read by 24 bit ADC. (thermistor is part of wheatstone circuit)
-Data fed via FPGA to LabVIEW GUI.
-LabVIEW PID loop implmements our PID constants and calculates the appropriate corrected output signal.
-Output signal travels through FPGA to 12-bit DAC.
-DAC output goes through a level shifter and power amplifier
-Power amplifier output drives peltier coolers (two of them in series)

x infinity :)
 

MrChips

Joined Oct 2, 2009
30,720
I think we could be running around in circles here.
Why do you need PWM output?
Why not feed the analog output of the DAC into the power amp?
Have you considered what effect the noise from a PWM driven power amp will have on a 24-bit ADC?
 

joeyd999

Joined Jun 6, 2011
5,237
I agree with Mr. Chips. You definitely do not need 12 bits of resolution on your PWM/DAC.

Once your copper mass has achieved proper temperature, the I of your PID will automatically modulate the PWM/DAC to maintain proper temp. You should easily be able to get by with 8 or 10 bits, especially if you update the PWM/DAC fast enough (i.e. >> thermal time constant of the thermal mass).

The analog front end (the temp sensor & A/D) is where the resolution in this app really counts.

I was relating just the other day where I implemented a temp regulator with 0.05C accuracy using 10 bit a/d and 10 bit pwm. Here is the thread:

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

Thread Starter

PaulEE

Joined Dec 23, 2011
474
I feel like everyone is forgetting something...

Imagine the load on the power amp when the chunk of metal first begins to race to 60 degrees...the linear amplifier will be punching amps out and it'll get hotter than the device it's cooling!

The pulse-width modulation scheme was going to allow me to use near-lossless mosfet switching circuits to supply the needed power without being grossly inefficient...
:)
 

joeyd999

Joined Jun 6, 2011
5,237
I feel like everyone is forgetting something...

Imagine the load on the power amp when the chunk of metal first begins to race to 60 degrees...the linear amplifier will be punching amps out and it'll get hotter than the device it's cooling!

The pulse-width modulation scheme was going to allow me to use near-lossless mosfet switching circuits to supply the needed power without being grossly inefficient in the amplifier...

:)
I assumed you were going to use a class 'D' power amp (i.e. pwm). Still don't need such high resolution on the PWM.
 

Thread Starter

PaulEE

Joined Dec 23, 2011
474
I assumed you were going to use a class 'D' power amp (i.e. pwm). Still don't need such high resolution on the PWM.
That's practically what it is. The analog circuit I have now is the complete package; ramp generator, level shifting, buffer, comparator, logic output to control MOSFET gates, gate driving transistors buffers, and the output.

And, the more I listen to you all talk about not needing such high resolution, the quicker I'm realizing that I can just use my design that exists and be done.

I just wish I knew the theoretical reasoning behind why I do not need the resolution.

Thanks for the support on this
 

joeyd999

Joined Jun 6, 2011
5,237
I just wish I knew the theoretical reasoning behind why I do not need the resolution.
This is easy. The 'I', or integral term, of your PID guarantees 0 DC error. The actual temperature, in a perfectly tuned system, will oscillate, just a little bit, around the set point. The magnitude of the oscillation is your AC error, and will be dependent upon the resolution of your A/D converter and the speed with which you update your PWM. The overall resolution of the PWM has little impact, *as long as you update it fast enough*.

You could do this with a 1 bit pwm with a very high update rate, and the results could be acceptable.
 

Thread Starter

PaulEE

Joined Dec 23, 2011
474
But don't forget what I said about messing up your nice 24-bit ADC.
The output of the H-bridge has two chunky capacitors. The peltiers see DC. I did think about the 24 bit converter noise :)

At low duty cycles, the response time might be slower, but at high power, which will be the case 95% of the time (it'll always be cooling, a lot) , the response time will be inherently quick because the caps will need to constantly discharge to supply current.

Thanks everyone!
 
Top