Parts: I2C audio volume potentiometer (DS1807)

ds1807ii

The DS1807 contains two logarithmic digital potentiometers (pots) for audio volume adjustment. Each pot has 64 volume levels plus a mute setting. The volume level of each pot is set over a two-wire I2C serial interface. We’ll show you how to connect and interface the DS1807 below.

DS1807 I2C audio volume potentiometer (Digikey #DS1807+-ND, $3.04)

Connections

Bus Pirate DS1807 (pin #)
GND GND (1)
GND A2 (2)
GND A1 (3)
GND A0 (4)
GND AGND (11)
SDA SDA (12)
Clock SCL (13)
+5volts VCC (14)

We connected the DS1807 to the Bus Pirate universal serial interface tool as shown in the table, the same basic principals apply to any custom configuration. We used the Bus Pirate’s 5volt power supply, but the DS1807 will also work at 3.3volts. I2C requires a pull-up resistor on each signal line, we used the Bus Pirate’s on-board resistors connected to the on-board 5volt power supply.

Connect the DS1807 to an audio source as shown on page 3 of the datasheet. Connect the raw audio signal to the H pin and connect the L pin to ground, the attenuated audio signal will come from the W pin.

Interfacing

First, setup the Bus Pirate for I2C mode, and activate the 5volt power supply. We covered this procedure in our last parts post.

I2C>v<–voltage monitor
9xx VOLTAGE MONITOR: 5V: 4.9 | 3.3V: 0.0 | VPULLUP: 5.0 |
I2C>

With the power supply configured, check the voltage monitor (v) to be sure the 5volt supply is active and that 5volts is present at the pull-up resistors.

I2C>(0)<–list available macros
0.Macro menu
1.7bit address search
I2C>(1)<–run address search
xxx Searching 7bit I2C address space.
Found devices at:
0×50 0×51 0×52<–potential addresses
I2C>

The Bus Pirate’s address search macro is a quick way to locate I2C devices without looking at the datasheet. 0×50 is an I2C write address because the last bit is 0, 0×51 is read address (last bit 1). 0×52 is probably a group/global write address because it doesn’t have a corresponding read address.

We could also determine the address from the datasheet: the base address is 0101 plus the three address select bits (A0-2, all grounded, 000) and the write or read bit (0 or 1) gives 0b01010000 (0×50).

I2C>[0x51 r r]<–read pot values
210 I2C START CONDITION
220 I2C WRITE: 0×51 GOT ACK: YES <–device read address
230 I2C READ: 0x3F<–pot0
230 I2C READ: 0x3F<–pot1
240 I2C STOP CONDITION
I2C>

First, we read the potentiometer values at startup. [ issues the I2C start condition, 0x51 is the device read address, "r r" reads two bytes, and ] issues the I2C stop command. The default startup value is 63 (0x3f), one position above mute (datasheet page 2).

I2C>[0x50 0b10101001 0]<–write pot0
210 I2C START CONDITION
220 I2C WRITE: 0×50 GOT ACK: YES<–DS1807 write address
220 I2C WRITE: 0xA9 GOT ACK: YES<–pot0 write command
220 I2C WRITE: 0×00 GOT ACK: YES<–volume to set
240 I2C STOP CONDITION
I2C>[0x50 0b10101010 64]<–write pot1
210 I2C START CONDITION
220 I2C WRITE: 0×50 GOT ACK: YES<–DS1807 write address
220 I2C WRITE: 0xAA GOT ACK: YES<–pot1 write command
220 I2C WRITE: 0×40 GOT ACK: YES<–volume to set
240 I2C STOP CONDITION
I2C>[0x51 r r]<–read values back to verify
210 I2C START CONDITION
220 I2C WRITE: 0×51 GOT ACK: YES<–DS1807 read address
230 I2C READ: 0×00<–pot0 value
230 I2C READ: 0×40<–pot1 value
240 I2C STOP CONDITION
I2C>

Next, we update each volume pot with a separate command. 0×50 is the DS1807 write address, 0b10101001 (0xA9) is the command to update pot0, and 0 sets the volume to full. The next sequence uses the update pot1 command, 0b10101010 (0xaa), and sets the volume to mute (64, 0×40). Finally, we use the read procedure to verify that the values are correct.

I2C>[0x50 0xA9 64 0]<–write both pot values
210 I2C START CONDITION
220 I2C WRITE: 0×50 GOT ACK: YES
220 I2C WRITE: 0xA9 GOT ACK: YES<–update pot0 command
220 I2C WRITE: 0×40 GOT ACK: YES<–pot0 value
220 I2C WRITE: 0×00 GOT ACK: YES<–pot1 value
240 I2C STOP CONDITION
I2C>[0x51 r r]<–read back values
210 I2C START CONDITION
220 I2C WRITE: 0×51 GOT ACK: YES
230 I2C READ: 0×40<–pot0 value
230 I2C READ: 0×00<–pot1 value
240 I2C STOP CONDITION
I2C>

The pot 0 write command can also be used to set both potentiometer values with a single command. Use the pot0 update command (0b10101001, 0xA9), and  send the pot1 value (0) following the pot0 value (64).

I2C>[0x50 0b10101111 0x20]<–update both pots with the same value
210 I2C START CONDITION
220 I2C WRITE: 0×50 GOT ACK: YES
220 I2C WRITE: 0xAF GOT ACK: YES<–dual update command
220 I2C WRITE: 0×20 GOT ACK: YES<–value to set
240 I2C STOP CONDITION
I2C>[0x51 r r]<–read back values
210 I2C START CONDITION
220 I2C WRITE: 0×51 GOT ACK: YES
230 I2C READ: 0×20<–pot0 value
230 I2C READ: 0×20<–pot1 value
240 I2C STOP CONDITION
I2C>

Finally, 0xAF (0b10101111) can be used to update both potentiometers with the same value. This is probably the most useful command for stereo audio volume control where both channels have the same value and change simultaneously.

Are there any chips or components you’d like us to cover in future parts posts?

6 thoughts on “Parts: I2C audio volume potentiometer (DS1807)

  1. These practical posts are great, keep it up.

    I’d really like you guys to do a writeup on the Winbond ISD1700 voice recorder chip.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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