Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Implementing I2C or SPI with Pxi6508 in Labview

Hello,

I would like to know if I2C or SPI with the PXI-6508 can be implemented in LabView.

Thanks
Message 1 of 36
(12,228 Views)

Hi Migueles-

The communication might be rather slow because the 6508 provides software-timed operation, but there's no reason that this shouldn't work.  I mocked up an SPI example a while back that might help you get started (see attachment).

Hopefully this helps-

Message Edited by Tom W [DE] on 07-23-2007 10:08 AM

Tom W
National Instruments
0 Kudos
Message 2 of 36
(12,226 Views)

Hi Tom W:

         I am really interested in your 6508 spi emulation vi.  Howerer your vi version(8.2) is later than my Labview version (8.0). So I could not open it. Do you have some other similar examples written in 8.0 Labview version?  I  have a PCI-6221 and I want to control a digital potentiometer with 3-wire SPI serial interface. I  just begin to learn Labview and I don' know how to do this.  Thank you so much for your help. 

0 Kudos
Message 3 of 36
(12,009 Views)

Hi ILLGG-

Here's the same VI, saved for LabVIEW 8.0.

Tom W
National Instruments
0 Kudos
Message 4 of 36
(12,001 Views)

Hi Tom W,

    Thank you for your 8.0 version of the example.  I am thinking of modify your code for my project. 

 I have the digital potentiometer AD 5290. I want to control it using Labview via PCI 6221(DAQ). It contains 3-wire digital interface

CS:Chip select input ,active low.

CLK: serial clock input . Positive edge triggered.

 SDI: 8-bit Serial data input. Shift in one bit at a time on positive clock CLK edges. MSB loaded first.

Can I have some advice on how to implement this? Thank you so much!

Message 5 of 36
(11,968 Views)

Hi ILLGG-

The example should almost work as shown.  First, the "Data Out" line refers to the line you will use to shift data out to your peripheral.  In order to clock on the rising edge, you'll want to change the "SPIClk Init
Condition" to False so that it will toggle high->low with each iteration of the loop.  The only other thing you'll need to add is the CS line- I would implement this by performing a single point write to a digital line before entering the loop and then another single point write to clear the CS line.

I have attached my VI, modified to include a single point CS update task.  Give this a try and let us know if you have other questions.

Thanks-



Message Edited by Tom W [DE] on 11-09-2007 09:45 AM
Tom W
National Instruments
0 Kudos
Message 6 of 36
(11,955 Views)

Hi Tom W:

    Thank you for the help.  i have a question about your vi: what is the :"data in line" for?

thank you.

0 Kudos
Message 7 of 36
(11,945 Views)

Hi ILLGG-

That line is for the case where you might need to perform a bi-directional SPI operation.  In other words, where you clock in one bit to your peripheral on the rising edge of the clock and then clock out one bit on the falling edge.  In the case where you need to clock in your entire input sequence before reading a response (for example, if you're clocking an address or command into the peripheral) you would actually need to seperate the two operations into two seperate loops.  If you don't need that functionality you can simply remove it from the example.

Tom W
National Instruments
0 Kudos
Message 8 of 36
(11,943 Views)
One more question: why did you set 5 milliseconds  delay in the loop?
0 Kudos
Message 9 of 36
(11,942 Views)
Hi ILLGG-
 
Here's another question- why not? Are you in a hurry or something? Smiley Very Happy
 
Joking, of course- I added that delay for the case where you might need to adjust the high time of your clock (of course within software-timed limits) to provide some data setup time between clock pulses.
Tom W
National Instruments
0 Kudos
Message 10 of 36
(11,937 Views)