How do I change the sampling time? (script mode)

Dear Sir,
I use the script to record the battery voltage.
The default sampling time is 250us. How do I change it to 1 sec??

My test log is very big. I want to reduce it.

Hi and welcome to the forum,

The sample rate is fixed during measurement and can only be changed when recording is finished.
You can use the downsample function in scripting or via UI to later downsample.

Best regards,
Björn

Dear Sir,
Could your share a example code for downsample function??

And I use the UI to downsample (1Hz) .
I export the CSV that the record period is 0.001sec . Why???

Hi,

Something like this (in lua, since I had it ready, but something similar in Python) will do the trick.

otii.clear()
local device = otii.get_devices(“Arc”)
box = otii.open_device(device[1].id)
local project = otii.get_active_project()
if project == nil then
project = otii.create_project()
end
box:enable_channel(“mc”,true)
box:enable_channel(“mv”,true)
box:enable_main(true)
project:start()
otii.msleep(10000)
project:stop()
box:enable_main(false)
project:save(“C:\Bjorn\Otii\original.otii”)
project:downsample_channel(box, “mc”, 4000)
project:downsample_channel(box, “mv”, 1000)
project:save(“C:\Bjorn\Otii\downsampled.otii”)Something similar in Python.

When Main Current channel is enabled, then also Main Voltage is enabled in the background, to be able to calculate the energy.
When you then downsample Main current channel, then you also need to downsample Main Voltage channel since that has 1ksps of data.
To do that, you must enable Main Voltage channel in Project Settings.
Then you can downsample main current with factor 4000 and main voltage with factor 1000.

Best regards,
Björn