This R/2R DAC was my first sound card (just 8 bits) on my first PC back in the early ‘90s! I managed to fit 18 resistors and a 100nF capacitor for integration of the output signal in a DB25 plug back then, playing WAV files from the printer port of that old PC! 😊 Great video! It literally took me back to those years!
@@phant0masterr Also known as “Disney Sound Source”. I found the schematics of it back then, on the text “readme” file of the “MODplay” player of Amiga music tracks. Something like a MIDI file with 8bit sampled instruments. It was supported by 1 or 2 games but I remember that I had to write the software to play the WAV files in assembly, because even Pascal wasn’t fast enough to play them at the actual speed. My 386sx/16MHz back then was even slower than an Arduino in some tasks!
This is an excellent video explaining how early DACs were built and the principles behind them, nice work! One thing got me at the end however, you mentioned that the original input signal captured by the ADC could never be reconstructed exactly by the DAC. This is (mostly) incorrect though, as it ignores Nyquist-Shannon. If you band limit the input of the ADC at 1/2 your sampling frequency (idealized case) or lower (practically, 1/5 to 1/10 is sufficient for slow, non-specialty filters), then include an exact copy of this input filter on your output, you will reconstruct a mathematically identical signal to the one received! The limitation bit depth poses in this scenario is an increase in base noise floor, rather than a distortion of the signal itself. Because of this, these filters are nearly always included on off-the-shelf components designed for distortion sensitive applications.
Hi... I did a similar thing almost twenty years ago, through the "User-port" of my Vic 20 with 16 KBytes RAM expansion, to make a long research about PCM synthesis of percussive sounds (bass drums, snare drums, toms, claps, hi-hats etc... ). My "DAC" wasn't a R/2R type, but just eight resistors (10K-20K-40K-80K... ) from MSB to LSB, linked to a common line and "grounded" through a 10K resistor to convert the out from current to voltage levels. I created the sounds with BASIC programs that simulates sine oscillators, white and pink noise generators, "click" and "crack" A-R envelope generators, mixers and LP/HP filters (the elaboration's time was a little terrible, as you can guess!!!) and played with a simple Assembler programs, with a sample rate around 25 kHz. The result wasn't bad, it was a fun experience, but i soon discovered that 8 bit is too low as resolution for percussive sound voices (anyway some commercial drum-machines, as Korg's DDM 110/220 or DDD5 actually makes use of 8 bit samples... ). Now I'm thinking to assemble a vintage-style drum-machine with Eight sampled voice-cards triggered via MIDI by a DAW (as "Caustic 3" and the like), with a Pic and a simple cheap 16 bit DAC in any voice-card. Today a 16 bit DAC is cheaper than a bunch of 1% resistors... :-D Anyway I would like to listen to a 44/16 wav file through your home-made DAC expanded to 16 bit... Bye... :-)
I also did something like that with, believe it or not, the parallel printer port on my Ohio Scientific computer (very similar to an old PET computer). I built an 8 bit DAC resistor network into a printer cable which I connected to my amplifier and I "printed" various wave forms which sounded... interesting. Random numbers made something of a rumbling white noise which could have sounded like explosions if I had known how to code envelopes. BASIC was too slow to make anything but the lowest frequency sine waves so I wrote a BASIC program to make a lookup table which then jumped into a machine language routine which "printed" values through the table, skipping values to increase the frequency. It didn't really sound like a pure sine wave but it had a flute-like sound. I could have done much more if I had known what I was doing.
Although a year old now, just a quick thanks for the video. It has inspired me further, to explore the MCP4728 device on my latest IPEC ESP32 ATM90E32 IoT Power Energy Controller and Monitor board (variation on the original IPEM). So many different DACs and ADCs available v massive variations in cost and availability, it is sometimes not straight forward to choose one device for a particular design. Keep up the good work.
You can also use as an alternative, one of the cheap stepper motors with a 64x gearbox divider which, combined with the 64 steps of the stepper gives 4096 steps for 360º, resolving better than 1/10º. I used a stepper motor like that to drive my telescope’s focuser, because I wanted the accuracy, especially for a 5x teleconverter when I’m imaging planets, and also because I wanted to focus without touching the telescope at such high magnifications.
These DACS are still still used in single chips since waffering Resistors is easy and produces very high tolerances. There are different kinds of DACs, and each of them have there specific requirements on their implementation.
Useful for raspberry Pi GPIO also if you don't want to use any dedicated chips. If you use a standard shift register that almost any hobbyist has, you don't need many pins
The tx and rx ports are always on due to the Serial.begin() command. This way, the first two bits are always on. To get over this problem you have two solutions, you can shift the pins by two, starting in pin 2, or just delete the Serial commands.
Thank you, this video really helped me. I have a question for you, if i were to use a controller that does not have any easy to use ports, could i use a shift register and a serial input to control the resistor ladder?
Indeed the ADC of the Arduino is only 10bit, so reading back the 12bit output of the DAC will not be accurate, but it doesn’t mean that the DAC can’t be used to drive something else. After all, the redirection of the DAC’s output back to the 10bit ADC input of the Arduino was mostly to demonstrate the different bit depths ladder output on the video. On the other hand, a 12bit DAC on the 5V digital output of the Arduino, would theoretically resolve in 1.2mV per step. So using 1% resistors may give you noise higher than that in the end, assuming that your power source is also stable enough.
It's good to be teaching hobbyists this. But a 12 bit DAC with 1% resistors? It is likely to have some serious non-linearity issues. You would need 0.025% resistors for an honest 12 bit converter. I did one of these for a my first serious professional project back in 1968/69. AFAICR is was 6 or 7 bits. I only had 5% resistors available. But I did have a kickass DVM available. So I soldered a bunch of resistors in a long chain, applied a stable voltage and measured and noted the voltage drop across each resistor. Then I sorted them in order of relative resistance and picked an optimum combination.
0:56 Isn't more bits purely the scale of assignable amplitude? Isn't 5:15 the digital version? I'd like to see the 8 bit sine on an oscilloscope after it is converted to analog.
I noticed this too. Serial ports Rx & Tx are the problem here. By using 2 Arduino's, one to generate and another to analogRead the signal it works correct.
This "zooming in" to 12 bits waveform shows pixels of screen, not 12bits DAC steps. Unless you have screen resolution with 4096 vertical lines. Nice video anyway :)!
The jaggedness of the pixels isn't what she's referring to, but rather the slight waviness of the line that's similar to the previous stair-stepping of the output but on a scale of 4-5 pixels per step.
It is not possible to achieve 12-bit resolution using R2R ladder and simple microcontroller. The problem lies in the resistors mismatch. Theoretically, even to achieve 8-bit resolution, 0.1% resistors are needed. But that is only part of the problem - the uC pins all have output resistances variation in the range of 100-200 oHms which adds to the mismatch error. Then take into consideration the pin voltage,Vdd, which is not very stable (typ 1-5% noise). There's more errors coming from the high-speed glitches due to pins risetime / falltme mismatch. In practice, 4-7 bits of resolution is achievable, depending on the update rate. What was shown here was at best 7-bit resolution in nearly static conditions. After falling into a pitfall and making few R2R DACs myself, I advise not to utilize such approach - a simple PWM DAC is more than adequate for the Arduino users, and saves a ton of digital pins on uC!
Look at E-Tims 2007 R2R DAC for N64 to get digital RGB to Analogue, for a laugh. It's being commercialised. He compressed the shift register and D flip flops into a single CPLD but it's still using R2R.
It's why no one ever practically makes a discrete R/2R ladder network DAC. Covered it in a lecture at degree level in about 10 minutes. Never thought anyone would be stupid enough to make one and then try and teach people how to do it. It's pointless, it has no value, not even from a teaching perspective.
nice; two notes: - when you change resolution you movevtge jumper wire, but you do nit show on schematic which one... - would be good to actually see the dac output on oscilloscope as well ; plot from serial is still ‘software’, we need real hardware signal, dont we?
Question about the code. You step through i from 0 to 360 by 1 to calculate your sign wave. That is 360 steps. Shouldn't you have used MAX_12_BIT_NUM as the number of steps between 0 and 360? It still looks okay because you showed graphs of 8bit (255) and 12bit (4095)... I wonder if 10bit (1023) would look the same as 12bit because they both would have been truncated to 360 steps by your loop.
I’m honestly not sure. Jeff wrote that part of the code and I didn’t fully understand how it worked. But since I was trying to create an arc 360 sounded right at the time.
Hey Karen, I met you at the Milwaukee Maker Faire a few years ago. Will you be at the one for this year? I plan to be there. Maybe I will bring my rPi mini Arcade.