LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I2C

Solved!
Go to solution
Highlighted

Hi,

I have an electronic module which communicates with a display module using I2C. I need to disconnect the display module and display the same stuff (what it used to display on the display module) , on a PC monitor instead.Got USB 8451 for this purpose.

 

8451 is getting recognized by labview on USB port.As a starting step , I am just using the same program in Labview examples for I2C with the name "Digital line readI2C script.vi." I select the USB port (only one displayed in the list),I/O voltage level as default 3.3V and start the program.Whether my module is ON or OFF , and line number anything from 1 to 7, it gives me same result without any error , i.e. the "value" is always True(ON)

 

I2C is completely new field for me and i might be doing something totally wrong. Just want some hint about what I am doing wrong here, and the pathway to get the things done.

0 Kudos
Message 1 of 7
(361 Views)
Highlighted

At the beginning of the year, someone handed me an NI USB-8451 and said "We need to communicate with a SPI Chip -- figure it out!".  Now, SPI isn't I²C, but the USB-8451 does both, and there are similarities in the software, some maybe my experience will help.

 

Like I²C, SPI has a Basic Programming Model and a Scripting Programming Model.  The one piece of "free advice" I was given was to stick with the Basic Programming Model.  I had three types of SPI chip to program -- an A/D converter, a D/A converter, and a 16-Bit Digital Register, able to program the bits as Readable or Writable, as needed.  I wrote a hand-full of sub-VIs that did the following:

  • A VIG that looked for the 8451 by enumerating the VISA devices, expecting to find exactly 1, and returning it as the presumed SPI Master.
  • A second VIG that used the SPI Master VIG, did the low-level configuration for SPI that matched what my Chips require (I don't really know what these mean, but they include such things as Clock Rate and Clock Polarity), and returns both the SPI Device Reference (from the first VIG) and the SPI Configuration Reference (from this VI).
  • A Setup function that uses the SPI References from the second VIG to write the Setup Bytes to the SPI Chip.
  • A Write function that uses the SPI References to write "Data" Bytes to the SPI Chip.
  • A Read function that uses the SPI References to read data Bytes from the SPI Chip.

I also had to learn that when you write data to a SPI chip, it sends you back data on another line.  If you are doing a real "Write" command, you ignore those bits, but if you are trying to do a Read, you get them by doing a "dummy Write" to get them "pushed back" to you.

 

So with a handful of my custom VIs to "hide the details" for the various Chips I was using, it was fairly easy to get SPI to work.

 

I recommend you examine the Basic Programming Model on pages 5-1 and 5-2 of the 845x Manual, and write your own "wrapper" VIs for the basic I²C functions using Property Nodes (for Configure), I2C Write, I2C Read, and I2C Write Read VIs that come with the 845x Software.

 

Bob Schor

 

 

0 Kudos
Message 2 of 7
(326 Views)
Highlighted

@maccapple wrote:

I have an electronic module which communicates with a display module using I2C. I need to disconnect the display module and display the same stuff (what it used to display on the display module) , on a PC monitor instead.Got USB 8451 for this purpose.


Is the display module the I2C master?  I doubt it is.  But you need to give us model numbers or documentation to verify.  So if my assumption is correct, you will need to act as an I2C slave.  You cannot use an USB-8451 to act as an I2C slave; you will need to get an USB-8452.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 3 of 7
(231 Views)
Highlighted

Sorry  I did not clarify it properly before.

Yes the display module is a I2C master. Confirmed with our R and D who designed it.Also, the communication is in both directions. The display module not only displays information but also has buttons which controls the electronic module.

0 Kudos
Message 4 of 7
(193 Views)
Highlighted

@maccapple wrote:

8451 is getting recognized by labview on USB port.As a starting step , I am just using the same program in Labview examples for I2C with the name "Digital line readI2C script.vi." I select the USB port (only one displayed in the list),I/O voltage level as default 3.3V and start the program.Whether my module is ON or OFF , and line number anything from 1 to 7, it gives me same result without any error , i.e. the "value" is always True(ON)


Well, your VI isn't even doing I2C.  It is just reading from one of the DIO lines on the board (there are 8, labeled P0.0 through P0.7).  If you don't have those wired up, then you will just read a 1 (on) due to the built-in pull-up resistor.

 

Something like this is what you should do for a simple read.  If you have to do a register read from a device, then you need to use the Write-Read function instead with some additional code to build up the request bytes.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Download All
0 Kudos
Message 5 of 7
(185 Views)
Highlighted

Thanks.

I'll check up if I can find any issue with the data from the hardware side.

0 Kudos
Message 6 of 7
(180 Views)
Highlighted
Solution
Accepted by topic author maccapple

Thanks.

I'll check up if I can find any issue with the data from the hardware side.

0 Kudos
Message 7 of 7
(170 Views)