I need to generate continuous (non-stop) waveform from Picoscope 2204a using python in Raspberry Pi 4.
So far, I managed to generate short-time waveform using the example with the built-in generator from https://www.picotech.com/picoapps/uploa ... als.md.pdf.
from picosdk.ps2000 import ps2000
from picosdk.functions import assert_pico2000_ok, adc2mV
from picosdk.PicoDeviceEnums import picoEnum
with ps2000.open_unit() as device:
print('Device info: {}'.format(device.info))
res = ps2000.ps2000_set_sig_gen_built_in(
device.handle,
1000_000, # offset voltage in uV
2000_000, # peak-to-peak voltage in uV
0, # type of waveform (0 = sine wave)
20000.0, # start frequency in Hz
20000.0, # stop frequency in Hz
0.0, # frequency change per interval in Hz
0.1, # interval of frequency change in seconds
0, # sweep direction (0 = up)
1_000 # number of times to sweep
)
assert_pico2000_ok(res)
However, this code can only generates the waveform for roughly less than 100 ms. I tried to find another example using python to generate non-stop waveform using python but unfortunately I cannot find one. Any help will be appreciated.
Thanks!
Last edited by amphebee90 on Tue Jan 03, 2023 3:18 am, edited 1 time in total.
import matplotlib.pyplot as plt
import numpy as np
from picosdk.ps2000 import ps2000
from picosdk.functions import assert_pico2000_ok
from picosdk.PicoDeviceEnums import picoEnum
with ps2000.open_unit() as device:
print('Device info: {}'.format(device.info))
res = ps2000.ps2000_set_sig_gen_built_in(
device.handle,
1000_000, # offset voltage in uV
2000_000, # peak-to-peak voltage in uV
0, # type of waveform (0 = sine wave)
20000.0, # start frequency in Hz
20000.0, # stop frequency in Hz
0.0, # frequency change per interval in Hz
0.1, # interval of frequency change in seconds
0, # sweep direction (0 = up)
1_000 # number of times to sweep
)
assert_pico2000_ok(res)
res = ps2000.ps2000_run_streaming_ns(
device.handle,
500,
2,
100_000,
False,
1,
50_000
)
assert_pico2000_ok(res)
fig, ax = plt.subplots()
plt.show()
However, it is a bit strange that if I remove the last two lines for the plot (which is unnecessary and unrelated with the signal generator), the Picoscope will stop generating the sine wave in less than 1 second.