Maker Pro
Maker Pro

micro PWM (0 ro 5V) to analog (0-12V) design help needed

C

craig

Jan 1, 1970
0
Hi guys,

I have a 12bit PWM output (0 to 5V) on my PIC.
I need to generate a 0-12V analog output.
preferably 50% duty cycle = 6V output.

I do have a 12V supply in my circuit already.

Any ideas on a simple way to convert the PWM to an analog signal.

Thanks,
Craig
 
A

A E

Jan 1, 1970
0
craig said:
Hi guys,

I have a 12bit PWM output (0 to 5V) on my PIC.
I need to generate a 0-12V analog output.
preferably 50% duty cycle = 6V output.

I do have a 12V supply in my circuit already.

Any ideas on a simple way to convert the PWM to an analog signal.

Thanks,
Craig

What are the frequencies involved here?
 
J

Jonathan Kirwan

Jan 1, 1970
0
I have a 12bit PWM output (0 to 5V) on my PIC.
I need to generate a 0-12V analog output.
preferably 50% duty cycle = 6V output.

I do have a 12V supply in my circuit already.

Any ideas on a simple way to convert the PWM to an analog signal.

Are you using a PIC which modulates several PWM outputs with its
hardware? Which part are you using for 12-bit PWM? Or is this
software driven? How fast are you driving the PWM?

Jon
 
C

craig

Jan 1, 1970
0
What are the frequencies involved here?
I could easily change the freqeuncy, but it will probably be around 20KHz
 
C

craig

Jan 1, 1970
0
Are you using a PIC which modulates several PWM outputs with its
hardware? Which part are you using for 12-bit PWM? Or is this
software driven? How fast are you driving the PWM?

Actually, now that I think about it, its a 10bit PWM.
I'm using the 18F458 at 40MHz

I'll probably drive the outputs at 20kHz
 
C

craig

Jan 1, 1970
0
I also forgot to mention I also already have a 6V supply in my circuit as
well.

Thanks,
Craig
 
F

Fred Bloggs

Jan 1, 1970
0
craig said:
I could easily change the freqeuncy, but it will probably be around 20KHz

He also means- how fast does the resulting output analog signal have to
change?
 
F

Frank Bemelman

Jan 1, 1970
0
craig said:
Hi guys,

I have a 12bit PWM output (0 to 5V) on my PIC.
I need to generate a 0-12V analog output.
preferably 50% duty cycle = 6V output.

I do have a 12V supply in my circuit already.

Any ideas on a simple way to convert the PWM to an analog signal.

CMOS 4011 used as a buffer, on 12V supply.


+12V
|
|
|
10K
|
| two 4011 gates
.-----------=[]o---=[]o----------10K-----.-------------- analog voltage
| |
| 1uF
| |
| GND
4K7
|
|
|
PIC PWM 0-5V
 
J

John Popelish

Jan 1, 1970
0
Frank said:
craig said:
Hi guys,

I have a 12bit PWM output (0 to 5V) on my PIC.
I need to generate a 0-12V analog output.
preferably 50% duty cycle = 6V output.

I do have a 12V supply in my circuit already.

Any ideas on a simple way to convert the PWM to an analog signal.

CMOS 4011 used as a buffer, on 12V supply.

+12V
|
|
|
10K
|
| two 4011 gates
.-----------=[]o---=[]o----------10K-----.-------------- analog voltage
| |
| 1uF
| |
| GND
4K7
|
|
|
PIC PWM 0-5V
As a general rule, I don't like to pull any input or output beyond the
supply rails of the PIC. I would go with:

+12V
|
10K
| two 4011 gates
.---=[]o---=[]o---10K--.--- analog voltage
| |
|/ 1uF
+5V-47K-| |
|> GND
|
PIC PWM 0-5V
 
J

Jonathan Kirwan

Jan 1, 1970
0
craig said:
Hi guys,

I have a 12bit PWM output (0 to 5V) on my PIC.
I need to generate a 0-12V analog output.
preferably 50% duty cycle = 6V output.

I do have a 12V supply in my circuit already.

Any ideas on a simple way to convert the PWM to an analog signal.

CMOS 4011 used as a buffer, on 12V supply.

+12V
|
|
|
10K
|
| two 4011 gates
.-----------=[]o---=[]o----------10K-----.-------------- analog voltage
| |
| 1uF
| |
| GND
4K7
|
|
|
PIC PWM 0-5V

I was going to suggest some of the chips designed for level
shifting (with separate supply pins for the input stage and the
output stage) or else a three BJT circuit (low impedance HI and
LO, of course.)

The 4011 is indeed simple.

But a high input must be at least 70% of the rail to meet the
worst case specs. That's 12*70% or 8.4V. And a low input must
be no more than 30% of the rail to meet the worst case specs.
That's 12*30% or 3.6V.

With the resistor values above and assuming that the PIC outputs
are dead-on 0V and 5V, these are:

HI (5V*10k+12V*4k7)/(10k+4.7k) = 7.24V
LO (0V*10k+12V*4k7)/(10k+4.7k) = 3.84V

Which misses the worst case thresholds -- both of them. No?

Jon
 
C

craig

Jan 1, 1970
0
I think I decided on the following.

I put the pic's PWM signal into a rail to rail output op-amp (comparator)
with a +12V rail.
I put 2.5 volts on the inverting input (using a simple resistive voltage
divider from the +5V supply)
and the pwm signal into the non-inverting signal.

So now I have a +12V PWM signal. Then I do the RC filter followed
by a buffer. This looks like it will do what I want. 50% duty cycle should
give me the 6V
I need. Thanks for your suggestions


Craig Beiferman










Jonathan Kirwan said:
craig said:
Hi guys,

I have a 12bit PWM output (0 to 5V) on my PIC.
I need to generate a 0-12V analog output.
preferably 50% duty cycle = 6V output.

I do have a 12V supply in my circuit already.

Any ideas on a simple way to convert the PWM to an analog signal.

CMOS 4011 used as a buffer, on 12V supply.

+12V
|
|
|
10K
|
| two 4011 gates
.-----------=[]o---=[]o----------10K-----.-------------- analog voltage
| |
| 1uF
| |
| GND
4K7
|
|
|
PIC PWM 0-5V

I was going to suggest some of the chips designed for level
shifting (with separate supply pins for the input stage and the
output stage) or else a three BJT circuit (low impedance HI and
LO, of course.)

The 4011 is indeed simple.

But a high input must be at least 70% of the rail to meet the
worst case specs. That's 12*70% or 8.4V. And a low input must
be no more than 30% of the rail to meet the worst case specs.
That's 12*30% or 3.6V.

With the resistor values above and assuming that the PIC outputs
are dead-on 0V and 5V, these are:

HI (5V*10k+12V*4k7)/(10k+4.7k) = 7.24V
LO (0V*10k+12V*4k7)/(10k+4.7k) = 3.84V

Which misses the worst case thresholds -- both of them. No?

Jon
 
F

Frank Bemelman

Jan 1, 1970
0
John Popelish said:
Frank said:
craig said:
Hi guys,

I have a 12bit PWM output (0 to 5V) on my PIC.
I need to generate a 0-12V analog output.
preferably 50% duty cycle = 6V output.

I do have a 12V supply in my circuit already.

Any ideas on a simple way to convert the PWM to an analog signal.

CMOS 4011 used as a buffer, on 12V supply.

+12V
|
|
|
10K
|
| two 4011 gates
.-----------=[]o---=[]o----------10K-----.-------------- analog voltage
| |
| 1uF
| |
| GND
4K7
|
|
|
PIC PWM 0-5V
As a general rule, I don't like to pull any input or output beyond the
supply rails of the PIC. I would go with:

+12V
|
10K
| two 4011 gates
.---=[]o---=[]o---10K--.--- analog voltage
| |
|/ 1uF
+5V-47K-| |
|> GND
|
PIC PWM 0-5V

The pic outputs have diodes, if I am not mistaken. I don't expect
big problems feeding ~400uA into the +5V supply. An extra transistor
is probably better, perhaps make the 47K a true voltage divider too,
as I am not sure about the PIC outputs giving a full swing. I like
that connection from the PIC to the emitter, not that classical
emitter to ground etc ;)
 
F

Frank Bemelman

Jan 1, 1970
0
Jonathan Kirwan said:
craig said:
Hi guys,

I have a 12bit PWM output (0 to 5V) on my PIC.
I need to generate a 0-12V analog output.
preferably 50% duty cycle = 6V output.

I do have a 12V supply in my circuit already.

Any ideas on a simple way to convert the PWM to an analog signal.

CMOS 4011 used as a buffer, on 12V supply.

+12V
|
|
|
10K
|
| two 4011 gates
.-----------=[]o---=[]o----------10K-----.-------------- analog voltage
| |
| 1uF
| |
| GND
4K7
|
|
|
PIC PWM 0-5V

I was going to suggest some of the chips designed for level
shifting (with separate supply pins for the input stage and the
output stage) or else a three BJT circuit (low impedance HI and
LO, of course.)

The 4011 is indeed simple.

But a high input must be at least 70% of the rail to meet the
worst case specs. That's 12*70% or 8.4V. And a low input must
be no more than 30% of the rail to meet the worst case specs.
That's 12*30% or 3.6V.

With the resistor values above and assuming that the PIC outputs
are dead-on 0V and 5V, these are:

HI (5V*10k+12V*4k7)/(10k+4.7k) = 7.24V
LO (0V*10k+12V*4k7)/(10k+4.7k) = 3.84V

Which misses the worst case thresholds -- both of them. No?

Thanks for the math ;) My wild guess was not even that bad, but 10K and
5K6 would give a slightly better centered swing around 6V. However, still
not within worst case limits. The difference between 8.4 and 3.6 is
4.8V, so we would need the full 0-5V swing of the PIC, and center it
precisely around 6V. Are zeners cheap? I don't like zeners for unrational
reasons, but we could swap the 4K7 for a 3V6 zener and still sit on
the edge of worst case, if not over it. OTH, I estimate 99% working
devices, with the resistors only, good enough for hobby purposes.
We better add that transistor, as John suggested in the other message.
 
F

Fred Bloggs

Jan 1, 1970
0
craig said:
I think I decided on the following.

I put the pic's PWM signal into a rail to rail output op-amp (comparator)
with a +12V rail.
I put 2.5 volts on the inverting input (using a simple resistive voltage
divider from the +5V supply)
and the pwm signal into the non-inverting signal.

So now I have a +12V PWM signal. Then I do the RC filter followed
by a buffer. This looks like it will do what I want. 50% duty cycle should
give me the 6V
I need. Thanks for your suggestions


Craig Beiferman

If you have a 12V buffer, then why bother with the 12V PWM when you can
average the 5V PWM and then buffer like so:

Please view in a fixed-width font such as Courier.


5R 7R
+--/\/\---+-------/\/\--+
| | |
| | |
| | |
| | 12V |
--- | | \ | |
+--|- \| |
| \ |
| >----+->
RF | /
PWM >-----/\/\--+--------|+ /| TLC071A
| | / |
from PIC |CF ---
===
|
---
 
J

John Popelish

Jan 1, 1970
0
Fred said:
If you have a 12V buffer, then why bother with the 12V PWM when you can
average the 5V PWM and then buffer like so:

Please view in a fixed-width font such as Courier.

5R 7R
+--/\/\---+-------/\/\--+
| | |
| | |
| | |
| | 12V |
--- | | \ | |
+--|- \| |
| \ |
| >----+->
RF | /
PWM >-----/\/\--+--------|+ /| TLC071A
| | / |
from PIC |CF ---
===
|
---

I agree. once you have added the rail to rail opamp, your good choices
multiply easily. You could also make the opamp into a 2 or 3 pole
Sallen-Key (voltage controlled voltage source) low pass filter (Bessel
would be well behaved but something between a Butterworth and a Bessel
might be even better) that would lower the ripple from the PWM
waveform more, while shortening the delay for the same ripple. And
the low output impedance of the opamp is very handy.
 
Top