Author Topic: DIY highly linear 12-bit PWM digital-analog-converter, pointers please  (Read 18602 times)

0 Members and 1 Guest are viewing this topic.

Offline RandallMcReeTopic starter

  • Frequent Contributor
  • **
  • Posts: 541
  • Country: us
Folks,
I have seen references in the forum to the PWM method of building a dac, the main virtue (I think) being temperature independence. Having mostly assembled an R-2R 10-bit dac I can see that that would be highly desirable.

Goals:
  • 10-12 bit resolution
  • Linear, ideally 24-bit linearity
  • Not fast, <10 changes per second
  • Temperature independent DC output

The current plan goes like this:
10Mhz oscillator --> counter --> magnitude comparator -> flip-flop -> 3rd order LP filter@20Hz

The above rough sketch seems to meet the goals..I think. Is there a better way?

I'm not sure of the best way to take a flip-flop output and generate a good analog input to the low-pass filter. We obviously want a good VRef to dictate the analog high value and not any old arbitrary 5v. What is typical here? The simpler the better, right?! Things I have thought of so far are: CMOS gate powered by VRef, or perhaps some fast analog comparator.

What I don't think is needed: fancy ways to spread the noise spectrum around, ala spread spectrum switching, lfsr, etc.: because I think the 2400Hz 50% duty cycle ripple can be adequately filtered without resorting to that complication. Also, I've built lots of analog filters and that is like, my, sweet spot. So if a 5th order LP is needed, fine.

Thanks!
Randy
Update: 2/26/2018: proposed schematic. See https://github.com/RMcRee/12-bit-linear-pwm
Update: 2/27/2018: Use HC688, jk ff, show time budget.
Update 3/25/2018: Updated schematic to that actually built. Used 74hc595 to interface to arduino, in the end. Tested, works.
« Last Edit: March 25, 2018, 10:14:49 pm by RandallMcRee »
 
The following users thanked this post: BravoV, cellularmitosis

Offline duak

  • Super Contributor
  • ***
  • Posts: 1041
  • Country: ca
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #1 on: February 11, 2018, 07:03:19 pm »
I was thinking of buying a Tek PS5004 precision power supply recently and downloaded a block diagram from somewhere to see how it worked.   It has a 0-20 V output with 0.5 millivolt resolution and accuracy.  It uses switched current sources controlled by the PWM followed by a summing amplifier and 5th order filter.  I couldn't find a schematic to confirm the nuts n' bolts of the circuit though.

Best o' luck,

 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14192
  • Country: de
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #2 on: February 11, 2018, 08:07:22 pm »
For producing the PWM signal I would consider a small 8 bit µC (thus without an PLL), like PIC18, 8051 or AVR. They usually have HW for PWM up to 16 Bit inside. The Output stage an filter can be a bit tricky. Maybe have a look at the circuit of the Fluke57xx calibrators. There is somewhere a thread here to show how it looks like that include a circuit diagram. The output stage might work with CMOS switches like DG419 or similar. It still needs good buffering of the reference.
 

Offline ch_scr

  • Frequent Contributor
  • **
  • Posts: 813
  • Country: de
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #3 on: February 11, 2018, 08:07:55 pm »
In a book on D2A converters i found this neat trick for PWM-DACs. It gets you a bit of noise-spreading / higher PWM frequency(s) for almost free, the almost being the type of digital comperator used. I have attached the rather explanatory illustrations.
 

Offline Mickle T.

  • Frequent Contributor
  • **
  • Posts: 467
  • Country: ru
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #4 on: February 11, 2018, 08:38:45 pm »
The design of such PWM DAC was recently submitted by adver on the forum radiokot.ru:
http://radiokot.ru/forum/viewtopic.php?p=3112844#p3112844
http://radiokot.ru/forum/viewtopic.php?p=3113890#p3113890 e.t.c.

Small Attiny25 with 8-bit PWM, software 3-order MASH, ADG419, OP177, 3-stage LP - that's all.
 

Offline Andreas

  • Super Contributor
  • ***
  • Posts: 3244
  • Country: de
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #5 on: February 11, 2018, 09:02:21 pm »
It gets you a bit of noise-spreading / higher PWM frequency(s) for almost free

not for free. it is at the cost of linearity: the rising and falling edges are never the same duration.
And with this method you have a variable number of edges within one counter period.
If you aim for linearity: keep the number of edges low. (e.g. 100 Hz) and use symmetrical switches.

with best regards

Andreas


 
The following users thanked this post: TiN

Offline ch_scr

  • Frequent Contributor
  • **
  • Posts: 813
  • Country: de
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #6 on: February 11, 2018, 09:41:34 pm »
Darn! Theres always something out there to get you. Thanks for the explanation!
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16614
  • Country: us
  • DavidH
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #7 on: February 12, 2018, 05:21:16 am »
We obviously want a good VRef to dictate the analog high value and not any old arbitrary 5v. What is typical here? The simpler the better, right?! Things I have thought of so far are: CMOS gate powered by VRef, or perhaps some fast analog comparator.

Instead of a gate, an analog switch which will normally be break-before-make is commonly used as the modulator.  Do not forget about keeping digital noise out of both the analog ground, power, and voltage references.

Quote
What I don't think is needed: fancy ways to spread the noise spectrum around, ala spread spectrum switching, lfsr, etc.: because I think the 2400Hz 50% duty cycle ripple can be adequately filtered without resorting to that complication. Also, I've built lots of analog filters and that is like, my, sweet spot. So if a 5th order LP is needed, fine.

The analog filter's settling time will limit usable update rate.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3802
  • Country: au
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #8 on: February 12, 2018, 06:07:18 am »
A Hellene and myself had a discussion with code about a 20+ bit PWM D/A using Atmega328 and ATiny chips. The time constant here was more like 1 second, but it is not hard to change for less resolution. You should be able to easily do a 16 bit PWM D/A with a 10/second rate.

The linearity even with a simple breadboard test was extremely good. In my test, I just used a cmos 74HC NAND gate IC powered directly by a 5V reference IC as the PWM output buffer into a R/C pair. Then all you need is a few more RC stages to reduce the ripple. You would probably need a buffer IC.

The Atmega328P has a very low jitter clock, as long as it is not run in low power clock mode.

The discussion started here:

https://www.eevblog.com/forum/projects/general-purpose-power-supply-design-7488/msg99807/#msg99807

Linearity tests:

https://www.eevblog.com/forum/projects/general-purpose-power-supply-design-7488/msg106218/#msg106218
« Last Edit: February 12, 2018, 06:16:16 am by amspire »
 
The following users thanked this post: doktor pyta

Offline Andreas

  • Super Contributor
  • ***
  • Posts: 3244
  • Country: de
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #9 on: February 12, 2018, 06:11:47 am »
Small Attiny25 with 8-bit PWM, software 3-order MASH, ADG419, OP177, 3-stage LP - that's all.

Thanks for the cirquit. But in this case it is a 7->10V transfer
so the linearity does not play a role.
Only stability over time.
But for that application it seems to be a very tricky solution.  :-+

with best regards

Andreas
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14192
  • Country: de
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #10 on: February 12, 2018, 04:42:05 pm »
It gets you a bit of noise-spreading / higher PWM frequency(s) for almost free

not for free. it is at the cost of linearity: the rising and falling edges are never the same duration.
And with this method you have a variable number of edges within one counter period.
If you aim for linearity: keep the number of edges low. (e.g. 100 Hz) and use symmetrical switches.

with best regards

Andreas

There is no need to have the same speed for both edges. Unequal edges would give rise to an offset though, but there may be some offset due to charge injection anyway.

The important part is to have the same number of switching events and enough time between so that the circuit has settled (especially the reference buffers) - so no super fast pulses. Buffering the reference can also be important, as the switches can cause quite some dynamic load.
Matching of both switches can also be important.
For the switches one should have resonably low resistance as the switch resistance usually has a high TC.
 

Online Alex Nikitin

  • Super Contributor
  • ***
  • Posts: 1175
  • Country: gb
  • Femtoampnut and Tapehead.
    • A.N.T. Audio
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #11 on: February 13, 2018, 08:49:49 am »
Folks,
I have seen references in the forum to the PWM method of building a dac, the main virtue (I think) being temperature independence. Having mostly assembled an R-2R 10-bit dac I can see that that would be highly desirable.

Goals:
  • 10-12 bit resolution
  • Linear, ideally 24-bit linearity
  • Not fast, <10 changes per second
  • Temperature independent DC output

The current plan goes like this:
10Mhz oscillator --> counter --> magnitude comparator -> flip-flop -> 3rd order LP filter@20Hz



Hi Randy,

Have a look at the Keithley 263 voltage source circuit.

Cheers

Alex
 
The following users thanked this post: zhtoor

Offline RandallMcReeTopic starter

  • Frequent Contributor
  • **
  • Posts: 541
  • Country: us
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #12 on: February 13, 2018, 06:49:39 pm »
Thanks folks,
Looking into all of these suggestions....

Is this Keithley manual the right one?

https://doc.xdevs.com/doc/Keithley/263/263_901_01E.pdf

Will try to come up with a schematic and put it in post #1.
 

Online Alex Nikitin

  • Super Contributor
  • ***
  • Posts: 1175
  • Country: gb
  • Femtoampnut and Tapehead.
    • A.N.T. Audio
 

Offline Magnificent Bastard

  • Regular Contributor
  • *
  • Posts: 139
  • Country: aq
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #14 on: February 14, 2018, 03:13:42 pm »
The DG636E looks like a good candidate for this sort of thing.
 

Offline zhtoor

  • Frequent Contributor
  • **
  • !
  • Posts: 337
  • Country: pk
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #15 on: February 14, 2018, 05:17:10 pm »
or an H11F1 optomos with ZERO charge injection, if speed is not an issue.

-zia
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14192
  • Country: de
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #16 on: February 14, 2018, 06:08:30 pm »
For PWM with switching at the reference side charge injection should not be such a big issue, though it helps to keep the dynamic load to the reference low. With a dual switch one could use the second one to switch the opposite way and this way keep the reference current approximately constant.
 

Online MasterT

  • Frequent Contributor
  • **
  • Posts: 785
  • Country: ca
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #17 on: February 14, 2018, 07:55:13 pm »
I don't think, that simple circuit like Ref->Switch->LPF  can provide linearity better than 15-bits or 10 ppm. There are two issues with the switches, Rds variation by temperature & voltage (non linearly) from one end, plus leakage current on the other side.  Using a current source as a feed to an analog switch may be a nice trick to cancel Rds , though preventing a current source out of saturation during the "off" time could be even more problematic.
 Real time monitoring of Rds could be a solution, using more switches for re-mapping  primary  switch to the measuring path, and supplementary ADC to do a measurement itself. Plus software correction of the PWM duty circle based on actual Rds. Thinking aloud.
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14192
  • Country: de
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #18 on: February 14, 2018, 08:27:29 pm »
With the switches choosing between 2 reference levels (0 and U_ref), there should be very little problem with leakage and R_on variations with voltage. However there still is the problem of Rds variations with temperature and a different Rds for the positive and negative side (because they are at a different voltage). So it takes some extra effort (e.g. careful Rds matching, extra current sources so that the switched that set the voltage don't see much current), but a good pair of switches is a first step.
 

Offline Andreas

  • Super Contributor
  • ***
  • Posts: 3244
  • Country: de
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #19 on: February 14, 2018, 08:42:10 pm »
Hello,

Is this Keithley manual the right one?

https://doc.xdevs.com/doc/Keithley/263/263_901_01E.pdf

don´t know how the Keithley cirquit behaves in comparison to the EDN cirquit mentioned here:
https://www.eevblog.com/forum/metrology/stacking-ad587s-for-higher-output-voltage-(20v-30v-etc-)/msg1320513/#msg1320513

At least with modern processors like e.g. ATMega1284 or PIC24FV32KA304 it takes much less components to build a 16 Bit PWM.

The DG636E looks like a good candidate for this sort of thing.

did you make a comparison how linear it behaves compared to the MAX4052A?

with best regards

Andreas
 

Offline Magnificent Bastard

  • Regular Contributor
  • *
  • Posts: 139
  • Country: aq
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #20 on: February 14, 2018, 10:30:19 pm »
The DG636E looks like a good candidate for this sort of thing.

did you make a comparison how linear it behaves compared to the MAX4052A?

with best regards

Andreas

Nope.  Just found it searching for the "least evil" SPDT switch I could find.  This one is a balance of being fast, has relatively low on resistance, good on/off resistance matching, and very low charge injection.  Taking all of those things into account, it has a very high figure of merit.  I think the linearity only matters if you are passing a variable analog voltage through it, but in this application it is more of a "digital" thing (where the analog voltage being switched does not vary).  If you are switching between some fixed voltage to another fixed voltage, and the power supply voltage does not change much, then this is the best switch I have found that is a "buy it and it just works" thing.  I can make a far better SPDT switch using discrete parts (good enough for 8.5 or 9.5 digits), but I don't think that is in line with the spirit of this thread, which is about 12-bits of accuracy.  I'm probably not going to build anything, I just mentioned it because I thought it might be useful to someone looking for a "good" (small, simple, and inexpensive) switch, ~US$1.53 at DigiKey.  You're welcome to make the comparison yourself, I will just watch...
:popcorn:
« Last Edit: March 09, 2018, 04:25:09 pm by Magnificent Bastard »
 

Offline Andreas

  • Super Contributor
  • ***
  • Posts: 3244
  • Country: de
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #21 on: February 15, 2018, 08:16:28 pm »
  You're welcome make the comparison yourself, I will just watch...   

I fear we will never know it ...
If all are only watching.

with best regards

Andreas
 
The following users thanked this post: zhtoor

Offline RandallMcReeTopic starter

  • Frequent Contributor
  • **
  • Posts: 541
  • Country: us
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #22 on: February 16, 2018, 02:39:43 am »

The switches I have on hand (which makes them top candidates in my mind!) are the DG411, the ADG1411 and 74hc405x. I picked the ADG1411 for a different application where Ron was important (1.5ohms), but the charge injection is 20pC, typical. Not sure what the interplay will be between Ron and charge injection.

That DG636E certainly has some great specs, especially for the price. So perhaps I will try that one, you can never have too many switches.

BUT the problem with trying switches is that they all have different pinouts. So I cannot promise to try them all...
 

Online MasterT

  • Frequent Contributor
  • **
  • Posts: 785
  • Country: ca
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #23 on: February 16, 2018, 05:22:13 am »

It was easier than I thought.  Inspired by LTC1043, and app. note from LT.
Here is the setup. Since I don't have good quality equipment to test linearity over 12 bits, my multimeter has only 1 mV resolution below 4V at the best,  I use ADS1232 board from aliex.  I also install  MAX5717A DAC (16-bits, 1 LSB INL) in parallel as a verification/ reference path. Arduino Mega is running pwm driver, reading ADC, updates both DACs and switching multiplexer in front of ADC, plus searching linear regression and print an error over serial monitor. 

Everything on a breadboard, a lot of noise, but results is quite good for start.

Linear:      y = 1.000762 * x  -249761.562500
Linear:      y = 1.004887 * x  -249921.296875

   bin_C   uVolt   5717a   error   er_uV   pwmD   error   er_uV

   16384   128000   -233375   -9   -70   -233456   +1   +7
   32768   256000   -216973   -4   -31   -216989   +4   +31
   49152   384000   -200576   -3   -23   -200524   +5   +39
   65536   512000   -184176   +0   +0   -184058   +7   +54
   81920   640000   -167779   +0   +0   -167594   +6   +46
   98304   768000   -151381   +1   +7   -151132   +4   +31
   114688   896000   -134982   +4   +31   -134674   -1   -7
   131072   1024000   -118585   +4   +31   -118210   -1   -7
   147456   1152000   -102187   +6   +46   -101747   -2   -15
   163840   1280000   -85791   +5   +39   -85284   -3   -23
   180224   1408000   -69394   +6   +46   -68815   +1   +7
   196608   1536000   -52998   +5   +39   -52347   +5   +39
   212992   1664000   -36601   +6   +46   -35885   +3   +23
   229376   1792000   -20206   +4   +31   -19422   +2   +15
   245760   1920000   -3811   +3   +23   -2959   +1   +7
   262144   2048000   +12586   +3   +23   +13504   +0   +0
   278528   2176000   +28979   +0   +0   +29965   -2   -15
   294912   2304000   +45373   -2   -15   +46428   -4   -31
   311296   2432000   +61771   +0   +0   +62892   -4   -31
   327680   2560000   +78166   -2   -15   +79356   -4   -31
   344064   2688000   +94563   -1   -7   +95820   -4   -31
   360448   2816000   +110959   -2   -15   +112284   -4   -31
   376832   2944000   +127354   -3   -23   +128747   -5   -39
   393216   3072000   +143752   -2   -15   +145212   -4   -31
   409600   3200000   +160148   -2   -15   +161677   -3   -23
   425984   3328000   +176545   -2   -15   +178144   +0   +0
   442368   3456000   +192942   -1   -7   +194610   +1   +7
   458752   3584000   +209341   +0   +0   +211077   +4   +31
   475136   3712000   +225736   +0   +0   +227544   +7   +54
   491520   3840000   +242130   -3   -23   +244009   +8   +62
   507904   3968000   +258524   -5   -39   +260471   +5   +39

Columns:   
1. bin_C- binary code, scaled to 19-bits, same as ADC, I don't need 24-noisy bits, 19-more than enough.

2. uVolt - microvolts associated with 4096mV reference
3. raw ADC data from    5717a   
4. error in 19-bits scale
5. error in microVolts   er_uV   
6. raw ADC data from pwmDAC
   error
   er_uV

PWM set to 3.9 kHz, based on 16 MHz / 4096 (12-bits).  MAX5717A getting 16-bits, pwmDAC - 12, to keep settling time low. I will check more on this tomorrow probably.
 

Online MasterT

  • Frequent Contributor
  • **
  • Posts: 785
  • Country: ca
Re: DIY highly linear 12-bit PWM digital-analog-converter, pointers please
« Reply #24 on: February 16, 2018, 03:09:08 pm »
More pics and more tests done. Overall close to 18-bits linearity +-1 bit INL.  Ripple voltage is quite high, luckily sigma-delta adc has no issue to filter it out.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf