Hi JouleScope Forum,
I just got a JouleScope for energy measurement tasks. At the moment I’m using the JouleScope in a similar way as using an oscilloscope: start capture → wait for a certain amount of time → stop capture → read samples.
After conducting a few energy measurement tests, I notice that sometimes the JouleScope would give me varying amounts of nan in current and voltage readings. Can anyone help me with the following issues:
- nan in sample readings
- find out what does “in frame_id mismatch xxx!= 0” mean
This is some information of an example test script and system info:
example test script:
import joulescope
from joulescope.v1.js220 import DeviceJs220
import numpy as np
from time import sleep
from numpy.typing import NDArray
OSC_FREQUENCY = 5000
TIME_WINDOW = 1200
for _i in range(20):
print(f"Test iteration {_i + 1}")
joulescope_device: DeviceJs220 = joulescope.scan_require_one(
name="joulescope", config="auto"
)
print(f"JouleScope {joulescope_device.model} is connected.")
joulescope_device.open()
# Set configuration
joulescope_device.parameter_set("sampling_frequency", int(OSC_FREQUENCY))
assert (
int(joulescope_device.parameter_get("sampling_frequency", "actual"))
== OSC_FREQUENCY
)
joulescope_device.parameter_set("buffer_duration", int(TIME_WINDOW))
assert (
int(joulescope_device.parameter_get("buffer_duration", "actual")) == TIME_WINDOW
)
joulescope_device.start(contiguous_duration=TIME_WINDOW)
print("Started data streaming.")
if not joulescope_device.is_streaming:
print("JouleScope is not streaming after start!")
break
print("Waiting for 1190 seconds.")
sleep(1190)
joulescope_device.stop()
print("Stop data streaming and get samples.")
(
starting_sample_id,
ending_sample_id,
) = joulescope_device.stream_buffer.sample_id_range
samples = joulescope_device.stream_buffer.samples_get(
starting_sample_id, ending_sample_id
)
statistics = joulescope_device.stream_buffer.statistics_get(
starting_sample_id, ending_sample_id
)
current: NDArray[np.float32] = samples["signals"]["current"]["value"]
voltage: NDArray[np.float32] = samples["signals"]["voltage"]["value"]
nan_current = np.sum(np.isnan(current))
nan_voltage = np.sum(np.isnan(voltage))
if nan_current > 0 or nan_voltage > 0:
print(f"Got {nan_current} nan in current values.")
print(f"Got {nan_voltage} nan in voltage values.")
print("Fail to fetch complete waveform")
joulescope_device.close()
print("JouleScope is closed.")
snapshot of test result:
Test iteration 1
JouleScope js220 is connected.
Started data streaming.
Waiting for 1190 seconds.
Stop data streaming and get samples.
Got 5598 nan in current values.
Got 5598 nan in voltage values.
Fail to fetch complete waveform
JouleScope is closed.
Test iteration 2
JouleScope js220 is connected.
in frame_id mismatch 983 != 0
Started data streaming.
Waiting for 1190 seconds.
Stop data streaming and get samples.
Got 1025 nan in current values.
Got 1025 nan in voltage values.
Fail to fetch complete waveform
JouleScope is closed.
Test iteration 3
JouleScope js220 is connected.
in frame_id mismatch 17226 != 0
Started data streaming.
Waiting for 1190 seconds.
Stop data streaming and get samples.
Got 873 nan in current values.
Got 873 nan in voltage values.
Fail to fetch complete waveform
JouleScope is closed.
a.t.m I’m sticking with Python 3.8 so I chose to install joulescope version 1.1.6
python -m joulescope info
System information
Python: 3.8.10 (default, May 26 2023, 14:05:08)
[GCC 9.4.0]
Platform: Linux-5.15.0-75-generic-x86_64-with-glibc2.29 (linux)
Processor: x86_64
executable: /home/allan/.cache/pypoetry/virtualenvs/testing-S71WflWI-py3.8/bin/python
frozen: Falsejoulescope version: 1.1.6
Found 1 connected Joulescope:
JS220-000882 ctl=1.0.4 sensor=1.0.3