JS220 python getting started

Using a JS220 - works fine.

I’ve got the python libraries installed - seems ok.
PS C:\git\pyjoulescope_examples-main\bin> C:/Users/scobb/AppData/Local/Programs/Python/Python312/python.exe -VV
Python 3.12.7 (tags/v3.12.7:0b05ead, Oct 1 2024, 03:06:41) [MSC v.1941 64 bit (AMD64)]

I can run bin\statistics.py

JS220-004622 0.0: -0.000000002 A, -0.418 V, -0.000000003 W, 0.000000000 C, 0.000000000 J
JS220-004622 0.0: -0.000000002 A, -0.418 V, -0.000000003 W, -0.000000000 C, 0.000000000 J
JS220-004622 0.0: -0.000000002 A, -0.418 V, -0.000000003 W, -0.000000000 C, 0.000000000 J
JS220-004622 0.1: -0.000000002 A, -0.418 V, -0.000000003 W, -0.000000000 C, 0.000000000 J
JS220-004622 0.1: -0.000000002 A, -0.418 V, -0.000000003 W, -0.000000000 C, 0.000000000 J
JS220-004622 0.1: -0.000000002 A, -0.419 V, -0.000000003 W, -0.000000000 C, 0.000000000 J
JS220-004622 0.1: -0.000000002 A, -0.420 V, -0.000000003 W, -0.000000000 C, 0.000000000 J
JS220-004622 0.1: -0.000000002 A, -0.420 V, -0.000000003 W, -0.000000000 C, 0.000000000 J
JS220-004622 0.2: -0.000000002 A, -0.420 V, -0.000000003 W, -0.000000000 C, 0.000000000 J
JS220-004622 0.2: -0.000000002 A, -0.420 V, -0.000000003 W, -0.000000000 C, 0.000000000 J
JS220-004622 0.2: -0.000000002 A, -0.420 V, -0.000000003 W, -0.000000000 C, 0.000000000 J

but running bin\monitor.py just sits there. No warnings or errors. Something did run, because bin\statistics.py runs faster than the first time I ran it before monitor.py. Anything obvious I’m missing? Will try stepping through it.

It finds and opens the device just fine:

Hello World - just one Joulescope found

Hello World - Before monitor.open u/js220/004622 -

Hello World - after monitor.open

I’ve been working fine with the other commands - just monitor.py is giving me issues

Hi @scobb and welcome to the Joulescope forum!

The description for this script is:

Inspect current data for errant conditions. On an errant condition, record data for analysis. For now, records 50 Hz statistics data to both a JLS v2 file and an Excel XLSX file.

So, this script does not do anything until it detects and errant condition, which is hard coded to self._i_threshold = 0.001 # 1 mA. Until your input exceeds 1 mA, it will just sit there waiting.

If I remember right, we made this for a customer looking for a specific issue in their device. The script says CAUTION: UNDER DEVELOPMENT for a reason. It looks like we never generalized it to customize the errant condition.

Are you looking to customize a measurement and having trouble finding a good starting point?

Hi,

Haha - on me. Thanks for the response. Yes, I didn’t look to carefully at what it was trying to do - now it makes sense. I’ve been looking at and working with the other examples and having reasonable luck.

Is there a simple example that periodically (say every 10 seconds) and spits out current and Voltage? Then every 20 seconds, also spits out the current Joule count. I think the documentation is sufficient, but working examples always help.

Eventually, I’ll tie it to a GUI. Planning on using Tkinter as the GUI framework. Anyone have luck with that? Or a recommendation for one of the other GUI frameworks?

If there is any interest, I can post some simple examples.

Thanks all,

Steve

Hi @scobb,

The lowest statistics frequency that the JS220 supports is 1 Hz. See statistics.py. If you would rather use pyjoulescope_driver, see the statistics entry point. You can run this using python -m pyjoulescope_driver statistics.

If you want lower than 1 Hz, you can combine statistics on the host side. As long as you don’t care about standard deviation, it’s easy. See downsample_logging.py for an example. Computing standard deviation is not too bad.

The Joulescope UI uses PySide6 / Qt6. You can steal the Multimeter widget.

Another approach is to make a Joulescope UI plugin.

Thanks! So far so good.

I’m currently using a variation on the example script trigger.py. I have updated it to behave as I need and it captures the data based on In0 state and saves the files perfectly.

Now I want to include IN0 in the capture (like I can do with the main JouleScope application. In the trigger script, there is:

p.add_argument(‘–jls_signals’,
    default=‘current,voltage’,
    help='The comma-separated list of signals to record to the JLS file. ’
        + 'The available signals include: current, voltage, power. ’
        + ‘Ignored if jls_version is 1.’)

But it seems to be limited to current, voltage and power. Is there a straightforward way to include IN0 and/or other signals?

Also, for the JouleScope file viewer, is there a way to get it to ignore or skip checking for software updates? Or if I choose “later”, can it not ask again until the next day? We have to go through IT to get admin privileges to allow the updates to complete - that can take a day or two.

Thanks!

@scobb - The Joulescope UI does not have any rate throttling on software update Later. For now, it will nag you every time you start the UI or view a JLS file using the file association. I just created issue 340 to make this less annoying.


So, one of the areas that changed a lot between the JS110 and JS220 is the general-purpose inputs and outputs. You will note that pyjoulescope_examples/bin/trigger.py uses the joulescope package, which still turns on the GPI like this:

device.parameter_set('current_lsb', 'gpi0')
device.parameter_set('voltage_lsb', 'gpi1')

Stuffing the GPI into the ADC LSBs was the JS110 approach. The JS220 communicates the GPI through dedicated messages. We decided to keep the joulescope package fully compatible, so it only supports JS220 IN0 and IN1 (not IN2, IN3, or Trigger IN). Note that the pyjoulescope_driver supports all JS220 features.

It looks like both pyjoulescope_examples/bin/trigger.py and pyjoulescope/jls_v2_writer.py would need updates to support recording IN0 and IN1.

Looking back, I see that you were thinking about developing a UI. For a UI, I recommend using the asynchronous API provided by the pyjoulescope_driver package rather than the synchronous API provided by the joulescope package.

The pyjoulescope_examples/bin/trigger_host_pyjoulescope_driver.py is a simpler example than trigger.py, but it shows how you can use the pyjoulescope_driver API. It does not record to JLS as given.

Do you really want trigger.py with the joulescope package, or is this just an intermediate step to pyjoulescope_driver?

I suspect that the above is a far better path long term. I only used the trigger.py because I saw that it was doing what I was looking for - and it worked. Let me look at trigger_host_pyjoulescope_driver.py first - assuming that is a better path, I’ll let you know.

Thanks