LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I2C implementation using Labview.

Hello ,
 
I am trying to communicate to my IC using Labview. The board on which the IC is uses I2C interface. currently it is connected to the PC using a parallel port dongle and there is GUI which does this, I want to make a I2C interface so that I can communicate to the IC directly using Labview. Is it possible that I use the parallel port to pass the signal directly to the IC, If yes how do i do that? Or is there any other way I can go about this issue.
 
Any help is appreciated.
Thanks
RKD
Message 1 of 7
(18,328 Views)
Do you actually have an I2C interface board, or are you directly connected to the parallel port? Where did you get this GUI?

If you have an interface board you should first check with the manufacturer of the I2C interface board that you have to see if they have LabVIEW drivers or a DLL (for Windows). Chances are they will at least have a DLL as that is what the GUI is probably using.

If you're directly connected you will need to write your own code to basically do bit-banging to set the SCL and SDL lines. You need to remember that for the parallel port you have to write out an entire port's value, which is 8 bits. To do this you can use either the "In Port" and "Out Port" functions or VISA. For the "In Port" and "Out Port" there's an example that ships with LabVIEW. Open LabVIEW and go to Help->Find Examples. Switch to the "search" tab and enter "parallel" in the search box. Open the "Parallel Port Read and Write" example. For VISA take a look a this example: http://zone.ni.com/devzone/cda/epd/p/id/4213.

Message 2 of 7
(18,317 Views)

Thanks sm,

Well i dont have a direct I2C interface board, its a simple PCB on which the IC is mounted. this IC uses I2C. so on the pcb there is a dongle that is connected to the parallel port of the PC. We have gui which is developed in-house which is used to prog, this part and communicate with it. I would like to know what kind of bit-banging i need to do in order to communicate with the IC, I am going through the examples that you have suggested, any lead on this one will be great and helpful.

Looking forward for help.

Thanks a bunch.

Regards

RKD

0 Kudos
Message 3 of 7
(18,289 Views)
The kind of "bit-banging" you need is defined in the Philips I2C spec. You can get a basic overview of the actual protocol from Wikipedia, or you can get the full spec from the Philips NXP site (at the very bottom there's a link to the PDF). Since the GUI developed in-house you should be able to see the code to see what it does. It should basically just be toggling two of the parallel port lines based on the I2C protocol.

Usually when you buy an I2C interface you get drivers for it that you can use from LabVIEW. Some companies provide LabVIEW drivers directly. Examples: Cal-Bay Systems (pretty popular as it's parallel port), Total Phase, Telos, MCC (Micro Computer Control Corporation) and NI. I've used the Cal-Bay interface and the Total Phase Aardvark so I know they work. The Cal-Bay approach is to basically do bit-banging of the parallel port so it's dependent on software timing. There's an open source interface that was designed for Linux, though there's a port of the library to Windows. Have no idea whether it will work with LabVIEW. As for other sources, you can take a look at the code that was posted in reply #4 of this post. The device being talked to is a SPI device, but the premise is similar. It's using the parallel port to toggle lines to generate the protocol. This 2-year old post refers to an interface with LabVIEW drivers that user KC created. Don't know if it's still available.
Message 4 of 7
(18,268 Views)

Hi there,

 

I am trying to use  my cRIO for I2C communication.

I am following the NI document 'Implementing I2C Comunication Protocol in LabView FPGA'.

I am using two DIO lines from a 9401 card to connect with the SDA and SCL lines of the I2C bus in the device.

The first thing is: How can I configure the 'Digital Enable' function? Each DIO line has only two state: read/write (input/output). I don't know if there is a 'Digital enable' state for this card.

The second thing is: did anyone succeed by following that document for I2C communication?

Users pointed out two obvious error in the code. Other than that, is it working?

Thanks

Z

0 Kudos
Message 5 of 7
(14,513 Views)

Hey zzyin,

 

It looks like that option is not available for the 9401. However, I simulated a 9403 and it gave me that option, below:

property.png

 

Digital enable allows you to write data (very slightly) faster, because you can set the output as enabled and then write data--an IO node will always make sure the output is enabled first.

 

I've found a few other bits of sample code which might help you:

http://decibel.ni.com/content/docs/DOC-1151

http://zone.ni.com/devzone/cda/epd/p/id/4063

http://zone.ni.com/devzone/cda/epd/p/id/3975

This document may also help:

http://zone.ni.com/devzone/cda/tut/p/id/9115

 

I hope that explains the purpose and helps you get around the digital enable items in that tutorial.

 

Thanks

0 Kudos
Message 6 of 7
(14,475 Views)

Hey, looks like I was somewhat wrong. Because it is the 9401, you have to enable/disable entire nibbles, like so:

correction.png

Apparently (according to the LabVIEW help), using an I/O node does not automatically enable or disable output. This method node, configured for the 9401 (pop down a property node, right click, select item>>fpga>>9401) is how you enable or disable a nibble.

Message 7 of 7
(14,470 Views)