Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
daq-and-datalogging:documents:ulx-for-ni-labview-2 [2023/06/13 14:18] – created Scandiwebdaq-and-datalogging:documents:ulx-for-ni-labview-2 [2023/07/28 00:51] (current) – Arthur Brown
Line 1: Line 1:
-====== Getting started with ULx for NI LabVIEW Part 2 ======+====== Getting Started with ULx for NI LabVIEW Part 2 ======
  
 In part one, we learned how what is the minimum amount of VIs needed to acquire one analog data sample and display it on the NI LabVIEW front panel.  In part 2 we will add to this example by including: In part one, we learned how what is the minimum amount of VIs needed to acquire one analog data sample and display it on the NI LabVIEW front panel.  In part 2 we will add to this example by including:
Line 22: Line 22:
 Here is where we left off: Here is where we left off:
  
-{{https://files.digilent.com/resources/measurement-computing/Reference Images/picture 3.png?453x116}} +<WRAP centeralign> 
-{{https://files.digilent.com/resources/measurement-computing/Reference Images/picture 4.png?454x98}}+{{https://files.digilent.com/reference-images/picture 3.png?453x116}} 
 +</WRAP> 
 + 
 +<WRAP centeralign> 
 +{{https://files.digilent.com/reference-images/picture 4.png?454x98}} 
 +</WRAP>
  
 From the Block Diagram, right click anywhere there is white space to pop up the Functions menu. Select Express >> Exec Control >> While Loop.  Your cursor will change to this .  Place the cursor between and above the two ULx VIs on the block diagram, click and hold your left mouse button down, then drag the cursor until it is to the right and below the data.VI.  Your diagram will look like this: From the Block Diagram, right click anywhere there is white space to pop up the Functions menu. Select Express >> Exec Control >> While Loop.  Your cursor will change to this .  Place the cursor between and above the two ULx VIs on the block diagram, click and hold your left mouse button down, then drag the cursor until it is to the right and below the data.VI.  Your diagram will look like this:
  
-{{https://files.digilent.com/resources/measurement-computing/Reference Images/picture 6.png?472x236}}+<WRAP centeralign> 
 +{{https://files.digilent.com/reference-images/picture 6.png?472x236}} 
 +</WRAP> 
  
 Plus you will see a ‘Stop’ button on your Front Panel.  Feel free to resize and move this on the panel to a size and place pleasing to you. Plus you will see a ‘Stop’ button on your Front Panel.  Feel free to resize and move this on the panel to a size and place pleasing to you.
Line 46: Line 54:
 To slow the looping down, we will add the Time Delay.VI.  It is located on the Functions Palette, select Express >> Exec Control, then click and drag it to inside the loop as shown here. To slow the looping down, we will add the Time Delay.VI.  It is located on the Functions Palette, select Express >> Exec Control, then click and drag it to inside the loop as shown here.
  
-{{https://files.digilent.com/resources/measurement-computing/Reference Images/picture 7.png?470x394}} +<WRAP centeralign> 
 +{{https://files.digilent.com/reference-images/picture 7.png?470x394}} 
 +</WRAP>
  
 As you can see, a dialog box pops up with this VI, asking you to set the time delay.  For the purposes of this example, I set it to 0.100 seconds so that I get a new sample 10 times a second or 100 mS. As you can see, a dialog box pops up with this VI, asking you to set the time delay.  For the purposes of this example, I set it to 0.100 seconds so that I get a new sample 10 times a second or 100 mS.
Line 64: Line 73:
    
  
-In its current state, this example can run indefinitely.  That is, as long as the [[https://www.mccdaq.com/usb-data-acquisition/USB-1608G-Series.aspx | USB-1608G]] stays connected, powered, and so long as no external influence damages the device.  But what is something like that should occur?  We would want 2 things to happen.  First we’d want to stop the procedure, in this case our loop, and second, we’d want to be notified there was a problem.  To handle these matters, we add error handling.+In its current state, this example can run indefinitely.  That is, as long as the [[https://digilent.com/shop/mcc-usb-1608g-series-high-speed-multifunction-usb-daq-devices/|USB-1608G]] stays connected, powered, and so long as no external influence damages the device.  But what is something like that should occur?  We would want 2 things to happen.  First we’d want to stop the procedure, in this case our loop, and second, we’d want to be notified there was a problem.  To handle these matters, we add error handling.
  
    
Line 74: Line 83:
 Now we will add a way to exit the While Loop when there is a problem.  Within the while loop, place your mouse cursor on the error out wire from the Read.VI.  When the wiring tool appears, right click, select Cluster, Class & Variant Palette.  Add an Unbundle.VI below and to the right of the Read.VI.  Wire the Read’s error out to the Unbundle’s error in.  You may need to widen the while loop to make it all fit, if so, left mouse click on the blue drag handle on the right side of the while loop and drag it to the right.  You’ll need to move the conditional terminal to the right as well.  Delete the wire between the Stop button and the conditional terminal.  You do this by left mouse clicking on the wire to select it, then press your keyboard’s "Delete" key.  We want to add an OR gate so if the Stop button is clicked OR it there is an error the loop stops.  Right mouse click on the output of the Unbundle.VI, select Boolean Palette and add an OR gate to the right of the Unbundle.VI.  If the OR gate does not already have one of its inputs wired to the Unbundle.VI, wire the other input to the Stop button, and wire the output of the OR gate to the conditional terminal.  Your Block diagram should look like this: Now we will add a way to exit the While Loop when there is a problem.  Within the while loop, place your mouse cursor on the error out wire from the Read.VI.  When the wiring tool appears, right click, select Cluster, Class & Variant Palette.  Add an Unbundle.VI below and to the right of the Read.VI.  Wire the Read’s error out to the Unbundle’s error in.  You may need to widen the while loop to make it all fit, if so, left mouse click on the blue drag handle on the right side of the while loop and drag it to the right.  You’ll need to move the conditional terminal to the right as well.  Delete the wire between the Stop button and the conditional terminal.  You do this by left mouse clicking on the wire to select it, then press your keyboard’s "Delete" key.  We want to add an OR gate so if the Stop button is clicked OR it there is an error the loop stops.  Right mouse click on the output of the Unbundle.VI, select Boolean Palette and add an OR gate to the right of the Unbundle.VI.  If the OR gate does not already have one of its inputs wired to the Unbundle.VI, wire the other input to the Stop button, and wire the output of the OR gate to the conditional terminal.  Your Block diagram should look like this:
  
-{{https://files.digilent.com/resources/measurement-computing/Reference Images/picture 8.png?687x284}}+<WRAP centeralign> 
 +{{https://files.digilent.com/reference-images/picture 8.png?687x284}} 
 +</WRAP>
  
-Run this now, then remove the USB cable from the [[https://www.mccdaq.com/usb-data-acquisition/USB-1608G-Series.aspx | USB-1608G]].  You should see the following error message pop up:+Run this now, then remove the USB cable from the [[https://digilent.com/shop/mcc-usb-1608g-series-high-speed-multifunction-usb-daq-devices/|USB-1608G]].  You should see the following error message pop up:
  
-{{https://files.digilent.com/resources/measurement-computing/Reference Images/picture 9.png?338x180}}+<WRAP centeralign> 
 +{{https://files.digilent.com/reference-images/picture 9.png?338x180}} 
 +</WRAP>
  
 When you click on Continue, notice execution of the VI has stopped.  This is exactly what we want to occur. When you click on Continue, notice execution of the VI has stopped.  This is exactly what we want to occur.
Line 95: Line 108:
 It should look like this: It should look like this:
  
-{{https://files.digilent.com/resources/measurement-computing/Reference Images/picture 10.png?338x180}}+<WRAP centeralign> 
 +{{https://files.digilent.com/reference-images/picture 10.png?338x180}} 
 +</WRAP>
  
 You’ll need to add a wire from the data terminal (pin) of the Read.VI to the data pin on the Waveform Chart.VI.  Your Block Diagram should look like this: You’ll need to add a wire from the data terminal (pin) of the Read.VI to the data pin on the Waveform Chart.VI.  Your Block Diagram should look like this:
  
-{{https://files.digilent.com/resources/measurement-computing/Reference Images/picture 11.png?686x280}} +<WRAP centeralign> 
- +{{https://files.digilent.com/reference-images/picture 11.png?686x280}} 
-You can run this, but before you do, did you remember to plug the USB cable back in to your device after the error test? +</WRAP>
  
 +You can run this, but before you do, did you remember to plug the USB cable back in to your device after the error test?\\ 
  
  
 Your Front Panel should look something like this while it is acquiring data: Your Front Panel should look something like this while it is acquiring data:
  
-{{https://files.digilent.com/resources/measurement-computing/Reference Images/picture 12.png?382x442}}+<WRAP centeralign> 
 +{{https://files.digilent.com/reference-images/picture 12.png?382x442}} 
 +</WRAP>
  
 //**Saving the data to file**// //**Saving the data to file**//
Line 114: Line 132:
  Our last goal is to save the data to a file. Again, we will use an Express.VI to keep this simple.  Right click to bring up the Functions Palette, select Express>>Output and click on Write to Measurement File.VI and place it on the Block Diagram, in the loop, to the right of the Waveform Chart.  Once placed, you will see a dialog box entitled “Configure Write to Measurement File.”  So as to keep this as straight forward as we can, change the file path to something you’ll remember.  Besides that, the only other change is Segment Headers, select ‘One header only’, and click on OK to close the dialog box and save the changes.  Only one wire to add and we’re done.  Wire the Signals input of the Write to Measurement File.VI to the data output of the Read.VI.  Your now completed block diagram VI will look like this:  Our last goal is to save the data to a file. Again, we will use an Express.VI to keep this simple.  Right click to bring up the Functions Palette, select Express>>Output and click on Write to Measurement File.VI and place it on the Block Diagram, in the loop, to the right of the Waveform Chart.  Once placed, you will see a dialog box entitled “Configure Write to Measurement File.”  So as to keep this as straight forward as we can, change the file path to something you’ll remember.  Besides that, the only other change is Segment Headers, select ‘One header only’, and click on OK to close the dialog box and save the changes.  Only one wire to add and we’re done.  Wire the Signals input of the Write to Measurement File.VI to the data output of the Read.VI.  Your now completed block diagram VI will look like this:
  
-{{https://files.digilent.com/resources/measurement-computing/Reference Images/picture 13.png?634x285}}+<WRAP centeralign> 
 +{{https://files.digilent.com/reference-images/picture 13.png?634x285}} 
 +</WRAP>
  
 Let’s run our VI!  Run it for a bit, then stop it.  If all ran correctly you should have a data file waiting for you.  Though the file is much longer that this, here is sample of contents of the file including the header: Let’s run our VI!  Run it for a bit, then stop it.  If all ran correctly you should have a data file waiting for you.  Though the file is much longer that this, here is sample of contents of the file including the header:
  
-{{https://files.digilent.com/resources/measurement-computing/Reference Images/picture 14.png?343x515}} +<WRAP centeralign> 
 +{{https://files.digilent.com/reference-images/picture 14.png?343x515}} 
 +</WRAP>
  
  
Line 132: Line 153:
  
 **Attachments**\\  **Attachments**\\ 
-[[ https://files.digilent.com/resources/measurement-computing/Reference Attachments/Getting started with simple Analog Input.zip | Getting started with simple Analog Input.zip]]+[[ https://files.digilent.com/reference-attachments/Getting started with simple Analog Input.zip | Getting started with simple Analog Input.zip]]