Generate constant-rate and accelerated finite pulse trains with optional direction control.
| Example | Task |
|---|---|
| 1 | generate a constant-rate pulse train |
| 2 | add direction and acceleration |
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.
Use a suitable signal source, meter or scope and the correct reference for the selected digital terminals. Verify electrical levels, loading and protection limits in the product manual before wiring; these tutorials do not infer them from analog voltage ranges. Disconnect competing output drivers. Pulse examples should first use an input-only load, not an actuator.
The complete programs take ownership of their named banks and return those entire banks to GPIO Input before work and during cleanup. This also releases specialty timer ownership. Do not adapt this cleanup to a shared bank without deciding which application owns it.
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.
Use a .NET 8 console project with a project reference to wrappers/csharp/SignalDAQ/SignalDAQ.csproj. The examples use SignalDAQ.Analog static methods and C# top-level statements. Set SIGNALDAQ_DLL to the absolute path of bin/x64/signaldaq.dll for an x64 process, or the x86 DLL for an x86 process. Read the examples before following the run commands below.
Use a Windows C compiler, include/signaldaq.h, the matching lib/x64/signaldaq.lib or lib/x86/signaldaq.lib, and the matching DLL beside the executable. Examples use C11 and the Windows timing API. The full header includes every handle, count and output parameter.
| Enum | Named values |
|---|---|
| DigitalLine | A0=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 |
| DigitalLevel | Low=0, High=1 |
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. DigitalLine.Unused disables direction; Python cannot use a member spelled None because None is reserved.
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
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
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.
# PowerShell from the SDK folder; use an x64 process.
dotnet new console -n SdkExample -f net8.0
dotnet add ./SdkExample/SdkExample.csproj reference ./wrappers/csharp/SignalDAQ/SignalDAQ.csproj
# Replace SdkExample/Program.cs with one complete C# listing.
$env:SIGNALDAQ_DLL = (Resolve-Path ./bin/x64/signaldaq.dll).Path
dotnet run --project ./SdkExample/SdkExample.csproj
For hardware, replace Analog.OpenSimulated(out uint handle) with Analog.Open(null, out uint handle), or supply a serial string instead of null. Every analog method returns status explicitly. The listing uses application-level Report helpers; the SDK does not throw analog status errors automatically.
cl /nologo /W4 /std:c11 /I include example.c /link lib/x64/signaldaq.lib
copy bin\x64\signaldaq.dll .
example.exe
Run the C commands in an x64 Visual Studio Developer Command Prompt from the SDK folder. For hardware, replace sdaq_open_simulated(&handle) with sdaq_open(NULL, &handle), or pass a serial string. Match the compiler target, import library and DLL architecture.
| Python | C | C# Digital |
|---|---|---|
| run_pulse_train | sdaq_pulse_train_run | RunPulseTrain |
| Parameter or result | Meaning |
|---|---|
| pulses | Positive finite number of periods requested; successful response confirms pulses_sent. |
| direction_line | Unused=255 disables direction; otherwise another supported digital terminal. |
| direction_value | Low=0 or High=1. |
| direction_setup_us | 0..65535 microseconds. |
| start_frequency_hz | 0 means target; otherwise positive starting frequency. |
| acceleration_hz_per_s | Nonzero when start differs from target. |
| actual_frequency_hz | Initial actual timer setting, not final ramp frequency. |
| Deadline | Derived from pulse count and slower requested rate plus setup/service margin. Close cannot abort this blocking firmware operation. |
All selections/settings are matching arrays except scalar Pulse Run. Validate every array before commands. Firmware applies selected commands in order, not as an atomic or synchronized batch. Later failure can leave earlier effects applied; do not automatically retry destructive measurements, resets or generated output. Native fixed-read outputs stay unchanged on failure; wrappers return empty arrays or None/null.
The selected line determines the hardware timer. Specialty input/output directions must be compatible across the whole bank, and timers cannot be used by incompatible modes at once. Per-handle specialty guards return Busy for concurrent specialty calls. HID traffic is serialized, so a long capture/gate/train can delay other command replies. Close does not release PWM or abort a running firmware operation. The complete examples reset only the entire banks they own to GPIO Input during cleanup.
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.