VirtualBench

cancel
Showing results for 
Search instead for 
Did you mean: 

Can VirtualBench be programmed in C (Or anything other than LV)

Here's my fairly basic project.  If anyone can run it using Visual Studio 2013 and figure out why it reports the LINK2019 error, I'll really appreciate it.  Both the nivirtualbench.h and the nivirtualbench.lib filtes are present in the same folder as proj1.cpp and the loader should have no difficulty picking them up.

 

Thanks!

0 Kudos
Message 21 of 32
(4,260 Views)

I created the project again.  The nivirtualbench.h and the nivirtualbench.lib (lib64 version since OS is 64-bit) are placed in the same folder as the proj.cpp file.  In visual studio, the header file is included via the explorer.  The .lib file is included via 'References'.  This time poject compiles. 

 

However, there is a runtime error because the deviceName = "virtualbench" is not recognized (VS yields a descBuf = "NI-VirtualBench - Unable to find device"). 

 

At least this is a runtime error 🙂

 

Question:  How does one determine the device name of the particular VB that is plugged into the USB port using Windows 8.1?

 

Thanks.

0 Kudos
Message 22 of 32
(4,251 Views)

My VirtualBench is called "VB8012-3064448".  Found this by launching the Ni-VirtualBench API and selecting 'About' which provides this name in the "Device" filed.  No runtime errors and code works as expected. 

 

0 Kudos
Message 23 of 32
(4,247 Views)

@ajog wrote:

Here's my fairly basic project.  If anyone can run it using Visual Studio 2013 and figure out why it reports the LINK2019 error, I'll really appreciate it.  Both the nivirtualbench.h and the nivirtualbench.lib filtes are present in the same folder as proj1.cpp and the loader should have no difficulty picking them up.

 

Thanks!


It looks like you got it figured out, but I didn't see the include or library directories set up in your project that I could tell.  From the C Reference help:

 

By default, the VirtualBench library is installed to Program Files\National Instruments\Shared\ExternalCompilerSupport\C\lib32\msvc. The 64-bit version of the library is installed in the lib64 directory.

The nivirtualbench.h header file is installed to Program Files\National Instruments\Shared\ExternalCompilerSupport\C\include\nivirtualbench. This file contains function descriptions and error enumeration values.

 

You also need to add the library nivirtualbench.lib.

------
Zach Hindes
NI R&D
0 Kudos
Message 24 of 32
(4,240 Views)

I work also with nivirtualbench library to control the device. The documentation is in my opinion not sufficient. I miss the parameter description for the functions. As example niVB_Dig_Initialize takes const char* lines as parameter. Which lines are meant? What is the string format?

 

Regards

0 Kudos
Message 25 of 32
(4,060 Views)

gludev wrote:

 

I miss the parameter description for the functions. As example niVB_Dig_Initialize takes const char* lines as parameter. Which lines are meant? What is the string format?


You have a few resources at your disposal:

  • The VirtualBench help [1] lists the terminal names. The GPIO lines are named "dig/N", where N is the line number.
  • The VirtualBench C Examples [2]

 

[1] NI VIrtualBench Help

C:\Users\Public\Documents\National Instruments\VirtualBench Documentation\VirtualBench Help

http://zone.ni.com/reference/en-XX/help/371526B-01/vbhelp/diopinout/

 

[2] VirtualBench ANSI C Examples

C:\Users\Public\Documents\National Instruments\VirtualBench ANSI C Examples

Joe Friedchicken
NI Configuration Based Software
Get with your fellow OS users
[ Linux ] [ macOS ]
Principal Software Engineer :: Configuration Based Software
Senior Software Engineer :: Multifunction Instruments Applications Group (until May 2018)
Software Engineer :: Measurements RLP Group (until Mar 2014)
Applications Engineer :: High Speed Product Group (until Sep 2008)
Message 26 of 32
(4,051 Views)

Thank your for the name convention resource. It helps a little. niVB_Dig_Initialize seems to be different compares to other initialization functions because it takes one parameter more. Which string should be used to define channels 1 and 5 as output? Is it really necessary to define the outputs at this place, or can it be defined in the niVB_Dig_Write function?

0 Kudos
Message 27 of 32
(4,048 Views)

gludev wrote:

 

niVB_Dig_Initialize seems to be different compares to other initialization functions because it takes one parameter more. Which string should be used to define channels 1 and 5 as output?


There is a normal expression syntax for describing channels [1]. In your example, you want to use "dig/1,dig/5".

 


gludev wrote:

 

Is it really necessary to define the outputs at this place, or can it be defined in the niVB_Dig_Write function?


Yes, the driver must reserve the output lines so that your session has exclusive control. Reading the lines never requires reservation since it doesn't change the instrument's state.

 

[1] What is the Syntax for Physical Channel Strings in DAQmx?

http://digital.ni.com/public.nsf/allkb/9A2AF5E10E0C893386256FE8006807DF

Joe Friedchicken
NI Configuration Based Software
Get with your fellow OS users
[ Linux ] [ macOS ]
Principal Software Engineer :: Configuration Based Software
Senior Software Engineer :: Multifunction Instruments Applications Group (until May 2018)
Software Engineer :: Measurements RLP Group (until Mar 2014)
Applications Engineer :: High Speed Product Group (until Sep 2008)
Message 28 of 32
(4,034 Views)

If I use digital IO as a trigger for my measurement the VertualBench report following trigger point:  'timestamp': (1433170387L, 0.199386852), 'T0': (-2082844800L, 0.0). Why is T0 negative?

0 Kudos
Message 29 of 32
(3,901 Views)

The function niVB_MSO_ReadAnalogDigitalU64 takes uint64_t* digitalData as parameter. Which elements does digitalData have and at which positions?

 

0 Kudos
Message 30 of 32
(3,878 Views)