Using the Logic Analyzer

If your device has a logic analyzer, you can access it via the property digital_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 logic analyzer:

Acquisition

Triggering

Channel specific Triggering

  • digital_input[ch].setup_trigger() - Sets up the trigger condition for this channel.

  • digital_input[ch].setup_reset_trigger() - Sets up the trigger reset condition for this channel.

Single Data Acquisition

You can use the single() function on the digital input unit to perform a single-shot data acquisition. To configure the logic analyzer, 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:
    logic = device.digital_input
    samples = logic.single(sample_rate=1e6, buffer_size=4096, configure=True, start=True)
    print(samples)

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

Recording Samples

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

import dwfpy as dwf

with dwf.Device() as device:
    logic = device.digital_input
    recorder = logic.record(sample_rate=1e6, sample_count=1e6, configure=True, start=True)
    samples = recorder.data_samples
    print(samples)

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

For an examples that uses data compression, see examples/digital_in_record_compress.py.