> ## Documentation Index
> Fetch the complete documentation index at: https://docs.embedder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Digilent WaveForms

> Use a supported Digilent WaveForms device for digital capture, analog measurement, generated stimulus, and supply-rail control in one workflow.

Embedder integrates Digilent WaveForms instruments through one provider. A compatible device can expose a logic analyzer, analog inputs, waveform outputs, or adjustable supply rails. Hardware status reports each instrument separately, so support for one instrument does not imply that every instrument is present.

The shipped workflow is hardware-verified with Analog Discovery 3. Other WaveForms devices are selected by the capabilities they report at runtime.

## Prepare the device

<Steps>
  <Step title="Connect the Digilent device">
    Use a data-capable USB cable, then check hardware status. Confirm the device name, serial number, and whether logic analyzer, oscilloscope, and waveform generator instruments are available.
  </Step>

  <Step title="Prepare the runtime">
    Approve the managed WaveForms runtime when the host does not already provide one. Approve `dwfpy` in Embedder's isolated Python environment on first use.
  </Step>

  <Step title="Close competing sessions">
    Close another application or script that owns the device before retrying a failed connection.
  </Step>

  <Step title="Map physical channels">
    Digilent helpers use zero-based channel indexes. For example, Analog Discovery 3 exposes digital indexes `0` through `15`; analog input channel `0` is Channel 1.
  </Step>
</Steps>

## Use the public script surface

Hardware scripts receive the provider-neutral `la_*` helpers automatically. Call those helpers directly; do not import `dwfpy`.

This keeps the digital-capture portion of a script portable across analyzer providers. Provider-specific capabilities and limits still apply.

## Capture and decode digital signals

Digilent supports timed and manual digital captures, edge or level triggers, raw CSV, decoded CSV, and `.dwf3.json` capture bundles. The built-in decoders cover UART, SPI, I2C, CAN, LIN, 1-Wire, Manchester, JTAG, SWD, Modbus, and I2S/PCM.

```text theme={"system"}
Use the Digilent analyzer. Trigger on a rising edge at digital channel 4,
capture UART on channel 0 at 230400 baud, and publish the decoded result to
the Logic tab.
```

Analog Discovery 3 has a fixed digital threshold. A threshold argument is validated so a generic script remains portable, but it does not change that device's threshold.

See [Logic analyzer](/debug-mode/logic-analyzer) for capture, trigger, decoder, and export details.

## Record analog channels

Use `la_record_analog` to sample analog inputs and publish the result to the Monitor's Power tab:

```python theme={"system"}
capture = la_record_analog(
    channels=[0, 1],
    duration_seconds=0.050,
    sample_rate=1_000_000,
    range_volts=5.0,
    channel_names=["vout_v", "vin_v"],
    name="startup rails",
)
la_print_result(True, "Captured startup rails", data={
    "capture_id": capture.get("capture_id"),
    "sample_rate": capture.get("sampleRate"),
    "sample_count": capture.get("sampleCount"),
})
```

`range_volts` is the expected positive or negative peak. A value of `5.0` requests a ±5 V acquisition window. Use the returned sample rate and sample count in calculations because the device can quantize or limit the request.

<Note>
  Digilent analog captures use the Power tab's multi-channel time-series format. They do not appear in the Oscilloscope tab used by the Siglent and PicoScope providers.
</Note>

Pass `publish=False` when you need to transform a capture first, then call `la_publish_power(capture)` to publish it later.

## Generate a stimulus

Configure a supported waveform output with `la_wavegen_setup`, then start it explicitly:

```python theme={"system"}
la_wavegen_setup(
    channel=0,
    function="square",
    frequency=10_000,
    amplitude=1.0,
    offset=1.0,
    symmetry=25.0,
)
la_wavegen_start([0])
```

The public helpers support DC, sine, square, triangle, ramps, noise, pulse, trapezium, sine-power, and normalized custom samples when the selected device exposes them. `la_wavegen_dc` and `la_wavegen_pulse` combine common setup and start operations.

Always stop generated outputs in cleanup:

```python theme={"system"}
la_wavegen_stop()
```

## Control and monitor supply rails

On a device with supported supplies, `la_psu_setup` changes only the rails you specify. Passing `None` leaves a rail unchanged, while `0` disables it.

```python theme={"system"}
status = la_psu_setup(positive_volts=3.3, negative_volts=None)
la_print_result(True, "Enabled the 3.3 V rail", data=status)
```

For Analog Discovery 3, the positive rail range is 0 to +5 V and the negative rail range is -5 to 0 V. `la_psu_status` reads the available voltage, current, and temperature values. `la_psu_monitor` polls those values and publishes a time series to the Power tab.

<Warning>
  Confirm the target's voltage, polarity, current demand, grounding, and external-power state before enabling a rail or waveform output. A successful API call does not prove the wiring is safe.
</Warning>

## Coordinate combined measurements

Logic, analog input, waveform output, and supplies share the same Digilent device lease. Put a stimulus and its response capture in one [hardware script](/debug-mode/hardware-scripts) so another session cannot reconfigure the device between steps.

Use `try` and `finally` around driven outputs:

```python theme={"system"}
try:
    la_wavegen_pulse(0, frequency=1_000, duty_pct=50.0, amplitude=1.0)
    capture = la_record_analog([0], 0.020, 500_000, name="pulse response")
    la_print_result(True, "Captured pulse response", data={
        "capture_id": capture.get("capture_id"),
        "sample_count": capture.get("sampleCount"),
    })
finally:
    la_wavegen_stop()
```

## Fix Digilent problems

<AccordionGroup>
  <Accordion title="No device appears">
    Refresh hardware status, check the USB cable, and close software that may own the device. Verify that the WaveForms runtime and `dwfpy` setup completed successfully.
  </Accordion>

  <Accordion title="One instrument is unavailable">
    Read the per-device capability result. Embedder discovers logic, analog input, and waveform output independently; choose a device that exposes the instrument used by the script.
  </Accordion>

  <Accordion title="A channel is out of range">
    Use zero-based indexes and the channel count shown in hardware status. Do not assume every WaveForms device has the Analog Discovery 3 layout.
  </Accordion>

  <Accordion title="The analog result is clipped">
    Increase `range_volts` or reduce the signal amplitude. Confirm that the offset keeps the full waveform inside the requested acquisition window.
  </Accordion>

  <Accordion title="The result opened in the wrong view">
    Digital captures publish to Logic. Analog input and supply-monitor captures publish to Power. Use Siglent or PicoScope for the Monitor's Oscilloscope view.
  </Accordion>
</AccordionGroup>

<CardGroup cols={2}>
  <Card title="Logic analyzer" icon="wave-square" href="/debug-mode/logic-analyzer">
    Configure digital capture, triggers, decoders, and exports.
  </Card>

  <Card title="Power analyzers" icon="bolt" href="/debug-mode/power-analyzer">
    Compare dedicated current and energy measurement paths.
  </Card>
</CardGroup>
