Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

PFI

I have an NI M series DAQ module. I need to configure the PFI lines (port 1 & port 2, each 8 bits wide) to input and output lines (they're sort of mixed) and set my output lines to some initial state (high or low). It seems that there are so many ways to do this. And that's where I'm confused.
 
There is the DAQmx Set Power Up States vi. Does this vi both configure AND write to the port lines? Or just writes to them?
 
Then there is the DIO Port Config vi and DIO Port Write vi. It seems that I can use that combination of vi calls to do the job. But then I ran into DIO Config vi and Write to Digital Port vi, and it seems that this combination should work as well. For writing to the lines there is also DIO Single Read/Write vi. I am confused as to which vi is best suited to do what I'm trying to do. And if they are all suitable, is there one that's more efficient than others? Keep in mind that I want to do this once at the beginning of my code to initialize the hardware. Can anyone tell me what's the best vi for configuring and writing to my hardware? Thanx a bunch.
 
Fataneh
 
0 Kudos
Message 1 of 13
(5,257 Views)
The reason you might be confused is that you have found VIs from both DAQmx and Traditional DAQ.  Your M Series board is designed for DAQmx, and it is much easier to use as well.

These two DAQmx example VIs might be helpful:

Read Dig Chan
Write Dig Chan

They can be found using the Example Finder (under LabVIEW's help menu) under the category Hardware Input and Output - DAQmx - Digital Generation and Hardware Input and Output - DAQmx - Digital Measurements.

The DAQmx Set Power Up States VI does not actually write to the digital lines, but instead applies settings to your board which are used to set the inital state of the digital lines immediately after the board powers up in your PC.

Please let me know if you have any more questions.

0 Kudos
Message 2 of 13
(5,251 Views)

jasonv,

Thank you for your reply. When you say that DAQmx Set Power Up States VI applies settings to my board to set the inital state of the digital lines, do you mean that it sets the line configurations to input or output. If so, then can I use it to set my port lines to inputs and outpts as I need them? If not, I don't really understand what it does. Can you explain it to me.

I've looked at Read Dig Chan VI and Write Dig Chan VI. They don't configure the channels as input or output. Or at least it's not obvious that it's doing so. They create an input channel (for Read) and output channel (for Write). Does the sub VI that creates the channel, also configure it? Since all the lines on the ports on my particular M series DAQ board are configured as inputs, I suppose I don't have to do anything for my input lines. Although for clarity, I'd like to explicitly set them to inputs in my init code. But for my output lines, I guess I can do what the Write Dig Chan VI does and set my output lines to whatever state I want. Is that right? Thanx.

Fataneh

0 Kudos
Message 3 of 13
(5,247 Views)
Calling the DAQmx Set Power Up States VI will not immediately change the state of any of your digital lines at all.  Powerup states are a part of the enhanced feature set of DAQmx, and are more adequately described in this tutorial:  http://zone.ni.com/devzone/conceptd.nsf/webmain/4cfcafe38e84d42386256e6800801af8

However, for what you are attempting to do the read and write VIs may be enough.

To answer your question, the direction of the digital lines on the board may be changed whenever a digital task is started.  The M Series board defaults to having all of the lines tristated.  For example, if you run the Write Dig Chan example, when DAQmx Start is called the lines specified in the task will be changed to drive output.  This actually occurs when the task is committed, which will happen when DAQmx Start is called if the task has not already been committed.

As long are not changing any other attributes using property nodes, all line configuration should be done automatically for both input and output.  Does your init code set the line directions the same every time it is run?  If so, then the Power Up States may be helpful since they can perform this initialization for you every time your PC is booted.
0 Kudos
Message 4 of 13
(5,244 Views)

jasonv,

I will read the tutorial on DAQmx Set Power Up States VI. But to answer your question, I am configuring my input and output lines once at the beginning of my code. Once set, this configuration does not change. I will however write different values to my output lines, of course, during the code execution, depending what the user wants to do. But all the input lines stay as input and all the output lines stay as output. In fact, each time the code runs, the input and output line designation remains the same. After reading the tutorial, if this VI does the job, I guess I'll use that.

Actually, after posting my question, I realized that with the Traditional DAQ VIs (DIO Port Config, DIO Config, Write to Digital Port) I have to specify a device number and my board being a DAQmx compatible, there is no device number assigned to it in MAX. So does this mean that the traditional DAQ VIs don't work for DAQmx compatible hardware? Thanx.

Fataneh

0 Kudos
Message 5 of 13
(5,242 Views)
If you used the Traditional NI-DAQ Compatibility VIs, you could run most LabVIEW applications written in Traditional NI-DAQ on devices that are only supported by NI-DAQmx.  However, I find programming in DAQmx to be far easier.  There are also some capabilities of your M Series board which are only supported by the DAQmx API.
0 Kudos
Message 6 of 13
(5,239 Views)

I guess my best option right now is to do the way it's done in Read Dig Chan and Write Dig Chan VIs.

Which VIs are the Traditional NI-DAQ Compatibility VIs? Thanx for all your help.

Fataneh

0 Kudos
Message 7 of 13
(5,234 Views)
Fataneh,

I did a search and found the download page for the Traditional DAQ compatibilty VIs at the following link:

http://digital.ni.com/softlib.nsf/websearch/9d67f671bcc6850586256e630059308b

If you have any other questions feel free to ask.

Jason
0 Kudos
Message 8 of 13
(5,235 Views)

Hi All-

The Traditional NI-DAQ Compatibility VIs are absolutely not your best option- they are not intended for new designs but rather for use with existing VIs that you would like to avoid rewriting, and (as jasonv mentioned) you lose out on the increased performance and ease of use that NI-DAQmx provides.

The examples Read/Write Dig Chan and Read/Write Dig Port from the NI Example Finder in LabVIEW (browse to Hardware Input and Output>>DAQmx>>Digital Generation and Hardware Input and Output>>DAQmx>>Digital Measurements) configure the lines for input or output based on the type of virtual channel or task created.  These settings will persist until you either clear the task or reset the card using the DAQmx Reset Device VI.

These should provide exactly the performance you're looking for.  Please let us know if you have any additional questions.

 

Tom W
National Instruments
0 Kudos
Message 9 of 13
(5,221 Views)

Jason,

Thank you so much for all your help. I'm doing it the way it's done in Read Dig Chan and Write Dig Chan VIs and it's working. Again, thanx for the help.

Fataneh

0 Kudos
Message 10 of 13
(5,090 Views)