Parts: LTC2631A I2C digital to analog converter


Linear Technology’s LTC2631A-LZ8 is an 8bit digital to analog converter (DAC) with an I2C interface. This DAC can output 255 different voltages, spaced evenly between 0 and 2.5volts. We previously demonstrated the LTC2640 with a three-wire SPI interface, but this version is controlled with only two signal wires.

Bus Pirate LTC2631A (pin #)
CA0/Address 0 (1)
+5volts CA1/Address 1 (8)
+5volts VDD (5)
REF (6)

We used the Bus Pirate universal serial interface tool to work with the DAC, but the same basic principals apply to any custom implementation. The connections between the Bus pirate and the LTC2631A are outlined in the table. We powered the chip from the Bus Pirate’s 5volt supply, but it would also work fine at 3.3volts.

The I2C bus requires pull-up resistors on both bus wires. 5volts is supplied to the pull-up resistors by connecting a wire from the 5volt supply to the pull-up resistor input terminal. Close the jumpers on the clock and data lines to supply the external voltage to the pull-up resistors.

Now, setup the Bus Pirate for I2C mode and activate the on-board power supply.

HiZ>m<–select mode
1. HiZ
2. 1-WIRE
4. I2C

MODE>4<–I2C mode
I2C>p<–setup power supply
W/w toggles 3.3volt supply?
1. NO
2. YES
MODE>1<–don’t use 3.3volts
W/w toggles 5volt supply?
1. NO
2. YES
MODE>2<–use 5volt supply
9xx VOLTAGE MONITOR: 5V: 0.0 | 3.3V: 0.0 | VPULLUP: 0.0 |
I2C>W<–capital ‘W’ activates the supply
I2C>v<–check the voltage levels
9xx VOLTAGE MONITOR: 5V: 4.9 | 3.3V: 0.0 | VPULLUP: 5.0 |<–supply on

After configuring the Bus Pirate, the voltage monitor shows that the 5volt supply is active (4.9volts). Additionally, the monitor shows that 5volts is connected to the pull-up resistor supply terminal (VPULLUP).

I2C>(0)<–list available macros
0.Macro menu
1.7bit address search
I2C>(1)<–search for I2C devices
xxx Searching 7bit I2C address space.
Found devices at:
0x40 0xE6<–got reply from these addresses

The state of pin 1 and 8 determine the LTC2631A I2C address, according to the table on page 22 of the datasheet. Instead of looking up the address in the datasheet, we used the Bus Pirate’s I2C address search macro to scan the entire I2C address range. The DAC responds to the set address (0X40) and a global address (0xE6). The global address is useful for controlling multiple DACs simultaneously over the same I2C bus.

I2C>d [0x40 0b00110000 0xff 0] d
9xx VOLTAGE PROBE: 0.0VOLTS<–output is 0volts
210 I2C START CONDITION<–start transaction
220 I2C WRITE: 0x40 GOT ACK: YES<–DAC address
220 I2C WRITE: 0x30 GOT ACK: YES<–set DAC output command
220 I2C WRITE: 0xFF GOT ACK: YES<–set DAC to full (255)
220 I2C WRITE: 0x00 GOT ACK: YES<–don’t care, extra byte
240 I2C STOP CONDITION<–end transaction
9xx VOLTAGE PROBE: 2.5VOLTS<–output at full

Now we’re ready to interface the DAC. An initial voltage measurement (d) shows that the DAC is currently outputting 0volts.

An I2C start condition ([) alerts connected I2C devices to listen for their address. The first byte is the address (0x40) that identifies the device we want to access. The next byte is the LTC2631A command to update the DAC output (0x30 or 0b00110000), followed by the output setting (0xff or 255, 100% output). The final byte doesn’t matter for the 8bit DAC we’re using, but carries additional data bits for higher resolution versions of the DAC. The transaction is completed by sending the I2C stop condition (]).

After updating the DAC to 100%, a voltage measurement (d) shows that the output is 2.5volts.

I2C>d [0x40 0x30 0 0] d
9xx VOLTAGE PROBE: 2.5VOLTS<–DAC at 100%
220 I2C WRITE: 0x40 GOT ACK: YES
220 I2C WRITE: 0x30 GOT ACK: YES
220 I2C WRITE: 0x00 GOT ACK: YES<–set DAC to 0
220 I2C WRITE: 0x00 GOT ACK: YES

A similar command sequence sets the DAC output back to 0. A voltage measurement confirms that the DAC output is now 0volts.

For a complete list of DAC features and command codes, see the in-depth discussion of the LTC2640 SPI DAC at the end of the Bus Pirate version 1 how-to.

Are there any chips you’d like us to interface in future parts posts?

9 thoughts on “Parts: LTC2631A I2C digital to analog converter

  1. The parts articles are great, I plan on building a bus pirate as soon as I get some free time. My suggestion for a future article is the MCP6S26 programmable gain amplifier from Microchip. PGA chips seem like a good way of taking some of the headaches out of amplifier design and the multiple inputs allow one to switch various filters in and out of the circuit. Another part you may consider covering is one of the digital potentiometer chips.

  2. great post !! it will great if u can do a parts post on some of the high speed ADCs like LTC2209 which can be useful a lot of people who want to do all sorts of sampling operations…

  3. I’ve got a chip for you guys to try out with the BusPirate, I bet you’d have troubles like I did.
    Its a Texas Instruments TLC5940 LED driver chip.
    I held great promise thinking this chip would be easy to interface. Not being a professionally taught electronics person, I found it almost impossible to use. Not only is the Data Sheet nigh on useless, I didn’t recognise the serial comms format it uses, even building a proto board for it was difficult.
    I tried interfacing it with a PIC 16F88 chip using PICBasic Pro. Couldn’t even get it to light any of the LEDs.
    I since switched to a pair of Maxim MAX6956 chips on one i2c bus – INFINITELY easier to use because it uses i2c, a great protocol, library routines already built into PicBasic Pro.

  4. Oh BTW.
    This is what I’m doing with the pair of MAX6956 chips and a 16F88 –

    I even wrote a little VB prog that allows you to generate the patterns with a GUI, it outputs PicBasic DATA blocks for you to paste into the PBP program. You then simply compile, then flash the F88. Job done.

  5. @stu

    I used the tlc5940 in my home lighting system, si-light.

    The TLC5940 has an SPI interface to the PWM registers, but the data out is primarily useful for cascading multiple chips.

    The tricky part about the TLC5940 is that you must provide your own clock and reset. You provide 4096 clock ticks, and then trip the reset pin. Inside, the 5940 has counters that turn off the LED when the clock ticks equal the duty cycle you program through the SPI interface; all come back on when the reset pin is triggered.

    As I recall, I connected the oscillator output of a PIC16F628a to the TLC5940 clock input, and used the PIC’s counter to count to 4096 and then toggle the reset pin on an interrupt.

    Now, can this be done with the Bus Pirate? Sure, but it will need a new module that creates the clock signal on one AUX pin and the reset on the other. This isn’t difficult, but it’s not a feature the Bus Pirate currently has.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s