LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-845X I2C communication example

Solved!
Go to solution

Wondering if anyone would be able to give a sample on how a read/write message is built up for this type of I2C communicaiton.

 

Im trying to use the NI USB-8451 I2C host adaptor to talk to a LTC4306 multiplexer.  I will be talking to other devices ( temp sensors, SE98ATP) through the multiplexer, but thought I would start with trying to talk with the first device in the path (the MUX).

 

Looking at the data sheet I think I may need to use the I2C scripting commands to build my read and write packages?  What I really dont get is how to build up the message.  My slave address is (1000 000) [7 bits] so Read/Write is 0x80 / 0x81 respectively.  "Register"[8bits] and "DataByte"[8bits] would be my inputs in both the read and write cases and I would choose them based on the data sheet and what operation I need to perform.  But how to build up an I2C message as I show in the picture below completely eludes me..

 

For refrence

 - Data sheet = http://pdf1.alldatasheet.com/datasheet-pdf/view/265255/LINER/LTC4306.html

 - I'm using LV2015

Protocol (see pic below)

4306 read write protocol.png

 

0 Kudos
Message 1 of 8
(8,639 Views)
Solution
Accepted by topic author Tim30

Been doing way too much I2C lately...

 

First of all, your address needs shifted to the right 1 bit.  So your address is actually 0x40.  Secondly, the USB-845X takes care of a lot of the lower lever stuff for you, including writing bytes without the need for another Start bit (the Write Byte Protocol).  All you have to do is tell the I2C Write to write the register and then the data byte.  For the Read, use the I2C Write Read, which will write the register and then get the slave to send the register data.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 8
(8,622 Views)

Fantastic!  Thanks.  It would have taken me forever to realize the address.  Found a blurb about it in the help for the address property node after your reply.

 

In-case anyone ever wants it, this is the same thing as what Crossrulz submitted, with the addition of my code to deal with the temp sensor I used SE98A, and created with LV2015. 

 

0 Kudos
Message 3 of 8
(8,571 Views)

Why did the address have to be shifted by 1?  The reason I'm asking is because I'm trying to do the same (read) from register 0x02 of the component LTC4151 which has device address of 0xDE but I'm having difficulties doing so.  

0 Kudos
Message 4 of 8
(7,955 Views)

@Eth wrote:

Why did the address have to be shifted by 1?


The address you tell the API is not to include the Read/Write bit.  That bit is added behind the scenes for you based on whether you are doing a read or write.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 8
(7,932 Views)

Hi,

 

I need I2C read  I2C Write block for NI_8452 module. I cannot open your I2Ccomm.vi because I use LabVIEW 2014 and yours is LV2015.

I would like to see your block diagram.

Thanks

 

0 Kudos
Message 6 of 8
(5,809 Views)

@minhdang_doan wrote:

I need I2C read  I2C Write block for NI_8452 module. I cannot open your I2Ccomm.vi because I use LabVIEW 2014 and yours is LV2015.

I would like to see your block diagram.

 


Then give this one a try.  It is extremely similar to the snippet I gave earlier, just with the specifics the OP added for the device they were interfacing with.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 8
(5,796 Views)

im also working on usb 8452 with PN532 RFID reader, i need to reach RFIC reading through I2C interface, slave address is the (0x48) and the according to the EEPROM address i couldnt foind that kind of address in PN532 datasheet, but in I2C section , I2CDAT address was the (D9h) i try with that address and still getting output as x80,x80,x80 ........ ( General I2C Read Script)

0 Kudos
Message 8 of 8
(1,612 Views)