Cannot communicate with I2C DS3502 Digital Pot

tecnition_ted

New Member
Hi All, I am having problems getting any settings or reading from a DS3502. I have tried a simple test code to just read the pot wiper location to try and communicate with the device without success. All is ok if I use an Arduino so the picaxe should work ok.

Code:
setup:
hi2csetup i2cmaster,$50,i2cfast,i2cbyte

main:
i2cslave 0x50, i2cfast, i2cbyte
readi2c 0x00,(b0)
debug
PAUSE 1000
Goto main
Data sheet is here:

It looks simple, two registers 00h for the wiper setting and 02h for the mode.
I have set the address of the device to 50h by grounding both A1 and A2
I have tried 400khz and 100khz


If I can read the device then I should be able to send a write to set the wiper so far no luck reading with a Picaxe.

Can anyone see what I am doing wrong?
 
Last edited:

inglewoodpete

Senior Member
Hi All, I am having problems getting any settings or reading from a DS3502. I have tried a simple test code to just read the pot wiper location to try and communicate with the device without success. All is ok if I use an Arduino so the picaxe should work ok.

Code:
setup:
hi2csetup i2cmaster,$50,i2cfast,i2cbyte

main:
i2cslave 0x50, i2cfast, i2cbyte
readi2c 0x00,(b0)
debug
PAUSE 1000
Goto main
Data sheet is here:

It looks simple, two registers 00h for the wiper setting and 02h for the mode.
I have set the address of the device to 50h by grounding both A1 and A2
I have tried 400khz and 100khz


If I can read the device then I should be able to send a write to set the wiper so far no luck reading with a Picaxe.

Can anyone see what I am doing wrong?
Remove the line that says "i2cslave", it is outdated and no longer used: all configuration is done with the hi2cSetup command..

Also, just a suggestion, start with running the bus in slow mode:
Code:
hi2cSetup i2cMaster, $50, i2cSlow, i2cByte
You can speed it up once you have both hardware and software working.
 

Technical

Technical Support
Staff member
This sounds more physical than software, have you continuity checked pin to pin from chip to chip and checked both sda and scl have a pull up resistor? These pots do work fine.
 

tecnition_ted

New Member
Thank you for all your suggestions so I will answer each.

Thank you Technical there is a 4.7 k pull up resister on the SCL and SDA lines.

Inglewoodpete. Thank you for the information about i2slave being outdated I copied the code from another project that read and wrote to a OLE screen and gas gauge chip, in that project the code worked without issue. As mentioned in my thread I have tried running the bus at slow and fast to see if there was any difference there was not.

Also I have used the exact same device on an Adriano and it works fine.

Any more suggestions would be greatly appreciated
 

inglewoodpete

Senior Member
If your circuit and code is as you say then it should be working. You say it's not, so there must be something wrong.

What is the distance (length of wires) between your master and slave? Standard i2c is limited to not much more than a metre.
 

tecnition_ted

New Member
Hi Inglewoodpete, My lines are short less than 10cm.
I am going to attach the I2c fuel gauge circuit to the picaxe circuit to see if it reads ok then swap over to the pot. I will also solder another pot to an adapter just in case there is any problems with the chip but it does work when plugged into an Adriano circuit.
I'll report back and see what happens
 

Goeytex

Senior Member
Here is how I might approach this ...

1) Double check that A0,A1 are actually grounded. Measure continuity between A0/A1 (on the device) and a known good ground point.

2) Try other possible addresses for the device. Wont hurt to try ...$52, $54, $56. If one of these works then there is a bad ground on one or both of the Address Pins (A0/A1)

3) Verify Pullups. When Idle, both the SCL and SDA lines should be high. Measure with a meter, both at Picaxe Pins and at the device. Make sure the pullups are not accidentally tied to ground. Make sure resistors are 4.7K (Yellow Purple Red) and not 47K.

4) Make sure you are using the correct Picaxe Pins for SCL and SDA. (Did not say what Picaxe Chip is being used?)

5) Verify all grounds are good and that all are common. Use a meter.

If all these fail to correct the problem ....

1) Post the complete code . All of it from top to bottom.
2) Post a schematic showing all connections
3) Take a clear close-up photo of your setup/breadboard, etc, and post it here
 

tecnition_ted

New Member
Hi Goeytex. Thank you for your sugestions.

just to answer a few points. There is two engineers looking at the circuit at the moment nether can understand why there is no read from the pot.
I am changing the pot and the adapter board just in case there is an issue but all pins ring through and there is no shorts.

1 This was the fist thing we checked. I have also tried changing the pin settings and the other addresses in the datasheet.
2 see note 1
3 both pull up resisters are correct and are pulling the sda and scl lines up, if I attach a I2c gas gauge it can be read
The picaxe we are using is a 20M2 and it communicates with a i2c gas gauge without trouble
5 all grounds are good supply is good to both picaxe and pot and there is a decupling capacitor across the ic supply close to the 20M2

on your other points
all the code is shown, it is simply a can you read the pot test nothing more at this time

I will change the pot and post the results unless I'm missing something in the data sheet then the rea should be simple.
 

tecnition_ted

New Member
O just another note the test board was built on an anti static bench and I am using a tested wrist strap so static shouldn't be an issue.
 

tecnition_ted

New Member
We Have a working pot!
It appears that there could be two possibility's
1. the first pot was broken. (Ill fit the old pot and check.)
2. the time between read and write I had set at 10ms when read the pot replied 255 when there was a delay added between write and read of 20 ms the correct answer came back.

Test code (with old i2slave command sill present)

Code:
setup:
hi2csetup i2cmaster,$50,i2cslow,i2cbyte

main:
i2cslave 0x50, i2cslow, i2cbyte
hi2cout 0x00,(0x00)
pause 20
readi2c 0x00,(b0)
b2 = 2
debug
PAUSE 1000
hi2cout 0x00,(0x7f)
pause 20
readi2c 0x00,(b0)
b2 = 3
debug
PAUSE 1000
Goto main
[\code]
 
Top