Data acquisition with deep memory mode
The data capturing capabilities of Moku instruments can be significantly strengthened by the utilization of deep memory mode. With an extended memory depth and high sampling rate, users can export high-resolution data effortlessly via the ‘Export Data’ menu.
The deep-memory acquisition is equipped in all Moku instruments that have embedded data logging, including Oscilloscope, Lock-in Amplifier, PID controller, Digital Filter Box, FIR Filter Builder, and Laser Lock Box. Table 1 provides a brief summary of the number of acquired data points at different sampling rates under deep memory mode.
Moku:Go |
Moku:Pro |
||
---|---|---|---|
Setting No.1 | Sampling rate & corresponding time span |
125 MSa/s (time span ≤ 25 ms) |
1.25 GSa/s (time span ≤ 10 ms) |
Number of acquired data points per channel | 8.4 million |
33.6 million |
|
Setting No. 2 | Sampling rate & corresponding time span |
Below 125 MSa/s (time span > 25 ms) |
Below 1.25 GSa/s (time span > 10 ms) |
Number of acquired data points per channel | 4.2 million |
16.8 million |
Data acquisition in Moku app
Deep memory mode can be activated under the tab ‘Timebase’, as shown in the screenshot below. To save data, simply click the cloud icon located at the top center of the window. Then toggle the ‘High-res data’ option, select a desired data format, and click ‘Export’.
Data acquisition using APIs
For users employing APIs, the following examples in MATLAB and Python demonstrate the process of saving data in deep memory mode. The command save_high_res_buffer
stores high resolution channel buffer data on the Moku's internal storage. A quick note is that deep memory mode must be enabled through set_acquisition_mode
before exporting high-res data.
→Moku:Pro
- MATLAB example of saving data via deep memory mode (using Oscilloscope on Moku:Pro)
NUM_FRAMES = 1;
i = MokuOscilloscope('XXX.XXX.X.XXX', true); % Connect to your moku device by its IP address
try
i.set_trigger('type',"Edge", 'source',"Input1", 'level', 0);
%% View +-5 msec, i.e. trigger in the centre
i.set_timebase(-5e-3, 5e-3);
i.set_acquisition_mode('mode',"DeepMemory");
i.get_samplerate()
% Set the data source of Channel 1 to be Input 1
i.set_frontend(1,'50Ohm','AC','400mVpp')
i.set_source(1, 'Input1');
i.set_source(2, 'None');
i.set_source(3, 'None');
i.set_source(4, 'None');
data_temp = [];
for iter = 1:NUM_FRAMES
i.get_data('wait_complete', true);
response = i.save_high_res_buffer();
file_name_temp = "./high_res_data_high_freq-" + string(datetime('now', 'Format','d-MMM-y-HH_mm_ss'));
i.download_file('ssd', response.file_name, file_name_temp +".li");
system("mokucli convert --format=mat " + file_name_temp +".li")
load(file_name_temp + ".mat");
if(iter == 1)
data_temp = moku.data(:,2);
else
data_temp = data_temp + moku.data(:,2);
end
end
figure (1);
plot(moku.data(:,1), data_temp./NUM_FRAMES); % This plots the average of all acquired high-res frames.
xlabel('Time [s]');
ylabel('Amplitude [V]');
grid on;
catch ME
% End the current connection session with your Moku
i.relinquish_ownership();
rethrow(ME);
end
i.relinquish_ownership();
- Python example of saving data via deep memory mode (using Oscilloscope on Moku:Pro)
import matplotlib.pyplot as plt
import os
import time
import numpy as np
from moku.instruments import Oscilloscope
# Connect to your Moku by its ip address using Oscilloscope('192.168.###.###')
i = Oscilloscope('XXX.XXX.X.XXX', force_connect=True)
NUM_FRAMES = 1
FILE_PATH = "C:/Users/XXXX/Downloads" # Please replace with your own FILE_PATH
try:
i.set_trigger(type='Edge', source='Input1', level=0)
# View +-5 msec, i.e. trigger in the centre
i.set_timebase(-5e-3, 5e-3)
i.set_acquisition_mode('DeepMemory')
print(i.get_samplerate())
# Set the data source of Channel 1 to be Input 1
i.set_frontend(1,'50Ohm','AC','400mVpp')
i.set_source(1, 'Input1')
i.set_source(2, 'None')
i.set_source(3, 'None')
i.set_source(4, 'None')
# Get initial data frame to set up plotting parameters.
data = i.get_data()
# Set up the plotting parameters
plt.ion()
plt.show()
plt.grid(visible=True)
plt.ylim([-1, 1])
plt.xlim([data['time'][0], data['time'][-1]])
line1, = plt.plot([])
# Configure labels for axes
ax = plt.gca()
for iter in range(0, NUM_FRAMES):
iter = iter + 1
i.get_data()
response = i.save_high_res_buffer(comments="Triggered")
file_name = response["file_name"]
temp_filename = FILE_PATH + "/high_res_data-" + time.strftime('%d-%m-%Y-%H_%M_%S')
i.download("ssd", file_name, temp_filename + ".li")
os.system("mokucli convert --format=npy " + temp_filename + ".li")
data_load = np.load(temp_filename + ".npy")
data = np.array(data_load.tolist())
if iter == 1:
ch1 = data[:,1]
else:
ch1 = ch1 + data[:,1]
time_column = data[:,0]
line1.set_ydata(ch1/NUM_FRAMES) # calculate the average of all acquired high-res frames
line1.set_xdata(time_column)
input("Enter any key to quit.")
except Exception as e:
print(f'Exception occurred: {e}')
finally:
# Close the connection to the Moku device
# This ensures network resources and released correctly
i.relinquish_ownership()
→Moku:Go
- MATLAB example of saving data via deep memory mode (using Oscilloscope on Moku:Go)
NUM_FRAMES = 1;
i = MokuOscilloscope('XXX.XXX.X.XXX', true); % Connect to your moku device by its IP address
try
i.set_trigger('type',"Edge", 'source',"Input1", 'level', 0);
%% View +-5 msec, i.e. trigger in the centre
i.set_timebase(-5e-3, 5e-3);
i.set_acquisition_mode('mode',"DeepMemory");
i.get_samplerate()
% Set the data source of Channel 1 to be Input 1
i.set_frontend(1,'1MOhm','AC','10Vpp')
i.set_source(1, 'Input1');
i.set_source(2, 'None');
data_temp = [];
for iter = 1:NUM_FRAMES
i.get_data('wait_complete', true);
response = i.save_high_res_buffer();
file_name_temp = "./high_res_data_high_freq-" + string(datetime('now', 'Format','d-MMM-y-HH_mm_ss'));
i.download_file('persist', response.file_name, file_name_temp +".li");
system("mokucli convert --format=mat " + file_name_temp +".li")
load(file_name_temp + ".mat");
if(iter == 1)
data_temp = moku.data(:,2);
else
data_temp = data_temp + moku.data(:,2);
end
end
figure (1);
plot(moku.data(:,1), data_temp./NUM_FRAMES); % This plots the average of all acquired high-res frames.
xlabel('Time [s]');
ylabel('Amplitude [V]');
grid on;
catch ME
% End the current connection session with your Moku
i.relinquish_ownership();
rethrow(ME);
end
i.relinquish_ownership();
- Python example of saving data via deep memory mode (using Oscilloscope on Moku:Go)
import matplotlib.pyplot as plt
import os
import time
import numpy as np
from moku.instruments import Oscilloscope
# Connect to your Moku by its ip address using Oscilloscope('192.168.###.###')
i = Oscilloscope('XXX.XXX.X.XXX', force_connect=True)
NUM_FRAMES = 1
FILE_PATH = "C:/Users/XXXXX/Downloads" # Please replace with your own FILE_PATH
try:
i.set_trigger(type='Edge', source='Input1', level=0)
# View +-5 msec, i.e. trigger in the centre
i.set_timebase(-5e-3, 5e-3)
i.set_acquisition_mode('DeepMemory')
print(i.get_samplerate())
# Set the data source of Channel 1 to be Input 1
i.set_frontend(1,'1MOhm','AC','10Vpp')
i.set_source(1, 'Input1')
i.set_source(2, 'None')
# Get initial data frame to set up plotting parameters.
data = i.get_data()
# Set up the plotting parameters
plt.ion()
plt.show()
plt.grid(visible=True)
plt.ylim([-1, 1])
plt.xlim([data['time'][0], data['time'][-1]])
line1, = plt.plot([])
# Configure labels for axes
ax = plt.gca()
for iter in range(0, NUM_FRAMES):
iter = iter + 1
i.get_data()
response = i.save_high_res_buffer(comments="Triggered")
file_name = response["file_name"]
temp_filename = FILE_PATH + "/high_res_data-" + time.strftime('%d-%m-%Y-%H_%M_%S')
i.download("persist", file_name, temp_filename + ".li")
os.system("mokucli convert --format=npy " + temp_filename + ".li")
data_load = np.load(temp_filename + ".npy")
data = np.array(data_load.tolist())
if iter == 1:
ch1 = data[:,1]
else:
ch1 = ch1 + data[:,1]
time_column = data[:,0]
line1.set_ydata(ch1/NUM_FRAMES) # calculate the average of all acquired high-res frames
line1.set_xdata(time_column)
input("Enter any key to quit.")
except Exception as e:
print(f'Exception occurred: {e}')
finally:
# Close the connection to the Moku device
# This ensures network resources and released correctly
i.relinquish_ownership()