Author Topic: Automated DP832 Calibration  (Read 16236 times)

0 Members and 1 Guest are viewing this topic.

Offline Gandalf_SrTopic starter

  • Super Contributor
  • ***
  • Posts: 1729
  • Country: us
Automated DP832 Calibration
« on: March 17, 2020, 10:35:35 am »
This thread is planned to be a step by step guide to calibrating a Rigol DP832(A) Power Supply using different languages such as Python and Java.  I managed to do this successfully using my Keysight 34461A meter but my Python environment is not right and I hope to figure out the correct way to make it all work and share that with the forum.

This is the best and latest method using Python & Pycharm, it worked for me.

There are problems associated with Windows fighting the Python environment on a security basis, it has been suggested that Python can be run in the (free) Windows Visual Studio, I will try this out.

This first post will get updated periodically to hold the latest, proven instructions on how to set it all up properly.
« Last Edit: March 19, 2020, 03:36:26 pm by Gandalf_Sr »
If at first you don't succeed, get a bigger hammer
 
The following users thanked this post: tangram, Daruosha, Simon_RL

Offline Gandalf_SrTopic starter

  • Super Contributor
  • ***
  • Posts: 1729
  • Country: us
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #1 on: March 17, 2020, 11:04:06 am »
So the Rigol DP832 - Firmware List and Bugs thread was getting clogged up with the info on calibration with a competition between a Java solution (which erased my DP832 Cal and then crashed) and a Python solution.  In the end I made the Pythin solution work but there are many pitfalls and I ended up with a badly installed Python program that would need setup changes every time I opened up Python - I'm trying to fix this and then put the results in the first post of the thread.  My setup is specifically using a Keysight 34461A 6.5 digit multimeter as the accurate reference meter but, maybe we can figure out how to adapt it to other meters too?  All of what follows is my understanding so, if I'm wrong, please chip in and correct me and I will edit the posts to be as accurate as possible - in th eend, I want to make the first post the go-to, tested instructions on how to set things up.

So let's look at the basics:

1. Python is an interpreted language which means that it doesn't compile to a .exe file that can run natively on a PC, instead it needs an environment to run in that takes a line at a time and translates that to actions such as sending and receiving signals to/from remote devices.

2. We need a user-friendly interface and the de facto choice is PyCharm which is an Integrated Development Environment (front end) for Python but PyCharm doesn't include the interpreter.

This is the first gotcha as to why my environment is dodgy.... There's a version of Python offered by Microsoft through the search menu but it doesn't work properly with PyCharm - it seems MS in their bid to protect us stop programs being able to do simple stuff like have us make changes to the code.  To get around this, PyCharm goes to great lengths to create a virtual environment by copying the Python interpreter into a virtual environment which we can add extra stuff to without upsetting the MS security bot that lives inside every Windows system.

So here's the first steps to get the environment set up properly:

1. Go to www.python.org and download Python (3.8.2 at time of writing) taking all the default settings.
2. Go to www.jetbrains.com/pycharm/ and download the (free) communty version of PyCharm taking all the default settings.

To be continued
« Last Edit: March 17, 2020, 11:13:24 am by Gandalf_Sr »
If at first you don't succeed, get a bigger hammer
 
The following users thanked this post: klamath

Offline Gandalf_SrTopic starter

  • Super Contributor
  • ***
  • Posts: 1729
  • Country: us
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #2 on: March 17, 2020, 11:18:59 am »
It seems clear that, what is wrong with my Python project is that it isn't running in a virtual environment that is created and maintained by PyCharm.  If I create a new project fro PyCharm's opening window, the virtual environment is created correctly and I can close PyCharm and reopen and everything is the same as I left it.

So the thing I need help on right now is how to move the files supplied by JDubU to the newly created environment.
If at first you don't succeed, get a bigger hammer
 

Offline JDubU

  • Frequent Contributor
  • **
  • Posts: 438
  • Country: us
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #3 on: March 17, 2020, 12:55:06 pm »
To establish a default environment for projects in PyCharm:

In PyCharm, select menu item:      File > Other Settings > Settings for New Projects...

You can make whatever changes or additions you want there but, at least, click on Project Interpreter in the left column and select the (already installed) default version of Python that you want to use.
When you do that, it should show all of the add in packages that have been installed for that version of Python (e.g. python-ivi, python-vxi11, numpy).  If not, you can add them here using the '+' button on the top of the column on the right.

When opening an existing project, you need to select the folder that contains all of the project files (not the top level .py file).  This will let you open and view all of the files and any documentation that is associated with that project from within PyCharm.  They will appear in the left column of the PyCharm IDE.
 

Offline Gandalf_SrTopic starter

  • Super Contributor
  • ***
  • Posts: 1729
  • Country: us
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #4 on: March 17, 2020, 02:27:44 pm »
I'm working through this process and here's the notes I have so far...

PyCharm setup
   1. Download ivi project folder and place in C:\Users\ted\PycharmProjects folder
   2. I renamed the long file folder of "Python 3.x DP832 calibration - 34461A version" to "MyDP832Cal" so the full folder was…
   C:\Users\ted\PycharmProjects\MyDP832Cal\venv\Lib\site-packages\ivi\agilent
   3. Run up PyCharm and, from the front screen click the folder icon in the center
   4. Navigate to C:\Users\ted\PycharmProjects\MyDP832Cal and select the folder and click open
   5. It opens with what looks like a web page but you can click on the left side to open up the project explorer view (picture)
   6. Exited PyCharm and Ran up PyCharm and got edited project back (this is promising)
   7. Went to File>Settings and add Packages which all took
   except numpy which gives an error saying it needs Visual C++ vn xxx? But I think I already have that???
   8. So I exited PyCharm and went to a PowerShell where I was able to pip install numpy successfully
   9. At this point I updated the files at C:\Users\ted\PycharmProjects\MyDP832Cal\venv\Lib\site-packages\ivi\agilent
   10. Back into PyCharm and numpy is not one of the packages with my project and it still won't install

So I have a problem which looks like the Virtual environment can't see the Visual studio needed to install, any ideas?

[Edit] Maybe a reboot will fix this, I have to stop tinkering and do some work now.  Thanks for the help.
« Last Edit: March 17, 2020, 02:43:26 pm by Gandalf_Sr »
If at first you don't succeed, get a bigger hammer
 

Offline JDubU

  • Frequent Contributor
  • **
  • Posts: 438
  • Country: us
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #5 on: March 17, 2020, 03:32:24 pm »
I think there is a misunderstanding about the add in library packages. They are associated with the Python interpreter and not with an individual project.  Think of them as modifications of the Python interpreter.

At this point, I would recommend uninstalling everything and starting over with a clean installation of Python, PyCharm and project folders.

Installation sequence:

1) Install Python 3.8.  Do not change any default installation settings. 
    It should automatically be installed at: C:\Users\ted\AppData\Local\Programs\Python\Python38

2) Install PyCharm with its default installation settings.

3) Start PyCharm and set the default Python interpreter ( File > Other Settings > Settings for New Projects...) to Python 3.8 and verify that it shows the above installation path in the drop down box.

4) Use the '+' button to add python-ivi, python-vxi11 and numpy to the Python 3.8 interpreter.

5)In Windows, navigate to:    C:\Users\ted\AppData\Local\Programs\Python\Python38\Lib\site-packages\ivi\agilent
and copy/replace the three Keysight/Agilent specific DMM files

6) In PyCharm, open a clean version of the DP832 Calibration project folder.  It should contain only:

  calibrate,py
  README.md,
  cal folder
       __init__.py
       DP832Cal.py

anything else in the project folder or cal folder should be deleted.

7) Run calibrate.py the first time by right clicking on its name in the Project tree (left top column) and selecting:  'Run calibrate'  from the pop up menu.
After that, you can run it with the menu item: Run > Run 'calibrate'

Edit: Modified step 7 to simplify first run (auto creation of run/debug configuration parameters)
« Last Edit: March 18, 2020, 03:54:02 am by JDubU »
 

Offline Gandalf_SrTopic starter

  • Super Contributor
  • ***
  • Posts: 1729
  • Country: us
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #6 on: March 17, 2020, 05:30:38 pm »
Thanks, I'll try that later.
If at first you don't succeed, get a bigger hammer
 

Online skander36

  • Frequent Contributor
  • **
  • Posts: 704
  • Country: ro
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #7 on: March 17, 2020, 07:54:21 pm »
@GandalfSr - May you should have try MS Visual Studio Code as I said to you before . It is more straightforward than PyCharm . You dont need to reinstall packages on every project .
https://code.visualstudio.com/
« Last Edit: March 17, 2020, 08:20:51 pm by skander36 »
 

Online skander36

  • Frequent Contributor
  • **
  • Posts: 704
  • Country: ro
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #8 on: March 17, 2020, 08:20:03 pm »
Siglent SDM3065X owners.
Attached is the version of DP832 Automated Calibration script fork by @JDuBU for Python 3 with added snippets for changing from DMM DC Current an back to DC Voltage . It was tested with a Siglent DMM3065X but is should work also with 3045 and 3055 series .

You need a Python IDE (MS VisualCode - recomended , or PY-Charm) and following packages :
python-ivi
python-vxi11
numpy

For testing you should ensure that line 68 in file calibrate.py has value : update_calibration = False . After you are sure that simulation of calibration has been done succesfully you must edit line with: update_calibration = True and do a real calibration .
Remember : You do this on your own risk !

 
« Last Edit: March 19, 2020, 07:32:36 pm by skander36 »
 
The following users thanked this post: tautech, klamath

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6272
  • Country: ca
  • Non-expert
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #9 on: March 17, 2020, 09:08:20 pm »
@GandalfSr - May you should have try MS Visual Studio Code as I said to you before . It is more straightforward than PyCharm . You dont need to reinstall packages on every project .
https://code.visualstudio.com/

https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html

Quote
Reuse installed packages

Create a new virtual environment and install packages that you want to be used in other projects. Then you can specify this virtual environment as a project interpreter for the target project and all the needed packages will be available.
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Offline Gandalf_SrTopic starter

  • Super Contributor
  • ***
  • Posts: 1729
  • Country: us
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #10 on: March 17, 2020, 09:13:34 pm »
Thanks for all the suggestions, I'll try to get to this tomorrow.
If at first you don't succeed, get a bigger hammer
 

Offline Gandalf_SrTopic starter

  • Super Contributor
  • ***
  • Posts: 1729
  • Country: us
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #11 on: March 18, 2020, 12:07:54 am »
@GandalfSr - May you should have try MS Visual Studio Code as I said to you before . It is more straightforward than PyCharm . You dont need to reinstall packages on every project .
https://code.visualstudio.com/
So do you run Python inside MS Visual Studio?
If at first you don't succeed, get a bigger hammer
 

Offline typoknig

  • Regular Contributor
  • *
  • Posts: 103
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #12 on: March 18, 2020, 02:06:13 am »
1. Python is an interpreted language which means that it doesn't compile to a .exe file that can run natively on a PC, instead it needs an environment to run in that takes a line at a time and translates that to actions such as sending and receiving signals to/from remote devices.

Python scripts can be bundled into an EXE.  There are several modules that can do that.  The one I use is PyInstaller.
 

Offline tautech

  • Super Contributor
  • ***
  • Posts: 28136
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #13 on: March 18, 2020, 03:11:43 am »
Siglent SDM3065X owners.
Attached is the version of DP832 Automated Calibration script fork by @JDuBU for Python 3 with added snippets for changing from DMM DC Current an back to DC Voltage . It was tested with a Siglent DMM3065X but is should work also with 3045 and 3055 series .

You need a Python IDE (MS VisualCode - recomended , or PY-Charm) and following packages :
python-ivi
python-vxi11
numpy

For testing you should ensure that line 68 has value : update_calibration = False . After you are sure that simulation of calibration has been done succesfully you must edit line with: update_calibration = True and do a real calibration .
Remember : You do this on your own risk !
Cool thanks for this.
There has been something developed for SDM user adjustment at the factory and one of my customers is currently trialling it with his SDM3065X however at this time Siglent are nervous about releasing anything into the public domain should users not have accurate enough references for manual calibration.

Could I trouble you to post about this in the SDM3000 thread:
https://www.eevblog.com/forum/testgear/siglent-new-bench-dmm-sdm3055/
TIA
Avid Rabid Hobbyist
Siglent Youtube channel: https://www.youtube.com/@SiglentVideo/videos
 

Online skander36

  • Frequent Contributor
  • **
  • Posts: 704
  • Country: ro
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #14 on: March 18, 2020, 12:54:29 pm »
Hi Tautech,
The target device is Rigol DP832 . Siglent DMM is only the source for calibration values not he device under troubleshooting .
Finally I found that SCPI implementation of Siglent is about the same as Keysight ar Keythely so I was able to run scripts by changing only the ports used for SCPI through Telnet .
You can post this info to Siglent thread .
I post this here because is about Rigol DP832 (using various DMM's) .
Thank you !
 
The following users thanked this post: tautech

Online skander36

  • Frequent Contributor
  • **
  • Posts: 704
  • Country: ro
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #15 on: March 19, 2020, 09:29:04 am »
@GandalfSr - May you should have try MS Visual Studio Code as I said to you before . It is more straightforward than PyCharm . You dont need to reinstall packages on every project .
https://code.visualstudio.com/
So do you run Python inside MS Visual Studio?

Yes . You can try for yourself .
 
The following users thanked this post: Gandalf_Sr

Online TurboTom

  • Super Contributor
  • ***
  • Posts: 1388
  • Country: de
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #16 on: March 19, 2020, 12:34:13 pm »
About two or three years ago when I calibrated my DP832(A) with one of the "old scripts" (sorry, don't remember which one it actually was), I also noticed the discrepancy of the low voltage cal points, especially on one of the channels (at that time, it didn't matter to me since the voltage settings I normally use are far off this critical range and those were more than accurate enough to me).

Comparing the cal lists recently published, it seems the offset of the ADC in the low range is about 300something millivolts negative. The problem is that the output stage won't be able to reach that negative voltages during calibration of the 0mV and 200mV point (at least), resulting in wrong calibration value feedback and the observed errors.

So what about trying a little "cheat"? First, just test the 0.5V and 1.2V cal points and evaluate the offset, and then (linearly) calculate readback value for the 200mV (and possibly 0V) cal point to feed back during the "real" calibration pass? Anybody wants to give it a try? Unfortuantely, my coding skills are close to none and moreover, currently I haven't got a cal setup running, otherwise I'ld give it a try. Using this approach, we may get a much better low-voltage calibration result than currently possible.

Cheers,
Thomas
 

Online skander36

  • Frequent Contributor
  • **
  • Posts: 704
  • Country: ro
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #17 on: March 19, 2020, 01:30:57 pm »
This is a good ideea, maybe JDubU can fork python script to do that .
But you can post this in the other thread (https://www.eevblog.com/forum/testgear/rigol-dp832-firmware-updates-and-bug-list/new/?topicseen#new)  where maybe garrettm can adapt his javascript to do this offset evaluation .
 

Offline Gandalf_SrTopic starter

  • Super Contributor
  • ***
  • Posts: 1729
  • Country: us
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #18 on: March 19, 2020, 01:43:03 pm »
I started the thread to stop clogging up the bug list thread and have one on PC Calibration - I don't mind narrowing the title to exclude PyCharm but sending Tom over to the firmware updates & bug list thread seems wrong IMHO.

Just trying to keep some semblance of organization on these threads.
If at first you don't succeed, get a bigger hammer
 

Online skander36

  • Frequent Contributor
  • **
  • Posts: 704
  • Country: ro
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #19 on: March 19, 2020, 02:16:05 pm »
Then you may change title of thread . It limits the language to python . The other script is in Java . Maybe if we discuss about it here you may send us to create another thread ... :D
L.E. Suggestion title : Automatic calibration of DP832/A
« Last Edit: March 19, 2020, 02:18:08 pm by skander36 »
 

Offline Gandalf_SrTopic starter

  • Super Contributor
  • ***
  • Posts: 1729
  • Country: us
Re: Automated DP832 Calibration
« Reply #20 on: March 19, 2020, 02:24:29 pm »
I've changed it to "Automated DP832 Calibration".
If at first you don't succeed, get a bigger hammer
 
The following users thanked this post: skander36

Online skander36

  • Frequent Contributor
  • **
  • Posts: 704
  • Country: ro
Re: Automated DP832 Calibration
« Reply #21 on: March 19, 2020, 03:00:42 pm »
TurboTom aproach is very good especially for cases like me , where I have by default, negative offset on CH2. If I will use different sets of cal. data for each channel I can solve the problem . I have measured the offset and created a different data for CH2 (cal_dacv1/cal_dacv2 for my PSU) but as Tom said we need a loop that measure the offset and set an apropriate value for calibration for more confort.
 

Offline garrettm

  • Frequent Contributor
  • **
  • Posts: 266
  • Country: us
Re: DP832 Calibration using Python & PyCharm Running on Windows
« Reply #22 on: March 21, 2020, 03:03:58 am »
Comparing the cal lists recently published, it seems the offset of the ADC in the low range is about 300something millivolts negative. The problem is that the output stage won't be able to reach that negative voltages during calibration of the 0mV and 200mV point (at least), resulting in wrong calibration value feedback and the observed errors.

So what about trying a little "cheat"? First, just test the 0.5V and 1.2V cal points and evaluate the offset, and then (linearly) calculate readback value for the 200mV (and possibly 0V) cal point to feed back during the "real" calibration pass? Anybody wants to give it a try? Unfortuantely, my coding skills are close to none and moreover, currently I haven't got a cal setup running, otherwise I'ld give it a try. Using this approach, we may get a much better low-voltage calibration result than currently possible.

That would be very easy to do.

But to clarify, you want to avoid using cal points that return a negative readback value, correct? Or are you suggesting to return a calculated value (rather than a measured value) for those lower cal points that measure negative?

I've been busy with work lately, but I've been meaning to write a new script to read back the entire output range in 10 mV increments to see what the raw output looks like from the calibration mode. This data might assist in figuring out where more cal points might actually help with linearizing the output.
« Last Edit: March 21, 2020, 03:18:45 am by garrettm »
 

Online TurboTom

  • Super Contributor
  • ***
  • Posts: 1388
  • Country: de
Re: Automated DP832 Calibration
« Reply #23 on: March 21, 2020, 05:28:31 pm »
@Garrettm: Initially, I meant to use calculated, extrapolated readback voltages for the lowest calibration points. My suggestion is more or less based on an educated guess that may explain the peculiar behavior of the PSU at low output voltages. This is based on the evidence from the recently published cal output lists and also on my own findings that suggest that there is a (more or less) constant negative offset of the instrument output that gets truncated by the hardware at the lowest cal points. So in case of these points, a proper calibration isn't possible. If the instrument's internal calibration routine actually accepts negative readback values, this approach may lead to a more accurate calibration.

But further reasoning may even suggest that the internal calibration routine of the DP832 ignores the negative readback values alltogether and already is using the offset of the first positive readback to correct all the lower output voltages. If there is no slope approximation used, this may actually explain why one channel may be fairly accurate and another off by several ten millivolts at the low end.

I guess my first suggestion is worth a try anyway. But if the cal routine really ignores negative voltages, and it's possible to use arbitrary cal points, it may be a good idea to run a test cal to find the lowest voltage preset that will result in a positive output and use this as the first calibration point. This way, the calibration for all the lower voltages may be more accurate.  ...once again an educated guess...  ;)

Cheers,
Thomas
 

Offline JDubU

  • Frequent Contributor
  • **
  • Posts: 438
  • Country: us
Re: Automated DP832 Calibration
« Reply #24 on: March 22, 2020, 02:28:32 am »
I've modified the Python calibration script to help optimize the near zero calibrations. 
It finds the lowest value calibration point that produces a non-negative dmm read back and uses it for the first calibration point in the sequence.  Any calibration point in the tables that would produce a negative dmm read back are skipped

The file DP832Cal.py is in the attached zip file.  Just replace the one that is already in the cal folder.  Be sure to save the old file, this one has had very limited testing and may have bugs.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf