Matlab start_logging bug (normal vs precision)

I couldn’t get the ‘get_stream_data’ working in matlab (just saw this thread), so I’m using ‘start_logging’ instead. It mostly works, except for one weird bug. This command works fine:

pid.start_logging('duration',10,'mode','Normal','rate',1e3)

(I’m using multi instrument and having the PID controller log) Polls using ‘logging_progress’ all make sense, it says “Logging in progress” while it counts down 10 seconds, then says 0 seconds remaining and “Logging complete”. But this command does not work:

pid.start_logging('duration',10,'mode','Precision','rate',1e3)

In this case, it says “Logging in progress” while it counts down 10 seconds, but then says 0 seconds remaining and “Logging in progress” for another 10 seconds until finally reports “Logging complete” after 20 seconds and the file saved has 20 s of data, not 10 s. The time is always double when I choose precision.

If it matters, my versions are:

  • mokucli: 4.3.0.0
  • mokuos: 4.3.0
  • matlab: 2024b (I could update if it would help)
  • moku-matlab: 4.3.0

(editing multiple responses into one for clarity)

Everything works fine from the Moku app saving data manually, but there seems to be an issue with the API (matlab & python) getting precision data from the PID controller (multi-instrument mode, 3 slots, PID in slot 2). The problem is with ‘start_logging’ and ‘start_streaming’. The data returned is not precision, it’s normal mode data. It also takes twice the duration to capture.

When I pipe the PID output to a lock-in amplifier I have in slot 1, I am able to get precision data just fine from the lock-in. So the problem is just with the PID controller. I have only tested with 3 slots and the PID in slot 2 so I don’t know if moving slots would change anything or going to 3 slots or the dedicated PID.

Hi Nathan, thanks for your forum posting.

I can confirm this is a bug. Specifically, for the datalogger embedded within the PID instrument, the Precision acquisition mode does not function correctly; it returns twice the expected number of samples and it is indeed ‘normal’ mode data, not ‘precision’ mode data.

While we work to fix this issue, attached is a Python script that will sample data at a higher rate (100x) and then average this data locally - within Python - achieving same outcome as precision acquisition mode.

The diagram shows a (slightly) noisy sine wave that is improved by this method.

Paul.

pid_datalogger_normal_vs_averaged100.py.zip (3.3 KB)