LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

using a .dll to control a mcs device

Solved!
Go to solution

Hey guys.

 

I have a big problem with my labview vi concerning using a .dll to talk to an usb device.

 

The device is a multichannel systems tcx controler and with it comes a .dll libary with functions to control it. in the libary called mcsusbnet.dll is the class ctcxdevicenet that holds all functions i want to use. (example setonoff: for setting channel 1 and 2 on or off).

 

I am now trying to use this .dll with my vi to make the connection but it always says it can't find the function i am trying to use. 

The documentation from mcs is rather short so i realy dont know whats wrong.

 

Further more i am a labview rookie so i dont even know where to start looking for errors.

 

i'll add my vi and the mcs .dll here. could someone pls have a qick look.

 

 

Download All
0 Kudos
Message 1 of 13
(3,581 Views)

i found that my .dll is a .net based dll so i can call it in with the .net nodes in labview. that i have done so far. problem now is to use the functions of the .net class i wired to my vi

0 Kudos
Message 2 of 13
(3,541 Views)

Now this error occures. (in bold)

Any ideas on how to fix this error guys?

 

LabVIEW: A .NET exception occurred in an external assembly. For information about correcting this error, copy the following exception (in bold), and search the Microsoft Developer Network (MSDN) Web site or the Web for a possible explanation.
System.Runtime.InteropServices.SEHException in Untitled 1

0 Kudos
Message 3 of 13
(3,527 Views)

Hey guys.

 

I am trying to make a controling software that reads temperature, compares it to a set value and if they are not equal heats or cools to the desired value.

 

The temperature reading and comparing works so far but my problem now is the communication between labview and the multichannel systems tc01.

 

I wanted to use a .net .dll provided by multichannel systems. opening it with the connectivity tab and selecting the operation from the dll works so far but when trying to execute it throws following error: 

 

error 1172

LabVIEW: A .NET exception occurred in an external assembly. For information about correcting this error, copy the following exception (in bold), and search the Microsoft Developer Network (MSDN) Web site or the Web for a possible explanation.
System.Runtime.InteropServices.SEHException in test

 

the dll and the vi are in the same directory, and everything. do you have any ideas what the problem might be?

 

I'll add the vi and the whole dll zip with documentation. maybe anyone could have a look?

 

with best regards, michael

Download All
0 Kudos
Message 4 of 13
(3,550 Views)

I don't have the hardware it is specifying and when I try your VI I do not receive this error, instead getting a ArgumentNullException. Based on the error message it suggests it is looking in a Dictionary<T> or equivalent for the channel specified ("1") and it can't find it. The error you say you are receiving indicates that there was an unmanaged exception (SEH) that has been wrapped into a managed exception type - this probably means that there is some setup needed for the hardware.

 

I don't have the opportunity yet to dig into the dll you supplied to see if there is anything specific there but it appears to come with extensive documentation; have you tried going through example code for comparison? I see some .NET examples where the method/property calls can be implemented by LabVIEW nodes.

0 Kudos
Message 5 of 13
(3,498 Views)

Dear tyk007,

 

thanks for looking into it and replying quickly.

 

i think my main problem at the time might be that i have no idea how i can make the labview vi communicate with the desired usb device in the first place.

 

as you said the nullexception error occures and i think its because the .net libary i want to use does not "know" what usb device it should talk to. do you know how i can make the connection between a usb device and the .net library so it communicates properly?

 

 

0 Kudos
Message 6 of 13
(3,490 Views)

Do you have an example to work from? Even if that example is written in another language it is most likely possible to translate that into LabVIEW via invoke and property nodes (thre are some caveats). If you can find an example I can help you get a head-start.

0 Kudos
Message 7 of 13
(3,463 Views)

You mean .net example?

 

Because the mcs tc02 is mearly ment to be controlled with their own tcx usb software. I had to contact their support to get intell about the existance of those .dll files and everything they gave me. (Documentation and .dll files is in the zip file i uploaded with the first post) ^^

Inside the .dll file the archive responsible for the tc01 and tc02 is called ctcxdevicenet().

It contains all commands you could possibly send to the controlers.

0 Kudos
Message 8 of 13
(3,454 Views)
Solution
Accepted by topic author octaris

Unfortunately I don't have access to a PC at the moment. What I would do in your situation is to contact the suppliers of the dll and ask for their assistance in the necessary order of calls, perhaps by providing them with what you are doing at the moment (just the constructor and then the Set method with those parameters). 

 

Another option is to execute the same calls in a .NET application you create. LabVIEW isn't showing you the wrapper internal exception that was thrown in the error cluster message but if you debug a .NET application doing the same thing you would be able to dig into the Exception object, perhaps seeing detail in the InnerException etc. that would help diagnose the issue.

 

I also see that your test VI tries to call the Set method effectively as fast as the OS scheduler will allow; you do not have a delay in your while loop. The assembly you are working with is s thin wrapper around unmanaged code and there is a chance that making so many calls in short order could cause issues on the hardware side. You could also try adding a delay in the while loop (say 1000ms) and see what difference that makes.

Message 9 of 13
(3,450 Views)

Thanks again!

 

Thirst thing today i will contact them and hope they respond quickly.

 

as im not that expirianced with programmin, making my own .net isnt the best idea i guess 😕

 

also i will try to add a delay.

 

i dont want to bore you too much with this but if you have time the other day would you take a little glance inside the dll for me? maybe im just to focused on something that i oversee the little thing that would make the differnce.

 

appreciate your help big time!!

0 Kudos
Message 10 of 13
(3,442 Views)