{"id":31661,"date":"2025-07-07T08:26:01","date_gmt":"2025-07-07T15:26:01","guid":{"rendered":"https:\/\/digilent.com\/blog\/?p=31661"},"modified":"2025-07-07T08:28:29","modified_gmt":"2025-07-07T15:28:29","slug":"teaching-digital-to-analog-conversion-with-r-2r-ladder-circuits-and-analog-discovery-3","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/teaching-digital-to-analog-conversion-with-r-2r-ladder-circuits-and-analog-discovery-3\/","title":{"rendered":"Teaching Digital-to-Analog Conversion with R-2R Ladder Circuits and Analog Discovery 3"},"content":{"rendered":"<p>Hi there Digilent Blog readers! I\u2019m Dr. Brian Faulkner, professor of Electrical Engineering at Milwaukee School of Engineering in Milwaukee, Wisconsin, USA, where I teach introductory circuit theory and power systems engineering.\u00a0<a href=\"https:\/\/digilent.com\/shop\/analog-discovery-3\/\">The Analog Discovery 3<\/a>\u00a0is a wallet-sized powerhouse and I\u2019m a huge fanboy.<\/p>\n<p>I\u2019m more of a volts-and-amps guy and less of a zeroes-and-ones guy. I\u2019ve started and abandoned at least four 7 segment display projects because I got to the digital type part and got frustrated and quit. But there\u2019s all these digital pins on the Analog Discovery 3 that I haven\u2019t used before so this was a fun one for me. Today we\u2019re going to use an enormous pile of resistors to build a digital-to-analog converter from scratch and drive it with the AD3\u2019s digital pins.<\/p>\n<h2>Equipment:<\/h2>\n<ul>\n<li>\n<h4>A rail-to-rail opamp<\/h4>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig1.png\" alt=\"\" width=\"300\" height=\"208\" class=\"alignnone wp-image-31662\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig1.png 374w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig1-135x93.png 135w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p><em>Figure 1: An op-amp<\/em><\/p>\n<p>The LT1677 is the consummate generalist opamp. It\u2019s basically got a B in every stat. It\u2019s rail-to-rail, good input bias current, good bandwidth. It\u2019s and everything the LM741 wishes it could be. Especially when working on the 5 volt supplies on the Analog Discovery 2\/3, rail-to-rail operation is very valuable.<\/p>\n<p>They\u2019re like 5 bucks though. Don\u2019t wire the supplies backwards and waste 5 bucks.<\/p>\n<ul>\n<li>\n<h4>An LED<\/h4>\n<\/li>\n<\/ul>\n<p>It\u2019s a diode. It emits light. I personally like the super-bright outdoor sign LEDs from CREE but any LED will work fine.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig2a.png\" alt=\"\" width=\"275\" height=\"82\" class=\"alignnone wp-image-31663\" \/><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig2b.png\" alt=\"\" width=\"275\" height=\"151\" class=\"alignnone wp-image-31664\" \/><\/p>\n<p><em>Figure 2: An LED<\/em><\/p>\n<p>Any color is fine for this build, just use what you have lying around.<\/p>\n<p>We\u2019re just going to use this as a more-fun voltage detector. Higher output voltages from our analog-to-digital converter will produce brighter light.<\/p>\n<ul>\n<li>\n<h4>An Analog Discovery 2 or Analog Discovery 3<\/h4>\n<\/li>\n<\/ul>\n<p>I have enormous enthusiasm for this platform as expressed in my previous blog post. It\u2019s just very flexible and very portable and the software is very easy to use.<\/p>\n<p>Have the Waveforms software installed, plus a breadboard and jumper wires.<\/p>\n<p>The Analog Discovery 3 has a ton of digital pins for doing digital stuff, we will just be using 8 of the pins and 2 of the digital functions, but there are so many more (the Protocol Analyzer is a favorite of senior design students).<\/p>\n<p>If you need EVEN MORE PINS the Digital Discovery <a href=\"https:\/\/digilent.com\/reference\/test-and-measurement\/digital-discovery\/\">https:\/\/digilent.com\/reference\/test-and-measurement\/digital-discovery\/<\/a> has more pins, faster pins, and other digital stuff using the same Waveforms software.<\/p>\n<p>None of the improved specs of the Analog Discovery 3 over the Analog Discovery 2 matter in this experiment. I will be showing the 3 in the photos of my breadboard setup.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig3.png\" alt=\"\" width=\"300\" height=\"210\" class=\"alignnone wp-image-31665\" \/><\/p>\n<p><em>Figure 3: The back-jeans-pocket sized powerhouse<\/em><\/p>\n<ul>\n<li>\n<h4>Thirty 10k resistors<\/h4>\n<\/li>\n<\/ul>\n<p>We can\u2019t go around pretending that resistors are exciting. They are here to support the real star of the show, the digital IO pins.<\/p>\n<p>We\u2019ll need about 30 identical 10 kiloohm resistors. Every resistor should be 10k unless you\u2019ve got a good reason for it to be something else. It\u2019s the most medium-est value in electronics.<\/p>\n<p>The converter relies on the values being the same. One other value mixed in breaks everything.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig4.png\" alt=\"\" width=\"300\" height=\"273\" class=\"alignnone wp-image-31666\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig4.png 633w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig4-600x546.png 600w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p><em>Figure 4: A handful of 10k resistors (brown-black-orange-gold) from the parts bin. Two resistors that aren\u2019t are mixed in among them.<\/em><\/p>\n<h2>Guide<\/h2>\n<h4>A quick primer on digital to analog conversion<\/h4>\n<p>Any digital circuit eventually needs to interact with the mechanical universe: there is no such thing as 001011 foot-pounds of torque! A Digital-to-Analog converter (DAC) converts a string of digital values from a digital system into a proportional analog voltage that can be used to drive loads that create motion, light, sound, etc. See the conversions in Table 1: the values are evenly spaced ascending by about 206 mV from one level to the next.<\/p>\n<p>Table 1 Primer on 4-bit digital numbers on a 3.3V logic system<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"72\"><strong>Number<\/strong><\/td>\n<td width=\"168\"><strong>Digital String<\/strong><\/td>\n<td width=\"192\"><strong>Analog Voltage (3 digits)<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Zero<\/td>\n<td width=\"168\">0000<\/td>\n<td width=\"192\">0.0 V<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">One<\/td>\n<td width=\"168\">0001<\/td>\n<td width=\"192\">206 mV<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Two<\/td>\n<td width=\"168\">0010<\/td>\n<td width=\"192\">413 mV<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Three<\/td>\n<td width=\"168\">0011<\/td>\n<td width=\"192\">619 mV<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Four<\/td>\n<td width=\"168\">0100<\/td>\n<td width=\"192\">825 mV<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Five<\/td>\n<td width=\"168\">0101<\/td>\n<td width=\"192\">1.03 V<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Six<\/td>\n<td width=\"168\">0110<\/td>\n<td width=\"192\">1.24 V<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Seven<\/td>\n<td width=\"168\">0111<\/td>\n<td width=\"192\">1.44 V<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Eight<\/td>\n<td width=\"168\">1000<\/td>\n<td width=\"192\">1.65 V<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Nine<\/td>\n<td width=\"168\">1001<\/td>\n<td width=\"192\">1.86 V<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Ten<\/td>\n<td width=\"168\">1010<\/td>\n<td width=\"192\">2.06 V<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Eleven<\/td>\n<td width=\"168\">1011<\/td>\n<td width=\"192\">2.27 V<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Twelve<\/td>\n<td width=\"168\">1100<\/td>\n<td width=\"192\">2.48 V<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Thirteen<\/td>\n<td width=\"168\">1101<\/td>\n<td width=\"192\">2.68 V<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Fourteen<\/td>\n<td width=\"168\">1110<\/td>\n<td width=\"192\">2.89 V<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Fifteen<\/td>\n<td width=\"168\">1111<\/td>\n<td width=\"192\">3.09 V<\/td>\n<\/tr>\n<tr>\n<td width=\"72\">Sixteen<\/td>\n<td width=\"168\"><em>Nope not enough bits!<\/em><\/td>\n<td width=\"192\"><em>You don\u2019t ever get 3.3 V!<\/em><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h4>1.\u00a0 Wire up a four-bit DAC<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig5a.png\" alt=\"\" width=\"300\" height=\"176\" class=\"alignnone wp-image-31669\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig5a.png 604w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig5a-600x352.png 600w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig5b.png\" alt=\"\" width=\"300\" height=\"230\" class=\"alignnone wp-image-31671\" \/><\/p>\n<p><em>Figure 5: A four-bit converter<\/em><\/p>\n<ul>\n<li>Wire the circuit in Figure 5. I recommend using ribbons of wire for the digital pin connections to keep the digital part as tidy as possible.<\/li>\n<li>Double check your wiring: one resistor out of place breaks everything!<\/li>\n<li>Click Welcome-&gt;Static IO to launch the manual digital interface as shown in Figure 6.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig6.png\" alt=\"\" width=\"145\" height=\"400\" class=\"alignnone wp-image-31670\" \/><\/p>\n<p><em>Figure 6: Opening the static IO (manual digital control) interface<\/em><\/p>\n<ul>\n<li>For digital pins 0, 1, 2 and 3, set them to switch-&gt;push\/pull as shown in Figure 7.<\/li>\n<\/ul>\n<p><em>Figure 7: Setting static IO pins to Push\/Pull mode<\/em><\/p>\n<ul>\n<li>If you are <strong><em>ANALOG4LIFE<\/em><\/strong> like me, you may find it helpful to think of the digital pins as double-pole switches with one pole to a logic HIGH voltage source (3.3 V by default) and one pole to ground as depicted in Figure 8, but this depiction is not compact enough to make the schematics readable.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig8.png\" alt=\"\" width=\"300\" height=\"195\" class=\"alignnone wp-image-31672\" \/><\/p>\n<p><em>Figure 8: Digital pins in push\/pull mode act like double-pole switches<\/em><\/p>\n<ul>\n<li>Also launch the voltmeter by clicking welcome-&gt; Voltmeter as shown in Figure 9.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig9.png\" alt=\"\" width=\"194\" height=\"300\" class=\"alignnone wp-image-31673\" \/><\/p>\n<p><em>Figure 9: Launching voltmeter<\/em><\/p>\n<ul>\n<li>Click the \u201cDocking windows\u201d button as shown in Figure 10 to view both instruments at the same time.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig10.png\" alt=\"\" width=\"300\" height=\"140\" class=\"alignnone wp-image-31674\" \/><\/p>\n<p><em>Figure 10: Docking windows is helpful for this part<\/em><\/p>\n<ul>\n<li>Toggle only switch DIO 3 (The most significant bit) to a 1, this bit combination (1000) is the number eight, which should have half of 3.3 volts, or 1.65 V as shown in Figure 11.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig11-600x275.png\" alt=\"\" width=\"600\" height=\"275\" class=\"alignnone wp-image-31675 size-medium\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig11-600x275.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig11.png 785w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><em>Figure 11: The analog voltage of 1.63 V quite close to the desired 1.65 V for the \u201cEight\u201d (1000) level<\/em><\/p>\n<ul>\n<li>Play around with the button combinations and reproduce the values in Table 1, such as Fifteen shown in Figure 12.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><em><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig12-600x282.png\" alt=\"\" width=\"600\" height=\"282\" class=\"alignnone size-medium wp-image-31676\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig12-600x282.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig12.png 975w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/em><\/p>\n<p><em>Figure 12: Fifteen (1111) is pretty close to the desired 3.09 V, an error of only 50 mV, less than a quarter of the least significant bit (206mV)<\/em><\/p>\n<p>&nbsp;<\/p>\n<h4>2. Look at the transients and converter performance<\/h4>\n<p>Clicking values by hand is insightful but takes forever. We cannot test high frequencies this way.<\/p>\n<ul>\n<li>Close the voltmeter and Static IO instruments.<\/li>\n<li>Click Welcome-&gt; Patterns as shown in Figure 13.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig13.png\" alt=\"\" width=\"267\" height=\"551\" class=\"alignnone size-full wp-image-31677\" \/><\/p>\n<p><em>Figure 13: Opening the Pattern Generator. It basically pushes buttons super-fast.<\/em><\/p>\n<ul>\n<li>Click (+)-&gt;Bus to create a bus of digital pins that are controlled together as a group as shown in Figure 14.<\/li>\n<\/ul>\n<p><em><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig14.png\" alt=\"\" width=\"300\" height=\"191\" class=\"alignnone wp-image-31678\" \/><\/em><\/p>\n<p><em>Figure 14: Creating a digital bus<\/em><\/p>\n<ul>\n<li>CTRL+Click DIO 0, DIO 1, DIO 2, and DIO 3 and click Insert and then Add as shown in Figure 15. Leave all the fields as the default values and Waveforms just does what we wanted anyway.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig15.png\" alt=\"\" width=\"500\" height=\"449\" class=\"alignnone wp-image-31679\" \/><\/p>\n<p><em>Figure 15: Grouping digital pins into a bus<\/em><\/p>\n<ul>\n<li>In the pattern generator, click Type-&gt; Binary Counter as shown in Figure 16. This should automatically set the output to PP (push\/pull, double pole switch mode that is either 3.3 V or 0 V). You will see a group of square pulses of different frequencies to the right as shown in Figure 16. Leave the frequency Parameter1 at the default value of 1 kHz.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig16-600x94.png\" alt=\"\" width=\"600\" height=\"94\" class=\"alignnone size-medium wp-image-31680\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig16-600x94.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig16.png 891w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><em>Figure 16: the generated pattern<\/em><\/p>\n<ul>\n<li>Click Run to start the pattern generator.<\/li>\n<li>To observe the analog output, we need an analog instrument. Open the oscilloscope by clicking Welcome-&gt;Scope as shown in Figure 17.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig17.png\" alt=\"\" width=\"262\" height=\"149\" class=\"alignnone size-full wp-image-31681\" \/><\/p>\n<p><em>Figure 17: Launching the scope<\/em><\/p>\n<ul>\n<li>Click Run to start the scope capture. It will jostle all over the place, because the staircase waveform of a binary counter doesn\u2019t have any rising zero crossings.<\/li>\n<li>Set the trigger to the <em>falling <\/em>edge at 1 V as shown in Figure 18. This should stabilize the waveform.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig18-600x39.png\" alt=\"\" width=\"600\" height=\"39\" class=\"alignnone size-medium wp-image-31682\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig18-600x39.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig18.png 975w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><em>Figure 18: Setting the trigger. The default values work great for sine waves but must be set manually for trickier waveforms.<\/em><\/p>\n<ul>\n<li>Add a cursor by clicking the Y button in the upper right hand corner. The top of the staircase should measure about 3.09 V, the Fifteen level for a 3.3 V system as shown in Figure 19. It might be off by the thickness of the cursor.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig19-600x400.png\" alt=\"\" width=\"600\" height=\"400\" class=\"alignnone wp-image-31683 size-medium\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig19-600x400.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig19.png 675w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><em>Figure 19: A DAC staircase waveform<\/em><\/p>\n<ul>\n<li>Increase the frequency in the Pattern Generator to 10 kHz, you should see a waveform like Figure 20. At this scale, we can see the finite settling times of about a hundred microseconds for each bit transition. The shape of the settling edge is most severe at the falling edge when transitioning from the highest state (Fifteen 1111) to the lowest state (Zero 0000).<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig20.png\" alt=\"\" width=\"599\" height=\"336\" class=\"alignnone wp-image-31684 size-full\" \/><\/p>\n<p><em>Figure 20: settling times at 10 kHz<\/em><\/p>\n<ul>\n<li>Increase the frequency in the Pattern Generator again to 100 kHz. At this frequency and timescale, the finite rise time of a couple of microseconds can be clearly observed as shown in Figure 21. This rise time comes from a combination of parasitic capacitances in the scope and breadboard, a hundred pF or so.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig21.png\" alt=\"\" width=\"598\" height=\"395\" class=\"alignnone wp-image-31685 size-full\" \/><\/p>\n<p><em>Figure 21: Stairstep waveform at100 kHz for 4-bit converter<\/em><\/p>\n<p>&nbsp;<\/p>\n<h4>3. Go to eight bits and an amplifier to run a load<\/h4>\n<p>Digital pins are wimpy, they only offer about 4 mA of output current. We\u2019ll add an opamp that will have no trouble driving a load up to about 25 mA.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig22-600x320.png\" alt=\"\" width=\"600\" height=\"320\" class=\"alignnone size-medium wp-image-31687\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig22-600x320.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig22.png 965w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><em>Figure 22: An 8 bit R2R ladder DAC. Yes that\u2019s twenty nine 10k resistors.<\/em><\/p>\n<ul>\n<li>Wire the circuit in Figure 22. Be very patient with yourself. Keep your wiring as tidy as possible like that shown in Figure 23.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig23-600x450.png\" alt=\"\" width=\"600\" height=\"450\" class=\"alignnone size-medium wp-image-31688\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig23-600x450.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig23.png 739w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><em>Figure 23: An 8-bit converter with an op-amp and LED load<\/em><\/p>\n<ul>\n<li>Click Welcome-&gt;Supplies and set the positive DC supply to Master Enable On and 5 V as shown in Figure 24.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig24-600x153.png\" alt=\"\" width=\"600\" height=\"153\" class=\"alignnone wp-image-31689 size-medium\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig24-600x153.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig24.png 784w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><em>Figure 24: Enabling the DC supply for the op-amp<\/em><\/p>\n<ul>\n<li>The non-inverting op-amp has a gain of 1.5, which will boost the 3.29 V from the highest converter output 4.93 V, just a hair under the supply voltage. Good thing the LT1677 is rail-to-rail!<\/li>\n<li>If you\u2019re using a 741 or other not-rail-to-rail amp, just replace the noninverting amp with a buffer. It\u2019ll be fine.<\/li>\n<li>In the Pattern Generator, delete the old bus and create a new one with digital pins 0 through 7 as shown in Figure 25.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig25.png\" alt=\"\" width=\"500\" height=\"445\" class=\"alignnone wp-image-31690\" \/><\/p>\n<p><em>Figure 25: creating an 8-bit bus<\/em><\/p>\n<ul>\n<li>Set the type to binary counter again as shown in Figure 26, and set the frequency to 64 Hz, which will produce a two-second cycle length to go through all the binary values, which is slow enough to track with the human eye.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig26-600x321.png\" alt=\"\" width=\"600\" height=\"321\" class=\"alignnone wp-image-31691 size-medium\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig26-600x321.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig26.png 699w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><em>Figure 26: A 64 Hz 8 bit binary counter pattern<\/em><\/p>\n<ul>\n<li>Click Run to start it and go back to the scope. Change the scope mode to Screen and the scale to 1s\/div. You may see a jagged, irregular waveform like Figure 27. These sudden drops in the fine staircase waveform shouldn\u2019t be here. This converter is not properly converting binary strings to analog voltages. Something is wrong!<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig27.png\" alt=\"\" width=\"534\" height=\"307\" class=\"alignnone size-full wp-image-31692\" \/><\/p>\n<p><em>Figure 27: 64 Hz DAC output with improper behavior<\/em><\/p>\n<ul>\n<li>The light from the LED will rise and fall irregularly as shown in Video 1.<\/li>\n<\/ul>\n<div style=\"width: 735px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-31661-1\" width=\"735\" height=\"413\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/video1_glitch_LED.mp4?_=1\" \/><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/video1_glitch_LED.mp4\">https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/video1_glitch_LED.mp4<\/a><\/video><\/div>\n<p><em>Video 1: R2R ladder with improper behavior causing erratic LED brightness changes<\/em><\/p>\n<p>&nbsp;<\/p>\n<h4>4. One of the resistors is wrong!<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig28-600x448.png\" alt=\"\" width=\"600\" height=\"448\" class=\"alignnone size-medium wp-image-31694\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig28-600x448.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig28.png 975w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><em>Figure 28: I spy with my little eye\u2026<\/em><\/p>\n<blockquote><p><em>I spy resistors, most ten thousand ohms<\/em><\/p>\n<p><em>What other things make this circuit their home?<\/em><\/p>\n<p><em>Four ground connections, nine colors of wire<\/em><\/p>\n<p><em>And an operational amplifier<\/em><\/p>\n<p><em>I spy a diode emitting blue light<\/em><\/p>\n<p><em>Eight digital pins, I count one full byte<\/em><\/p>\n<p><em>Having all the same ohms is what matters<\/em><\/p>\n<p><em>When you are building R two R ladders<\/em><\/p>\n<p><em>In this entire resistor array,<\/em><\/p>\n<p><em>Do you spy the one that <strong>isn\u2019t <\/strong>ten kay?<\/em><\/p><\/blockquote>\n<p>The solution is at the end of the post, if you can\u2019t find the mistake.<\/p>\n<h4>5. Run the fixed 8-bit converter<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig29-600x393.png\" alt=\"\" width=\"600\" height=\"393\" class=\"alignnone size-medium wp-image-31696\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig29-600x393.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig29.png 682w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><em>Figure 29: Brown-black-orange-gold Brown-black-orange-gold Brown-black-orange-gold\u2026<\/em><\/p>\n<ul>\n<li>Find and replace any wrong-value resistors in the circuit to remove the errors.<\/li>\n<li>Debug the op-amp part too (check that it has power and negative feedback).<\/li>\n<li>When any glitches are fixed, you should see a triangle-shaped wave again on Channel 1. This triangle wave is actually a very, very fine staircase waveform with 256 steps.<\/li>\n<li>Channel 2 monitors the current through the LED using the series resistor R29. After the output reaches the turn-on voltage of the blue LED, it begins tracking linearly as shown in Figure 30.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig30-600x334.png\" alt=\"\" width=\"600\" height=\"334\" class=\"alignnone size-medium wp-image-31697\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig30-600x334.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig30.png 835w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><em>Figure 30: 64Hz with pesky glitches fixed<\/em><\/p>\n<ul>\n<li>Since LED brightness is proportional to current, the brightness of the LED tracks with the level of channel 2 as shown in Video 2.<\/li>\n<\/ul>\n<div style=\"width: 735px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-31661-2\" width=\"735\" height=\"413\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/Video2-fixed-glitches.mp4?_=2\" \/><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/Video2-fixed-glitches.mp4\">https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/Video2-fixed-glitches.mp4<\/a><\/video><\/div>\n<p><em>Video 2: Properly working DAC circuit driving a blue LED<\/em><\/p>\n<h2>Wrap-up<\/h2>\n<p>Well that was fun! We learned a bit about how to pilot the digital features and the issues that lie on the border between the Kingdom of Analog and the Empire of Digital. This can give you a little insight into the experimental issues that DACs can have. The R2R ladder is not the only DAC, but it\u2019s one of the easier ones to build on a breadboard from boring passives and amplifiers.<\/p>\n<p>Oh, you didn\u2019t want to mess with that? Digilent even sells a little R2R ladder module in Figure 31 that all the resistors are definitely the right value! <a href=\"https:\/\/digilent.com\/shop\/pmod-r2r-resistor-ladder-d-a-converter\/\">https:\/\/digilent.com\/shop\/pmod-r2r-resistor-ladder-d-a-converter\/<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig31.png\" alt=\"\" width=\"429\" height=\"323\" class=\"alignnone size-full wp-image-31699\" \/><\/p>\n<p><em>Figure 31: In the words of chef Ina Garten, \u201cIf you don\u2019t have homemade, store bought is fine\u201d<\/em><\/p>\n<p>To the professors in the audience: I\u2019ve rewritten all my circuit labs here at MSOE all around the Analog Discovery 2. All 30ish of them are compatible with the new\u00a0<a href=\"https:\/\/digilent.com\/shop\/analog-discovery-3\/\">Analog Discovery 3<\/a>\u00a0and feature at least one sensor or transducer. If you are looking for circuits lab experiments that don\u2019t put your students to sleep, drop me an email (faulkner@msoe.edu). Taking circuit theory isn\u2019t the price of admission to interesting subjects like controls and instrumentation, it can be fun on its own, and it\u00a0<em>should<\/em>\u00a0be fun.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig32-600x450.png\" alt=\"\" width=\"600\" height=\"450\" class=\"alignnone size-medium wp-image-31700\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig32-600x450.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/06\/fig32.png 975w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><em>Figure 32: It was R23 that was brown-black-RED-gold instead of brown-black-ORANGE-gold. And that blew up everything.<\/em><\/p>\n<p>&nbsp;<\/p>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-31661 jlk' data-task='like' data-post_id='31661' data-nonce='202d78e1e0' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Like' \/><span class='lc-31661 lc'>0<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-31661 jlk' data-task='unlike' data-post_id='31661' data-nonce='202d78e1e0' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Unlike' \/><span class='unlc-31661 unlc'>0<\/span><\/a><\/div><\/div> <div class='status-31661 status align-left'>Be the 1st to vote.<\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>Hi there Digilent Blog readers! I\u2019m Dr. Brian Faulkner, professor of Electrical Engineering at Milwaukee School of Engineering in Milwaukee, Wisconsin, USA, where I teach introductory circuit theory and power &hellip; <\/p>\n","protected":false},"author":47,"featured_media":31705,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,4312,35,1561,4326],"tags":[4544,4342,4432,1736,4433,5181,5182,4529,5179,5110,5178,5180,4565],"ppma_author":[4569],"class_list":["post-31661","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-products","category-usb-scopes-analyzers-generators","category-fpga","category-applications","category-teaching-training","tag-academic","tag-ad2","tag-ad3","tag-analog-discovery-2","tag-analog-discovery-3","tag-dac","tag-digital-to-analog","tag-lab","tag-ladder","tag-led","tag-r2r","tag-r2r-ladder","tag-resistors"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2025\/07\/Teaching-DA-Conversion-1080sq.png","authors":[{"term_id":4569,"user_id":0,"is_guest":1,"slug":"dr-brian-faulkner","display_name":"Brian Faulkner","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":"","9":"","10":""}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/31661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/users\/47"}],"replies":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/comments?post=31661"}],"version-history":[{"count":5,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/31661\/revisions"}],"predecessor-version":[{"id":31701,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/31661\/revisions\/31701"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/31705"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=31661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=31661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=31661"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=31661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}