ABV Labs
HomeProductsResourcesSupport & CommunityResellersContact

API Reference

Python SDK API

Use the SDK 0.13.0 AI, AO, DIO, counter, encoder, time measurement, PWM and pulse-train calls with explicit handles, status and complete parameter references.

SignalDAQ 2421

Documentation edition: SignalDAQ SDK 0.13.0 — Current

Choose another edition

Use the SDK 0.13.0 AI, AO, DIO, counter, encoder, time measurement, PWM and pulse-train calls with explicit handles, status and complete parameter references.

Start with single/finite analog operations and separate ADC/DAC code functions. Then use bank DIO and every timer-backed digital area. Every worked listing below is a complete independent program; the reference tables include the current parameters and outputs.

Use SDK 0.13.0 and firmware 1.1.36, the development pairing documented by this SDK. This is a breaking wrapper/read API update; rebuild callers and use the matching DLL. Use Windows 10 or later, the SignalDAQ WinUSB driver for hardware, and an x64 or x86 DLL matching the calling process. Close other SignalDAQ applications before opening hardware.

All complete examples open the simulator by default. It opens no USB device and generates no physical voltage. Simulation checks API usage and software state, not analog accuracy, electrical timing, throughput, or waveform integrity.

Device operations take an explicit handle and return signed status: 0 is success; AI/DIO stream reads also return +1 at normal finite EOF. Python returns status first when data is returned; C# uses out parameters; C uses output pointers. Check status before using outputs, and preserve partial stream-read data/counts on errors. These APIs do not automatically throw status errors. Loader/runtime failures and some utility helpers can still raise exceptions.

AI Single Read and Read return voltage values only. Single Read Codes and Read Codes return decoded signed I32 samples without host voltage conversion. Code reads and voltage reads consume the same acquisition queue. Raw AI Read returns packet bytes and is not a decoded-code read. AO likewise has separate voltage and decoded-code writes, plus a packet-byte Raw Write.

Use Python 3.9 or later. Install the wrapper from the SDK folder with python -m pip install ./wrappers/python. The worked programs import signaldaq as s; they use module functions, not Device analog methods. Keep the same environment for installation and execution.

SE means single ended. A DIFF selection measures the first input relative to the second. Selections are sequential; physical pin overlap is permitted but duplicate logical IDs are invalid.

Analog input selectionValueAnalog input selectionValue
AIChannel.AI0_AI8_DIFF0AIChannel.AI4_SE12
AIChannel.AI1_AI9_DIFF1AIChannel.AI5_SE13
AIChannel.AI2_AI10_DIFF2AIChannel.AI6_SE14
AIChannel.AI3_AI11_DIFF3AIChannel.AI7_SE15
AIChannel.AI4_AI12_DIFF4AIChannel.AI8_SE16
AIChannel.AI5_AI13_DIFF5AIChannel.AI9_SE17
AIChannel.AI6_AI14_DIFF6AIChannel.AI10_SE18
AIChannel.AI7_AI15_DIFF7AIChannel.AI11_SE19
AIChannel.AI0_SE8AIChannel.AI12_SE20
AIChannel.AI1_SE9AIChannel.AI13_SE21
AIChannel.AI2_SE10AIChannel.AI14_SE22
AIChannel.AI3_SE11AIChannel.AI15_SE23
PurposeNamed values
Output channelsSDAQ_AO0 / SDAQ_AO1 in C; AOChannel.AO0 / AOChannel.AO1 in wrappers.
AI acquisition modeSDAQ_CONTINUOUS=0 / SDAQ_FINITE=1 in C; AcquisitionMode.Continuous / .Finite in wrappers.
AO generation modeThe same C values; GenerationMode.Continuous / .Finite in wrappers.

Use the SDK constants and enums; do not redefine them. Current onboard capacity and minimum prefill come from firmware capabilities read at Open. Legacy exported capacity constants are not a substitute for device-reported limits.

Read a calibrated AI0 voltage without configuring a stream. Every language supplies handle explicitly and checks status before using the output.

Single Read uses the fixed calibrated 1600 S/s profile with ADC filter settling; this is not a promise of 1600 host calls per second. Simulator samples are zero; real readings depend on the signal.

Single Read returns volts only. Use Single Read Codes for decoded ADC codes. LabVIEW requires regenerated call nodes; no LabVIEW diagram is supplied here.

Code example

Python

import math
import sys
import time
import signaldaq as s

def report(status):
    print(f"SDK status {status}: {s.status_message(status)}", file=sys.stderr)
    return status

def run_example(handle):
    status, volts = s.read_single_ai(handle, [s.AIChannel.AI0_SE])
    if status != 0:
        return report(status)
    print(f"AI0: {volts[0]:.4f} V")
    return 0

def main():
    status, handle = s.open_simulated()
    if status != 0:
        report(status)
        return 1
    result = 0
    try:
        result = run_example(handle)
    finally:
        # Attempt every cleanup operation, even when an earlier one fails.
        cleanup = [
            ("Stop AI", s.stop_ai(handle)),
            ("Close", s.close_device(handle)),
        ]
        for label, status in cleanup:
            if status != 0:
                print(label, file=sys.stderr)
                report(status)
                if result == 0:
                    result = status
    return 0 if result == 0 else 1

if __name__ == "__main__":
    raise SystemExit(main())

Configure a finite total of 100 samples from AI0 with a request of 1000 S/s/channel, then Start and Read.

The current profile table selects 1600 S/s/channel for this request. The nominal duration is 100/1600 = 0.0625 seconds, before startup and transfer overhead.

Read returns volts only. Inspect the returned count even if status indicates an error: complete samples already delivered remain valid. A further read after completion and draining returns +1 with an empty array and zero count.

Code example

Python

import math
import sys
import time
import signaldaq as s

def report(status):
    print(f"SDK status {status}: {s.status_message(status)}", file=sys.stderr)
    return status

def run_example(handle):
    status, actual_rate = s.configure_ai(handle, [s.AIChannel.AI0_SE], 1000,
        s.AcquisitionMode.Finite, total_finite_acquisition_samples_per_channel=100)
    if status != 0:
        return report(status)
    print(f"Nominal rate: {actual_rate:g} S/s/channel")
    status = s.start_ai(handle)
    if status != 0:
        return report(status)
    status, volts, count = s.read_ai(handle, 100)
    print("Samples returned, including any partial result:", count)
    if status not in (0, 1):
        return report(status)
    if count:
        print("First voltage:", volts[0])
    status, tail, count = s.read_ai(handle, 1)
    print("End status:", status, "remaining samples:", count)
    if status != 1:
        return report(status if status != 0 else -10)
    return 0

def main():
    status, handle = s.open_simulated()
    if status != 0:
        report(status)
        return 1
    result = 0
    try:
        result = run_example(handle)
    finally:
        # Attempt every cleanup operation, even when an earlier one fails.
        cleanup = [
            ("Stop AI", s.stop_ai(handle)),
            ("Close", s.close_device(handle)),
        ]
        for label, status in cleanup:
            if status != 0:
                print(label, file=sys.stderr)
                report(status)
                if result == 0:
                    result = status
    return 0 if result == 0 else 1

if __name__ == "__main__":
    raise SystemExit(main())

Use the new Single Read Codes and Read Codes functions. They return signed I32 sample values without host voltage conversion; the values still reflect the ADC calibration applied by firmware.

Single Read Codes invalidates earlier scan configuration, so Configure is called after the single measurement. Configure/Start lifecycle and stream-read count semantics match voltage reads.

Read Codes and voltage Read consume the same acquisition queue. Calling one after the other returns successive samples, not two views of one sample block. Raw Read is a different interface returning firmware packet bytes.

Code example

Python

import math
import sys
import time
import signaldaq as s

def report(status):
    print(f"SDK status {status}: {s.status_message(status)}", file=sys.stderr)
    return status

def run_example(handle):
    status, single_codes = s.read_single_ai_codes(handle, [s.AIChannel.AI0_SE])
    if status != 0:
        return report(status)
    print("Single ADC code:", single_codes[0])
    status, actual_rate = s.configure_ai(handle, [s.AIChannel.AI0_SE], 1000, s.AcquisitionMode.Finite, 100)
    if status != 0:
        return report(status)
    status = s.start_ai(handle)
    if status != 0:
        return report(status)
    status, codes, count = s.read_ai_codes(handle, -1)
    print("Decoded samples:", count)
    if count:
        print("First ADC code:", codes[0])
    if status not in (0, 1):
        return report(status)
    return 0

def main():
    status, handle = s.open_simulated()
    if status != 0:
        report(status)
        return 1
    result = 0
    try:
        result = run_example(handle)
    finally:
        # Attempt every cleanup operation, even when an earlier one fails.
        cleanup = [
            ("Stop AI", s.stop_ai(handle)),
            ("Close", s.close_device(handle)),
        ]
        for label, status in cleanup:
            if status != 0:
                print(label, file=sys.stderr)
                report(status)
                if result == 0:
                    result = status
    return 0 if result == 0 else 1

if __name__ == "__main__":
    raise SystemExit(main())

Upload a 256-sample sine cycle once, then repeat it onboard for a short demonstration. The requested waveform spans 0.5 to 4.5 V.

Configure Onboard does not upload or start. Write the complete cycle before Start. The entire waveform must fit the reported onboard capacity; no PC refill is needed during repeat.

Use the returned rate to calculate frequency: actual rate / 256. At 10000 S/s that is 39.0625 Hz. Increase the hold time when observing hardware.

Code example

Python

import math
import sys
import time
import signaldaq as s

def report(status):
    print(f"SDK status {status}: {s.status_message(status)}", file=sys.stderr)
    return status

def run_example(handle):
    samples_per_cycle = 256
    waveform = [2.5 + 2.0 * math.sin(2 * math.pi * i / samples_per_cycle) for i in range(samples_per_cycle)]
    status, actual_rate = s.configure_ao_onboard(handle, [s.AOChannel.AO0], 10000, samples_per_cycle)
    if status != 0:
        return report(status)
    print(f"Cycle frequency: {actual_rate / samples_per_cycle:g} Hz")
    status = s.write_ao(handle, waveform)
    if status != 0:
        return report(status)
    status = s.start_ao(handle)
    if status != 0:
        return report(status)
    time.sleep(0.25)
    return 0

def main():
    status, handle = s.open_simulated()
    if status != 0:
        report(status)
        return 1
    result = 0
    try:
        result = run_example(handle)
    finally:
        # Attempt every cleanup operation, even when an earlier one fails.
        cleanup = [
            ("Stop AO", s.stop_ao(handle)),
            ("Zero owned outputs", s.write_single_ao(handle, [s.AOChannel.AO0], [0.0])),
            ("Close", s.close_device(handle)),
        ]
        for label, status in cleanup:
            if status != 0:
                print(label, file=sys.stderr)
                report(status)
                if result == 0:
                    result = status
    return 0 if result == 0 else 1

if __name__ == "__main__":
    raise SystemExit(main())

Use Single Write Codes for one integer value and Write Codes for a finite waveform. Current DAC codes are unsigned integers from 0 to 65535.

These calls bypass host voltage calibration. A code is not a calibrated voltage request. Raw Write is different: it accepts firmware packet bytes, not an array of decoded DAC values.

The finite waveform alternates codes 13107 and 39321; do not infer measured voltages from these example codes. The program stops and commands AO0 to 0 V during cleanup.

Code example

Python

import math
import sys
import time
import signaldaq as s

def report(status):
    print(f"SDK status {status}: {s.status_message(status)}", file=sys.stderr)
    return status

def run_example(handle):
    status = s.write_single_ao_codes(handle, [s.AOChannel.AO0], [32768])
    if status != 0:
        return report(status)
    waveform = [13107 if (i // 64) % 2 == 0 else 39321 for i in range(1024)]
    status, actual_rate = s.configure_ao(handle, [s.AOChannel.AO0], 10000, s.GenerationMode.Finite, len(waveform))
    if status != 0:
        return report(status)
    status = s.write_ao_codes(handle, waveform)
    if status != 0:
        return report(status)
    status = s.start_ao(handle)
    if status != 0:
        return report(status)

    deadline = time.monotonic() + 5.0
    while True:
        status, output_state = s.get_ao_status(handle, [s.AOChannel.AO0])
        if status != 0:
            return report(status)
        if not output_state['waveform_running'][0]:
            break
        if time.monotonic() >= deadline:
            return report(-3)
        time.sleep(0.01)
    print("Finite waveform stopped")
    return 0

def main():
    status, handle = s.open_simulated()
    if status != 0:
        report(status)
        return 1
    result = 0
    try:
        result = run_example(handle)
    finally:
        # Attempt every cleanup operation, even when an earlier one fails.
        cleanup = [
            ("Stop AO", s.stop_ao(handle)),
            ("Zero owned outputs", s.write_single_ao(handle, [s.AOChannel.AO0], [0.0])),
            ("Close", s.close_device(handle)),
        ]
        for label, status in cleanup:
            if status != 0:
                print(label, file=sys.stderr)
                report(status)
                if result == 0:
                    result = status
    return 0 if result == 0 else 1

if __name__ == "__main__":
    raise SystemExit(main())

Configure banks A and B as outputs. Set A to 85 and B to 3, then clear only bit 0 of A with mask 1. Read both banks in reverse order.

Omitted masks mean every valid bit, not zero bits. Explicit mask 0 changes nothing. Supplied masks, values and directions must match the bank selection length.

The simulator snapshot is [3, 84] for [B, A]. On hardware, Single Read samples pin levels; Status reports the output latch and configured direction. Neither is a waveform recorder. Static writes are sequential, not atomic.

This example owns bank A/B and resets that entire selection to GPIO Input before the example and during cleanup. Run separately; do not use it on a bank owned by another task.

Code example

Python

import math
import sys
import time
import signaldaq as s

def report(status):
    print(f"SDK status {status}: {s.status_message(status)}", file=sys.stderr)
    return status

def run_example(handle):
    status = s.configure_dio_direction(handle, [s.DIOBank.A, s.DIOBank.B], [s.DIODirection.Input] * 2)
    if status != 0: return report(status)
    banks = [s.DIOBank.A, s.DIOBank.B]
    status = s.configure_dio_direction(handle, banks, [s.DIODirection.Output]*2)
    if status != 0: return report(status)
    status = s.write_single_dio(handle, banks, [85, 3])
    if status != 0: return report(status)
    status = s.write_single_dio(handle, [s.DIOBank.A], [0], write_masks=[1])
    if status != 0: return report(status)
    status, pins = s.read_single_dio(handle, [s.DIOBank.B, s.DIOBank.A])
    if status != 0: return report(status)
    print("Pin snapshot B, A:", pins)
    status, state = s.get_dio_status(handle, banks)
    if status != 0: return report(status)
    print("Bank state:", state)
    return 0

def main():
    status, handle = s.open_simulated()
    if status != 0:
        report(status)
        return 1
    result = 0
    try:
        result = run_example(handle)
    finally:
        # Attempt every cleanup operation, even when an earlier one fails.
        cleanup = [
            ("Return owned banks to Input", s.configure_dio_direction(handle, [s.DIOBank.A, s.DIOBank.B], [s.DIODirection.Input] * 2)),
            ("Close", s.close_device(handle)),
        ]
        for label, status in cleanup:
            if status != 0:
                print(label, file=sys.stderr)
                report(status)
                if result == 0:
                    result = status
    return 0 if result == 0 else 1

if __name__ == "__main__":
    raise SystemExit(main())

Configure bank B for SevenBit input at a requested 1000 samples/s. Start, read all 17 samples, and verify the next read returns +1 with zero count.

Every U32 sample holds one bank bit pattern in bits 0..6. Python/C# allocate internally; the C buffer capacity is 17 samples. Preserve the returned count and data before handling a read error.

Simulator input samples are zero, not a measured external voltage or loopback. Actual input values depend on wiring. The returned rate is nominal board timing; CPU-paced firmware and transfers can affect observed throughput.

This example owns bank B and resets that entire selection to GPIO Input before the example and during cleanup. Run separately; do not use it on a bank owned by another task.

Code example

Python

import math
import sys
import time
import signaldaq as s

def report(status):
    print(f"SDK status {status}: {s.status_message(status)}", file=sys.stderr)
    return status

def run_example(handle):
    status = s.configure_dio_direction(handle, [s.DIOBank.B], [s.DIODirection.Input] * 1)
    if status != 0: return report(status)
    status, actual = s.configure_dio(handle, [s.DIOBank.B], [s.DIODirection.Input],
        s.DIOWidth.SevenBit, 1000, s.AcquisitionMode.Finite, 17)
    if status != 0: return report(status)
    status = s.start_dio(handle)
    if status != 0: return report(status)
    status, values, count = s.read_dio(handle, -1)
    print("Nominal rate:", actual, "S/s; samples including partial data:", count, values)
    if status not in (0, 1): return report(status)
    status, tail, count = s.read_dio(handle, 1)
    print("End status:", status, "count:", count)
    if status != 1 or count != 0: return report(status if status != 0 else -10)
    return 0

def main():
    status, handle = s.open_simulated()
    if status != 0:
        report(status)
        return 1
    result = 0
    try:
        result = run_example(handle)
    finally:
        # Attempt every cleanup operation, even when an earlier one fails.
        cleanup = [
            ("Stop DIO", s.stop_dio(handle)),
            ("Return owned banks to Input", s.configure_dio_direction(handle, [s.DIOBank.B], [s.DIODirection.Input] * 1)),
            ("Close", s.close_device(handle)),
        ]
        for label, status in cleanup:
            if status != 0:
                print(label, file=sys.stderr)
                report(status)
                if result == 0:
                    result = status
    return 0 if result == 0 else 1

if __name__ == "__main__":
    raise SystemExit(main())

Queue 17 SevenBit bank A samples, alternating 0 and 127. Start and poll bank Status until generation is no longer running, with a five-second application deadline.

Write success means host acceptance. Start is asynchronous: do not Stop immediately after upload. The finite total is smaller than 8000, so queue the entire 17-sample total before Start.

Finite completion retains the last output pattern until Stop. Stop returns the stream bank to Input; the runner also resets its owned bank. Status running=false is not an electrical waveform-integrity measurement.

This example owns bank A and resets that entire selection to GPIO Input before the example and during cleanup. Run separately; do not use it on a bank owned by another task.

Code example

Python

import math
import sys
import time
import signaldaq as s

def report(status):
    print(f"SDK status {status}: {s.status_message(status)}", file=sys.stderr)
    return status

def run_example(handle):
    status = s.configure_dio_direction(handle, [s.DIOBank.A], [s.DIODirection.Input] * 1)
    if status != 0: return report(status)
    status, actual = s.configure_dio(handle, [s.DIOBank.A], [s.DIODirection.Output],
        s.DIOWidth.SevenBit, 1000, s.AcquisitionMode.Finite, 17)
    if status != 0: return report(status)
    status = s.write_dio(handle, [127 if i%2 else 0 for i in range(17)])
    if status != 0: return report(status)
    status = s.start_dio(handle)
    if status != 0: return report(status)
    deadline = time.monotonic()+5
    while True:
        status, state = s.get_dio_status(handle, [s.DIOBank.A])
        if status != 0: return report(status)
        if not state['stream_running'][0]: break
        if time.monotonic() >= deadline: return report(-3)
        time.sleep(0.002)
    print("Generation stopped; nominal rate:", actual)
    return 0

def main():
    status, handle = s.open_simulated()
    if status != 0:
        report(status)
        return 1
    result = 0
    try:
        result = run_example(handle)
    finally:
        # Attempt every cleanup operation, even when an earlier one fails.
        cleanup = [
            ("Stop DIO", s.stop_dio(handle)),
            ("Return owned banks to Input", s.configure_dio_direction(handle, [s.DIOBank.A], [s.DIODirection.Input] * 1)),
            ("Close", s.close_device(handle)),
        ]
        for label, status in cleanup:
            if status != 0:
                print(label, file=sys.stderr)
                report(status)
                if result == 0:
                    result = status
    return 0 if result == 0 else 1

if __name__ == "__main__":
    raise SystemExit(main())

Configure A Output and B Input in FourBit mode, prefill 17 output values 0..15, then Start and read 17 input samples.

Current FourBit streaming fixes A as output and B as input. SevenBit streaming allows the supported alternative bank mappings. There is one bank per direction today; two input or two output banks are not supported by the streaming engine.

The simulator returns zero input samples and does not connect A to B. For physical loopback, wire only permitted digital outputs to inputs according to the product manual. DIO sample values are not packet bytes; there are no public DIO raw transfer calls.

This example owns bank A/B and resets that entire selection to GPIO Input before the example and during cleanup. Run separately; do not use it on a bank owned by another task.

Code example

Python

import math
import sys
import time
import signaldaq as s

def report(status):
    print(f"SDK status {status}: {s.status_message(status)}", file=sys.stderr)
    return status

def run_example(handle):
    status = s.configure_dio_direction(handle, [s.DIOBank.A, s.DIOBank.B], [s.DIODirection.Input] * 2)
    if status != 0: return report(status)
    status, actual = s.configure_dio(handle, [s.DIOBank.A, s.DIOBank.B],
        [s.DIODirection.Output, s.DIODirection.Input], s.DIOWidth.FourBit,
        1000, s.AcquisitionMode.Finite, 17)
    if status != 0: return report(status)
    status = s.write_dio(handle, [i%16 for i in range(17)])
    if status != 0: return report(status)
    status = s.start_dio(handle)
    if status != 0: return report(status)
    status, inputs, count = s.read_dio(handle, -1)
    print("Input samples including partial data:", count, inputs)
    if status not in (0,1): return report(status)
    return 0

def main():
    status, handle = s.open_simulated()
    if status != 0:
        report(status)
        return 1
    result = 0
    try:
        result = run_example(handle)
    finally:
        # Attempt every cleanup operation, even when an earlier one fails.
        cleanup = [
            ("Stop DIO", s.stop_dio(handle)),
            ("Return owned banks to Input", s.configure_dio_direction(handle, [s.DIOBank.A, s.DIOBank.B], [s.DIODirection.Input] * 2)),
            ("Close", s.close_device(handle)),
        ]
        for label, status in cleanup:
            if status != 0:
                print(label, file=sys.stderr)
                report(status)
                if result == 0:
                    result = status
    return 0 if result == 0 else 1

if __name__ == "__main__":
    raise SystemExit(main())

Connect a permitted digital pulse source to A6 and the correct reference before hardware use. Count rising edges, read the accumulated count, then measure over a 100 ms gate.

Frequency measurement resets the hardware counter, blocks during its gate, and returns the gated count and rounded integer Hz. It is not a nondestructive instantaneous-frequency query. Gate arrays match line arrays; multiple gates execute sequentially.

The simulator starts the count at zero and models a 1 kHz source during the gate, returning count 100 and frequency 1000 Hz. These are deterministic simulator values, not a hardware accuracy specification. Hardware counts wrap at the selected timer width.

This example owns bank A and resets that entire selection to GPIO Input before the example and during cleanup. Run separately; do not use it on a bank owned by another task.

Code example

Python

import math
import sys
import time
import signaldaq as s

def report(status):
    print(f"SDK status {status}: {s.status_message(status)}", file=sys.stderr)
    return status

def run_example(handle):
    status = s.configure_dio_direction(handle, [s.DIOBank.A], [s.DIODirection.Input] * 1)
    if status != 0: return report(status)
    lines=[s.DigitalLine.A6]
    status=s.configure_counter(handle,lines,[s.DigitalEdge.Rising])
    if status!=0: return report(status)
    status=s.reset_counter(handle,lines)
    if status!=0: return report(status)
    time.sleep(0.1)
    status,counts=s.read_counter(handle,lines)
    if status!=0: return report(status)
    print("Accumulated edges:",counts)
    status,counts,hz=s.read_counter_frequency(handle,lines,gate_ms=[100])
    if status!=0: return report(status)
    print("100 ms count:",counts,"Frequency Hz:",hz)
    return 0

def main():
    status, handle = s.open_simulated()
    if status != 0:
        report(status)
        return 1
    result = 0
    try:
        result = run_example(handle)
    finally:
        # Attempt every cleanup operation, even when an earlier one fails.
        cleanup = [
            ("Return owned banks to Input", s.configure_dio_direction(handle, [s.DIOBank.A], [s.DIODirection.Input] * 1)),
            ("Close", s.close_device(handle)),
        ]
        for label, status in cleanup:
            if status != 0:
                print(label, file=sys.stderr)
                report(status)
                if result == 0:
                    result = status
    return 0 if result == 0 else 1

if __name__ == "__main__":
    raise SystemExit(main())

Connect encoder channel A to A6 and B to A5, using compatible signal levels and the correct reference. Configure X4 decoding, reset position, and read its signed count.

Read and Reset select the configured A line; the SDK resolves its timer. Supported A/B pairs are A4/A3, A6/A5, B4/B3 and B6/B5. Pair order matters. Modes are X2 or X4.

Simulator position is zero because it has no moving encoder input. Hardware position is a signed 16-bit or 32-bit timer count depending on the selected timer; the SDK does not extend rollover or convert to distance/angle. Configure also resets the count.

This example owns bank A and resets that entire selection to GPIO Input before the example and during cleanup. Run separately; do not use it on a bank owned by another task.

Code example

Python

import math
import sys
import time
import signaldaq as s

def report(status):
    print(f"SDK status {status}: {s.status_message(status)}", file=sys.stderr)
    return status

def run_example(handle):
    status = s.configure_dio_direction(handle, [s.DIOBank.A], [s.DIODirection.Input] * 1)
    if status != 0: return report(status)
    lines_a=[s.DigitalLine.A6]
    status=s.configure_encoder(handle,lines_a,[s.DigitalLine.A5],[s.EncoderMode.X4])
    if status!=0: return report(status)
    status=s.reset_encoder(handle,lines_a)
    if status!=0: return report(status)
    time.sleep(0.1)
    status,positions=s.read_encoder(handle,lines_a)
    if status!=0: return report(status)
    print("Encoder position counts:",positions)
    return 0

def main():
    status, handle = s.open_simulated()
    if status != 0:
        report(status)
        return 1
    result = 0
    try:
        result = run_example(handle)
    finally:
        # Attempt every cleanup operation, even when an earlier one fails.
        cleanup = [
            ("Return owned banks to Input", s.configure_dio_direction(handle, [s.DIOBank.A], [s.DIODirection.Input] * 1)),
            ("Close", s.close_device(handle)),
        ]
        for label, status in cleanup:
            if status != 0:
                print(label, file=sys.stderr)
                report(status)
                if result == 0:
                    result = status
    return 0 if result == 0 else 1

if __name__ == "__main__":
    raise SystemExit(main())

Connect a permitted repeating signal to A6. Configure Period with Rising edges, reset measurement state, and read the captured interval.

The result includes ticks, rounded integer microseconds, tick_hz and prescaler. Microseconds can be zero for sub-microsecond intervals; use ticks/tick_hz for finer numerical interpretation. This does not establish absolute hardware accuracy.

Simulator values are 108000 ticks, 1000 microseconds, 108000000 ticks/s, and prescaler 0. Hardware requires actual edges; missing input returns a firmware error. For PulseWidth mode, firmware uses its fixed PWM-input capture polarity rather than selecting pulse polarity with the edge argument.

This example owns bank A and resets that entire selection to GPIO Input before the example and during cleanup. Run separately; do not use it on a bank owned by another task.

Code example

Python

import math
import sys
import time
import signaldaq as s

def report(status):
    print(f"SDK status {status}: {s.status_message(status)}", file=sys.stderr)
    return status

def run_example(handle):
    status = s.configure_dio_direction(handle, [s.DIOBank.A], [s.DIODirection.Input] * 1)
    if status != 0: return report(status)
    lines=[s.DigitalLine.A6]
    status=s.configure_time(handle,lines,[s.TimeMode.Period],[s.DigitalEdge.Rising])
    if status!=0: return report(status)
    status=s.reset_time(handle,lines)
    if status!=0: return report(status)
    status,result=s.read_time(handle,lines)
    if status!=0: return report(status)
    seconds=result['ticks'][0]/result['tick_hz'][0]
    print("Period:",result['microseconds'][0],"us; ticks/tick_hz:",seconds,"s")
    return 0

def main():
    status, handle = s.open_simulated()
    if status != 0:
        report(status)
        return 1
    result = 0
    try:
        result = run_example(handle)
    finally:
        # Attempt every cleanup operation, even when an earlier one fails.
        cleanup = [
            ("Return owned banks to Input", s.configure_dio_direction(handle, [s.DIOBank.A], [s.DIODirection.Input] * 1)),
            ("Close", s.close_device(handle)),
        ]
        for label, status in cleanup:
            if status != 0:
                print(label, file=sys.stderr)
                report(status)
                if result == 0:
                    result = status
    return 0 if result == 0 else 1

if __name__ == "__main__":
    raise SystemExit(main())

Connect a suitable scope or input-only load to A6. Configure 1000 Hz and 25% duty, change to 50%, and inspect configured timer state.

Duty values are fractions 0.0..1.0, not percentages or ppm. Every frequency/duty array must match the line selection. Actual frequency/duty reflect timer quantization; Status is not electrical pin feedback.

The simulator reports 1000 Hz and 0.5 duty here. Writing duty 0 holds low without releasing timer ownership. The complete runner returns its owned bank to Input afterward, which releases specialty ownership; Close alone does not do this.

This example owns bank A and resets that entire selection to GPIO Input before the example and during cleanup. Run separately; do not use it on a bank owned by another task.

Code example

Python

import math
import sys
import time
import signaldaq as s

def report(status):
    print(f"SDK status {status}: {s.status_message(status)}", file=sys.stderr)
    return status

def run_example(handle):
    status = s.configure_dio_direction(handle, [s.DIOBank.A], [s.DIODirection.Input] * 1)
    if status != 0: return report(status)
    lines=[s.DigitalLine.A6]
    status=s.configure_pwm(handle,lines,frequency_hz=[1000],duties=[0.25])
    if status!=0: return report(status)
    status=s.write_pwm(handle,lines,duties=[0.5])
    if status!=0: return report(status)
    status,state=s.get_pwm_status(handle,lines)
    if status!=0: return report(status)
    print("Actual timer frequency:",state['actual_frequency_hz'],"Hz; duty:",state['actual_duties'])
    time.sleep(0.1)
    status=s.write_pwm(handle,lines,duties=[0.0])
    if status!=0: return report(status)
    return 0

def main():
    status, handle = s.open_simulated()
    if status != 0:
        report(status)
        return 1
    result = 0
    try:
        result = run_example(handle)
    finally:
        # Attempt every cleanup operation, even when an earlier one fails.
        cleanup = [
            ("Return owned banks to Input", s.configure_dio_direction(handle, [s.DIOBank.A], [s.DIODirection.Input] * 1)),
            ("Close", s.close_device(handle)),
        ]
        for label, status in cleanup:
            if status != 0:
                print(label, file=sys.stderr)
                report(status)
                if result == 0:
                    result = status
    return 0 if result == 0 else 1

if __name__ == "__main__":
    raise SystemExit(main())

Generate 100 pulses on A6 at 1000 Hz, with 50% duty and direction disabled. Use DigitalLine.Unused in Python/C#, or SDAQ_LINE_UNUSED in C.

The call blocks until firmware completion. start_frequency_hz=0 means target frequency; acceleration 0 is valid for this constant-rate train. Success returns pulses_sent=100; the simulator reports actual frequency 1000 Hz.

For hardware, use an appropriate scope or disconnected input-only load first. Do not connect an actuator merely to test this example. A timeout/failure may follow real pulse generation; never automatically retry. Close cannot abort this firmware command.

This example owns bank A and resets that entire selection to GPIO Input before the example and during cleanup. Run separately; do not use it on a bank owned by another task.

Code example

Python

import math
import sys
import time
import signaldaq as s

def report(status):
    print(f"SDK status {status}: {s.status_message(status)}", file=sys.stderr)
    return status

def run_example(handle):
    status = s.configure_dio_direction(handle, [s.DIOBank.A], [s.DIODirection.Input] * 1)
    if status != 0: return report(status)
    status,sent,actual=s.run_pulse_train(handle,line=s.DigitalLine.A6,
        direction_line=s.DigitalLine.Unused,direction_value=s.DigitalLevel.Low,
        frequency_hz=1000,duty=0.5,pulses=100,direction_setup_us=0,
        start_frequency_hz=0,acceleration_hz_per_s=0)
    if status!=0: return report(status)
    print("Pulses sent:",sent,"Initial actual timer frequency:",actual,"Hz")
    return 0

def main():
    status, handle = s.open_simulated()
    if status != 0:
        report(status)
        return 1
    result = 0
    try:
        result = run_example(handle)
    finally:
        # Attempt every cleanup operation, even when an earlier one fails.
        cleanup = [
            ("Return owned banks to Input", s.configure_dio_direction(handle, [s.DIOBank.A], [s.DIODirection.Input] * 1)),
            ("Close", s.close_device(handle)),
        ]
        for label, status in cleanup:
            if status != 0:
                print(label, file=sys.stderr)
                report(status)
                if result == 0:
                    result = status
    return 0 if result == 0 else 1

if __name__ == "__main__":
    raise SystemExit(main())

Generate 1000 pulses on A6 with A5 direction High and 10 us direction setup. Ramp from 200 Hz toward a 1000 Hz target at 400 Hz/s.

Different start and target frequencies require nonzero acceleration. direction_setup_us accepts 0..65535; the SDK derives its command deadline from the pulse count and slower requested rate.

The returned actual_frequency_hz describes the initial timer setting, not the final ramp frequency or a measured waveform. The simulator reports 200 Hz here. Firmware cleans up after the finite train; there is no separate asynchronous Start/Stop API or multi-axis synchronization in this call.

This example owns bank A and resets that entire selection to GPIO Input before the example and during cleanup. Run separately; do not use it on a bank owned by another task.

Code example

Python

import math
import sys
import time
import signaldaq as s

def report(status):
    print(f"SDK status {status}: {s.status_message(status)}", file=sys.stderr)
    return status

def run_example(handle):
    status = s.configure_dio_direction(handle, [s.DIOBank.A], [s.DIODirection.Input] * 1)
    if status != 0: return report(status)
    status,sent,actual=s.run_pulse_train(handle,line=s.DigitalLine.A6,
        direction_line=s.DigitalLine.A5,direction_value=s.DigitalLevel.High,
        frequency_hz=1000,duty=0.5,pulses=1000,direction_setup_us=10,
        start_frequency_hz=200,acceleration_hz_per_s=400)
    if status!=0: return report(status)
    print("Pulses sent:",sent,"Initial actual timer frequency:",actual,"Hz")
    return 0

def main():
    status, handle = s.open_simulated()
    if status != 0:
        report(status)
        return 1
    result = 0
    try:
        result = run_example(handle)
    finally:
        # Attempt every cleanup operation, even when an earlier one fails.
        cleanup = [
            ("Return owned banks to Input", s.configure_dio_direction(handle, [s.DIOBank.A], [s.DIODirection.Input] * 1)),
            ("Close", s.close_device(handle)),
        ]
        for label, status in cleanup:
            if status != 0:
                print(label, file=sys.stderr)
                report(status)
                if result == 0:
                    result = status
    return 0 if result == 0 else 1

if __name__ == "__main__":
    raise SystemExit(main())

Each worked listing is a complete independent program. Copy one language tab into a file; do not combine several listings or paste API reference declarations into a program. Run the simulator first. Cleanup checks Stop, output reset where applicable, and Close even after an earlier operation fails.

python -m pip install ./wrappers/python
python example.py

For hardware, replace s.open_simulated() with s.open_device() or s.open_device("YOUR_SERIAL"). Both return (status, handle); leave explicit handle arguments and status checks in place.

Reference declarations below include every parameter and default from SDK 0.13.0 source. They are not standalone executable listings. Selected arrays have matching dimensions; counts are explicit in C and inferred by high-level wrappers. Device operations take handles; Open creates them, pure helpers do not require them, and firmware upload uses its own session token.

Module callReturn and meaning
s.open_device(serial=None)Open hardware; returns (status, handle).
s.open_simulated()Open the simulator; returns (status, handle).
s.close_device(handle)Cancel pending operations and release the handle; returns status.
s.read_single_ai(handle, input_channels)One calibrated voltage per selected input; returns (status, volts).
s.read_single_ai_codes(handle, input_channels)One decoded signed ADC code per selected input; returns (status, codes).
s.configure_ai(handle, input_channels, requested_samples_per_second_per_channel, acquisition_mode_finite_continuous, total_finite_acquisition_samples_per_channel=0)Select channels, nominal rate and mode without starting; returns (status, actual_rate).
s.start_ai(handle)Start configured input; returns status.
s.stop_ai(handle)Stop AI and cancel pending reads; returns status.
s.read_ai(handle, samples_to_read_per_channel=1024)Consume voltage samples; returns (status, volts, samples_read_per_channel).
s.read_ai_codes(handle, samples_to_read_per_channel=1024)Consume decoded signed codes; returns (status, codes, samples_read_per_channel).
s.write_single_ao(handle, output_channels, volts)Write one calibrated voltage per selected output; returns status.
s.write_single_ao_codes(handle, output_channels, codes)Write one integer DAC code per selected output; returns status.
s.get_ao_status(handle, output_channels)Return (status, output_state); output_state is None on error.
s.configure_ao(handle, output_channels, requested_samples_per_second_per_channel, generation_mode_finite_continuous, finite_samples_per_channel=0)Configure finite/continuous output without starting; returns (status, actual_rate).
s.configure_ao_onboard(handle, output_channels, requested_samples_per_second_per_channel, waveform_samples_per_channel)Configure an onboard repeat cycle without uploading/starting; returns (status, actual_rate).
s.write_ao(handle, volts)Accept voltage waveform samples in configured channel order; returns status.
s.write_ao_codes(handle, codes)Accept decoded unsigned DAC samples in configured channel order; returns status.
s.start_ao(handle)Prefill/start configured output; returns status.
s.stop_ao(handle)Cancel pending waveform output and reset its queues; returns status.
s.read_ai_raw(handle, capacity_bytes=512, timeout_ms=1000)Read packet bytes, not decoded samples; returns (status, bytes).
s.write_ao_raw(handle, data, timeout_ms=1000)Write complete firmware packet bytes; returns status.
s.configure_dio_direction(handle, dio_banks: list[signaldaq.DIOBank], directions: list[signaldaq.DIODirection])status; matching selected-bank direction enum array.
s.write_single_dio(handle, dio_banks: list[signaldaq.DIOBank], output_bits, write_masks=None)status; matching values/masks; None means all valid bits.
s.read_single_dio(handle, dio_banks: list[signaldaq.DIOBank])(status, input_bits); one snapshot value per selected bank.
s.configure_dio(handle, dio_banks: list[signaldaq.DIOBank], directions: list[signaldaq.DIODirection], width, requested_samples_per_second, acquisition_mode_finite_continuous, finite_samples_per_bank=0)(status, actual_rate); saves bank selections, width and mode.
s.start_dio(handle)status; starts SDK transfer workers.
s.stop_dio(handle)status; cancels transfers and stops workers.
s.write_dio(handle, output_bits)status; accepts sample values, not firmware packets.
s.read_dio(handle, samples_to_read_per_bank=1024)(status, input_bits, samples_read_per_bank); partial data/count can accompany an error.
s.get_dio_status(handle, dio_banks: list[signaldaq.DIOBank])(status, result or None); output_bits, directions, stream_running arrays.
s.configure_counter(handle, lines, edges)status; configure matching edge selections.
s.read_counter(handle, lines)(status, counts).
s.reset_counter(handle, lines)status; reset selected hardware counters.
s.read_counter_frequency(handle, lines, gate_ms)(status, counts, frequency_hz); resets counters and measures sequential gates.
s.configure_encoder(handle, lines_a, lines_b, modes)status; configure supported ordered A/B pairs and X2/X4 modes.
s.read_encoder(handle, lines_a)(status, signed_positions).
s.reset_encoder(handle, lines_a)status; select configured A lines.
s.configure_time(handle, lines, modes, edges)status; configure matching time modes and edges.
s.read_time(handle, lines)(status, result or None); ticks, microseconds, tick_hz, prescalers arrays.
s.reset_time(handle, lines)status; reset selected measurement state.
s.configure_pwm(handle, lines, frequency_hz, duties)status; matching line, frequency and duty arrays.
s.write_pwm(handle, lines, duties)status; matching line/duty arrays.
s.get_pwm_status(handle, lines)(status, result or None); actual_frequency_hz and actual_duties arrays.
s.run_pulse_train(handle, line, direction_line, direction_value, frequency_hz, duty, pulses, direction_setup_us, start_frequency_hz, acceleration_hz_per_s)(status, pulses_sent, actual_frequency_hz); blocking scalar operation; frequency is initial timer setting.
CallBehavior
s.status_message(status)Returns explanation string; utility validation/lookup failures may raise.
s.devices()Returns serial strings; native failures raise SignalDAQError.
s.upload_firmware(path, serial=None, progress=None, cancelled=None)Advanced bootloader upload; returns acceptance/reset flags, with exceptions/callbacks. Not used in these tutorials.

s.library() exposes generated ctypes bindings for all native C exports, including discovery, conversion and firmware-session functions. These are advanced native calls, not an alternative high-level configuration path. Do not bypass wrapper metadata during a managed acquisition.

Parameter namesMeaning
handleExplicit U32 open-device token in C, Python and C#. Open creates it; Close releases it. Configure through the same wrapper API used for managed Read/Write.
input_channels / inputChannelsOrdered list of 1 to 24 unique input selections.
output_channels / outputChannelsOrdered list of one or two unique outputs.
channel_countExplicit selected-channel count in C; inferred from the selected array by Python/C#.
requested_samples_per_second_per_channel / requestedSamplesPerSecondPerChannelRequested sampling rate per channel, unsigned 32 bit integer.
acquisition_mode_finite_continuous / acquisitionModeFiniteContinuousAI AcquisitionMode or the C SDAQ_FINITE / SDAQ_CONTINUOUS constant.
total_finite_acquisition_samples_per_channel / totalFiniteAcquisitionSamplesPerChannelAI sample total per channel; positive in finite mode, ignored in continuous mode.
generation_mode_finite_continuous / generationModeFiniteContinuousAO GenerationMode or the C finite / continuous constant.
finite_samples_per_channel / finiteSamplesPerChannelAO finite total per channel, unsigned 32 bit; ignored in continuous mode.
waveform_samples_per_channel / waveformSamplesPerChannelPositive onboard cycle length per channel, within reported capacity.
actual_nominal_samples_per_second_per_channelC double output pointer for configured nominal AI rate.
actual_samples_per_second_per_channelC double output pointer for configured AO rate.
samples_to_read_per_channel / samplesToReadPerChannelPositive sample count or minus one; zero and below minus one are invalid.
output_capacity_samples_per_channelC output buffer capacity measured per channel.
samples_read_per_channelComplete scans returned, including on error: C output pointer, Python third tuple element, or C# out samplesReadPerChannel.
samples_per_channelC waveform input count measured per channel.
voltsVoltage-only AI output or calibrated AO input. Single/stream Read no longer also return codes.
codesAI decoded signed I32 sample array from *_read_codes; AO unsigned U32 DAC array for *_write_codes. These are not packet-byte arrays.
estimated_voltsC double output array containing estimated AO voltages.
output_enabled / waveform_runningC uint32 output Boolean arrays, one entry per selected output.
capacity_bytes / capacityBytesRaw read capacity, 512 to 16777216 bytes.
data / bytesRaw byte buffer. C bytes is the supplied raw write byte count, 1 to 16777216.
read_bytesC uint32 output pointer receiving the actual raw read count.
timeout_ms / timeoutMsRaw transfer timeout in milliseconds; wrapper default is 1000.

Device operations take an explicit handle and return signed status: 0 is success; AI/DIO stream reads also return +1 at normal finite EOF. Python returns status first when data is returned; C# uses out parameters; C uses output pointers. Check status before using outputs, and preserve partial stream-read data/counts on errors. These APIs do not automatically throw status errors. Loader/runtime failures and some utility helpers can still raise exceptions.

Native status nameValueNative status nameValue
SDAQ_OK0SDAQ_BUSY-6
SDAQ_END_OF_ACQUISITION1SDAQ_BUFFER_TOO_SMALL-7
SDAQ_INVALID_ARGUMENT-1SDAQ_INVALID_HANDLE-8
SDAQ_IO-2SDAQ_OVERFLOW-9
SDAQ_TIMEOUT-3SDAQ_INTERNAL-10
SDAQ_NOT_FOUND-4SDAQ_UNSUPPORTED-11
SDAQ_PROTOCOL-5SDAQ_CANCELLED-12

Always preserve Read data/count before handling a nonzero status. +1 is normal EOF; timeout -3 and cancellation -12 may accompany partial complete samples. Python returns empty values on validation failure; C# returns empty arrays and zero count. get_ao_status returns None on failure; GetAOStatus returns a null output object.

OperationPython return
Single voltage/code read(status, values)
Streaming voltage/code read(status, values, samples_read_per_channel)
Configure AI/AO/onboard(status, actual_rate)
AO state query(status, output_state); None on error
AO writes, Start, Stop, Closestatus
Raw AI Read(status, bytes)

For detailed native operation errors, call sdaq_error_message immediately on the same OS thread before another SDK call changes its text. Python status_message and C# Status.Message explain a saved numeric status independently. Wrapper-side argument validation returns -1 and does not establish new detailed native error text.

AI read countBehavior
Positive NWait for N complete scans, or the finite tail at completion.
Minus one in continuous modeImmediately return currently buffered scans, up to capacity. Zero scans can be a successful result.
Minus one in finite modeWait for completion and return all unread scans. C capacity must hold all of them.
Zero or below minus oneInvalid argument.
Completed and drained finite acquisitionReturn zero scans and the normal end of acquisition indicator.

A scan contains one sample per configured channel. For selections [AI0, AI1], the array order is AI0 sample 0, AI1 sample 0, AI0 sample 1, AI1 sample 1. Array length is returned count per channel times channel count. Each voltage/code read consumes the next samples; use explicit offline conversion if both representations of one stored block are needed.

Python/C# allocate one output array for the requested voltage or code representation. C callers allocate the selected array with output_capacity_samples_per_channel times channel_count elements. Capacity bounds memory; it is not a sampling or ring-size setting. Insufficient capacity returns -7 without consuming data. Read requests are bounded by 16 million scalar output elements.

Current aggregate AI profiles are 5, 20, 100, 1600, 12500, 100000 and 400000 conversions/s. Configure selects a supported profile meeting requested per-channel rate times channel count and reports nominal rate per channel. Sequencer settling can reduce throughput. Managed reads have internal absolute deadlines; callers do not supply timeout parameters.

Both Single Read variants invalidate earlier AI scan setup. Configure again before Start. Start clears previous buffered data. Early Stop cancels pending reads; completed finite data remains readable. Stop affects AI only, and is safe to attempt during cleanup.

ModeSequence and behavior
FiniteConfigure a positive total, Write prefill, Start, continue writing if needed, wait for completion, Stop.
ContinuousConfigure, Write prefill, Start, continue Write, Stop on application cancellation.
Onboard repeatConfigure Onboard, upload the entire reported-capacity-bounded cycle, Start, then Stop.

Voltage writes validate every value as finite and within 0 to 5 V before accepting data. Code writes validate integer DAC values 0 to 65535 and bypass host voltage calibration. Values follow configured output order; for [AO0, AO1], [1.0, 3.0, 1.5, 3.5] contains two scans.

Host-streaming Write success means host acceptance, not physical DAC generation. No public timeout or host-capacity argument is required. Running writes use a five-second absolute acceptance deadline. An error can follow partial acceptance; do not blindly retry. Stop, refill and restart according to the SDK recovery contract. Start is asynchronous; an immediate Stop can truncate the waveform.

AO Status is an output-state query, distinct from its returned SDK status. It reports firmware-cached DAC codes, estimated volts, enabled flags and waveform-running flags. It does not measure voltage or read physical DAC registers. A stopped flag alone does not establish fault-free waveform completion.

Firmware 1.1.36 derives the AO sample clock from PLLSAI/SAI. Always use the returned configured rate when computing waveform duration and frequency; do not assume the requested rate was applied. The nominal clock calculation is not proof of DAC settling, electrical performance or sustained USB throughput.

AI Single Read and Read return voltage values only. Single Read Codes and Read Codes return decoded signed I32 samples without host voltage conversion. Code reads and voltage reads consume the same acquisition queue. Raw AI Read returns packet bytes and is not a decoded-code read. AO likewise has separate voltage and decoded-code writes, plus a packet-byte Raw Write.

InterfaceData unitsPacket handling
AI Read Codes / AO Write CodesDecoded I32 ADC or U32 DAC values; counts per channelSDK handles packet decoding/encoding and managed streaming.
AI Raw Read / AO Raw WriteU8 packet bytes; lengths/capacities in bytesCaller manages firmware packet format and raw lifecycle.

Raw AI Read and AO Write perform a single transfer with a caller-supplied timeout; they do not issue Configure or Start, convert voltages, or fill the requested buffer in a loop. Raw read capacity is 512 to 16777216 bytes. Do not mix raw and managed streaming on the same subsystem.

Open hardware or the simulator, check status before using its handle, and always Close in cleanup. Stop and Close can cancel blocked analog operations. Same-direction concurrent operations return Busy; AI and AO can progress independently. Wrapper metadata belongs to each handle. Configure and perform managed transfers through the same wrapper API; do not externally change configuration underneath its metadata.

EnumNamed values
DIOBankA=0, B=1
DIODirectionInput=0, Output=1
DIOWidthFourBit=4, SevenBit=7
DigitalLineA0=0, A1=1, A2=2, A3=3, A4=4, A5=5, A6=6, B0=7, B1=8, B2=9, B3=10, B4=11, B5=12, B6=13, Unused=255
DigitalEdgeRising=0, Falling=1, Both=2
DigitalLevelLow=0, High=1
EncoderModeX2=2, X4=4
TimeModePeriod=1, PulseWidth=2

Individual lines A0..A6 map to 0..6 and B0..B6 to 7..13. Supported timer-backed lines are A2, A4, A6, B4 and B6. Use enum selections rather than hardware timer IDs. Encoder pairs are A4/A3, A6/A5, B4/B3, B6/B5; A-line selection identifies Read/Reset. DigitalLine.Unused disables direction; Python cannot use a member spelled None because None is reserved.

Static DIO selects one or two unique banks; values, directions and supplied masks match that selection. Omission is NULL/None/null and writes all valid bank bits. Explicit zero masks are no-ops. Single Read samples pin levels; Status returns output latches, directions and per-bank streaming flags, without measuring PWM waveforms.

Managed DIO Configure saves the bank selection. Subsequent sample Read/Write take handle and sample arrays/counts, not another bank selection. Today streaming supports one bank per direction. FourBit fixes A Output/B Input; SevenBit supports the permitted alternative mappings. Both directions share nominal firmware rate and finite total. Raw DIO Read/Write have been removed; SDK workers handle packet encoding and decoding.

DIO Read requestBehavior
Positive NWait for N samples per input bank or the finite tail. Preserve returned partial samples on error.
-1 in FiniteRead all remaining finite samples; bounded by the wrapper single-call allocation limit.
-1 in ContinuousReturn currently buffered samples without waiting.
After finite data drainsReturn status +1, empty array and count 0.

C DIO Read capacity bounds caller memory; Python/C# infer allocation. Output prefill is min(8000, finite total) samples for finite generation; longer output requires continued refills. Write accepts host data, not confirmation of generation. Read/write overflow, timeout or uncertain acceptance require recovery; never blindly retry blocks. Stop/Configure before restarting. Stop retains completed finite input but returns stream output banks to Input.

All timer-backed selections/settings are matching arrays except scalar Pulse Run. Firmware executes selected commands in order, not simultaneously or atomically. Every input is validated before any command; later hardware failures can leave earlier effects applied. Native outputs publish only on full success; wrapper fixed reads return empty arrays or None/null on failure. Gated frequency resets each counter and uses gate_ms=1..10000 per line, with rounded integer Hz.

Counter/time/PWM/pulse selections automatically map to hardware timers. Encoder Read/Reset identify the configured A line and return signed hardware positions without rollover extension. Time results include ticks, microseconds, tick_hz and prescalers. PulseWidth configuration accepts an edge argument but firmware uses fixed PWM-input capture polarity in that mode.

PWM duties are finite 0..1 fractions. Status returns actual configured timer frequency and compare/(period+1), not measured pin feedback. Timer-backed functions share bank direction/resource restrictions enforced by firmware. A bank cannot simultaneously serve incompatible input and output specialty modes.

Pulse Run blocks until completion. Unused=255 disables direction; setup is 0..65535 us. A start rate of 0 selects the target rate; a differing start/target requires nonzero acceleration. Returned actual_frequency_hz is the initial timer setting, not a final ramp measurement. A timeout or transport error may follow physical pulses. Close does not abort these firmware commands; never automatically retry.

Specialty deadlines are internal: normal HID commands 3 s per selection, gated frequency gate_ms+3 s, Time Read up to 20 s, Pulse Run derived from pulse count and slower requested rate plus setup/service margin. Long commands serialize other HID traffic. Per-handle specialty guards reject competing operations with Busy before wrapper preparation. Closing alone does not reset PWM; write duty 0 to hold low, or reconfigure the entire owned bank to GPIO Input to release timer-backed use.

SDK 0.13.0: include/signaldaq.h; wrappers/python/signaldaq/init.py; wrappers/csharp/SignalDAQ/Analog.cs, Digital.cs, Specialty.cs, Native.cs; ANALOG_API_0_9_0.md; DIO_API.md; DIGITAL_SPECIALTY_API.md; TIMEOUT_POLICY.md. Firmware 1.1.36: SignalDAQ 2421/Software/Core/Inc/daq_protocol.h and Core/Src/daq_app.c, dio.c, dac80502_sai.c. Existing analog API documentation version names are historical; current public signatures come from this SDK source.

Worked listings are validated with the SDK simulator, not physical hardware. LabVIEW import headers and DLLs are current; binary VI regeneration and execution remain pending. No LabVIEW diagram or fabricated textual diagram is included.

Related API references

Explore the language references and examples for the SignalDAQ API.

Related resources