Using the Oscilloscope

If your device has an oscilloscope, you can access it via the property analog_input. Individual channels can be accessed via a zero-based index, or a label, such as ‘ch1’.

There are various high-level functions that you can use to control the oscilloscope:

Channel Setup

  • analog_input[ch].setup() - Sets up the channel for data acquisition.

Data Acquisition

Triggering

Setting Up Channels

You can use the analog_input[ch].setup() function on a respective analog input channel to setup a channel. You can specify the channel voltage range, offset voltage, and more.

import dwfpy as dwf

with dwf.Device() as device:
    scope = device.analog_input
    scope[0].setup(range=5.0, offset=2.0)

Getting the Current ADC Sample

You can use the analog_input[ch].get_sample() function on a respective analog input channel to get the current ADC reading.

Note

You need to call the analog_input.read_status() function before calling get_sample() to read a sample from the device.

import dwfpy as dwf

with dwf.Device() as device:
    scope = device.analog_input
    scope[0].setup(range=50.0)
    scope.configure()
    scope.read_status()
    print(f'CH1: {scope[0].get_sample()}V')

For a complete example, see examples/analog_in_sample.py.

Single Data Acquisition

You can use the single() function on the analog input unit to perform a single-shot data acquisition. To configure the oscilloscope, pass the parameter configure=True. To start the acquisition immediately and wait for the acquisition to finish, pass the parameter start=True.

import dwfpy as dwf

with dwf.Device() as device:
    scope = device.analog_input
    scope[0].setup(range=5.0)
    scope.single(sample_rate=1e6, buffer_size=4096, configure=True, start=True)
    samples = scope[0].get_data()
    print(samples)

For a complete example, see examples/analog_in_single.py.

Recording Samples

You can use the record() function on the analog input unit to perform data recording. To configure the oscilloscope, pass the parameter configure=True. To start the acquisition immediately, pass the parameter start=True.

import dwfpy as dwf

with dwf.Device() as device:
    scope = device.analog_input
    scope[0].setup(range=5.0)
    recorder = scope.record(sample_rate=1e6, sample_count=1e6, configure=True, start=True)
    samples = recorder.channels[0].data_samples
    print(samples)

For a complete example, see examples/analog_in_record.py.

Setting Up an Edge Trigger

You can use the setup_edge_trigger() function to trigger the oscilloscope on a positive or negative slope of the waveform.

import dwfpy as dwf

with dwf.Device() as device:
    scope[0].setup(range=5.0)
    scope.setup_edge_trigger(mode='normal', channel=0, slope='rising', level=0.5, hysteresis=0.01)
    scope.single(sample_rate=1e6, buffer_size=4096, configure=True, start=True)
    samples = scope[0].get_data()

For a complete example, see examples/analog_in_single.py.