I have been having an issue with using the pyjoulescope_driver when current range is set to Auto.
In short, when I select a fixed current range, the current and voltage profile is as expected, I have sleep current levels of 150nA with short spikes of current up to 1mA. When I select the auto range for current, the recorded current profile just shows a noisy flat line. There is no change in my measurement setup other than setting the range setting. I can tell the device is operating correctly, because I can see the voltage line blips that coincide with where I expect to see the current spikes.
The auto range feature has no issue in the Joulescope GUI, current profile is as expected, though obviously you can see the range switching artifacts.
I have pasted my basic script ‘recorder.py’ which just records 5 seconds of data when launched. To fix the error and see the expected current values I simply set the range to manual and select 1.8mA range ( comment out line 33, and remove comment ‘#’ from lines 37 & 38 - the recorder.py script is also attached).
I feel I am missing some step in setting up auto range feature - or perhaps the data needs to be handled differently when auto range feature is set?
from pyjoulescope_driver.record import Record
from pyjoulescope_driver import Driver
import datetime
import time
import os
import logging
SAMPLING_FREQUENCY_HZ = 1000000
logging.basicConfig(level=logging.DEBUG)
def construct_filename(out_dir):
timestamp = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
filename = 'IVT_' + timestamp + '.jls'
os.makedirs(out_dir, exist_ok=True)
full_file_path = os.path.join(out_dir, filename)
return full_file_path
filepath = construct_filename("recordings")
with Driver() as d:
devices = d.device_paths()
device = devices[0] # open first device -
d.open(device)
d.publish(f'{device}/s/i/range/mode', 'auto')
#d.publish(f'{device}/s/i/range/max', '180 mA') # Limits max range to 180mA
#d.publish(f'{device}/s/i/range/min', '18 µA') # Limits min range to 18µA
#d.publish(f'{device}/s/i/range/mode', 'manual')
recorder.py (1.6 KB)
#d.publish(f'{device}/s/i/range/select', '1.8 mA')
d.publish(f'{device}/s/v/range/mode', 'auto')
d.publish(f'{device}/h/fs', SAMPLING_FREQUENCY_HZ)
try:
print(f'STARTING RECORDER....')
recorder = Record(d, device, signals = 'current,voltage')
recorder.open(filepath)
logging.info("Recording started...")
time.sleep(5)
recorder.close()
logging.info("Recording ended...")
except Exception as e:
logging.error(f'Error: failed to start recording: {e}')
EDIT TO THIS POST:
I had access to a second joulescope device and tried the same recorder.py script, I did not see the same error. However I was able to reproduce the error after I set the range max and min values ( uncommented lines 34 and 35). But I could not recover operation after commenting these lines out again. It seems I must be making a mistake in setting the range max and min values and in re-setting default max and min values.