08-06-2008 07:14 PM
Hello,
I've been using Microsoft Visual C#.NET and Microsoft Visual Basic.NET as a test executive. I'd like to make use of LabView toolkits to control PXI modules like the NI PXI-4461 by creating LabView dlls to access via .NET. I've successfully passed data to/from my LabView dlls with .NET, but I haven't been able to pass the instrument task handles. Are there any conversions that need to happen on the task handles as they are input and output to/from LabView? How should the .NET code be written for this? Are there any examples available for this?
Thanks,
Luke
08-07-2008 02:45 PM
08-07-2008 04:55 PM
Mark,
Thanks for the reply.
I have tried passing the handles as strings and other data types, but I haven't had any luck.
On the .NET side, I'm not modifying the tasks, but only passing them for later use. For example, I will want to output a signal, then take some measurements, and once the measurements are complete, stop the waveform output.
Attached is a quick and dirty LabView project that includes VI's to output signal, measure signal, and stop the card. The "PXI_AudioAnalyzer.vi" is a pseudo example that ties these VI's together.
Thanks,
Luke
08-08-2008 12:31 PM
08-13-2008 03:11 PM
Mark,
Sorry, I had some issues attaching my files. In the attache zip, there is a LabView project with 4461_waveform_out_noLoop.vi and 4461_Stop.vi that I used to create the 4461_Stop.dll. I have also included a directory with my .NET code (4461_Labview_Stop). In this example, I'm just trying to output a waveform with the 4461 via .NET through a call to the 4461_waveform_out_noLoop.vi (this step works) and then stop it witha call to the 4461_Stop.vi (this part doesn't work).
I've tried doing this by converting the LabView task handle to a string and have had the same results as the provided example. I haven't had any error code, but the instrument doesn't respond to the .NET calls when handles are passed in to LabView.
Do you have any recommendations?
Thanks,
Luke
08-14-2008 03:24 PM
Hi Luke,
Have you considered just accessing the DAQmx Dlls instead? That may be easier than writing your own. You can find the reference help for those under start » programs » National Instruments » NI-DAQ.
As far as your code goes, you are passing the tasks as numeric integers. Does that work for the waveform output call? Also, I didn't find the stop function in your dlls, did you include it in the compiled dll?
08-14-2008 03:44 PM
Mark,
I'm trying to get the handle passes to work with my simple 4461 output example first because I'd like to use Labview's Sound and Vibration toolkit. From what I know, the Sound and Vibration Toolkit is only available in LabView. Likewise, I'd like to use some LabView code for my RF PXI instruments too. Ultimately, I'd like to use .NET for as much as I can, but only use LabView created dlls for features that aren't available in .NET. To do this, I need to be able to pass handles in and out of LabView and I've started simple with the 4461 output example where I have one VI initialize the instrument and generate the signal and have another VI stop the instrument. Do you know if it's possible to get toolkits that are only available in LabView for .NET? I can't find any examples that do this. Do you have any examples available that pass instrument handles into and out of .NET, preferrably in C#?
For my provided code, the tasks are numeric integers. I've tried many different data types for the tasks (including strings), and NOTHING has worked. The waveform output calls outputs a signal because at that point I'm only passing my amplitude and frequency information into the LabView dll but if I pass the task handle as a string, I get garbage in .NET. For every method that I've tried, once I get the handle into .NET, when I call the stop VI, the instrument doesn't stop outputting signal.
In the dll, the stop function is called _4461_Stop, so yes, it's in my compiled dll.
Thanks,
Luke
08-15-2008 08:33 AM
Hi Luke,
Here are some references about programming in c# .NET. I recommend seperating your program and doing the DAQ tasks using the DAQ API and passing the data you want to run in the sound and vibration toolkit to your labview dlls. This way you have supported functions for DAQ and many examples.
You are corrct about the sound and vibration toolkit, it is not intended to be used in anything other than LabVIEW, so you will have to create wrapper dlls to access the functionality that you want.
http://digital.ni.com/public.nsf/allkb/F0FD13D2DD0C433986256D9C00468D29?OpenDocument
Let me know if this helps or if that isn't an option.
08-15-2008 08:50 AM
Mark,
Thanks for the info. I've used the NI provided DAQmx examples successfully, but wouldn't I still need to pass the handle to the LabView dll to take measurements using the Sound and Vibration toolkit? How do I do this?
Thanks,
Luke
08-15-2008 08:54 AM