MCP4802 DAC Waveform Generation on Raspberry Pi

04/09/2012

This project is a simple waveform generation using the MCP4802 DAC on the Raspberry Pi.

Wire up the breadboard as shown below.

The output of the DAC is on pin 8 (channel 0). The example software is a triangle waveform.

To install the software:

wget http://skpang.co.uk/dl/mcp4802.tar

Unpack the tar file and change into directory by:

tar xf mcp4802.tar 
cd mcp4802

Compile the software by:

make all

Start the example by:

sudo ./dtoa

Using an oscilloscope the output waveform can be viewed. The main routine is in dtoa.c file

 

To stop the program running press CTL-C

 

Parts List

Short URL:

Tags: , , ,

One Response to MCP4802 DAC Waveform Generation on Raspberry Pi

  1. Shane on 03/03/2014 at 03:38

    We are struggling to get an analog output from our Pi. We are using a MCP4921, which differs from yours in that it is 12 bit and it uses an external V_Ref. While attempting to use your method, I’ve come to receive seemingly nothing at the output of the DAC. I have it connected just as yours with the exception of the V_Ref pin. I’ve changed a couple lines of code (gb_spi.c 106 and 112 by adding one F to the equation to accommodate one additional byte.) The four most significant bits should be the same on our chips. I am receiving some square signals at the MOSI, clock and CS pins, which seem reasonable. Do you have any thoughts as to where the issue lies?

    -Shane