Each PXI(e) backplane trigger line (PXI_TRIG<0..7>) must be connected to a separate PFI or DO line on the PXIe-634x card.
This can be done by either:
For efficiency purposes, the example below uses the For Loop method. For a more detailed explanation of the difference between using/not using a For Loop in a DAQmx Task, refer to DAQmx Task with Multiple Terminal Configurations.
The completed code can be found at the bottom of this article. To create the code from scratch, follow the steps below:
1. In LabVIEW, open a new VI by going to File >> New.
2. On the Block Diagram, place a For Loop.
3. Inside the For Loop, place a DAQmx Connect Terminals VI.
4. On the VI's Front Panel, place a Cluster and rename it "Connect Terminals".
- Do this by navigating to Data Containers >> Cluster in the Controls palette.
5. On the
Source Terminal and
Destination Terminal inputs of the
DAQmx Connect Terminals VI, create a
Control.
- Do this by right-clicking on each of the inputs and selecting Create Control. Delete the wires connecting the controls to the VI.
- Rename the Source Terminal Control to "PFI Source".
- Rename the Destination Terminal Control to "PXI_TRIG Destination".
6. On the
Front Panel, drag the newly created
Controls into the
Cluster.
7. Right-click on the
Cluster and select
Change to Array.
- This cluster now contains a pair of terminals in each array element. This can be seen below:
8. On the Block Diagram, wire the output of the "Connect Terminals" Cluster to the For Loop.
- Ensure that the terminal connecting to the For Loop is Indexing, as seen below.
- If Indexing is disabled, right-click on the terminal and select Enable Indexing.
9. Next, place an Unbundle By Name inside the For Loop and wire the "Connect Terminals" Cluster to it's input.
- Unbundle By Name can be found navigating to Cluster, Class and Variant >> Unbundle By Name in the Functions palette.
10. Expand the
Unbundle By Name function so that 2 elements are displayed.
- Select the PFI Source and PXI_TRIG Destination as each element inside the Unbundle By Name. At this point, the code should resemble the following:
11. Wire the PFI Source output to the Source Terminal input of the DAQmx Connect Terminals VI.
12. Wire the PXI_TRIG Destination element to the Destination Terminal input of the DAQmx Connect Terminals VI.
13. Connect the Error Out of the DAQmx Connect Terminal VI to the edge of the For Loop.
- Right-click the Error Out terminal and select Replace With Shift Register.
- Click on the left edge of the For Loop to place the Shift Register.
- Wire the left Shift Register to the input of the DAQmx Connect Terminals VI, as shown:
14. Place a DAQmx Create Channel VI outside the For Loop.
- This can be found by navigating to Measurement I/O >> NI DAQmx >> Create Channel in the Functions palette.
15. From the drop-down list on the
DAQmx Create Channel VI, select
Digital Output.
16. Right-click on the
Lines input and select
Create Control.
- Rename this Control "Digital Output Lines".
17. On the
Front Panel, define the digital ports/lines inside the "Digital Output Lines"
Control.
- For this example, 8 PFI lines on a PXIe-6341 will be used. The PXIe-6341 Pinout document indicates that the first 8 PFI lines (PFI<0..7>) correspond to digital lines 0 to 7 on port 1.
- The "Digital Output Lines" Control contains 6341/port1/line0:7 to define these 8 digital lines for use.
18. Wire the
Error Out from the
For Loop into the
Error In of the
DAQmx Create Channel VI.
19. Next, place a
DAQmx Start Task VI.
- Find this in Measurement I/O >> NI DAQmx >> Start in the Functions palette.
20. Connect the
Task Out and
Error Out of the
DAQmx Create Channel VI to the
Task/Channels In and
Error In of the
DAQmx Start Task VI.
- The Front Panel and Block Diagram should now resemble the image below.
21. Place a DAQmx Write VI onto the Block Diagram.
- Find this by navigating to Measurement I/O >> NI DAQmx >> Write.
22. Wire the
Task Out and
Error Out of the
DAQmx Start VI to the
Task/Channels In and
Error In of the
DAQmx Write VI.
23. From the drop-down menu on the
DAQmx Write VI, select
Digital >> Single Channel >> Multiple Samples >> 1D (U8) port format.
23. On the
Front Panel, place a
Boolean Control by navigating to
Boolean >> Push Button in the
Controls palette.
24. Right-click the
Boolean Control and select
Change To Array.
- Rename the array "Data To Write".
- Each element of this array will be written to each digital line defined in the "Digital Output Lines" Control.
Note: the number of elements enabled in the
"Data To Write" array
must equal the number of elements enabled in the "Connect Terminals" array.
25. Place a
For Loop on the
Block Diagram and wire the output of the "Data To Write" array to the edge of the
For Loop.
- Using the same method as earlier, ensure the array terminal is set to Indexing.
26. Inside the
For Loop, place a
Boolean To (0,1).
- Locate this in Numeric >> Conversion >> Boolean To (0,1) in the Functions palette.
27. Wire the indexed terminal of the "Data To Write" array to the input of
Boolean To (0,1).
- This converts the Boolean data type into a number that is compatible with the Data input of the DAQmx Write VI.
28. Wire the output of
Boolean to (0,1) to the right edge of the
For Loop. Again, ensure that the output terminal is set to
Indexing.
29. Outside the
For Loop, place a
To Unsigned Byte Integer.
- Navigate to Numeric >> Conversion >> To Unsigned Byte Integer in the Functions palette to find this.
30. Wire the output of the
For Loop to the input of the
To Unsigned Byte Integer.
31. Wire the output of the
To Unsigned Byte Integer to the
Data input of the
DAQmx Write VI.
- The VI should now resemble the image below.
32. Place a DAQmx Stop Task VI from Measurement I/O >> NO DAQmx >> Stop in the Functions palette.
33. Wire the Task Out and Error Out from the DAQmx Write VI to the Task/Channels In and Error In of the DAQmx Stop Task VI.
34. Next, place a DAQmx Clear Task VI from the same palette. Similarly, wire the outputs from the DAQmx Stop VI to the inputs of the DAQmx Clear VI.
35. Place a For Loop.
36. Wire Error Out of the DAQmx Clear Task VI to the For Loop.
- Using the method described earlier, ensure that the error terminals on the For Loop are Shift Registers.
37. Place a
DAQmx Disconnect Terminals VI inside the
For Loop.
- Find this by navigating to Measurement I/O >> NI DAQmx >> Advanced >> Signal Routing >> Disconnect in the Functions palette.
38. Connect the output from the "Connect Terminals"
Cluster to the edge of the
For Loop. Again, make sure that the terminal is set as
Indexing.
39. Place an
Unbundle By Name inside the
For Loop and wire the
PFI Source and
PXI_TRIG Destination elements to the
Source Terminal and
Destination Terminal of the
DAQmx Disconnect Terminals VI.
40. Wire the
Error Out of the
DAQmx Disconnect Terminals VI to the right edge of the
For Loop.
41. Right click on the
Error Out wire of the
For Loop and select
Create Indicator.