Toggle DUT Target Power in Python

Hello,

We would like to use Python to toggle the DUT Target Power. Essentially the same function as clicking ‘Target Power’ button on the Joulescope UI.

We are using the joulescope driver for Python.

What is the correct way to do this? We are looking into the parameter_set methods, maybe linked to the current range item?

Thankyou for any help,
Steven

Hi @spark_res and welcome to the Joulescope forum!

Yes, you want to set the i_range parameter to off, like this:

import joulescope
device = joulescope.scan_require_one(config='auto')
with device:
    # Turn off DUT power
    device.parameter_set('i_range', 'off')
    # ... do stuff ...
    # Turn on DUT power and resume Joulescope current autoranging
    device.parameter_set('i_range', 'auto')
    # ... do stuff ...
1 Like

Great, thanks for confirming @mliberty.

We will give that a go and post back the results.

1 Like

To close out the thread, the above method worked as described. Thankyou!

1 Like

Another alternative, if you’re (like me) working with the pyjoulescope_driver directly, comes from one of the examples provided in the repo (dut_power.py):

from pyjoulescope_driver import Driver
def dut_power_set(jsdrv, device_path, power_on):
    i_range = 'auto' if power_on else 'off'
    jsdrv.publish(_topic(device_path), i_range)

with Driver() as jsdrv:
    device_paths = sorted(jsdrv.device_paths())
    dut_power_set(jsdrv, device_paths[0], True)
1 Like