1 Attachment(s)
DS1803 digital pot - can't get it working!
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;Attachment 5308
Code:
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
Re: DS1803 digital pot - can't get it working!
The 2nd word, "command" should be 101010xx where xx=which pot.
Why"IF B0 = 255 THEN LOOP"?
Quote:
Originally Posted by
orjon1
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;
Attachment 5308
Code:
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
Re: DS1803 digital pot - can't get it working!
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!
Re: DS1803 digital pot - can't get it working!
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.