Spartan-6 Microboard: 16-bit R-2R DAC! [Part One]

So how do you produce a usable, somewhat analog signal out of a purely digital device? Well it’s actually simple; use a R-2R ladder and a bunch of digital pins. Basically we’re turning a dearth of extremely high speed digital IO pins into one high-resolution analog output. Oh, also necessary for this circuit (go ahead and crack out the protoboard and soldering iron) is 3 matched resistor per bit of resolution; so in our case, 48.

A 16-bit R-2R Ladder Schematic

A 16-bit R-2R Ladder Schematic

Fun! Here’s a diagram. So how’s it work? When we drive our 16 outputs with digital logic, each pin has half the voltage range of its leftwards neighbor — due to it being a stacked  voltage divider. This is exactly how you  convert from binary to decimal; each digit has twice the value of one neighbor, and half that of the other (discounting the Most and Least Significant Bits) so we can  convert 1s and 0s into a wide numeric  range of values.

This is probably confusing: I know how it works, and I just confused myself. For a *much* better explanation, refer to this previous post of mine.

We’ve got a  circuit, we know conceptually how it works, how do we make it do? Make…make it do right? This is where my brain started screeching to a halt. Hell, I must be driving with the E-brake on, because this is actually super easy, and explaining why helps to understand VHDL/Verilog.

Firstly, in programming languages, things happen sequentially: A, then B, then conditionally C, for example. In Hardware Description Languages, things happen simultaneously: A <= a and B <= b and C <= c all happen simultaneously. Secondly, all of our analog values we’d want to output, such as 62101 is actually represented in a variable, described thusly:

wire [15:0] our_var

It’s actual designation in the chip is in the form 0b1111001010010101.
This means all we have to do to convert our digital data to our analog output at full clock speed is this:

always @(*) begin
pin15 <= our_var[15]
pin14 <= our_var[14]
pin1 <= our_var[1]
pin0 <= our_var[0]

These all update at the same time, and our output is produced thusly. So, I’ve been dismissing the most major disadvantage? Speed. Lets say we want to make a 16b sine wave. Our speed is limited to f_clk/number_of_levels. So FM is out of the question with this particular implementation (I’m not ruling it out completely, let me know if you know more than I do) but it’s the perfect speed for audio applications.

With a 350MHz DCM, and using 16,384 distinct levels, I can generate a f_max of around 21kHz, well above the range of human hearing. So let me work on getting that code finished, and I’ll return tomorrow. I’ve got my wheels pointed towards the curb, and my E-brake on, and I need a break for the night.

Update: Spartan-6 LX9 Microboard


I’ve gotten this development board in, and it is amazing! Haven’t had time to do much but plug it in and watch the example design blink away at me, but impressive knowing instead of a microprocessor controlling the pattern, it’s an actual (mostly) physical multivibrator circuit (I’m assuming, or a binary counter (i think in this case that’d still apply (woo nested parenthesis (it’s late, forgive me.))))

Where-was-I-going-with-this that’s right.

Xilinx/Avnet support for this product is abysmal to the point of embarrassment. That’s a bit harsh. I believe they’ve simply let their respective websites become spaghetti coded to shit, making the documentation, drivers, and reference designs become deadlocked behind levels and levels of infinite loops of server redirects. I’ve contacted them, but in the mean time, I’ve found an excellent listing of tutorials (for both this product, and FPGAs in general) that I will me manually sorting and posting, tomorrow evening, round this time.

Stay posted, let me know what your thinking down below.

I’m out.

Teaser: Spartan-6 LX9 Microboard

Sparta-6 LX9 Microboard from AVNET and Xilinx

Sparta-6 LX9 Microboard from AVNET and Xilinx

This is teasing you as much as it is me. This is the Microboard. it’s an FPGA development board with onboard ram, 10/100 ethernet, and USB (among the various blinky switchy things all development boards must have) for the low, low cost of around $90.

Or if you know someone like Vlad a bit cheaper. Thanks for the donation!

For my first project, I’m looking at a simple FM (re)transmitter.  I want to make a local area delay filter. Think about it.

IR remote control reverse engineering

If you’re anything like me, or the vast majority of Americans, you are surrounded by IR devices at home, at work, and pretty much everywhere you go. A great number of these devices (round 90%, its kind of the standard) use the 38 kHz SonyIR protocol, but knowing just that doesn’t help much. Especially if you lack a proper oscilloscope, like me. Plus, hell, your remote might be in that mysterious 10 percent. In order to figure out the actual encoding, you need to be able to plot the signals while you fiddle with the remote, and then make a chart relating the independent variable (the fiddling) to the depedent variable, the bursts of 0s and 1s that inevitably ensue.

IR pulses for various button presses on someone else's oscilloscope :-\ man browser up

Trandi has done precisely that, in his reverse engineering a remote controller from a toy chinook to operate his land based Rover and has devised an excellent technique for visualizing the data transmissions from the remote with just an attiny and a IR photodetector IC from radio$hack. Now if you, like me, find your local radio$hack overpriced and understocked, over on the arduino forums its been discovered the same resolution can be had with a plain IR phototransistor and optionally a cheap opamp like the lm741 (or also I hypothesize with a TL082 dual biFET (perhaps wired as a fourth order Butterworth high-pass?) and a IRled. Likely it’d work best reverse biased, reducing the slow response time typical of using an led as a photodiode, at the expense of increased noise. What’s the point? Never had one. And that just burns you up inside!) provided you modify your timings a bit.

A remote much like this one was harmed. Severely.
Continue reading

Blog at

%d bloggers like this: