LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI USB-8451 I2C read error '301742'

Hello, I'm using a NI USB-8451 to communicate with a TI battery gauge BQ34z100-G1 via the I2C interface. I'm new to LabVIEW as well as I2C interface so I'm stuck at a basic read operation. Using the example finder in LV, I looked up an I2C basic read operation and am using the same block diagram with a few edits (I've attached images of front panel and block diagram). For entering the addresses of registers to be read, I referred to the gauge's I2C communication document (first example in the document). However, I'm getting an error 301742:

 

The slave did not acknowledge an address+direction byte transmitted by the I2C master.  If you are using ACK polling, consider increasing the timeout. Other reasons include the incorrect address set in the I2C configuration or the incorrect use of the 7-bit address. When entering an address to access a 7-bit device, do not include the direction bit. The NI-845x Basic I2C API internally sets the direction bit to the correct value, depending on the function (write or read). If your datasheet specifies the 7-bit device address as a byte, discard the direction bit (bit 0) and right-shift the byte value by one to create the 7-bit address

 

How do I resolve this error?

 

Also, if there are multiple (or even one) devices connected to the 8451, what VI do I use to address them so that I'll receive an ACK? (In this block diagram, I've used the I2C basic read, which I feel might be wrong)

 

 

Battery Gauge Register AddressBattery Gauge Register AddressBlock DiagramBlock DiagramBattery gauge informationBattery gauge informationFront panelFront panelI2C basic read on NI websiteI2C basic read on NI website

0 Kudos
Message 1 of 6
(3,138 Views)

Subsequently, I modified the program using I2C scripting API for general read function. I've posted the front panel and block diagram below. I've added the I2C address for the battery gauge as well as the specific register address, as specified in the gauge technical document. However, the same error 301742 persists.

 

P.S. The device address is missing in the front panel, but that is because I captured the screenshot after disconnecting the device. It was connected when I ran LV.

 

Block DiagramBlock DiagramFront PanelFront PanelThe text states that, we have to address the gauge first and the specific register later.The text states that, we have to address the gauge first and the specific register later.

0 Kudos
Message 2 of 6
(3,116 Views)

Sorry for the repetitive corrections. I had entered the device address value in the front panel image as 'AB', which is applicable for a general read. So the 'AA' in there is actually 'AB'

0 Kudos
Message 3 of 6
(3,113 Views)

Hello,

Based on the error description, and the example I think it is likely that the error is generated because you are entering an incorrect address or there might be an "incorrect use of the 7-bit address", but I am not sure.

Could you clarify where is the error generated? What VI in your VI gives out the error?

Also, could you attach your actual VI?

 

-A.V.

 

0 Kudos
Message 4 of 6
(3,093 Views)

Hey, thanks for the reply!

 

I rechecked the address values, they were correct, but I needed to discard the direction bit and right shift to make it a 7-bit address as specified in the error: "The NI-845x Basic I2C API internally sets the direction bit to the correct value, depending on the function (write or read). If your datasheet specifies the 7-bit device address as a byte, discard the direction bit (bit 0) and right-shift the byte value by one to create the 7-bit address."

The VI is reading the register now, but the readings keep changing every time I run the VI. I'm reading the voltage which is being supplied by a constant DC voltage power supply at 4V, whereas the voltage read by LabVIEW is varying between 1 to 4 V. Sometimes, it also shows the error 301742 again. I tried using ACK polling for 2000 and 5000 ms, but I'm still having the same problem.

I checked the voltage with a DMM and also with TI's I2C interface (which is specially intended for TI's battery gauge), and both of them are reading a constant 4 V. Where could I be making a mistake? I'll attach the VI here too. Here are the VI front panel parameters: Device address: 55, Register Address: 8, Clock frequency: 100 kHz, No. of bytes to be read: 2.

0 Kudos
Message 5 of 6
(3,083 Views)

The error is being generated in the 'run script' or 'extract data' VIs in my VI.

0 Kudos
Message 6 of 6
(3,082 Views)