reading 12 bit adc on i2c

klaasje

Member
Hello all.

I have made a pcb with a 40x2 picaxe and 3 12 bit adc to i2c converters ADS1015IDGST. They are hardware set op adres 72, 73, and 74. I tried to read fom them but i don't no how and i can't find it in the manual.
Does anyone now how to read them? Example would be very nice.

Thanks!
 

hippy

Ex-Staff (retired)
The datasheet appears to be here - http://www.farnell.com/datasheets/1788973.pdf

According to page 14 the I2C Device Address is dependant on what the ADDR pin connects to, is 10010xx in 7-bit format which would be %10010xx0 for a PICAXE HI2CSETUP command; $90, $92, $94 or $96 -

HI2CSETUP I2CMASTER, $90, I2CSLOW, I2CBYTE

If you can post your circuit what the exact value would be can be determined.

Configuring and reading from the device is described from page 14 to 19. I am not familiar with the device or the exact mechanism it uses but someone may be able to figure it out. It looks like access is done through a pointer register which can be treated as if a byte address so it seems that the following should work -

to write ...

HI2COUT address, ( msbToWrite , lsbToWrite )

to read...

HI2COUT ( address ) : HI2CIN ( msbReadVariable , lsbReadVariable )

address of 0 = Conversion register, 1 = Config register, 2 = Lo_thresh register, 3 = Hi_thresh register.
 

klaasje

Member
Hi hippy,

Thank you for the fast response.

my test code is below.

ADDR pin is connected to vdd so %1001001

i get a respond of 131 in b19 and 133 in b18.
This is not responding on anolog change, so it could not be wright.
Also there are 4 channels to read.

#picaxe 40x2

HI2CSETUP I2CMASTER, $92, I2CSLOW, I2CBYTE
pause 200
do
HI2COUT (%1001001) : HI2CIN ( b19 , b18 )
debug
pause 500
loop


Did i not understand it?
 

hippy

Ex-Staff (retired)
HI2COUT (%1001001) : HI2CIN ( b19 , b18 )

The HI2COUT value should be the address 0-3, 0 = Conversion, so I guess that should be -

HI2COUT (0) : HI2CIN ( b19 , b18 )
 

klaasje

Member
HI2COUT (%1001001) : HI2CIN ( b19 , b18 )

The HI2COUT value should be the address 0-3, 0 = Conversion, so I guess that should be -

HI2COUT (0) : HI2CIN ( b19 , b18 )

Oke thanks,

But i have 3 parts of that on the i2c bus with adress 72, 73 and 74. How do i select the wright one then?
 

hippy

Ex-Staff (retired)
Probably the best way to start is ...

Code:
Do
  HI2CSETUP I2CMASTER, $92, I2CSLOW, I2CBYTE : HI2COUT (0) : HI2CIN ( b1 , b0 ) ; w0
  HI2CSETUP I2CMASTER, $94, I2CSLOW, I2CBYTE : HI2COUT (0) : HI2CIN ( b3 , b2 ) ; w1
  HI2CSETUP I2CMASTER, $96, I2CSLOW, I2CBYTE : HI2COUT (0) : HI2CIN ( b5 , b4 ) ; w2
  Debug
  Pause 500
Loop
That should put the three readings in w0, w1 and w2
 

klaasje

Member
Probably the best way to start is ...

Code:
Do
  HI2CSETUP I2CMASTER, $92, I2CSLOW, I2CBYTE : HI2COUT (0) : HI2CIN ( b1 , b0 ) ; w0
  HI2CSETUP I2CMASTER, $94, I2CSLOW, I2CBYTE : HI2COUT (0) : HI2CIN ( b3 , b2 ) ; w1
  HI2CSETUP I2CMASTER, $96, I2CSLOW, I2CBYTE : HI2COUT (0) : HI2CIN ( b5 , b4 ) ; w2
  Debug
  Pause 500
Loop
That should put the three readings in w0, w1 and w2
Thanks.

I wil try that and let you know
 
Top