DAC vs PWM+LC - Page 1
Forum section: electronics / projects

author: colejohnson66
author_rank: Unknown
timestamp: May 01, 2020, 05:11:54 pm
content: I'm working on a programmer, and I was wondering if there's any practical difference between a DAC and a PWM with a low-pass filter? I understand there will be more ripple on the PWM+LC one compared to a true DAC, but DACs can be pretty expensive compared to PWM. So which is better? And does anyone know of a PWM expander IC? Or would a I2C GPIO expander work?

author: SiliconWizard
author_rank: Super Contributor
timestamp: May 01, 2020, 05:23:42 pm
content: What would this DAC be used for?

author: David Hess
author_rank: Super Contributor
timestamp: May 01, 2020, 06:06:49 pm
content: PWM+LC has to trade off resolution versus speed making it more acceptable for low frequency applications. So for instance I might use PWM+LC to control the supply voltage to a programmable part but not as a variable output pin driver for which a DAC would be more appropriate.

author: Buriedcode
author_rank: Super Contributor
timestamp: May 01, 2020, 10:54:47 pm
content: PWM DAC's tend to have very good linearity, but worse absolute accuracy - unless you can precisely control the PWM driver output voltage. That may not be a problem if some kind of feedback is used. PWM DACs are pretty good when driving something that is inherently a low pass filter.If you're working on a programmer, I can only assume the PWM is used to generate VPP or some voltage for programming (VPP?). This is generally a low current, and doesn't have to be accurate (+/-0.1V is fine). In that case it is used as part of a boost converter and isn't so much about being a "DAC" as regulating the output with feedback.I'm unsure what you mean by "PWM expander" IC, there are PWM generators that are controlled by I2C or SPI that have anywhere from 4 to 16 channels. PCA9685 seems quite popular for I2C interface.

author: colejohnson66
author_rank: Unknown
timestamp: May 01, 2020, 11:16:28 pm
content: Yes, the DAC (or PWM+LC) would be used to drive the pins. As for accuracy, I was thinking of using a few ADCs, so if the PWM+LC is, say, too low, I can increase the pulse width slightly. In essence, it would calibrate itself (assuming stable ADCs).And when I said "PWM expander", I was thinking of using an Arduino like board (Adafruit Grand Central M4), however, it doesn’t have enough PWM outputs. So, I want a chip where I can set a value and frequency, and it’ll output a PWM signal at the set duty cycle and frequency. The PCA9685 looks perfect for that.Re: current, I was thinking of running the output through a buffer to allow higher current draw.

author: Buriedcode
author_rank: Super Contributor
timestamp: May 02, 2020, 03:54:07 am
content: I'm unsure why you would need to control the absolute voltage on digital IO for a programmer. Sure there are different standards (1.8V,3V 3.3V etc..), but I dont' think individual PWM for each IO line is advisable - not only would each one require a low pass filter, they would have terrible update rates. Perhaps I misunderstood what you meant by "programmer".Check out the PICkit 2 or PICkit 3 schematic to see how its done with discretes.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 02, 2020, 03:57:12 am
content: Why LC specifically? Are we to assume this is a lowpass filter, but then why constrain it to a two-pole passive type? The choice depends on application, and we've been told very little of that.Maybe all you want to do is flash ATTINYs. Maybe you want to burn whole 27C1024 EPROMs. Maybe you want to support the whole history of nonvolatile semiconductor storage. No idea.If you're "driving pins" directly, you'll need a lot of channels (as many as there are pins) and fast response. You can't afford to wait a settling time for a PWM filter (..can you?), and the rise/fall time alone may violate edge triggered timing constraints of the target. A DAC array is the way to go here. The settling time can be rapid, multiple levels can be set up and triggered at once, and many platforms have the means to dump data rapidly via DMA or whatever, perhaps with a little glue logic. (Example: an STM32 parallel memory interface, address decoder, and an array of parallel-input DACs. A DMA transfer from internal RAM (or external too, if you put RAM elsewhere on the parallel bus) can load a whole chip's worth of outputs in a fraction of a microsecond. Even more obvious, an FPGA -- though you'll have to craft everything yourself, from built-ins and library code; the MCU is probably easier.)Would it not be better to have just two or three DC channels (so a slow passive or active RC filter + PWM will do), and level shifters to deliver the logic signals at full speed? (If a huge range of supply voltage is needed, the level shifting can be performed with analog switches; you can even set V_OH and V_OL independently, making floating signals like ECL accessible.)Maybe that's what you were planning all along, who knows; this is why it's so important to give all possible supporting information. We can guess, we can assume, but you know what that makes us...Tim

author: David Hess
author_rank: Super Contributor
timestamp: May 02, 2020, 08:23:06 am
content: Quote from: colejohnson66 on May 01, 2020, 11:16:28 pmMore thorough pin drivers include two DACs and two ADCs. The two DACs provide voltage and current limiting while the ADCs provide read-back of the actual values applied to the pin.In a programmer, this could be implemented on the supply and programming pins so current limiting prevents device and programmer damage and the read-back detects invalid operating conditions, supply current, and quiescent current for reliable diagnostics.Reading back the current for each pin driver would also allow detecting damaged inputs. The same might be applied to outputs in the highest reliability applications.Incidentally, in the past the difference between a development and production programmer was that the production programmer would execute the verify operation at different worst case supply voltages.

author: Mazo
author_rank: Regular Contributor
timestamp: May 02, 2020, 09:06:48 am
content: Not sure if not offtopic slightly,but a few interesting articles I have read on making PWM DACs better:https://www.edn.com/cancel-pwm-dac-ripple-with-analog-subtraction/https://www.edn.com/a-faster-pwm-based-dac/https://www.edn.com/fast-pwm-dac-has-no-ripple/

author: Siwastaja
author_rank: Super Contributor
timestamp: May 02, 2020, 12:50:00 pm
content: Do not use LC. L is an expensive and very inaccurate component. L is used when high power (low ohmic losses) is required; for actual energy storage. A buck converter would be an example of PWM+LC high-power DAC!But, for low-power signals, you use RC if 1st order -6db/oct is enough. If you need steeper than that, you use an opamp active filter circuit instead of using actual inductors as building blocks. And you can easily go to higher orders than 2nd, if needed.MCU PWM output builds a nice, cheap & small PWM DAC with 1st order RC, but being 1st order, the settling time must be very long (large R and/or C values), OR the PWM comes "through" quite badly. The plus side is, no external active components, and with a bit of design/(luck?), R and C can be BOM reuse components.Output voltage range? What's your required update rate samples per second? Settling time t to x% of error, define t and x? How much ripple or noise you can deal with, in dB or % of full scale voltage?

author: mikerj
author_rank: Super Contributor
timestamp: May 02, 2020, 01:00:56 pm
content: Quote from: Mazo on May 02, 2020, 09:06:48 amThey are certainly interesting designs, but given the low price of an 8 bit serial DAC you'd need a good reason to add the additional complexity.

author: eliocor
author_rank: Unknown
timestamp: May 03, 2020, 03:24:12 am
content: MAYBE you can use one or morePCA9685:- 16 PWM output- 12 bit resolution for each output- 1500/3000Hz max output frequency (internal/external clock): LC filter should not be too steep- up to 62 of them can be cascaded on the same I2C bus- not pricey to experiment with:https://www.aliexpress.com/item/4000468996665.html

author: colejohnson66
author_rank: Unknown
timestamp: May 03, 2020, 05:01:55 pm
content: I apologize for not including more information. I want to make a universal programmer. One that can drive each pin to its own voltage, ground, or floating.Cost is not going to be an issue (I don’t plan on mass producing this).The DAC I’ve currently chosen (DAC7614U) is a 12-bit SPI-like 4-output DAC that can be run from dual supply (-5V to +5V). The output of this DAC is ran through an OPA454 to boost it up (as close to) the supply rails of -48V to +48V. I realize this is extreme, but I want to support every possible IC (my research shows the Intel 1702 (first(?) EPROM) requires down to -48V).However, (I know I said cost isn’t an issue, but) the DAC costs about $14 in one off quantity. Having a DAC per pin means I’m spending about $150 on just the DACs. So, I’m looking for ways to reduce the cost if possible, and PWM+LPF seemed like a possible idea, but the update rate of the PCA9685 is too slow (1.5kHz).Any suggestions would be appreciated.

author: SiliconWizard
author_rank: Super Contributor
timestamp: May 03, 2020, 05:27:20 pm
content: So you're generating programming voltages. But why do you need fast update? (Sorry if the question is naive, I haven't used/considered traditional programmers in ages!)

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 03, 2020, 05:32:45 pm
content: MCP4922 is dual and cheap, and runs up to 1MS/s or so. Single supply, no problem with that opamp in there, just add the offset, shift around a few resistors. Doesn't seem to be an SPI quad in the family, probably others have cheap multipart types?Tim

author: colejohnson66
author_rank: Unknown
timestamp: May 03, 2020, 07:01:59 pm
content: Quote from: SiliconWizard on May 03, 2020, 05:27:20 pmYes, each pins’ voltage will be individually controlled by setting it’s DAC to the required value. As for update speed, some devices can be programmed at different speeds, and the faster you can update the pin voltage, the faster you can program.

author: Buriedcode
author_rank: Super Contributor
timestamp: May 03, 2020, 10:23:46 pm
content: I'm not sure I fully understand this. Programming pins are digital, 0, 1, or High-Z. I understand the need to control the '1' /high voltage - there are different standards and different target VDD's, but is there really a need to be able to control eachindividualpins voltage? Surely having one DAC with a buffer to drive all the pin drivers to determine their high level is enough. The driver controls its level, and if required, its output buffer (to disconnect it, High Z).The PWM DAC's you're talking about, the PWM period is not the same as "update" rate.The update rate depends on the settling time of the filter, as well as the PWM period. The PCA9685 I mentioned has a PWM frequency (1/period) programmable from "24 Hz to 1526", so its update rate is much less than this. A ladder DAC - generally the cheapest non-PWM solution for 8-12bit can be updated much quicker, but I fail to see why this is needed for the programming pins, as they can all have the same voltage output when they are '1'. A faster PWM device can indeed be updated quicker, but you'll need a few PWM periods for the filter to settle if you want to have a reasonably clean output (not massive ripple on it).If you are driving digital IO pins, from a DAC, and you have say 12 lines, it'll take a very long time to program the device using PWM to drive each output, even though each output only requires three levels.. because you'll be writing to 12 DACs, for every edge of every signal. A single byte-wide write would require 8 + 2 = 10 DAC writes.If you're talking VPP - programming voltages for eeproms and the like, then again, a single DAC/boost supply, digitally controllable is enough. That means you need a total of TWO DAC's, both can be set and left for whatever the target device needs.I'm sure I'm missing something here, I've just never heard of a programmer where each IO used to program required an "analogue" voltage to be individually controlled.

author: colejohnson66
author_rank: Unknown
timestamp: May 03, 2020, 10:31:55 pm
content: Maybe I’m missing something? I’ve never had my hands on a truly universal programmer like the Data I/O UniSite, but it was my understanding that one would need a DAC (PWM-based or other) per pin. In fact, my research shows these kinds of programmers exist (ex. Allpro 88 has 88 DACs - one per pin), but looking at the (available) schematics for the UniSite, it appears to not utilize that approach.I am aware that I could support 95+% of the devices out there using just one or two positive voltage only DACs (a la TL866 series which have two controllable voltages and digital I/O for the rest), but I want it to be trulyuniversal.

author: oPossum
author_rank: Super Contributor
timestamp: May 03, 2020, 10:39:42 pm
content: The DACs are used to provide a *steady* voltage, not for digital signals. The update rate is therefore somewhat irrelevant.See "Pin IO"http://blog.kevtris.org/blogfiles/allpro88/Allpro%2088.txt

author: mikerj
author_rank: Super Contributor
timestamp: May 03, 2020, 10:40:08 pm
content: No you wouldn't have a DAC per pin. The digital lines would have buffers that translate between some internal voltage (typically 3.3v logic) and the required voltage for the device being programmed. There would only need to be a single DAC to control the voltage to these buffers. You also need higher programming voltages for EEPROMs etc. but gain you'd have one DAC controlling voltage generation and then electronic switches to apply this voltage to the required pins.

author: colejohnson66
author_rank: Unknown
timestamp: May 03, 2020, 10:47:55 pm
content: Quote from: oPossum on May 03, 2020, 10:39:42 pmWell, my plan wasn’t to control I/O through the DAC; Each pin could be left floating, connected to ground, or to the DAC. So for I/O, I just switch between the DAC voltage and ground.

author: SiliconWizard
author_rank: Super Contributor
timestamp: May 03, 2020, 10:55:34 pm
content: Quote from: colejohnson66 on May 03, 2020, 10:47:55 pmBut this is this switching that needs to be fast - not the change of programming voltage?

author: colejohnson66
author_rank: Unknown
timestamp: May 03, 2020, 11:09:11 pm
content: Quote from: SiliconWizard on May 03, 2020, 10:55:34 pmYes, I was confused early and was mixing up the update rate of the DAC with the switching speed of the pin’s voltage. I apologize for the confusion I caused.

author: kipp
author_rank: Contributor
timestamp: June 20, 2023, 02:27:55 am
content: I've developed some familiarity with the Logical Devices ALLPRO88, and have been using mine to dump some vintage ROMs, test components, and act as a pattern generator for testing out mystery display modules. Some features it has that have proven valuable:1. yes, it has true DAC-per-pin architecture, but it's overkill. any of its 88 output channels can be set to anything from 0 V to nearly 26 V completely independently of the others, but no part I've encountered, including weird LCD modules, needs more than a half dozen distinct voltages to operate it. the vast majority of programmable devices only need three (one being a ground sink, so only two actual supply voltages).nothing needs 88 distinct voltages, but you do need to be able to route a given voltage to any of the pins, arbitrarily. just 3 or 4 DACs would be enough for almost anything, if you can devise a way to switch each pin on a given part between any of the DACs. analogue switch ICs have too much internal resistance and are as expensive as DACs, so you're almost certainly looking at large numbers of discrete transistors and latch ICs to control them.2. in the ALLPRO88 the DACs are not ramped up and down to generate rapid time-dependent signals, for example as are needed for data pins and address pins, instead they are set to fixed target voltages and separate output drive transistors are used to switch pins between "1" and "0" as needed. also, it goes without saying, that some pins, outputs for example, need to not be driven by a DAC at all, they need to be floating. so coming back to the idea of using transistors to switch the pins between a small number of DACs, you can see that some of that circuitry you're going to want/need to implement anyway.3. don't forget about the need to turn parts on and off in a controlled manner. programming isn't just about setting voltages on I/O pins. some specific issues:3a. parts might have slew rate limits when power is applied. I've read that some GALs will malfunction if the programming voltage is ramped up too quickly. slew rate control is something to think about, the ALLPRO88 offers a programmable slew rate for the DACs, but that might be overkill. perhaps a fixed, modest, slew rate would be sufficient to meet the needs of all parts. I don't know enough about this.3b. sequencing application of power. the ALLPRO88 uses a ganged DAC system: a primary DAC provides a main supply voltage for the whole system, with pin DACs deriving their individual outputs from that via pass transistors, and in this way the target device can be brought up and brought down in a synchronized way, with voltages tracking each other. this hardware arrangement makes doing the right thing easy to program in software, but if you're careful to control your DACs in unison the same effect can be achieved entirely in software.3c. likewise, control lines that need to be pulled high, for example an active low write line, will need to have voltages applied to them and removed from them carefully in sync with power rails. most parts cannot tolerate logic inputs being above their positive supply rail, but if at power-on an active low input falls too far behind the supply rail as voltages ramp up, the part might decide you've initiated a write operation and erase part of its contents. holding a control line low for an extra few microseconds can be a lifetime for some memory chips, but that sort of delay is infinitesimal in the world of power supplies, so this can be very tricky. I had a near accident with a battery powered SRAM chip containing calibration data this way. to accommodate this, the ALLPRO88, in addition to directly applying voltages to pins, can connect pull-up and/or pull-down resistors to the pins. the pull-up resistors are connected to their own independent DAC (shared with all pull-up resistors), but since that DAC tracks the same main DAC that the pin DACs do the effect is to keep active-low pins safely in the "false" state while power is applied to and removed from the part. a pull-up resistor is an extremely reliable and fool-proof way to ensure a logic pin is set to the correct voltage at all times during power-up and power-down, I wouldn't want to rely on software and precision DAC timing to get this right, so I would say a programmable pull-up and pull-down resistor on each pin really isn't an optional feature.4. don't forget about the need to apply timed pulses to parts to program them. EEPROMs, for example, often require a programming pulse whose duration is between 95 us and 105 us. a pulse duration outside that range might damage the part. again, if pins are controlled by a combination of DACs and switching elements, then this shouldn't be a problem, but trying to get a low-pass filtered PWM based DAC to do this is likely a tall order.

author: colejohnson66
author_rank: Unknown
timestamp: July 15, 2023, 11:45:31 pm
content: Thanks! I ultimately decided that I'd go with 4 (maybe 8 ) DACs. Much cheaper than one per pin, and would allow using real DACs instead of PWN+LC as I originally envisioned. Regarding switching, I also came to the same conclusion that, if slew rate control is desired (among other things), I will need to use a handful of voltage choosing FETs on each pin. Reading the documentation on the ALLPRO88 made me decide to also include pull-ups and pull-downs. I, however, was not aware of using a "chained DAC" system to bring all pins up together. That's a good idea! It does mean I'd need to use DACs with external references, instead of internal, but that's doable.