A LabView / Model 30x pictorial showing
Module Reuse





Below is a screen-shot of   "!_Main.vi"   showing the indicators and controls we'll be using from it.
!_Main.vi   makes use of many of the individual modules to demonstrate some of the functionality of the Model 30x made available through the DLL. Although there may be many VI's within the archive you receive, only the ones that handle the functionality that you need for your application are required and the rest can be stored for later use. For example if all you want to do is connect and read one voltage from channel zero of one or more of the devices, all you need is two VI's to do everything,   "ConnectMulti.vi"   and   "GetOneVoltage.vi".   As an alternative you can just copy the code from those two VI's and paste it into your own. If you have only one of the Model 30x devices connected to your PC and that is all you will be using, you can also make use of the easy-connect,   "connectJustOne.vi"   module. This documentation will deal with the more complicated method of connecting to multiple devices since the USB interface is one designed with that purpose in mind. It is not recommended to connect several Model-30x devices to your PC and then try to make use of the simpler   "connectJustOne.vi"   module to connect and then interract with them individually!



Here is a closeup of just the   "connect"   controls and indicators from the   "main.vi"   sample application (the area that's circled above) that we'll be copying and pasting into a new application. The actual copy will need to be done from within the code diagram.



This shows the section within the diagram that corresponds with the section we highlighted in the main panel of the VI.



This is the code that we want to copy into a new application to add the connection functionality. Since this is already a working application there are some wires connected and even a few terminals that we won't need so just copy what is shown and we can get rid of the extras after we have it in the new application we are about to create.



Once properly highlighted LabView shows what has been selected



Now copy it to the Windows "clipboard" by selecting menu items "edit" and "copy"



Next, create a new VI.



Here's how the blank main panel will look with the blank code diagram behind it.



Go into the code diagram and paste the contents of the clipboard into it. From the   "edit"   menu, select   "paste". The contents from the   "main"   vi that we copied should appear. If they don't, you need to start from the top here and try again.



After they are pasting process, there will be a little cleanup to do since this all came from a working application. However, once cleaned up, you can save your's as a VI that you can later copy and paste from and just create another using everything you've done and are about to do.



It's unlikely that you will be needing this Boolean indicator that followed us over from the application that we copied from, so higlight and delete it. The terminal in the code diagram will also be deleted, but there will be some remaining variables that were associated with this indicator within the sequences in the code diagram that will need to be deleted.



Once the extra indicator is deleted, the front panel should look pretty clean, so go back to the code diagram to finish the cleanup process.



In the code diagram there is a loose wire that represents the current device that is being indexed in the array of device ID's. Create an indicator and connect it to it. Although you may not need that indicator, you will need the individual device ID's for certain function calls into the DLL, and since this array indexing is already in place you might as well preserve it for now.



This just shows the terminal that represents the indicator that was just created.



Next give the terminal a label and a name for the label. The one shown is the one I use.



Finally, take care of the errors that remain which are nothing more than errors related to the Boolean indicator that we removed on the front panel. There is one sequence frame and one local variable and it's associated wire that will need to be remvoed.



Pressing the run button will show the location of the errors that prevent it from running



This is one of the local variables that once referenced the Boolean indicator on the front panel that we deleted - that's the reason there is a question mark now in it. Nothing is needed in this frame so just delete the entire frame - DO NOT DELETE the entire sequence!



This is one of the local variables that once referenced the Boolean indicator on the front panel that we deleted - that's the reason there is a question mark now in it. Delete the local variable and also just the wire that connects it to the other wire. Do not delete the wire connecting the Boolean constant and the   "Connect"   variable. Once the things just mentioned are deleted, the remaining wire between the Boolean constant and local variable will become once again active.



The   "Run"   button should now show that there are no errors and the application is ready to run. Please read the text in the image below and the text in the next 3 images as well.



Read the text in the image below.



Read the text in the image below.



Read the text in the image below.



Be sure the   "continuous run"   button is still pressed and then press the   "connect"   button.



I have the button configured to display a wait message until it pops back up. It will pop back up when the enumeration is completed and the function call into the DLL returns. I suggest that you use the same functionality in any application that you create, so the user just waits without doing anything else until the enumeration process is complete. Please read the notes within the image to find out more.



The button has popped back up and the LED has changed to green. The green does not mean that any or all of your devices enumerated correctly. Please read the notes within the image to find out more.




Additional notes


This has been an example of   "module reuse".   You may find it much easier to create your own controls and call into the   "ConnectMulti.vi"   module. Or you may want to just make the call to the connect function directly into the DLL yourself. The connect module was created for your convenience due partly to the fact that array management and calling into a DLL is concidered difficult by some LabView developers who haven't done that sort of thing before. Array intialization is important so please keep that in mind. Both the   "Device ID"   and the   "Rate"   arrays that are passed into the DLL must be sized to 32 elements, or erroneous behaviour   (such as an application crash)   could result. Regardless of how many devices you will be connecting, the DLL will index every element in those arrays. Please be sure to set all unused elements to zero and the   "NumDevices"   variable to the number of devices you wish to connect.

Many of the scanning functions will accept an array of devices to scan. However you will need to pass a single device ID in the function calls to read the scan data unless you use the default option of simply allowing the DLL to record all of the scan data to a disk file. A single device ID is required in the I/O function calls. The simplest method to deal with that is by indexing the device ID within the DeviceID array and passing that to the DLL.
Last modified 7-6-05 by Tim Van Dusen