LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

usb-8451

Solved!
Go to solution

Hi,

I am trying to communicate with a gyro using NI USB-8451, I used the "General I2c Read.vi" example to try to communicate to the device but i get different errors every time I run the program, I have used the gyro with my Arduino board and it works perfectly, Attached i have the data sheet and the sample Arduino code for the gyro. Any assistance would be greatly appreciated. 

Download All
Message 1 of 13
(7,641 Views)

Here is on of the errors for example:

Possible reason(s):

NI-845x: The I2C master lost arbitration and failed to seize the bus during transmission of an address+direction byte.

0 Kudos
Message 2 of 13
(7,640 Views)

here is another error:

Possible reason(s):

NI-845x: The slave did not acknowledge an address+direction byte transmitted by the I2C master. 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 specfies 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.

0 Kudos
Message 3 of 13
(7,639 Views)

1. Do you have pull-ups on the I2C bus?

2. What address are you using for the 845x I2C slave address? I believe it should be 0x34 (011 0100). When the NI-845x API does a write, it will append the write bit (1) to the end to create the address of 0x69 (what your sample code is using).

Message 4 of 13
(7,631 Views)

No i dont have any pullup resistors and the address i am using is 0x69, since that is the address that works for me when using my other microcontroller ( Arduino).

Do i need physical pullups on the the NI module or it is internally taken care of?

0 Kudos
Message 5 of 13
(7,627 Views)

Oh i just realized what you said, i thought labview will do the write/read bit internally!!

0 Kudos
Message 6 of 13
(7,626 Views)

1) The USB-8451 does not have any internal pull-ups (the USB-8452 does, but is currently only available in OEM format, which means w/o an enclosure). You need to have external pull-ups on the both the SDA and SCL lines to VCC since I2C is an open-drain bus and cannot drive high. Your demo board may have the pull-ups, but typically they are external. Internally devices on the I2C bus can only go to two states -> Grounded or tristated. They cannot drive high and unless you have pull-ups, the bus will be floating, which rarely works well. 🙂

 

2) I think you got the answer already, but different APIs use different things for the I2C address. The official I2C address is 7-bits (0x34, in your case). The transmission across the bus is 8-bits with a Read/Write bit (0 = read, 1 = write) send immediately after the 7-bit address. Some data sheets describe the address as 7-bits, whereas other describe it as an 8-bit read address/8-bit write address. In the NI-845x API, we support a single API for read and write, so we require the 7-bit base address and handle the read/write bit for you. It appears that the Arduino may take the full 8-bit address which you will have to handle separately.

 

 

Message 7 of 13
(7,621 Views)

Thanks for you helpful explanation. I am going tor try that righ now. So do you think two 4kohm resistors from VCC to SDA and SCL is fine?

0 Kudos
Message 8 of 13
(7,619 Views)
Solution
Accepted by topic author Merd

4K should be good. For moderate baud rates you can probably get by with somewhere between 3k-10k. I think I use 4.7k often since I have them, but it really isn't too picky. The Arduino (I think) has some weak pull-ups (20k-40k?) which probably explains why you had some communication, but I would be surprised if it was robust as the waveforms are probably not going to be very pretty. 

 

This has some pretty good pictures of different I2C pullups and the effect on the waveform: http://dsscircuits.com/articles/effects-of-varying-i2c-pull-up-resistors.html

Message 9 of 13
(7,616 Views)

Thank you very much, pull up resistors did the job, but just for the reference the 7bit address (0x69) worked as oppose to 0x34, i think 0x34 is 6bit isn't it?

anyways my problem is solved thanks to you

0 Kudos
Message 10 of 13
(7,611 Views)