Skip navigation
I'm back again with the resistor DAC on an Arduino Uno as a simple audio generator. I'm not clear how I came to do so many blogs on it, but this is going to be the last one.   Here's the latest sketch with commands for setting the output level as well as the frequency. This sketch is for a Uno, so may need adaption for other boards. I've changed the command to be 'FUNCtion' rather than 'SOURce' simply because I can (though I probably ought to read the SCPI spec and see what you should use, ...
I'm back with the test sketch and I've implemented a frequency sweep. This starts at 20Hz and continuously changes the frequency until it arrives at 20kHz where it starts all over again. The sweep is linear because that was what was easy to do (normally, for a frequency response curve, you'd be looking at a logarithmic scale). I might have a go at a log version later if I can get myself in the right frame of mind for some mathematics.   /* AD Test */ unsigned int tableOffset = 0; & ...
I've made a bit more progress. I now have my test code connected to the SCPI parser. That was very easy to do: I simply copied their generator example, took out the lines specific to the chip they were using, and adapted it slightly to calculate the table step. Much to my amazement it works and I can now program the output frequency.   Here's the sketch. The two includes that the highlighting wipes out are:   #include <scpiparser.h> #include <Arduino.h>   #include ...
Another diversion - I'm going all round the houses here. Who would have thought that there could be so much to a few simple resistors arranged in a network? This time I'm playing with the simulator.   When I did the hardware in a previous blog, I mentioned that the output of the resistor ladder needed to be buffered but didn't actually say what the output resistance is. Given that we know the 'R' value - for my circuit I chose 4.7k - can we say what the output resistance is analytically ...
More on the R-2R ladder as a DAC. This time some work on the firmware.   What I'm doing here is the reverse of what happens when we digitize a signal; at regular intervals I have to come up with the value for the waveform at that moment in time rather than read the value. When filtered, that will then reconstruct the waveform.   To do that I need an accurate time interval. The only sensible way to do that on the Arduino is with interrupts, so I had to have a quick read on how that ...
I'm still fiddling around with the R-2R ladder as a DAC on an Arduino. This time some hardware.   This isn't a project to be built, instead I'm experimenting with analogue stuff; you're looking over my shoulder as I get some things right and quite a lot of things wrong. What I've ended up with is messy and not really the way to do it, but if I blog about it at least you'll be forewarned and in a position to do it better.   I decided that I wanted to be able to control both the fre ...
Part one is here: https://www.element14.com/community/people/jc2048/blog/2018/04/12/arduino-r-2r-experiment   I was going to do some hardware next but got sidetracked into playing with software instead.   Here's a very well-known waveform being produced by the simple resistor-ladder DAC I built in part one.       and here's what it looked like before I got the arithmetic right       That's generated by this sketch   // //  --- Sine table ...
jc2048

Arduino: R-2R Experiment

Posted by jc2048 Apr 12, 2018
R-2R sounds like it might be a robot from the Star Wars universe (a ladder robot, maybe?), but in electronics it's the name of a resistor network that can be used to make a DAC (digital-to-analogue converter). I'm going to try doing just that with an Arduino and see how I get on. If this works, it's then going to be the basis for a piece of Arduino test equipment controlled by the SCPI library that Jan introduced us to last weekend.   The network looks like this. This is from the simul ...