Controlling Rigol DP832A PSU with python - Page 1
Forum section: electronics / testgear

author: kimmok
author_rank: Newbie
timestamp: September 01, 2017, 12:09:55 pm
content: Trying to build python control for Rigol DP832A PSU with x86 tablet running windows10.(done before:-got it working with Win7+NI-VISA+C#-got it working on x86 tablet with Win10 +NI-VISA+pyvisa+python2)Now my goal is to get it working by using opensource tools on Win10.So far:-clean Win10 installation-installed python2-7.x-cmd/ python -m pip install -U pip-cmd/ pip install pyusb-cmd/ pip install pyvisa-cmd/ pip install pyvisa-pyThen python nagged about no backend... (python -m visa info)so,I:-installed usblib for DB800 via zadig GUII should now have all things in place.did in python console:>>> import visa>>> resources = visa.ResourceManager('@py')>>> print(resources.list_resources())(u'USB0::6833::3601::DP8B185350299::0::INSTR',)So far all works as expected, Rigol is seen on the USB connection.But this fails:>>> rigolpsu = resources.open_resource('USB0::6833::3601::DP8B185350299::0::INSTR')Traceback (most recent call last):File "<stdin>", line 1, in <module>File "C:\Python27\lib\site-packages\pyvisa\highlevel.py", line 1644, in open_resourceres.open(access_mode, open_timeout)File "C:\Python27\lib\site-packages\pyvisa\resources\resource.py", line 203, in openself.session, status = self._resource_manager.open_bare_resource(self._resource_name, access_mode, open_timeout)File "C:\Python27\lib\site-packages\pyvisa\highlevel.py", line 1601, in open_bare_resourcereturn self.visalib.open(self.session, resource_name, access_mode, open_timeout)File "C:\Python27\lib\site-packages\pyvisa-py\highlevel.py", line 191, in opensess = cls(session, resource_name, parsed)File "C:\Python27\lib\site-packages\pyvisa-py\sessions.py", line 184, in __init__self.after_parsing()File "C:\Python27\lib\site-packages\pyvisa-py\usb.py", line 176, in after_parsingself.parsed.serial_number)File "C:\Python27\lib\site-packages\pyvisa-py\protocols\usbtmc.py", line 236, in __init__self.usb_dev.set_configuration()File "C:\Python27\lib\site-packages\usb\core.py", line 869, in set_configurationself._ctx.managed_set_configuration(self, configuration)File "C:\Python27\lib\site-packages\usb\core.py", line 102, in wrapperreturn f(self, *args, **kwargs)File "C:\Python27\lib\site-packages\usb\core.py", line 148, in managed_set_configurationself.backend.set_configuration(self.handle, cfg.bConfigurationValue)File "C:\Python27\lib\site-packages\usb\backend\libusb0.py", line 493, in set_configuration_check(_lib.usb_set_configuration(dev_handle, config_value))File "C:\Python27\lib\site-packages\usb\backend\libusb0.py", line 431, in _checkraise USBError(errmsg, ret)usb.core.USBError: [Errno None] libusb0-dll:err  could not set config 1: win error: The parameter is incorrect.((my third day using python, so, sorry if it's something obvious...))

author: Dalun
author_rank: Newbie
timestamp: September 01, 2017, 06:13:22 pm
content: Your >>> print(resources.list_resources())(u'USB0::6833::3601::DP8B185350299::0::INSTR',)Your >>> rigolpsu = resources.open_resource('USB0::6833::3601::DP8B185350299::0::INSTR')The 'u' before the string in open_resource('USB... is missingTry>>> rigolpsu = resources.open_resource(u'USB0::6833::3601::DP8B185350299::0::INSTR')This is one of the string handling things of Python 2, it's to do with strings and bytes being the same in Python 2 and thankfully separate types in Python 3. seehttps://docs.python.org/3/howto/pyporting.html#text-versus-binary-dataHave you considered trying Python 3 as "Short version: Python 2.x is legacy, Python 3.x is the present and future of the language ":https://wiki.python.org/moin/Python2orPython3PyVISA & PyVISA-Py work well in Python 3

author: kimmok
author_rank: Newbie
timestamp: September 04, 2017, 07:25:11 am
content: With u'USB0::6833::3601::DP8B185350299::0::INSTR'->'int' object has no attribute 'interface_type'+I'll set another setup to try with python3, etc...

author: bd139
author_rank: Super Contributor
timestamp: September 04, 2017, 09:56:54 am
content: The first thing I've learned playing with my DG1022Z/DG1054Z is to do this via ethernet / TCP and use SCPI. You can cut and paste a simple line based TCP client and talk to it like that. Much easier than even getting VISA working with USB. I crapped an hour trying to get it to talk to my DG1022Z. The protocol is easier to debug as you can drive it with telnet as well and do any exploration.

author: RoGeorge
author_rank: Super Contributor
timestamp: September 04, 2017, 10:15:33 am
content: Maybe this will help (no VISA or Rigol drivers required):https://hackaday.io/project/6857-master-your-rigol-from-command-lineAnd some example in Python (continuously logging the values measured by DP832):https://github.com/RoGeorge/DP832_charger_logger

author: kimmok
author_rank: Newbie
timestamp: September 04, 2017, 01:39:40 pm
content: Thank you so far.I got same errors with python3.Next.I try to do control over LAN.Meanwhile:Would you guys recommend DP832A (and other rigol products) for high reliability needing robustness testing?I've found Monsoon Inc PowerMonitor pretty good for the price.(done hunderds of thousands test cycles with it & very little problems)But it would be nice to get wider voltage range as I need to test 4V, 12V and 24V products.

author: RoGeorge
author_rank: Super Contributor
timestamp: September 04, 2017, 02:11:53 pm
content: Quote from: kimmok on September 04, 2017, 01:39:40 pmNo, I do not recommend Rigol for high reliability. I know nothing about Inc PowerMonitor, so I can not tell if PowerMonitor is better or worst than Rigol.All I can tell is that Rigol is not famous for being reliable. They are famous for being cheap and hack-able (you can illegally unlock software options for free), but in my experience Rigol was not reliable, especially for automated testing. In my experience it happened that my DP832 had restarted once while I was logging the data, and the closed control loop that I put for fun in another project (https://rogeorge.wordpress.com/2016/09/23/zero-parts-thermostated-soldering-station/) in order to control the temperature of a soldering iron with a Rigol DP832 power source and a DS1054Z oscilloscope sometimes hanged. So, definitely not reliable. Also, Rigol firmware was buggy for years, and it still is, especially for SCPI control.

author: bd139
author_rank: Super Contributor
timestamp: September 04, 2017, 02:16:05 pm
content: Agreed.I only use it because it's cheap and adequate for my needs. I'd probably hit Keysight if I wanted anything reliable and not necessarily new product lines.

author: kimmok
author_rank: Newbie
timestamp: September 05, 2017, 06:30:49 am
content: Thanks again.We are anyway getting "high voltage powermonitor" to see if it's as good as their previous (<5V) model.HVolt model can cover our needs up to 15V.Monsoon Inc has some(~ok) support and in cases when powermonitor "hangs", we have SW means to automatically recover it and continue. It uses USB control interface and it's driver robustness seem to depend on control PC's windows, .NET and setup.(and yes USB in general is crappy/joke as a "standard" etc)(Also Powermonitor needs extra effort to be usable from python and non-windows control PCs....am I dreaming of RPis running a farm of test setups...?)With Rigol, our evaluation time-frame has now passed and I think we will not get these until there is more pressing need to measure 24V devices.

author: bd139
author_rank: Super Contributor
timestamp: September 05, 2017, 07:23:21 am
content: I wouldn't consider a Raspberry Pi to be reliable either.HP enterprise kit is. That means Z/Elite series workstations/desktops.

author: kimmok
author_rank: Newbie
timestamp: September 05, 2017, 07:36:29 am
content: For some reason pyvisa-py is not able to find RIGOL from LAN interface "automagically".But this works...QuoteUsing pyvisa-py & python2.

author: _joost_
author_rank: Contributor
timestamp: March 08, 2018, 03:43:00 pm
content: Code:inst = rm.open_resource("TCPIP::192.168.1.5")Thats not very automagic either; you provide a hard coded address. Instead, you can use multicast discovery as implemented in the zeroconf python package. Have a look at this repo for some ideas how that is done:https://github.com/pklaus/ds1054z