Python code¶
In [1]:
import box0
import numpy as np
import time
# When 1000 samples are output at 100KS/s, the generate waveform is of 100Hz
SAMPLE_BITSIZE = 12
SAMPLE_SPEED = 100000 # 100KS/s
SAMPLE_COUNT = 1000
# Build the waveform
x = np.linspace(0, 2 * np.pi, SAMPLE_COUNT)
y = np.sin(x)
# Get all the resources
dev = box0.usb.open_supported()
aout = dev.aout()
# Prepare for static mode
aout.snapshot_prepare()
aout.bitsize_speed_set(SAMPLE_BITSIZE, SAMPLE_SPEED)
aout.snapshot_start(y)
# wait for the user to ask for exit
try:
while True:
time.sleep(0.1)
except KeyboardInterrupt:
pass
# Return all the resources
aout.snapshot_stop()
aout.close()
dev.close()