Author Topic: R2R DAC "Conversion gain"  (Read 1488 times)

0 Members and 1 Guest are viewing this topic.

Offline ChristofferBTopic starter

  • Frequent Contributor
  • **
  • Posts: 929
  • Country: dk
  • Chemistry phd student!
    • My channel:
R2R DAC "Conversion gain"
« on: June 19, 2021, 02:34:39 pm »
Hia!

I'd like to be able to drive both axes of an XY pen plotter/chart recorder as a counter - so TTL pulses into a binary counter, bits TBD, probably between 8-12, and then binary out to a simple R2R DAC. Not that difficult.

However, I would like to be able to set how many counts is full scale, in effect counts/volt output. I'm pretty sure I have seen a simple way of doing this once, but I can't get my head around what.

One could isolate the DAC and simply vary the reference voltage, or one could (for not too many bits), shift the bits upwards with a huge multi-pole switch.

Ideally I'd like ranges like 2^12, 2^10, 2^8, 2^7, 2^6 counts for full voltage (5 or 10V).

I'd like to keep this in discrete logic as well.

Thanks in advance!

--Christoffer //IG:Chromatogiraffery
Check out my scientific instruments diy (GC, HPLC, NMR, etc) Channel: https://www.youtube.com/channel/UCZ8l6SdZuRuoSdze1dIpzAQ
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5817
  • Country: de
Re: R2R DAC "Conversion gain"
« Reply #1 on: June 19, 2021, 04:52:47 pm »
Have you thought about the resistor tolerances you'll need for your R2R ladder? For 12 bits it'll be around 0.02%. Good luck. I wouldn't even know where to buy those, and the price will be tremendous. If you drop one, it'll be out of tolerance at once... not to mention soldering.



 

Offline phil from seattle

  • Super Contributor
  • ***
  • Posts: 1029
  • Country: us
Re: R2R DAC "Conversion gain"
« Reply #2 on: June 19, 2021, 05:30:02 pm »
Decent quality DACs aren't that expensive. But that changes your design, I'm sure.
 

Offline ChristofferBTopic starter

  • Frequent Contributor
  • **
  • Posts: 929
  • Country: dk
  • Chemistry phd student!
    • My channel:
Re: R2R DAC "Conversion gain"
« Reply #3 on: June 19, 2021, 05:57:01 pm »
Resistor tolerance may be an issue, yeah hadn't thought that through.

The issue is exactly equivalent when using a parallel input DAC though.
--Christoffer //IG:Chromatogiraffery
Check out my scientific instruments diy (GC, HPLC, NMR, etc) Channel: https://www.youtube.com/channel/UCZ8l6SdZuRuoSdze1dIpzAQ
 

Offline RoGeorge

  • Super Contributor
  • ***
  • Posts: 6136
  • Country: ro
Re: R2R DAC "Conversion gain"
« Reply #4 on: June 19, 2021, 06:15:29 pm »
That would be a perfect application for a $2 Arduino, a PWM or PDM (pulse density modulation) 1 pin digital IO followed by an RC integrator (instead of parallel IO followed by R2R), and a few lines of code.  Strongly recommend this one, even I'm a big fan of TTL and vintage digital.



However, if you insist to use a counter + R2R, better switch the input point into the chain of flip-flops that makes the counter.
- Implement the first LSB bits of the counter with independent flip-flops, for example 74N74 (two independent D type FF).
- The R2R DAC stays the same, say 8 bits (255 pulses) for 10Volts.
- To switch to 7 bits (127 pulses) for 10V, redirect the stream of input pulses to the 2nd FF, to switch to 6 bits redirect the input pulses to the 3rd FF input, and so on.  The bypassed LSB FF will stay to zero after each reset (you'll need to reset the counter before each train of pulses anyway).  The redirection can be made with some additional glue logic, either with a multiplexer/demultiplexer, with gates, or with a mechanical switch if the application allows.
- If you want to be exactly 1111 1111 for 6 bits and not 1111 1100, then send a Set instead of a Reset to the first 2 FF



Another way to switch the DAC resolution could be to put a parallel in / parallel out shift register (i.e. a 74N95), and after all the pulses are counted, shift the output of the counter with 1 bit to the MSB direction so the following R2R will see the counted pulses multiplied with 2.  When shift fill the LSB with 1, so the DAC will see N*2+1 for N pulses counted.



I would choose the microcontroller solution for being much cheaper, faster to implement, and more flexible.
« Last Edit: June 19, 2021, 06:26:46 pm by RoGeorge »
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2578
  • Country: us
Re: R2R DAC "Conversion gain"
« Reply #5 on: June 19, 2021, 07:55:42 pm »
Quote
- To switch to 7 bits (127 pulses) for 10V, redirect the stream of input pulses to the 2nd FF, to switch to 6 bits redirect the input pulses to the 3rd FF input, and so on.  The bypassed LSB FF will stay to zero after each reset (you'll need to reset the counter before each train of pulses anyway).  The redirection can be made with some additional glue logic, either with a multiplexer/demultiplexer, with gates, or with a mechanical switch if the application allows.

This seems like the simplest digital solution short of using an mcu. The simplest analog solution is probably to switch the reference voltage or add a switchable gain stage after the dac. The analog solutions have the possible advantage of easily supporting maximum counts that are not a power of two, if that matters to you.
 

Offline ChristofferBTopic starter

  • Frequent Contributor
  • **
  • Posts: 929
  • Country: dk
  • Chemistry phd student!
    • My channel:
Re: R2R DAC "Conversion gain"
« Reply #6 on: June 19, 2021, 10:56:13 pm »
Thank you for the input! The discrete flip flop switching sounds like the way to go. I am now however slightly tempted by the arduino route..

--Christoffer //IG:Chromatogiraffery
Check out my scientific instruments diy (GC, HPLC, NMR, etc) Channel: https://www.youtube.com/channel/UCZ8l6SdZuRuoSdze1dIpzAQ
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2516
  • Country: us
Re: R2R DAC "Conversion gain"
« Reply #7 on: June 19, 2021, 11:11:55 pm »
You would not build a parallel DAC with a discrete R2R ladder network.
There are plenty of 12-bit parallel input DACs available:
   https://www.mouser.com/Semiconductors/Data-Converter-ICs/Digital-to-Analog-Converters-DAC/_/N-4c44dZ1yzvvqx?P=1z0w0o4Z1z0vhtuZ1yzxnag&Ns=Pricing|0

The DAC7821IPWG4 appears to be about the cheapest.

There are also the DAC0808 8-bit DACs that don't need a clock.


However if you decide to use an Arduino, there is the MCP4822 Dual 12-bit DAC with a SPI interface.
These are very easy to use and come in 8, 10, or 12 bits and are in a 8 pin DIP package.
« Last Edit: June 19, 2021, 11:17:06 pm by MarkF »
 
The following users thanked this post: ChristofferB

Offline RoGeorge

  • Super Contributor
  • ***
  • Posts: 6136
  • Country: ro
Re: R2R DAC "Conversion gain"
« Reply #8 on: June 19, 2021, 11:30:05 pm »
If you use a microcontroller, I have the backbone for generating PDM on interrupts, with adjustable resolution and number of DACs (from another proj of mine that I can modify), based on this code idea (there is no nice Arduino lib, I'm not a programmer, all I have is a working example):
https://hackaday.io/project/6356-delta-sigma-versus-pwm
https://github.com/RoGeorge/Delta-Sigma_versus_PWM

The github example is for MSP430, the one I used recently is for ATmega328 (Arduino Nano).

Standard PWM libraries should work, too, just that it would create stronger harmonics when the DAC is at its 1/2 of full scale (symmetric square wave has strong 3rd harmonic component that is pretty close to the PWM frequency, therefore harder to filter out)

However, given that your plotter is analogue, you might not need filtering at all.  Let the slow analog electronic from inside the plotter (together with mechanical inertia) to integrate the digital PWM pulses for you.   ;D
 
The following users thanked this post: ChristofferB

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2516
  • Country: us
Re: R2R DAC "Conversion gain"
« Reply #9 on: June 20, 2021, 02:13:02 am »
Just to clarify a little more of what others have said about spinning your own R2R ladder network.
You can get SIP packages with R2R ladder networks so you don't need to use discrete resistors.
This would help with some of the accuracy in resistance values.

But resistor accuracy is not the only issue.  I would say not even the biggest issue.
The actual voltage applied to each bit must be the same across all bits. 
You would not want to just attach a counter chip's outputs directly to a R2R ladder.

That's why you at least would want to use something like the DAC0808 because the input bits are buffered so you minimize any variation in voltage levels.

Have you considered using stepper motors (like in 3D printers) with either belts or lead screw rods.
 

Offline ChristofferBTopic starter

  • Frequent Contributor
  • **
  • Posts: 929
  • Country: dk
  • Chemistry phd student!
    • My channel:
Re: R2R DAC "Conversion gain"
« Reply #10 on: June 20, 2021, 01:29:43 pm »
I already have a fairly precise Brüel and Kjaer XY graph recorder I'd like to add functionality, hence the strange choice.

Instead of a counter, could one implement a full adder, and make the full scale switch set the number to be added on each count?
--Christoffer //IG:Chromatogiraffery
Check out my scientific instruments diy (GC, HPLC, NMR, etc) Channel: https://www.youtube.com/channel/UCZ8l6SdZuRuoSdze1dIpzAQ
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2516
  • Country: us
Re: R2R DAC "Conversion gain"
« Reply #11 on: June 20, 2021, 01:50:45 pm »
If you use an Arduino and a shift register instead of counter chips, you could increment the value anyway you wanted for each update and clock out the value to the shift register.  The serial-in/parallel-out shift register would drive a 12-bit DAC. 

Of course you would need two shift registers and two clocks (a pair for each axis).

You could also use a 14 pin Microchip PIC if you have a programmer.
« Last Edit: June 20, 2021, 01:55:17 pm by MarkF »
 

Offline RoGeorge

  • Super Contributor
  • ***
  • Posts: 6136
  • Country: ro
Re: R2R DAC "Conversion gain"
« Reply #12 on: June 20, 2021, 04:39:48 pm »
Instead of a counter, could one implement a full adder, and make the full scale switch set the number to be added on each count?

That would be a very elegant design.   :-+
A 483 followed by a 495 used as latch (can be any other latch that can load data on an edge).  At the output of the 495 will be the R2R ladder.  The output of the 495 is routed back into the adder.  All is needed would be a 7483 and a 7495 for each group of 4 bits.

The only drawback is that adders were used quite rarely back in the days of TTL era, therefore they might be hard to find and/or too expensive.

It still needs the R2R ladder, so I guess PWM or PDM with a single RC filter will still beat R2R in performance.  But, since you have an adder and a latch, you can now implement the PDM algorithm with TTL so to bypas the R2R ladder and use a single RC instead.   :)
« Last Edit: June 20, 2021, 04:46:44 pm by RoGeorge »
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14018
  • Country: de
Re: R2R DAC "Conversion gain"
« Reply #13 on: June 20, 2021, 08:02:34 pm »
For scaling the result, I would add some switchable gain at the DAC output.

For the fine part one can use math and a little more resolution from the DAC (e.g. 12 Bit should be enough for the mechanical part). Because of the usually low speed needed, using a PWM based DAC may be a good idea - it can be high resolution and can be relatively cheap compared to discrete R2R at more than 8 bits.
 

Offline bson

  • Supporter
  • ****
  • Posts: 2259
  • Country: us
Re: R2R DAC "Conversion gain"
« Reply #14 on: June 20, 2021, 09:10:14 pm »
However, I would like to be able to set how many counts is full scale, in effect counts/volt output. I'm pretty sure I have seen a simple way of doing this once, but I can't get my head around what.
A discrete R2R DAC usually has an op amp buffering the output, and changing the voltage swing is as simple as changing its feedback resistor.
 

Offline bson

  • Supporter
  • ****
  • Posts: 2259
  • Country: us
Re: R2R DAC "Conversion gain"
« Reply #15 on: June 20, 2021, 09:18:32 pm »
The problem with PWM DACs is the high frequencies required.  Even a 20kHz audio signal requires a 40kHz period, and with 12 bit resolution this requires a 2^12 * 40000 = 163MHz timebase.  Of course you also need a low-pass filter with half this bandwidth, and may find an RC filter produces waveform artifacts due to its nonlinear phase.  (At the cut-off frequency an RC filter has a 45 degree phase shift, although at below 20kHz this would be pretty low.)  PWM DACs work best when dealing with very slowly changing signals that are effectively DC (like say, a bias voltage).
« Last Edit: June 20, 2021, 09:21:56 pm by bson »
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14018
  • Country: de
Re: R2R DAC "Conversion gain"
« Reply #16 on: June 21, 2021, 06:07:29 am »
If a single run is of limited time, one could do the counting analog with an integrator to add up charge packages. The precision and time is limited, but may be sufficcient. With a modern OP and reasonabble size PP capacitor accuracy should be OK for maybe a few minutes.

The mechanical plotter is relatively slow - so a PWM DAC would be OK, but it would need quite some effort, if not done in a µC.
 

Offline ChristofferBTopic starter

  • Frequent Contributor
  • **
  • Posts: 929
  • Country: dk
  • Chemistry phd student!
    • My channel:
Re: R2R DAC "Conversion gain"
« Reply #17 on: June 21, 2021, 07:45:03 am »
Adding analog gain to the count won't do, I'm afraid, as the number of discrete steps would be left the same, and the goal here is to make histograms with a select number of "sticks" - the other axis will be events in each stick.

Either way I need a fair bit of RC filtering as I dont want to expose the recorder to shooting up at full speed.

One way or another, It's beginning to look more like a job for an mcu

Thanks for the feedback!
--Christoffer //IG:Chromatogiraffery
Check out my scientific instruments diy (GC, HPLC, NMR, etc) Channel: https://www.youtube.com/channel/UCZ8l6SdZuRuoSdze1dIpzAQ
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14018
  • Country: de
Re: R2R DAC "Conversion gain"
« Reply #18 on: June 21, 2021, 08:24:47 am »
The task looks a lot like a job for a µC. It is than still not clear if the output to the old analog plotter is the way to go, or if it is better to export digital data to the PC, e.g. write data to a SD card or send via USB/RS232.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf