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)|
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.
9. PC AT KEYBOARD
900 MODE SET
202 I2C READY
I2C>p<–setup power supply
W/w toggles 3.3volt supply?
MODE>1<–don’t use 3.3volts
W/w toggles 5volt supply?
MODE>2<–use 5volt supply
9xx SUPPLY CONFIGURED, USE W/w TO TOGGLE
9xx VOLTAGE MONITOR: 5V: 0.0 | 3.3V: 0.0 | VPULLUP: 0.0 |
I2C>W<–capital ‘W’ activates the supply
9xx 5VOLT SUPPLY ON
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
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%
210 I2C START CONDITION
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
240 I2C STOP CONDITION
9xx VOLTAGE PROBE: 0.0VOLTS<–DAC at 0%
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?