PDA

View Full Version : DS1803 digital pot - can't get it working!



orjon1
- 28th March 2011, 21:26
I'm having problems with the DS1803 010 (10Kohm) digital pot.

This is simply a test circuit - ultimately I'd like to use the device to alter the brightness of a LED. Problem is, the simple circuit doesn't work. I have a feeling it may be an address issue. Any help from those more experienced would be greatly appreciated!

code and circuit diagram;5308


Button1 var portb.7 ' low is pressed
led1 var portb.6
SDA VAR portc.2
SCL VAR portc.3

B0 var word

LOOP:

'***************** VARY POT OVER RANGE **********************
FOR B0 = 1 TO 255
I2CWRITE SDA, SCL, %01010000, %10101111, [B0]
PAUSE 10 ' Wait =>10 mS for write to complete
IF B0 = 255 THEN LOOP
NEXT B0

'************************************************* ***********
GOTO LOOP

end

ronsimpson
- 28th March 2011, 22:03
The 2nd word, "command" should be 101010xx where xx=which pot.
Why"IF B0 = 255 THEN LOOP"?



I'm having problems with the DS1803 010 (10Kohm) digital pot.

This is simply a test circuit - ultimately I'd like to use the device to alter the brightness of a LED. Problem is, the simple circuit doesn't work. I have a feeling it may be an address issue. Any help from those more experienced would be greatly appreciated!

code and circuit diagram;5308


Button1 var portb.7 ' low is pressed
led1 var portb.6
SDA VAR portc.2
SCL VAR portc.3

B0 var word

LOOP:

'***************** VARY POT OVER RANGE **********************
FOR B0 = 1 TO 255
I2CWRITE SDA, SCL, %01010000, %10101111, [B0]
PAUSE 10 ' Wait =>10 mS for write to complete
IF B0 = 255 THEN LOOP
NEXT B0

'************************************************* ***********
GOTO LOOP

end

orjon1
- 29th March 2011, 08:09
Hi Ron,

Thanks - that line you point out is indeed unnecessary.

However, the 2nd command word, which I have at "%10101111" is the correct command to write to both pots according to the datasheet.

Very frustrating!

orjon1
- 29th March 2011, 09:06
Hi Ron,

Solved the problem - the value being written was a variable of type "word", where it needs to be a byte.

Thanks for your assistance.
-orjon.