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]
end

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.

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.

UPDATE: Galago is fully-funded!

http://www.kickstarter.com/projects/kuy/galago-make-things-betterImage

As of this morning (15 September) this Kickstarter had reached $30 000 in funding, and as such will be produced. So begins the debate on whether or not to order a few more…

In any case, hopefully Kuy can get these built relatively quickly and the development environment pans out as described. If not, I’ve got plenty of nights and weekends to try and write my own bootloader/toolchain.

Galago, a ARM Cortex-M3 development board with a real time debugger!

http://www.kickstarter.com/projects/kuy/galago-make-things-better

ImageWhat a great find for $19. Half the price of a Arduino (from radio shack, at least, I go with the chinese knockoffs for $17) and orders of magnitude more capability. Too great to pass up, I swung for one. Here’s the bad news, unless they sell $30k worth, they don’t get any of the funding. And, there’s only 17 days to go. Hopefully they can pull this one out of their ass, get funded and give PJRC and their new Teensy 3.0 a run for their money.

Blog at WordPress.com.

%d bloggers like this: