LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I communicate with a USB device using Labwindows 6.0?

Hi all,

I am kind of new to programming, but was given the task of communicating with a USB device using Labwindows 6.0, but the current code is for serial communication. I was able to get my USB device connected and showing up as a Visa, but I have no clue what to do next. Thanks for the help.

 

 

0 Kudos
Message 1 of 8
(5,241 Views)

If you see your device as a VISA resource, then you can use alla the VISA functions (see Library >> VISA to browse into the complete list).

With this functions you can read, write, flush the buffers, list the devices, ...

As a starting point you can substitute all the old serial functions with the VISA ones.

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 2 of 8
(5,230 Views)
Ok, I can get the device to work in VISA Interactive Control, but not using the libraries or sampel code I found. I keep getting an error for the instrument descriptor which I am copying from NI-VISA as USB0::0x10C4::0xEA60::0001::RAW. The error is an undeclared indentifier.
0 Kudos
Message 3 of 8
(5,216 Views)

This is the sample code I am using:

 

#include "visa.h"

int main(void)
{
ViStatus status;
ViSession defaultRM, instr;
/* Open Default RM */
status = viOpenDefaultRM(&defaultRM);
if (status < VI_SUCCESS) {
/* Error Initializing VISA...exiting */
return -1;
}
/* Access other resources */
status = viOpen(defaultRM, USB0::0x10C4::0xEA60::0001::RAW, VI_NULL, VI_NULL, &instr);
/* Use device and eventually close it. */
viClose(instr);
viClose(defaultRM);
return 0;
}

0 Kudos
Message 4 of 8
(5,215 Views)
Oh I think I got it, I forgot the "" around the call. But I am sure more questions will follow 🙂
0 Kudos
Message 5 of 8
(5,213 Views)

Does anyone have concrete examples for communication? I can open and close a session, but I cannot even get the device's manufacturer name without errors or timeouts.

 

 

0 Kudos
Message 6 of 8
(5,191 Views)

Redseal94 wrote:

Does anyone have concrete examples for communication?


Concrete examples depend on devices...

This tutorial is a really useful starting point: I would suggest you this steps

  1. try to successfully communicate with your device using VISA through MAX
  2. try to give the same commands through CVI
Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 7 of 8
(5,175 Views)

Hi! 

 

I've attached an example that I downloaded from NI and modified to work with

my Tektronix TDS2024B digital scope via USB port.  The original code was written

to use GPIB connection for the instrumental control.  As you can see in the code,

I simply change the device ID from "GPIB::11::INSTR" to 

"USB0::0x0699::0x036A::C034102::INSTR" as it is assigned in the NI-MAX.

Works seamlessly in LabWindows 6.0, but you do need to install NI VISA 4.2 and

NI IVI Compliance Package 3.1 first.  Hope this example help!

 

0 Kudos
Message 8 of 8
(5,090 Views)