From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
01-08-2021 10:27 PM
Hello Friends,
It is my first time to use USB 8451, a I2C device. I am just playing around to write data to a slave I2C device using the I2C basic write vi, which is found in program samples and attached here below.
I would like to write a hexadecimal value of "2801" to a register (address is "1A") of the slave I2C device (device address is "2A"). The write sequence shown in the device datasheet is as below. Can someone let me know how to combine address "1A" and data "2801" together for inputting in the front panel's EEPROM data address?
There is a note in block diagram, I paste it here below, but I do not know how to make it work
----------------------------------------------
The format for many EEPROMs is:
a) The first two bytes or the first byte are the address to write to.
Check the correct endianess for your device to sent in big endian format (MSB first) or little endian format (LSB first).
b) The next x bytes sent to the device are the bytes that are to written to the EEPROM. For this example, we are creating an array of x sequential bytes (0, 1, ...) up to the number of bytes to write. Many EEPROMs, when they exceed the page size will simply begin to
write at the beginning of the page boundary, thus the write must be split into page aligned writes.
-------------------
Thanks,
Gu
Solved! Go to Solution.
01-09-2021 10:38 AM - edited 01-09-2021 10:39 AM
For writing a 16-bit value to a register, you use Split Number to break up the U16 value into 2 U8 values (MSB and LSB). You then use Build Array to combine the register address, MSB, and LSB into an array that you can then wire up to the I2C Write function.
NOTE: Notice the radix is visible for all of those numerics and they are set to Hexidecimal display.
01-09-2021 01:04 PM
Hi Crossrulz,
Thank you very much for your effort.
I modified the write vi according to your suggestion and added a read vi to read the written value back to see if the written value is correct. The read value shows 0,0 rather than 28,01.
The read vi is also found from the LabVIEW program samples, which I verified to work properly.
Both write & read VIs are attached here below.
Could I trouble you to check anything wrong?
Thanks,
Gu
01-09-2021 08:47 PM - edited 01-09-2021 08:48 PM
The problem I have with many NI examples is they try to do too much. Simplification often helps a lot more here.
01-09-2021 09:41 PM
Hi Crossrulz,
Thanks. It worked. I think that the Write VI of the sample program should have had writing a register with a value rather than just a register alone without a value.
In addition, I have searched on the community forum about the USB 8451 I2C, and found an old post, saying the maximum speed of reading data was 400 samples per second via a loop. However, the 8451 has a clock speed range of 32-250 kbit/s.
https://forums.ni.com/t5/LabVIEW/8451-I2C-Loop-Running-Slowly-When-Reading-Data/td-p/2130782
My question: Does the USB 8451 really a hardware-timed device?
Regards,
Gu
01-10-2021 08:23 AM
The protocol part is hardware timed. But when those messages are performed is software timed when using the I2C Basic API. You could try using the I2C Scripting API, but I have no experience using it.