Matlab connection with device by .net library by .dll

14 visualizaciones (últimos 30 días)
franco otaola
franco otaola el 30 de Abr. de 2019
Comentada: Guillaume el 2 de Mayo de 2019
Hello,
I just bought a hardware that is USB connected to the computer, with a software to control it.
The hardware is a captor, which has an acquisition frequency between 1-100hz. My problem is that from the software that they provide you can choose between 1 or 100 and some of my experiences need acquisition frequencies with values between them.
When I contacted the provider, they told me that if I need another frequency I will need to work around myself. The captor has a .dll (a .NET library) file that was created from the installation of the software, and from its application note there is a MODBUS communication protocol too.
From the application note, the library is a .NET assembly and any .net supporting programming language or program like C#, LabVIEW, IronPython, Visual Basic .net, or Mathworks MATLAB should be able to use it and fully control the detector. From what this phase and as I have no knowledge of the other languages/programs and I have used Matlab and I have a license to use it I thought I would follow that path.
The problem is that I haven’t work with a library before, and the application note only gives more information for C# and IronPython.
From what I read in the matlab forum, matlab needs a header file too (besides the library file .dll) where I don’t have anything else from the provider.
Is it that I am missing something or is there another way to work around?
If any essential information is missing, I excuse myself as it is not at all my field of work and I am doing this to be able to use a captor correctly.
Thanks in advance,

Respuestas (1)

Guillaume
Guillaume el 30 de Abr. de 2019
It's actually fairly easy to call .Net functions from matlab. No you don't need a header file for Net assemblies (these don't exist in the .Net world), header files are for non .Net dlls (that use Windows API instead of .Net).
Instead for .Net you make the assembly visible to matlab with NET.addAssembly, e.g
net.addAssembly('C:\somewhere\somefolder\yourdll.dll'); %assuming the assembly has not been added to the GAC, otherwise use the GAC name
Then you use more or less the same code as you'd use in VB.Net, C#, or Python to interact with the assembly. Just instantiate a class and call its methods and properties. If you show an example in any language of the code you want to use we can probably show you the matlab equivalent.
  6 comentarios
franco otaola
franco otaola el 2 de Mayo de 2019
okey, now I understand you better
if I do Test=NET.addAssembly('C:\Program Files (x86)\QIAGEN\FLDigital\clDigital.dll');
i have a "Test" assembly with as you said, it has differents properties ( assemblyHandle/Classes/Structures/Enums/GenericTypes/Interfaces/Delegates)
"One of these classes is called Detector, so when you do [...]" non is called Detector neither directly in Test neigther inside classes (Test.Classes), I think it is from that, that I wasnt following you.... i have all the classes different from what it was in C#
for example inside classes (Test.Classes) I have:('clDigital.Digital'/'clDigital.Digital+MethodDataEventArgs'/'clDigital.Digital+MethodDoneEventArgs'/'clDigital.Digital+ScanDataEventArgs'/'clDigital.Digital+ScanDataDoneEventArgs'/'clDigital.Digital+AutozeroDoneEventArgs')
is there anyway to see at least what the function gives me? if it is a double a matrix?
also then i can begin a function (that would be measure it) as i run the code and is connected to the pc, no?
is there anyway to explore more? as from the functions of C# I have they were evidents (what they were doing) but in the names I have no, E.G nothing is called temperature, or temp....
thanks
Guillaume
Guillaume el 2 de Mayo de 2019
I probably had a momentary case of blindness. Indeed, the original code was:
Digital Detector = new Digital();
The class name is therefore Digital. So the construction in matlab is
example = clDigital.Digital;
methodsview or methods with the '-full' option will allow you to see all the methods with all their input and output arguments (translated to matlab types):
methodsview('clDigital.Digital'); %displays in a an window
methods('clDigital.Digital', '-full'); %displays at the command prompt
Whatever function would allow you to change the frequency will be a method of that Digital class. The other classes listed in that assembly are just to encapsulate event data. It is also possible that the frequency is a property of the object:
properties('clDigital.Digital'); %displays at the command prompt. There's no pop-up equivalent.

Iniciar sesión para comentar.

Categorías

Más información sobre Call Web Services from MATLAB Using HTTP en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by