VirtualBench

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with analog channels measurements using VirtualBench and Python

Solved!
Go to solution

Dear all,
I try to automate VirtualBench measurements using Python application in order to measure 2 analog channels simultaneously. I work with library found on GitHub:

https://github.com/armstrap/armstrap-pyvirtualbench

,which is recommended by NI examples.

I’ve prepared a code, which based on the example from GitHub, working perfectly with only one channel activated. The problem occurs when I’m trying to activate 2 channels and make a parallel measurement. Both channels are activated for sure, because there is a feedback form “query_enabled_analog_channels()” function but “read_analog_digital_u64()” function give an error:

Error/Warning 374309 occurred

NI-VirtualBench: Not enough memory was provided to complete the operation.

To activate channels I use “configure_analog_channel()” witch different parameters:
One channel version:

mso.configure_analog_channel('VB8054-3159FB1/mso/1', True, 10, 0, 10, 1)

Two channel version:
mso.configure_analog_channel('VB8054-3159FB1/mso/1:2', True, 10, 0, 10, 1)

Do you have any ideas how to solve this problem? (Python code is attached below):

 

python codepython code

 

 

 

0 Kudos
Message 1 of 6
(4,244 Views)

Hi!

 

Would you also add the stack trace? I want to know which line(s) from pyvirtualbench are failing.

 

If you have a C/C++ compiler available, would you try the MSO sample? (here is a getting-started post that describes a Visual Studio IDE)

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)
0 Kudos
Message 2 of 6
(4,180 Views)

Hi JoeFriedchicken,
Here is a stack trace:

stack_trace.png

Also interesting fact is: when I run code, both channels are captured. It is possible to check that with VirtualBench application. After python script run and error occurred VirtualBench application looks like:

vb_app_screenshot.png

I don’t use C/C++, so I have no compiler installed, but if you don’t have any idea how to solve the problem with given information, I will configure C/C++ and try to run the example written with C.

Message 3 of 6
(4,166 Views)

Thanks for both screenshots! My recommendation is to use the latest version of pyvirtualbench.

 

My hypothesis from the stack trace is that the version of pyvirtualbench you're using is too old for your device.

 

The current master for the package doesn't raise an exception on line 1474, but it did when the library only supported the 8012 model (click the "Load diff" link to see) but not the 8054 you have.

JoeFriedchicken_0-1583944160799.png

 

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 4 of 6
(4,156 Views)
Solution
Accepted by lukasiewicz_pat

Good point JoeFriedchicken, I was using old version of the library. I had updated it and new error occurred, caused by collapse_channel_string():

new_lib_1.png

Collapse_channel_string() function is needed only for debugging purposes, so I erased it and old problem came back:

new_lib_2.png

In the next step, I modified pyvirtualbench.py file (I commented problematic lines)…

pyvirtualbench_change.png

… in order to saw if read_analog_digital_u64() function give some return and it does. I received list with 2 channels captured which looked like:

[Channel11, Channel21, Channel12, Channel22, Channel13, Channel23, … ]

Separated and plotted channels are below:

Figure_1.png

What is interesting sampling frequency correspond to configured value. I set f=200kHz and it is for sure this value because blue sine wave has frequency 50Hz and one period contains 4000 samples but acquisition time is two times shorter than configured value. I set Ta=0.08[s], and Python app receive only 0.04[s]. For comparison VirtualBench app captured 0.08[s]:

vb_app_screenshot2.png

For me solution is satisfactory because I need to measure phase difference for two sine waves but probably the library contains some error.

0 Kudos
Message 5 of 6
(4,135 Views)

@lukasiewicz_pat wrote:

 

The old problem came back (not enough memory)

 

In the next step, I modified pyvirtualbench.py file (I commented problematic lines) in order to see if read_analog_digital_u64() function give some return and it does.

 

but acquisition time is two times shorter than configured value. I set Ta=0.08[s], and Python app receive only 0.04[s]. For comparison VirtualBench app captured 0.08[s].


Well, the library did say that it didn't have enough memory to service the call, so I would expect a partial read 😛

 

If you only want the analog channels, then maybe you don't need also ask for the digital channels. Perhaps read_analog doesn't have the same misbehavior, but certainly it seems like this library hasn't been fully tested with this model.

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 6 of 6
(4,124 Views)