Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending digital output to the right pins

After reading a bunch of examples, I got this program to run correctly....but only on channel 0 (P0.0, the first digital channel).  I am using a PCI-6221 to output a square wave of N samples, using an array as an input.  It works perfectly on dev0/port0/line0, but not for anything else.  Can you please tell me what I'm doing wrong?  I can use the Digital IO examples to write data to the channels, which I can measure using an oscilliscope, but i'm missing something here. 

I'm wondering if the 10kHz counter i'm using is only being sent to /dev0/port0/line0 (P0.0).  Is there a way to multiplex this to the other digital out pins, or even better, to the digital I/O pins (PFI series of pins)? Or is the problem occuring because i'm not using one of the MHz counters?

Thanks,

Steve
0 Kudos
Message 1 of 4
(3,671 Views)

Hi Steve,

I've taken a look at your VI and made some modifications.  I attached it to this post...please take a look.  Here are the changes I made:

1.  I replaced your "Channel" string control with an I/O selector control.  This allows you to choose which port(s) or line(s) you want to write to from a drop down menu.  This was accomplished by deleting the string control and then right-clicking on the lines input terminal and selecting Create » Control.

2.  I changed the source of your sample clock.  It now comes from a counter output on the same board.  I used and example program to generate a pulse train on a specific counter, and then I told your program to look at this counter for its sample clock.  The example program I used was named "Gen Dig Pulse Train-Continuous.vi" and is located in the NI Example Finder under Hardware Input and Output » DAQmx » Generating Digital Pulses.  On the front panel of this example, just choose a counter, a frequency and a duty cycle...then be sure to take your sample clock from the same counter in your VI. 

3.  I changed the polymorphic instance of the DAQmx Write VI.  You had it set for Digital » Multiple Channels » Multiple Samples » 2D U32.  Since "one channel for all lines" was chosen for the line grouping input of the DAQmx Create Channel VI, the polymorphic instance should not be specified for Multiple Channels, but rather Single Channel.  In the modified VI  you will see that I changed the polymorphic instance to Digital » Single Channel » Multiple Samples » 1D U16.  In this configuration, the program will write the first element of the array to the digital line, then write the second element of the array to the digital line, then the third element and so on.  Thus the line will basically retain the last element in the array. 

If you wish to write to multiple lines at the same time, you can take a look at the "Write Dig Chan.vi" (or "Write Dig Port.vi") example VI which performs a continuous acquisition inside a while loop.  The polymorphic instance is configured for Digital » Single Channel » Single Sample » 1D Boolean.  Also this KB describes the polymorphic instances and when to use them with particular line grouping input selections. 

Hope that helps.  Please let me know if you have any additional questions...

Regards,

Nicholas B, National Instruments

0 Kudos
Message 2 of 4
(3,649 Views)
Would it be possible for you to save the modified program as a labview 8.0 vi, or better yet, 7.2?  I do not have access to labview 8.2, and I do not know of any way to open vi's made with later versions.

I was able to make modifications 1 and 3 without seeing your vi, but i really do not know how to make the program "look at this counter for its sample clock" or to "take your sample clock from the same counter in your VI".  I'm sure it's all very simple, and I would know exactly how to do it when I see your program.  Since making the first and third change you suggested didn't get the other physical lines to output any voltage changes, I assume it was the second of your suggestions that will do the trick.  I wonder though, how does my sample clock keep the output from going to pins 1-7 (P0.1 through P0.7)? 

I'll keep fiddling with the examples.

Thanks,

Steve
0 Kudos
Message 3 of 4
(3,638 Views)

Hi Steve,

Attached you will find the VI saved for LabVIEW version 8.0.  Please take a look and let me know if (a) it still does not work or (b) you have any additional questions. 

Thanks and have a great day!

Regards,

Nicholas B, National Instruments

0 Kudos
Message 4 of 4
(3,607 Views)