R2R DAC "Conversion gain" - Page 1
Forum section: electronics / projects

author: ChristofferB
author_rank: Frequent Contributor
timestamp: June 19, 2021, 02:34:39 pm
content: 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!

author: Benta
author_rank: Super Contributor
timestamp: June 19, 2021, 04:52:47 pm
content: 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.

author: phil from seattle
author_rank: Super Contributor
timestamp: June 19, 2021, 05:30:02 pm
content: Decent quality DACs aren't that expensive. But that changes your design, I'm sure.

author: ChristofferB
author_rank: Frequent Contributor
timestamp: June 19, 2021, 05:57:01 pm
content: Resistor tolerance may be an issue, yeah hadn't thought that through.The issue is exactly equivalent when using a parallel input DAC though.

author: RoGeorge
author_rank: Super Contributor
timestamp: June 19, 2021, 06:15:29 pm
content: 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 FFAnother 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.

author: ajb
author_rank: Super Contributor
timestamp: June 19, 2021, 07:55:42 pm
content: QuoteThis 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.

author: ChristofferB
author_rank: Frequent Contributor
timestamp: June 19, 2021, 10:56:13 pm
content: 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..

author: MarkF
author_rank: Super Contributor
timestamp: June 19, 2021, 11:11:55 pm
content: 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|0The 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 theMCP4822 Dual 12-bit DACwith 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.

author: RoGeorge
author_rank: Super Contributor
timestamp: June 19, 2021, 11:30:05 pm
content: 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-pwmhttps://github.com/RoGeorge/Delta-Sigma_versus_PWMThe 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.

author: MarkF
author_rank: Super Contributor
timestamp: June 20, 2021, 02:13:02 am
content: 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.

author: ChristofferB
author_rank: Frequent Contributor
timestamp: June 20, 2021, 01:29:43 pm
content: 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?

author: MarkF
author_rank: Super Contributor
timestamp: June 20, 2021, 01:50:45 pm
content: 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.

author: RoGeorge
author_rank: Super Contributor
timestamp: June 20, 2021, 04:39:48 pm
content: Quote from: ChristofferB on June 20, 2021, 01:29:43 pmThat would be a very elegant design.A483followed by a495used 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.

author: Kleinstein
author_rank: Super Contributor
timestamp: June 20, 2021, 08:02:34 pm
content: 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.

author: bson
author_rank: Unknown
timestamp: June 20, 2021, 09:10:14 pm
content: Quote from: ChristofferB on June 19, 2021, 02:34:39 pmA discrete R2R DAC usually has an op amp buffering the output, and changing the voltage swing is as simple as changing its feedback resistor.

author: bson
author_rank: Unknown
timestamp: June 20, 2021, 09:18:32 pm
content: 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).

author: Kleinstein
author_rank: Super Contributor
timestamp: June 21, 2021, 06:07:29 am
content: 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.

author: ChristofferB
author_rank: Frequent Contributor
timestamp: June 21, 2021, 07:45:03 am
content: 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 mcuThanks for the feedback!

author: Kleinstein
author_rank: Super Contributor
timestamp: June 21, 2021, 08:24:47 am
content: 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.