17
$\begingroup$

I would like to use Mathematica 9 for to acquire data from a Measurement Computing (MC) USB-201 analog to digital (and other) device for classroom demonstration. I do not have a budget to buy LabView and link Mathematica with it to accomplish what I would like to.

Within Mathematica I have tried using Manipulate to see if I can detect a signal (anything) from this board (excited artificially with a variable 0-5V source). So far, I do not see any changes indicating I am communicating with this equipment.

Has anyone done something like this? Do I need a driver, and if so, where do I get it?

Clearly, I am not a DAQ expert. I need someone to speak slowly and distinctly so I can understand them.

Thank you.

$\endgroup$
  • $\begingroup$ Use the C++ library Measurement Computing is distributing ? $\endgroup$ – Sektor Jan 18 '14 at 22:03
  • $\begingroup$ @Sektor Why the question mark... Anyway, the obvious follow-up is how? This is what the OP wants to know. $\endgroup$ – C. E. Jan 18 '14 at 23:00
  • $\begingroup$ Can you elaborate on what you used inside your Manipulate? $\endgroup$ – bobthechemist Jan 18 '14 at 23:10
  • $\begingroup$ Have you seen the device interface? And this guide? $\endgroup$ – carlosayam Jan 19 '14 at 0:13
  • $\begingroup$ @Pickett A suggestion. Well, he did not specify ... $\endgroup$ – Sektor Jan 19 '14 at 0:26
12
$\begingroup$

If this device support NI-VISA (as I understood from your reference to LabVIEW), then you can use following way:

  1. Install the VISA engine (available at National Instruments' web-site)
  2. Use the following code.

    Needs["NETLink`"]
    
    lib = LoadCOMTypeLibrary[
    "C:\\Program Files (x86)\\IVI \Foundation\\VISA\\VisaCom\\GlobMgr.dll"]
    mgr = NETNew["Ivi.Visa.Interop.ResourceManagerClass"];
    OSA = NETNew["Ivi.Visa.Interop.FormattedIO488Class"];
    
    devs = mgr@FindRsrc["?*instr"];
    devdescr = {};
    Do[
    OSA@IO = mgr@Open[devs[[i]]];
    OSA@WriteString ["*IDN?"];
    id = OSA@ReadList[];
    AppendTo[devdescr, id[[2]]],
    {i, 1, Length[devs]}];
    
    If[devs == $Failed, devs = {"empty"}; devdescr = {"NoDeviceDetected"}];
    

The first string enables NETLink and the next three strings load the VISA global manager and create an object named OSA.

The next block asks the VISA global manager for connected devices and gives you a list, devs, with their inner descriptions, devdescr.

You can connect to the needed device using the command:

OSA@IO = mgr@Open[devs[[x]]]

Where x is number in the list... After this, you can send any commands to a device using

OSA@WriteString ["<command>"]

And read answers using:

OSA@ReadList[]

Or

OSA@ReadString[]

The list of supported commands should be in the user manual for your device.

$\endgroup$
  • 1
    $\begingroup$ Shouldn't "\\IVI \Foundation\\" be "\\IVI\\Foundation\\"? $\endgroup$ – Peter Mortensen Jun 3 '15 at 22:54
  • $\begingroup$ In "Needs["NETLink`"]", what does the ` do (after the "k")? $\endgroup$ – Peter Mortensen Jun 3 '15 at 22:55
  • $\begingroup$ @Peter, the backtick denotes the context of the functions about to be loaded by Needs[]; in this case, NETLink` . $\endgroup$ – J. M. will be back soon Jun 3 '15 at 23:20
  • $\begingroup$ In the line "devs = mgr@FindRsrc["?*instr"];" I get this error: "A .NET exception occurred: \ System.Runtime.InteropServices.COMException (0x8002000B): HRESULT = \ 8002000b at Ivi.Visa.Interop.ResourceManagerClass.FindRsrc(String expr).". What may be wrong? $\endgroup$ – LeoRon7 Nov 30 '15 at 21:53
  • $\begingroup$ @LeoRon7, Did you check the mgr value? Try NETTypeInfo[mgr], do it has such method as FindRsrc? If it has then try mgr@FindRsrc["?*"] Will it show you any connected instruments? $\endgroup$ – Rom38 Dec 1 '15 at 15:10
1
$\begingroup$

Thanks, it works fine.

But the following string had to be corrected in my case: "C:\Program Files (x86)\IVI \Foundation\VISA\VisaCom\GlobMgr.dll"] by: "C:\Program Files (x86)\IVI Foundation\VISA\VisaCom\GlobMgr.dll"]

And I did not receive a device number, so I guessed 1 and that was the right number.[listing in my case

$\endgroup$
  • 1
    $\begingroup$ Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review $\endgroup$ – m_goldberg Apr 23 at 15:31
  • $\begingroup$ @m_goldberg Isn't this more than a "thank you?" It seems to contain additional information required to solve the problem on this user's system $\endgroup$ – Mr.Wizard Apr 23 at 22:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.