PARTS: I2C AUDIO volume POTENTIOMETER (DS1807)

The DS1807 consists of 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)

روابط

حافلة القراصنة
DS1807 (pin #)

GND
GND (1)

GND
A2 (2)

GND
A1 (3)

GND
A0 (4)

GND
agnd (11)

SDA
SDA (12)

ساعة حائط
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-made 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: 0x50 0x51 0x52<–potential addresses I2C>

The Bus Pirate’s address search macro is a quick way to locate I2C devices without checking out the datasheet. 0x50 is an I2C write address because the last bit is 0, 0x51 is read address (last bit 1). 0x52 is probably a group/global write address because it doesn’t have a corresponding read address.

We could also figure out 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 (0x50).

I2C>[0x51 r r]<–read pot values 210 I2C start CONDITION 220 I2C WRITE: 0x51 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: 0x50 got ACK: YES<–DS1807 write address 220 I2C WRITE: 0xA9 got ACK: YES<–pot0 write command 220 I2C WRITE: 0x00 got ACK: YES<–volume to set 240 I2C stop CONDITION I2C>[0x50 0b10101010 64]<–write pot1 210 I2C start CONDITION 220 I2C WRITE: 0x50 got ACK: YES<–DS1807 write address 220 I2C WRITE: 0xAA got ACK: YES<–pot1 write command 220 I2C WRITE: 0x40 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: 0x51 got ACK: YES<–DS1807 read address 230 I2C READ: 0x00<–pot0 value 230 I2C READ: 0x40<–pot1 value 240 I2C stop CONDITION I2C>

Next, we update each volume pot with a separate command. 0x50 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, 0x40). 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: 0x50 got ACK: YES 220 I2C WRITE: 0xA9 got ACK: YES<–update pot0 command 220 I2C WRITE: 0x40 got ACK: YES<–pot0 value 220 I2C WRITE: 0x00 got ACK: YES<–pot1 value 240 I2C stop CONDITION I2C>[0x51 r r]<–read back values 210 I2C start CONDITION 220 I2C WRITE: 0x51 got ACK: YES 230 I2C READ: 0x40<–pot0 value 230 I2C READ: 0x00<–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: 0x50 got ACK: YES 220 I2C WRITE: 0xAF got ACK: YES<–dual update command 220 I2C WRITE: 0x20 got ACK: YES<–value to set 240 I2C stop CONDITION I2C>[0x51 r r]<–read back values 210 I2C start CONDITION 220 I2C WRITE: 0x51 got ACK: YES 230 I2C READ: 0x20<–pot0 value 230 I2C READ: 0x20<–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 beneficial command for stereo audio volume control where bothالقنوات لها نفس القيمة والتغيير في وقت واحد.

هل هناك أي رقائق أو مكونات تريد منا أن تغطيها في مشاركات أجزاء المستقبل؟