# Data acquisition from a Measurement Computing USB device

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.

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

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"]

"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?"];
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>"]


OSA@ReadList[]


Or

OSA@ReadString[]


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

• Shouldn't "\\IVI \Foundation\\" be "\\IVI\\Foundation\\"? – Peter Mortensen Jun 3 '15 at 22:54
• In "Needs["NETLink"]", what does the  do (after the "k")? – Peter Mortensen Jun 3 '15 at 22:55
• @Peter, the backtick denotes the context of the functions about to be loaded by Needs[]; in this case, NETLink . – J. M. will be back soon Jun 3 '15 at 23:20
• 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? – LeoRon7 Nov 30 '15 at 21:53
• @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? – Rom38 Dec 1 '15 at 15:10

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.[

• 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 – m_goldberg Apr 23 at 15:31
• @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 – Mr.Wizard Apr 23 at 22:40