DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

calling LabVIEW from DIAdem

I am trying to run a LabVIEW VI from DIAdem. I looked in the help files but the example seems to only open LabVIEW 7.0 and not open the VI. The process stops on the LabVIEW startup screen. Also I have LabVIEW 7.1 loaded on my machine and would like to be able to select which version of LabVIEW I start with DIAdem. Is any of this possible?

Thanks in advance.

AJL
0 Kudos
Message 1 of 8
(4,841 Views)
Hi,

Check out

http://zone.ni.com/devzone/conceptd.nsf/webmain/1A98AB48E35D913086256E23004E6A22?opendocument&node=5050_US

The link above can also be found at www.ni.com/diadem, check out the section "Featured Example Programs" halfway down on the page

Hope this helps, let us know how it works for you

Regards

Tom Ferraro
DIAdem Product Manager
0 Kudos
Message 2 of 8
(4,829 Views)
Hi AJL,

If your VI happens to be in the LabVIEW directory or subdirectory structure, you can use native functions in DIAdem 9.1 to call that VI from DIAdem. If the VI is further configured to run when opened, it will automatically start:

IF IsAvailLabVIEW = TRUE THEN
LVTemplatePath = "examples\DIAdem\File\File Headers\"
LVTemplateVI = "Binary File Analyzer.vi"
Call LaunchLabVIEW
END IF

Otherwise you will need to create VBScript object variables from the VI server of LabVIEW and execute their methods and set their properties to have the same remote control over the VI as you would from another VI using VI server. The example Tom pointed you to shows this in intricate detail, in the context of a very large application. Here's what VI server looks like in VBScript:

Dim lvapp, vi, viPath, paramName(0), paramVal(0)
Set lvapp = CreateObject("LabVIEW.Application")
viPath = "C:\Favorite LV Menu\Binary File Analyzer.llb\Binary File Analyzer.vi"
Set vi = lvapp.GetVIReference(viPath)
vi.FPWinOpen = True
paramName(0) = "file path"
paramVal(0) = "C:\DIAdem Hands-On\ReadMe.txt"
Call WndShow("SHELL", "MINIMIZE")
Call vi.Call(paramName, paramVal)
Call lvapp.Quit()

You can read and write more than one parameter for VIs with multiple input/output terminals. Note that the paramName() and paramVal() variables are VBScript arrays. The number of elements in these arrays does NOT have to match the number of terminals-- all you need to put in these VBScript arrays are the parameters that you care to read/write in the VI.

Ask if you have additional questions,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
0 Kudos
Message 3 of 8
(4,815 Views)
Thanks Brad, using the script to call labview and specify the inputs worked great. One more question on this subject though. How do you read back the outputs of the VI?


Thanks,
AJL
0 Kudos
Message 4 of 8
(4,808 Views)
With the LabVIEW DIAdem Connectivity VIs you can write directly into DIAdem variables. Problem is, you cant do that while a DIAdem script is running. So if you start your VI from within a script and want to read the results later from within the same DIAdem script, you cant use this. You then have the possibility to write the results to a DIAdem data file (a VI available in the connectivity VIs), and in DIAdem open this file.
0 Kudos
Message 5 of 8
(4,799 Views)
Hey AJL,

You just need to add another element to the parameter array and specify the name of the output terminal you want to read in that array, then when the "vi.Call()" command returns, the paramVal(1) element will automatically contain the value present at the VI's output terminal when the VI stopped.

Dim lvapp, vi, viPath, paramName(1), paramVal(1)
Set lvapp = CreateObject("LabVIEW.Application")
viPath = "C:\Favorite LV Menu\Binary File Analyzer.llb\Binary File Analyzer.vi"
Set vi = lvapp.GetVIReference(viPath)
vi.FPWinOpen = True
paramName(0) = "file path"
paramVal(0) = "C:\DIAdem Hands-On\ReadMe.txt"
paramName(1) = "file path out"
Call WndShow("SHELL", "MINIMIZE")
Call vi.Call(paramName, paramVal)
Call lvapp.Quit()
MsgBox paramVal(1)

The world is now your oyster,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
0 Kudos
Message 6 of 8
(4,786 Views)
Can I pass an array to DIAdem from LabVIEW? I can pass values just fine using the ParamName() and ParamVal() commands but I cannot get this to work for a array of integers. Is this possible?

Thanks,

AJL

Using DIAdem 9.1 and LV 7.1
0 Kudos
Message 7 of 8
(4,662 Views)
Hi AJL,

DIAdem numeric channels are always DBL internally, so the pointer to the 2D array you get back from the "ValueRangeGet" method of the "diadem.todatasheet" OLE Server will always be a pointer to a 2D array of DBLs. So to pass an array of integers from LabVIEW to DIAdem, you should convert the integer array to a DBL array in LabVIEW, expose it as a DBL array output terminal in the VI, then retrieve the output terminal pointer and pass it to DIAdem with the "ValueRangeSet" method.
I am attaching a VBScript (as a doc) that works with all data types, but only DBL arrays can be handles by reference. Any pthers will have to be assigned cell by cell by value.

Thanks,
Caroline
National Instruments
Thanks,
Caroline Tipton
Data Management Product Manager
National Instruments
0 Kudos
Message 8 of 8
(4,633 Views)