05-26-2009 06:37 PM
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.
05-27-2009 01:19 AM
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.
05-27-2009 08:49 AM
05-27-2009 08:50 AM
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;
}
05-27-2009 09:02 AM
05-27-2009 01:44 PM
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.
05-28-2009 06:51 AM
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
06-09-2009 04:06 PM
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!