Author Topic: Using external reference voltage with a PWM DAC  (Read 2594 times)

0 Members and 1 Guest are viewing this topic.

Offline mduchalskiTopic starter

  • Newbie
  • Posts: 8
  • Country: pl
Using external reference voltage with a PWM DAC
« on: September 12, 2018, 09:14:34 pm »
Hello,

I'm trying to use filtered PWM signal as a analog output in my power supply project. I want to use an external 4.096V reference voltage (MCP1501), so I've been using a simple single transistor-based inverter with a RC filter on the output. This approach, however, does not seem to produce good results. I played around with it using Atmega328p Timer1 PWM modes - Fast PWM at 15.6kHz and Phase-Corrected PWM at 7.8kHz, 10-bit resolution. In both cases I'm getting maximum recorded error of 15-20 LSB. I've included more detailed measurements below. Unfortunately I don't have a scope to take a look at the signals, and simulation wasn't all that helpful, showing performance far inferior to what I actually got (order of magnitude bigger errors). I initially thought that C-E voltage drop when transistor is driven into saturation will put the average a little higher, but simulation suggests that the "high" collector voltages may be significantly off - ~200mV lower than the expected 4.096V (@50% duty cycle 7.8kHz). My questions are - what is most likely to be the primary source of these errors and is it possible to achieve better performance of a PWM DAC with an external voltage reference, if so how?
 

Offline JS

  • Frequent Contributor
  • **
  • Posts: 947
  • Country: ar
Re: Using external reference voltage with a PWM DAC
« Reply #1 on: September 12, 2018, 09:23:18 pm »
Use a CMOS buffer, any CMOS aimple logic will help. Inverter, buffer, schmid trigger... Try our and see which is better, I recon all of them will be much better than your approach.

Power them from the voltage reference, and they will stat low right at ground ans high right at the reference. Test that, just to be sure, how much error you are having from your circuit?  Meaning 0 output and FS output errors. In your circuit it will widely change with load, in the CMOS not so much but still, the higher impedance the load has the better.

JS

If I don't know how it works, I prefer not to turn it on.
 
The following users thanked this post: mduchalski

Offline mduchalskiTopic starter

  • Newbie
  • Posts: 8
  • Country: pl
Re: Using external reference voltage with a PWM DAC
« Reply #2 on: September 12, 2018, 09:42:57 pm »
Thanks for the quick reply and suggestions. I have some 4000-series logic laying around, so I will definitely test that. The main reason I tried to do it with a discrete transistor was to avoid the need for another IC on the board. I was hoping that there is some trick you can use here I'm not aware of/obvious mistake I'm making. But if such an elementary circuit is not able to deliver decent performance and I will need to put an additional IC on there anyway, I might as well make it some cheap dedicated DAC. Thanks again.
 

Offline JS

  • Frequent Contributor
  • **
  • Posts: 947
  • Country: ar
Re: Using external reference voltage with a PWM DAC
« Reply #3 on: September 12, 2018, 10:04:25 pm »
  You could do it with discrete fets, but a bjt is not the device for the job. And you need push pull config or it will still have high error.

  The obvious error is BJT has a saturation voltage of quite a few mV instead of a low Rds on, so with low Rds on you will get quite close to the rails while you won't be able to get close to the rails with a BJT. Then, when the BJT is off you hace a high resistance, so the load will have a huge impact on the high voltage you get. Not getting right to the rails is the problem here, with a CMOS buffet you will get much closer to the rails. The other problem is the slew rate of rising and falling edges being different, making the switching time less precise. If you have the same ahape going up and down and your edges are much faster than the PWM signal you will have much greater accuaracy.

JS

If I don't know how it works, I prefer not to turn it on.
 
The following users thanked this post: mduchalski

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16618
  • Country: us
  • DavidH
Re: Using external reference voltage with a PWM DAC
« Reply #4 on: September 13, 2018, 12:04:30 pm »
I was hoping that there is some trick you can use here I'm not aware of/obvious mistake I'm making.

There is a not so obvious trick; reverse the collector and emitter connections to run the bipolar transistor backwards for lower saturation voltage.  The base drive needs to be increased to make up for the lower gain.  Also use a low valued speed up capacitor in parallel with the base series resistor to improve switching times and especially reduce storage time.

But the real way now is to use a CMOS inverter or buffer powered by the reference voltage or even better, an analog switch.  In the past switching might have been done with currents and diodes.
 
The following users thanked this post: oPossum, mduchalski

Online Buriedcode

  • Super Contributor
  • ***
  • Posts: 1612
  • Country: gb
Re: Using external reference voltage with a PWM DAC
« Reply #5 on: September 13, 2018, 03:40:04 pm »
PWM DACS have great linearity  - because clocks are generally very consistent, but tend not to have the best absolute accuracy due to the problem you've encountered - precise high/low levels.

As suggested, using buffers powered by your reference and a high impedance filter will help, but I would still add calibration to account for any remaining offset if you're after absolute accuracy.  Offset is much easier to calibrate (simply adding or subtracting values, or use a trimmer if in hardware) than linearity.
 
The following users thanked this post: mduchalski

Offline mduchalskiTopic starter

  • Newbie
  • Posts: 8
  • Country: pl
Re: Using external reference voltage with a PWM DAC
« Reply #6 on: September 13, 2018, 06:23:56 pm »
Thanks for your responses. I tried the suggested BJT trick (and also increased filter input impedance) , and while performance is better and I'll definitely keep this approach in mind for the future, it's still not quite what I would like. I'll try experimenting with different component values but since it seems that as you suggested using a CMOS buffer is the best option here, I think I'm going to go for a dedicated DAC IC in this case to avoid the need for calibration and get better performance in general.

Thank you all for your help.
« Last Edit: September 13, 2018, 06:26:15 pm by mduchalski »
 

Offline JS

  • Frequent Contributor
  • **
  • Posts: 947
  • Country: ar
Re: Using external reference voltage with a PWM DAC
« Reply #7 on: September 13, 2018, 07:46:00 pm »
  The thing with jelly beam CMOS is that they are cheaper and more available than the ADC you will look for... And in the end linearity for PWM is very good as already stated. Also, with one part you could buffer several channels.

JS

If I don't know how it works, I prefer not to turn it on.
 
The following users thanked this post: mduchalski

Online Buriedcode

  • Super Contributor
  • ***
  • Posts: 1612
  • Country: gb
Re: Using external reference voltage with a PWM DAC
« Reply #8 on: September 13, 2018, 10:29:29 pm »
It's all a question of application.  PWM DACs are great for some things, and not for others.  For apps where you have explicit feedback and you don't know how much of an adjustment you'll need, then PWM can be very good.  If you're trimming a voltage - that doesn't vary that much, but must be stable, then a DAC with absolute accuracy is better.  A dedicated DAC chip will *generally* be better, if your application is say, trimming voltages, and will requires less filtering.

PWM DACs can be excellent for audio (again, because its so linear, and absolute accuracy isn't needed) just look at class D amps!
 
The following users thanked this post: mduchalski

Offline mduchalskiTopic starter

  • Newbie
  • Posts: 8
  • Country: pl
Re: Using external reference voltage with a PWM DAC
« Reply #9 on: September 13, 2018, 10:57:40 pm »
My application is digital control of a power supply - setting voltage and current, so it is exactly "trimming the voltage". That's why I was leaning towards a dedicated chip in my last reply. But in the meantime I found some CMOS logic chips and tested them. I must say I'm very satisfied with the performance - I tested CD4011BE and 74HC00 NAND gates used as inverters. The latter one worked much better with errors within a few milivolts over the entire range, max. recorded -6mV/1.5LSB (approximately, my multimeter is only +/-1% accurate in that range), as opposed to max. -16mV/-4LSB with the 4000-series one. This makes me think I'm going to stick with PWM after all. Thanks!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf