VirtualBench

cancel
Showing results for 
Search instead for 
Did you mean: 

VB python control errors

Hi,

 

I am using a NI module supplied with the virtual bench to try to control the power through python. I use the code beneath, but I get the error: 

Error/Warning -375905 occurred
NI-VirtualBench: Invalid channel name.
Configuration: Power Supply Channel
Requested Value: 獰⬯㔲V㔈౻
Allowed Values: ps/+6V, ps/+25V, ps/-25V

 

I am using the example's channel name, and the requested value in the error does not relate to it as far as I can tell.

Has anyone come across this before or know a solution?

 

Thanks a lot,

Matt

 

 

from pyvirtualbench import PyVirtualBench, PyVirtualBenchException, Waveform

try:
# Power Supply Configuration
channel = "ps/+25V"
voltage_level = 24.0
current_limit = 0.5

virtualbench = PyVirtualBench('VB8012-31373F7')
ps = virtualbench.acquire_power_supply()

ps.configure_voltage_output(channel, voltage_level, current_limit)
ps.enable_all_outputs(True)

# for i in range(10):
# voltage_measurement, current_measurement, ps_state = ps.read_output(channel)
# print("Measurement [%d]: %f V\t%f A\t(%s)" % (i, voltage_measurement, current_measurement, str(ps_state)))

ps.release()

except PyVirtualBenchException as e:
print("Error/Warning %d occurred\n%s" % (e.status, e))

finally:
virtualbench.release()

0 Kudos
Message 1 of 5
(4,879 Views)

Matt,

 

Which version of python are you using (python2 or python3)?  If you're using python3, I think I may see the issue because it's something I've run into personally when migrating from python2 to python3.  The underlying C API is expecting a traditional C string (char *) data type, but in python3, 'all strings are sequences of Unicode characters' (which is a fancy way of saying it doesn't use the same encoding).  You can read more about the string datatype in python3 http://www.diveintopython3.net/strings.html .

 

If my theory is correct here, you should be able to fix this error by changing the assignment to
channel = "ps/+25V".encode('ascii')

 

----------------------------------------------------

Daniel Larsen

Digital Hardware Engineer

National Instruments

 

Message 2 of 5
(4,860 Views)

Hi Daniel,

 

Thanks for the help. Sadly im using python2.7 for this, and using an ascii encoding didnt help, still the same error.

Would it be better to try it in python3 do you think?

 

Matthew

0 Kudos
Message 3 of 5
(4,855 Views)

Sorry to hear your issue isn't resolved yet, though I still suspect it's a string encoding issue.  Now that I look closer, this page actually specifies that you should be using python >= 3.4, so switching might just work around the problem.

https://github.com/armstrap/armstrap-pyvirtualbench/blob/master/README.md .

 

----------------------------------------------------

Daniel Larsen

Digital Hardware Engineer

National Instruments

0 Kudos
Message 4 of 5
(4,847 Views)

I installed 3.4 and tried that, but still the same error sadly. I will try to automate it with Labview I think.

Thanks for the help.

0 Kudos
Message 5 of 5
(4,773 Views)