Monday, February 7, 2011

Review of Arduino DAC solutions

I was in a need of an analog output output for my Arduino, and I found quite many different digital-to-analog converter (DAC) solutions by googling around. So finally I decided to gather them on one page as a reminder for myself and a guide for others. So here it comes!


R-2R ladder DAC

The most common way to build a DAC is to use a R-2R ladder circuit. Make: Online has a photo-guide for building one. However, this DAC has no output buffer, which would make this circuit a bit more reliable and working with all kinds of loads.

MAKE: Online's DAC shield

Make: Online - Proto-DAC shield for Arduino
A Direct digital synthesizer build using a R-2R ladder DAC - This is worth a look if you're interested in outputting audio.


R-2R ladder DAC with output buffer

For the best results, you should use an output buffer in the DAC. The buffer separates your R-2R ladder from the load you connect it to and makes the result non load dependent. Here's maybe the best tutorial I've seen for a R-2R DAC with an output buffer. It uses a common LM358 operational amplifier that can be driven from single supply. Note that in order to get the full output range to work with this circuit, you need to have a higher than 5V supply for the LM358. Of course, another way to get around this problem is to use a 5V supply but put a simple voltage divider in front of the op amp. Then you'll get lower than 5V output but don't lose fidelity.


Ikalogic's R-2R DAC with an output buffer.

Ikalogic's very good page on R-2R DACs



The 2 cent DAC by raalst



A very clever solution utilizing the integrated pullup resistors on the Atmega chip. You need only 1 resistor and as many output pins as you want bits. The output is a bit crude but 500kHz could be reached. The internal pullups are specified to be minimum 20kohms and maximum 50kohms so the result might not be the most accurate.

Arduino Forum - The 2ct DAC


Simple 10-bit DAC by avdweb



This design uses only two output pins, and the circuit is fairly simple, utilizing an op amp. The max settling time is 20ms, which is way too low for audio output. But the settling time could be enhanced with a circuit modification...

Arduino Forum - Simple 10-bit DAC
avdweb - Simple 10-bit DAC



Using the PWM as a DAC

Of course, you can also use the PWM outputs to get an analog output signal from the Arduino. Just put a low pass filter after the PWM output to get a nice & smooth output with a frequency range up to 16kHz, according to this Lab3 experiment.

A direct digital synthesizer realized with Arduino's PWM output.

Lab3 - Arduino DDS using PWM



Resistor/PWM hybrid DAC



This is a good explanation on how to combine two PWM outputs in order to double the bit resolution. So combining two 8-bit arduino PWM outputs you can get a 16-bit PWM output! Remember Arduino's limits if you plan on going down this road. I mean, the Atmega chip is just 8-bit...

http://www.k9spud.com/traxmod/pwmdac.php
Link doesn't work? Try this one via the Wayback Machine



SPI-interfacing two Microchip MPC4921 DAC chips with Arduino

Stepan Schulz used SPI to interface two MPC4921 12-bit DAC chips. This saves you pins compared to the R-2R ladder. Using the onboard SPI of the Arduino like Stepan, you need 5 pins, but you can save one (maybe even two) if you code the SPI code by hand.

Stepan's post on the Arduino forum
See the code here
MPC4921 datasheet


Audio shield with MCP4921 DAC



Adafruit industries' Wave shield is an audio shield for Arduino that also uses the MCP4921 SPI DAC chip. You can play back 12-bit 22kHz wav files. This means the maximum output frequency is 11kHz.

Adafruit Industries - Wave shield


Midivox - synthesizer shield with the MCP4921

Another shield that uses the MCP4921 DAC chip. This one's quite cool, it's a monophonic synthesizer with MIDI input and the synth engine has an attack / release generator and a cool filter! Proves that the Arduino can be used to generate synth sounds.

Narbotic instruments - Midivox - A synth shield featuring the MPC4921.


DAC using AD420 16-bit serial-input DAC

Shaduzlabs.com has a good article for using the AD420 with Arduino. There's schematics, pictures and a code example.

Shaduzlabz.com - High-accuracy 16-bit DAC for Arduino
AD470 datasheet


That's it for now. Thanks for reading! Please comment, if you have anything to add!

[Edit: randy pointed out this site with some hints for Arduino audio DAC solutions. Thanks!]

Tuesday, February 1, 2011

Vinculo - Arduino clone with USB slave / host capability

I just got hold of  FTDI chip's new Vinculo developing platform, so here's a quick review for you!

Vinculo is a 25€ development platform for the FTDI Vinculum II (VNC2) dual USB host/slave microcontroller. The board design has been copied from Arduino, and they even advertise it as Arduino-inspired and Arduino shield compatible. FTDI seems to have realized the potential that comes when having a large hobbyist userbase...

Vinculo could be called a USB-enabled Arduino, but that really doesn't do the board justice. There are many features that set it apart from the Arduino, and it also beats Arduino in all the specs (see below). Of course, it's not nearly as user-friendly as the Arduino as a first platform.

Look what I got in the mail!


Vinculo board with the programming header uncovered (the pins on the right).


Compared to Arduino, there are many differences:
 - The USB ports on the Vinculo can not used for programming the microcontroller - they are used for connecting host or slave devices.
 - You need also a 15€ USB programmer for the Vinculo (it's the small device on the right in the picture below)
 - Due to the flexibility of the VNC2 chip, the signals can be rerouted to different pins
 - Many feature & performance differences, more detail below.

Vinculo board and the programming & debugging module.

A close-up of the USB slave/host ports and the 9V jack.

Vinculo next to an Arduino Duemilanove.


 Vinculo board features:
 - 16-bit VNC2-64Q microcontroller (Arduino is 8-bit)
 - USB Type A connector for use in USB 2.0 host applications
 - USB Mini-B connector for use in USB 2.0 slave applications
 - Connector for external 9V power supply
 - Compatible with shields built by the Arduino community
 - 30 digital input/output pins (Arduino Duemilanove has 14)
 - 8 analog-to-digital converter inputs with 10 bit resolution (Arduino Duemilanove has 6 at same resolution)
 - 8 PWM outputs (Arduino Duemilanove has 6)
 - Variable clock speed: 12 / 24 / 48 MHz (Arduino Duemilanove is 16 MHz)
 - 256 kilobytes of FLASH memory (Arduino Duemilanove has 32 kbytes)
 - 16 kilobytes of RAM (Arduino Duemilanove has 2 kbytes)

Datasheets for the chips on board:
Vinculum-II Embedded Dual-USB Host Controller IC datasheet
MCP3008 8-channel 10-bit analog-to-digital converter datasheet


The pin headers in my Vinculo were all a bit crooked. I seem to have bad luck since my Duemilanoves look like this too. Here's the 8 ADC channels and Reset, 3V3, 5V, GND and Vin pins.
Also the two-row headers were a bit crooked. I'll have to use some force when installing the shields.


Software

The language used to program the Vinculum is a subset of ANSI C. For Arduino users it should be no big challenge but still a bit more complex. The Arduino IDE actually goes so far that it completes the user code to be valid C++, with some extra header code. I don't think the Vinculum-II does any of that.

Unfortunately, the toolchain is only for Windows. This seems to be a very common grief in the embedded world. I'm not sure if it works under Wine. The development IDE can be downloaded for free from here. You need to register to download it. Be sure to install also the patch for the 1.2.2 version.

There's some firmware code examples on the FTDI chip page, with good documentation. You get examples for a 16x2 LCD interface, a graphical LCD interface and a Volt meter using an OLED screen.

If you make a USB slave device with this board, let's say for example some custom game controller, you'll need to use either the Virtual Com Port (VPC) driver or the D2XX direct USB access driver. I haven't gotten that far yet. See the links for the drivers, guides and programming examples.


Vinculo Prototyping shield

The Vinculo prototyping shield in it's package

I also got a 10€ prototyping shield for the Vinculo. The package contains a prototyping PCB, pin headers to fit the Vinculo board, and a minimal set of components: 2 pushbuttons, 2 green and 1 yellow leds and three resistors.

Contents of the prototyping package.

Related links
Vinculo board home
Vinculo board datasheet

Vinculum II homepage
Vinculum II datasheet
Vinculum II toolchain


That's it for now. Stay tuned for some more articles on this board!


EDIT 28. March 2011: Problems with the Vinculo platform.

I haven't had the time to work on this board yet, but others have. Unfortunately it seems that they're not very pleased with the toolchain and the documentation.

Josh Pieper has been hard at work exploring the various issues with the VNC2 Toolchain, and complains that the newly released version 1.4.0 didn't solve any of the many issues he has found & reported. Very good work!

In an element14 post, Josh also answers a question by nickname WestfW:
WestfW:
"Do any of the FTDI documents describe the architecture of the Vinculum2 CPU or chip/peripherals? I couldn't find anyhing in the docs I looked at, or anything that seemed likely on their web site.  They provide a C compiler and a bunch of libraries, but programming something of that complexity without more indication of how it works seems ... scary.

It seems like quite a lot of value stuffed into that chip.  About the same price as an FT232RL with a lot more capability..."

jpieper:
"FTDI appears to be keeping the architectural details closed.  I've been working on a project with the VNC2 and have run into serious problems in the compiler, linker, libraries, and IDE which make me think that the toolchain is just not that robust yet."

So, looks like Vinculo is a quite closed and immature platform. FTDI probably rushed the product to market. That's not strange at all, seems like nowadays every company does that. But not fixing the serious user-reported bugs in the toolchain - that's strange.

Let's hope FTDI fixes these problems in the next update and even gives some more information on this platform so the power of Vinculo could be fully unleashed among the hobbyists.