Using NI-VIsa in Matlab without Instrument Control Toolbox

10 ビュー (過去 30 日間)
Simon
Simon 2024 年 10 月 2 日
回答済み: Simon 2024 年 10 月 3 日
I am trying to establish a Visa session in Matlab without the Instrument Control Toolbox.
Either via COM-Interface or .NET reference. However neither seems to work.
I tried creating COM-Servers with the same DLLs that are used in MS Excel to create a Visa Session (GlobMgr.dll and BasFormIO.dll). I have tried every ProgID i could find in the DLLs but none works. Because every time I run the file Matlab just crashes, logging Access violation detected at "Time I ran the file". However, if i try to create a COM-Server of an own created object it works fine.
So maybe i can't create COM-Interfaces from DLLs or I use the wrong ProgIDs?
visaObj = actxserver('VISA.GlobalRM');
formIO = actxserver('VISA.BasicFormattedIO');
As for the .NET references I added the Ivi.Visa DLL which should already add all dependencies it needs with it. Matlab even tells me Assembly Ivi.Visa.Interop has alread been added from Ivi.Visa.Interop.dll when i try to add it too.
asm1 = NET.addAssembly('C:\Windows\assembly\GAC_MSIL\Ivi.Visa\7.2.0.0__a128c98f1d7717c1\Ivi.Visa.dll');
asm2 = NET.addAssembly('C:\Program Files\IVI Foundation\VISA\VisaCom64\Primary Interop Assemblies\Ivi.Visa.Interop.dll');
I can import the namespaces I need which would be.
import Ivi.Visa.*
import NationalInstruments.Visa.*
import Ivi.Visa.interop.*
import NationalInstruments.Common.*
But as soon as I try to use functions from them Matlab says "Error using Ivi.Visa.Interop.ResourceManager: No constructior 'Ivi.Visa.Interop.ResourceManager' with matching signature found."
rm = ResourceManager();
Which is odd because obviously it understood, that the resource manager is in the Ivi.Visa.Interop namespace.
Has anyone encountered a similar issue and managed to fix it?
  1 件のコメント
Walter Roberson
Walter Roberson 2024 年 10 月 2 日
Complete guess:
Maybe the ResourceManager call needs to be passed a parameter?

サインインしてコメントする。

回答 (1 件)

Simon
Simon 2024 年 10 月 3 日
I figured out the .NET part:
Don't make an instance of the resource manager. Instead directly open a session like so:
session = GlobalResourceManager.Open("YourResource");
Also you only have to load the Ivi.Visa assembly and don't need to import the namespaces. Then you can read and write with
session.RawIO.Write()
session.RawIO.ReadString()
However I still have not figured out the correct ProgId to implement the same functionality via COM.

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by