Joulescope data logging

Questions from a Joulescope user:
I want to log the current and voltage of a charging cycle of a Li-Ion battery. The charging time is about 3h.

  • Is it possible to show the entire cycle on the screen?
  • Is it possible to set the sampling rate?
  • Is it possible to save the data or export images?
1 Like

With the latest 0.5.1 software, the “.jls” file format is about 8.6 MB/s, which is 92 GB for 3 hours. If you are only concerned with monitoring charge or energy, recording the 2 million samples per second is overkill. We recently added downsample_logging.py to pyjoulescope_examples that records downsampled 2 Hz Joulescope data to a CSV file. Here is what you need:

  • Install python 3.6+ and pyjoulescope. See the instructions. Although we recommend using a virtualenv, that step is optional.
  • Clone the pyjoulescope_examples repo.
  • python pyjoulescope_examples/bin/downsample_logging.py

Here are the commands for windows without virtualenv. Open a command line (terminal) and type:

cd {your_repo_path}
pip install joulescope
git clone https://github.com/jetperch/pyjoulescope_examples.git
python pyjoulescope_examples/bin/downsample_logging.py

The script will print the logging location, which is:

C:\Users\{your_user_name}\Documents\joulescope\jslog_YYYYMMDD_HHMMSS_uuuuuu.csv

By default, the CSV contains a single line column header. Here is the full help from the script:

>python bin\downsample_logging.py --help
usage: downsample_logging.py [-h] [--header {none,simple,comment}] [--resume]

Capture downsampled data.

optional arguments:
  -h, --help            show this help message and exit
  --header {none,simple,comment}
                        CSV header option. "none" excludes all header
                        information and just includes data. "simple" (default)
                        adds a first line with column labels. "comment"
                        contains multiple lines starting with "#" and also
                        inserts events into the CSV file.
  --resume, -r          Resume the previous capture and append new data.

>

Here are example output files:

Units are SI: second, ampere, volt, watt, coulomb, joule

3 Likes

Just what I was looking for. I was planning to code something similar (but likely not as good).

Is this still processing the full 2MSPS? I presume the output is average values?
Any chance this will be extended to include min & max values per time interval? At least for current.
I may find some time to do that and create a PR - but probably not for a week or two.

2 Likes

Hi @Kean, Just capturing data is much simpler (see capture.py), and much of the extra complexity in downsample_logging.py comes from the error handling and recovery.

Yes. The Joulescope sampling still runs at 2 MSPS, and those full rate samples are used to compute power. The existing output for current, voltage and power are the average (mean) values. The existing implementation uses a rectangular window (trivial window) with no other downsampling filter. The energy is the discrete integration (sum multiplied by period) of power.

Adding other statistics and configurable CSV columns should be relatively straightforward. The implementation uses the same statistics as the multimeter display, so variance, standard deviation, min, max, and peak-to-peak are available.

1 Like

Hi, I downloaded the python joulescope files and tried to test the capture.py function. I did the example “python3 -m joulescope capture --contiguous 1.0 mycapture.jls”. I can see the .jls file, but when I open it, I only get readings of the voltage stored. The current values are always 0. I know I’m drawing current on my device in thetestcapture.jls (1.5 MB) uA range. Any reason why my captures are not storing any data for the current reading?

Hi @Gary,

In 0.5.0, I added a “config” option so that Joulescope devices were not automatically initialized. This causes the capture.py example to leave the i_range parameter set to off which keeps your target powered off. For now, you can insert a line to set i_range after line 75 in capture.py:

device.parameter_set('source', 'raw')
device.parameter_set('i_range', 'auto')
device.start(stop_fn=on_stop, duration=duration, 
    contiguous_duration=contiguous_duration)
1 Like

Awesome that was the issue! thanks

I just updated the downsample_logging.py script to support additional downsampling using the --downsample command-line option. The script normally logs at 2 Hz. To record 1 sample per minute, provide --downsample 120. I also improved the documentation within the script to more clearly explain how to use it. I tested logging data with both the Python joulescope 0.5.x package and the upcoming 0.6.x. A quick 5-minute accuracy test with constant 3.3V and 1000 Ω load (shown in the downsample_logging.py documentation) works correctly with both --downsample 1 (default) and --downsample 120.

You can tail the CSV log file to check on the script and the charge/energy. On linux and macOS (with brew), use:

tail -f {filename}

On Windows, you can use PowerShell. Here is an example of using Windows PowerShell to tail the CSV file:

Get-Content {filename} -Tail 2 -Wait

Please don’t hesitate to post with your feedback, questions, or issues!

2 Likes

Is it also possible to log this way with a higher frequency, like 20Hz or more?

Not with the existing script, but it should be possible without that much work. I’ll add it to the near-term list.

Note to self: modify the reductions in the stream buffer instance to [200, 50, x] and allow x to be [2, 4, 10, 20, 40, 100] for [100, 50, 20, 10, 5, 2] Hz

1 Like