Live plots from the DP832 Rigol power supply - Page 1
Forum section: electronics / projects

author: RoGeorge
author_rank: Super Contributor
timestamp: April 06, 2023, 01:14:12 pm
content: Quick note, I've just realized today that LibreOffice Calc can auto-import periodically from a CSV file.Now, if in that CSV file we log U, I and P from each channel of the DP832, we can have live plots in a spreadsheet.The script to log the values by LAN and put them in a CSV file is ancient, should still work when run with Python 2.https://github.com/RoGeorge/DP832_charger_loggerLogged values are timestamped and saved inside DP832_charger_logger/csvLog/Code:sudo apt install python2git clone https://github.com/RoGeorge/DP832_charger_loggercd ./DP832_charger_loggerpython2 ./DP832_logger.py 60 192.168.1.4Now open the attached spreadsheet and allow it to load the linked CSV file from thecsvLogdirectory, or go to the LibreOffice menu 'Sheet' -> 'Link to external data...' and browse to the file you want to see it plotted. LibreOffice allows to set an auto-update interval to keep re-importing the CSV file. Customize the plot.If you point the LibreOffice to the file you are logging right now, the plot will update live.(in the pic is the plot of U battery while charging an alkaline 9V battery at 0.25C on CH1 of the DP832 - in red - and a pack of 3 series NiMH at 1C on CH2 of the DP832 - in green)

author: rstofer
author_rank: Super Contributor
timestamp: April 06, 2023, 04:04:49 pm
content: Nice work! I have the PS but not an application. I'm going to download the files anyway.Thanks for sharing!

author: voltsandjolts
author_rank: Unknown
timestamp: April 06, 2023, 04:19:49 pm
content: Nice.You use sleep() to determine interval for logging.Is there a way in Python to get a callback at specific wall clock times?Like upon every 10sec or every 60sec.My OCD wants to see round times for the samples...2023-04-06T18:00:002023-04-06T18:00:102023-04-06T18:00:202023-04-06T18:00:30...

author: RoGeorge
author_rank: Super Contributor
timestamp: April 06, 2023, 06:01:17 pm
content: The timestamp is from the second when the data arrived into PC, and the interval can be anything between 1s and maxint seconds, specified as an argument at start, in the command line. Default is one second. First parameter is the sampling interval, second the IP address, both optional.In the pics the interval is 60 seconds. If you want the values sampled once at 10 seconds, the logging script should be started with:python2 ./DP832_logger.py 10Now, if you want the second units-digit to always be zero, either lie by overwriting it with zerotimeString[-1] = '0', or wait for the time to be a multiple of 10s before starting the loop, for example by inserting between line 132 and 133 in the file 'DP832_logger.py', the following code to wait for a round number:Code:OCD_criteria = Falsewhile not OCD_criteria:t1 = time()timeString = strftime("%Y-%m-%d,%H:%M:%S", localtime(t1))if timeString[-1] == '0': OCD_criteria = TrueI'm not a programmer, so I prefer easy over elegant. To make the delay non-blocking, or to use callbacks would be an effort for me, but feel free to change the script as you wish.

author: RoGeorge
author_rank: Super Contributor
timestamp: April 06, 2023, 06:29:56 pm
content: Quote from: rstofer on April 06, 2023, 04:04:49 pmIf you mean you don't have LibreOffice Calc, it's free to install and use, and it can read/write Microsoft Office files, too.Also, if you don't want to install LibreOffice but you already have Microsoft Office's Excel, then you can start the Python2 script from a cmd prompt, then open the .odt file with Excel. Might still work.Or if Excel can not read or import .odt files, you can open the .csv file with Excel, and set your own charts in Excel upon wish. Should be similar to achieve the same in Excel (but I don't have Excel to tell the exact buttons to link a live CSV file generated by python into an Excel sheet - IIRC it's something with datasources, or connectors, IDK, been many years since I didn't use Excel). What I know for sure is Excel and Calc are almost identical from an end user standpoint, just that Calc is free and open source.If periodic auto-update of an imported CSV files is possible in Calc, similar should be possible in Excel, too.

author: alm
author_rank: Super Contributor
timestamp: April 06, 2023, 07:09:21 pm
content: Quote from: voltsandjolts on April 06, 2023, 04:19:49 pmNot that I know of, but you could easily write it yourself by calculating the number of seconds until the next even 10s, and sleeping for that amount of time. But be aware that communication may take some dozens or hundreds of milliseconds, so by the time your measurement is done you will no longer be at an even interval of 10s. I would just round the output to an even 10 seconds and not tell your personality disorder (for which I hope you're seeking treatment) about it:Code:t1 = 10 * round(time() / 10)