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

Thread Starter

PaulEE

Joined Dec 23, 2011
423
Thank you all in advance for viewing my post.

I have a project that involves high-resolution pulse-width modulation. I am contemplating the best way to generate it.

The reason I need at least 12-bit resolution is because the control signal is being generated by a 12-bit DAC.

I contemplated microcontroller-derived signals; both with the pulse-width modulation unit as well as interrupt-driven timer solutions. All work, but the former is limited to 8-bits and the latter is very slow, even at a 20 MHz clock.

I've seen single-IC pulse-width modulation solutions in applications like switching power supplies, but I have no experience with these (do they work well?)

Another important factor is the duty-cycle capabilities. I need a duty-cycle that is linearly-proportional to the control voltage as well as a duty-cycle that can run as close to zero and as high as 98-100% of a full duty-cycle.

The eventual application is a temperature control circuit - hence the tight specs on PWM resolution and duty-cycle capability.

Thank you in advance.
 

Thread Starter

PaulEE

Joined Dec 23, 2011
423
nickel,

I have a full license to an 8-bit PIC compiler; if the 18f1330 does indeed have 11-bits of resolution, you've just saved me a ton of time. I scoured Microchip's website a few months back for the same project and could *not* find anything higher than 10-bits.

Thinking in more detail, 11-bits would work. The DAC is able to control a power amplifier in the current device such that 0-2.5V is heat and 2.5-5v is cool. Using the same logic, a 12-bit output split in half will be a lesser overall resolution for any particular heat/cool range.

I am definitely going to look into the 18f1330.

Any other thoughts also appreciated, everyone! Thank you!
 

kubeek

Joined Sep 20, 2005
5,724
I dont uderstand where is the PWM being generated? Is it in the amp, or in the fpga? Is the DAC linear or pwm? You could simply generate the PWM right in the fpga..
 

Thread Starter

PaulEE

Joined Dec 23, 2011
423
I dont uderstand where is the PWM being generated? Is it in the amp, or in the fpga? Is the DAC linear or pwm?
kubeek,

That is the question, precisely! I am trying to figure out the best method to generate the pulse-width modulation signal itself.

Thanks
 

Thread Starter

PaulEE

Joined Dec 23, 2011
423
In the Microchip series, look at the Power Control PWM devices. A Pic18f1330 has about 11 bits resolution, and a dsPIC30f1010 has around 15 bits, in the 20 kHz frequency range.
nickelflipper,

You've just saved me a TON of time. I really appreciate you bringing the 18f1330 to my attention. Up until today, I have never seen this chip before.

It is *exactly* what I was looking for. I am well-versed in PIC programming and solve many of my design problems with 12f683s, 18f4550s, etc., and now it seems that another will be solved via the 18f1330.

The other great thing about the 18f1330 is that I can control other fault protection circuitry and logic with spare pins. Very, very cool.

MUCHOS gracias, as they say!
 

kubeek

Joined Sep 20, 2005
5,724
I think generating arbitrary precision PWM will be easier inside the fpga´s digital domain, as oposed to converting it to analog and then back to "digital". That is if you still got enough pins and space, but hopefully that would not be a problem.
 

Thread Starter

PaulEE

Joined Dec 23, 2011
423
That was my original thought, but the circuit boards (ten of them, four layer) have already been designed and populated with AD5440 (or something similar) DAC chips. Some of the applications that this board is used for require analog power amplifiers to be used, which was the other reason that the PWM wasn't synthesized in the FPGA; great suggestion, though.

Thanks
 

kubeek

Joined Sep 20, 2005
5,724
Fixed frequency PWM with duty cycle x can be made by simply counting from 0 to n and then again from 0, setting the output bit to '1' for numbers 0 to x and to '0' from x to n.
Making a 20bit counter is as easy as a 8bit one, and the FPGAs i know run on 50MHz internal clock so there should be no problem getting any frequency and resolution you need.
 
nickelflipper,

You've just saved me a TON of time. I really appreciate you bringing the 18f1330 to my attention. Up until today, I have never seen this chip before.

It is *exactly* what I was looking for. I am well-versed in PIC programming and solve many of my design problems with 12f683s, 18f4550s, etc., and now it seems that another will be solved via the 18f1330.

The other great thing about the 18f1330 is that I can control other fault protection circuitry and logic with spare pins. Very, very cool.

MUCHOS gracias, as they say!
You are welcome. The 18f1330 is a unique device. At the time, I picked one up for the three PWM outputs for rgb led's. As an added bonus, was able to get 500 step servo resolution (1000 steps do-able), all in hardware :).
 

Thread Starter

PaulEE

Joined Dec 23, 2011
423
You are welcome. The 18f1330 is a unique device. At the time, I picked one up for the three PWM outputs for rgb led's. As an added bonus, was able to get 500 step servo resolution (1000 steps do-able), all in hardware :).
What makes me angry is Microchip's parametric search. Under the 18F series chips, I had "N/A" or "10 bits" under "PWM Resolution" to choose from.

N/A does not equal "12 bits"!!!

I am sending them a crabby-gram.

Thanks again, this chip was precisely (pun) what I was looking for!
 

Markd77

Joined Sep 7, 2009
2,806
Another possible approach would be dithering. You could use 10 bit PWM and if you wanted an output in between 2 available duty cycles, just alternate between them for either 1/4, 1/2, or 3/4 of the time.
 

Thread Starter

PaulEE

Joined Dec 23, 2011
423
Another possible approach would be dithering. You could use 10 bit PWM and if you wanted an output in between 2 available duty cycles, just alternate between them for either 1/4, 1/2, or 3/4 of the time.
Another interesting suggestion. I thought about that also, except, I was not sure if I could tell the PWM modules in the PIC to act the way I needed.

Thanks for that thought
 

MrChips

Joined Oct 2, 2009
21,070
The reason I need at least 12-bit resolution is because the control signal is being generated by a 12-bit DAC.
The resolution of the PWM output may have nothing to do with the resolution of the DAC. You really have to define what are you controlling with the PWM and how much resolution do you actually need.
 

THE_RB

Joined Feb 11, 2008
5,438
12bit has been done on 10bit PIC PWM DACs for years, you just keep 4 PWM variables and alternate between them (in sequence, in the PWM interrupt);
A 602
B 601
C 601
D 601

Which gives a 12bit PWM value of 601.25
:)
 

Thread Starter

PaulEE

Joined Dec 23, 2011
423
The resolution of the PWM output may have nothing to do with the resolution of the DAC. You really have to define what are you controlling with the PWM and how much resolution do you actually need.
Is it not the same thing? In my mind (which is apparently wrong?), I think of 12 bits of resolution as being 2^12 discrete controllable states that the output can be in. It seemed to stand to reason that this carried over to pulse-width modulation.

Can you cite an example in which there is not a 1:1 correspondence?

Anxious to hear about this. Thanks
 

Thread Starter

PaulEE

Joined Dec 23, 2011
423
12bit has been done on 10bit PIC PWM DACs for years, you just keep 4 PWM variables and alternate between them (in sequence, in the PWM interrupt);
A 602
B 601
C 601
D 601

Which gives a 12bit PWM value of 601.25
:)
This is quite interesting. Basically, you're using the law of averages to effectively generate 12 bits by superimposing four PWM module outputs? Very cool, but I can think of issues at the H-bridge output stage. Since the PWM modules are all going at once (right?), I would have to be careful that an entire half bridge on either side of the H-bridge wasn't on at once, or...SMOKE! :/

Then again, if all I'm doing is alternating values, it should work just as it would if I were only using one...very neat.

Thanks
 
Last edited:

Thread Starter

PaulEE

Joined Dec 23, 2011
423
MrChips,

I think I understand why it isn't necessarily the same.

With the DAC 12-bit output giving 0v-5v, the PWM signal might be amplified and buffered for 0v-12v output, which will correspond to different resolution.

It seems to me that I will have to quantify amount of power needed to move a particular amount of heat energy from the aluminum block with the peltier modules, such that I can correctly scale and derive the proper resolution.

Is this what you were getting at?

Thanks
 
Top