jetperch / pyjoulescope

Joulescope driver and utilities
https://www.joulescope.com
Apache License 2.0
37 stars 11 forks source link

Joulescope on raspberrpi #34

Closed foofel closed 4 months ago

foofel commented 8 months ago

We are trying to create a setup for long term data collection using the joulescope and timescaledb. When trying to run the joulescope example data streamer on the raspberry one core is always at 100%, is this normal or does this mean the raspberry can not keep up with the data collected? (We are want to collect at 1000Hz). As far as i understand all data is streamed to the host computer at 1Msps and then reduced on the host? It looks like all data is arriving as expected but would i notice/ how do i notice if we had data drops?

mliberty1 commented 8 months ago

Hi @foofel - I am not sure what CPU utilization is normal for a JS220 connected to a Raspberry Pi streaming data to another computer.

I want to make sure that I understand what you are doing:

  1. Are you running a Raspberry Pi 4 with 64-bit Linux OS?
  2. Are you using a Joulescope JS220?
  3. By "example data streamer", do you mean pyjoulescope_server and the provided client?

With pyjoulescope_server, the data will be downsampled on the Raspberry Pi, which may be why you are seeing a high CPU utilization. Another possible approach is to capture statistics at 1 kHz. This "downsampling" is performed on the JS220 instrument which may reduce the Raspberry Pi's processing load.

foofel commented 8 months ago

Hi @mliberty1,

yes it is raspberrypi4 with the default 64 bit raspbian and a Joulescope JS220. I took the example from the read_by_callback.py. I haven't really looked at the server yet. Using statistics at 1Khz sounds promising, is there also an example for that?

When receiving data via streaming, is there a mechanism to know when samples were dropped/could not be delivered? As i said, it seems to work, i just want to make sure its working for a longer period and not silently failing.

mliberty1 commented 8 months ago

The easiest way to get statistics is by running:

python -m pyjoulescope_driver statistics

You can provide the --frequency 1000 optional argument to get 1 kHz data. This command displays the statistics to stdout using the newer pyjoulescope_driver directly. You can also do the same from a python script. You can find the code for this pyjoulescope_driver entry point here.

You should get NaN (not a number) values if samples are being dropped when streaming full-rate samples or downsample samples.

foofel commented 8 months ago

Thanks!

I will look into the statistics and getting NaNs is easily detectable :)

mliberty1 commented 4 months ago

Using statistics is a good solution. Closing as addressed.

foofel commented 4 months ago

Just as short feedback, the statistics work well, thanks :)