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 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.
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 selection | Value | Analog input selection | Value |
|---|---|---|---|
| SDAQ_AI0_AI8_DIFF | 0 | SDAQ_AI4_SE | 12 |
| SDAQ_AI1_AI9_DIFF | 1 | SDAQ_AI5_SE | 13 |
| SDAQ_AI2_AI10_DIFF | 2 | SDAQ_AI6_SE | 14 |
| SDAQ_AI3_AI11_DIFF | 3 | SDAQ_AI7_SE | 15 |
| SDAQ_AI4_AI12_DIFF | 4 | SDAQ_AI8_SE | 16 |
| SDAQ_AI5_AI13_DIFF | 5 | SDAQ_AI9_SE | 17 |
| SDAQ_AI6_AI14_DIFF | 6 | SDAQ_AI10_SE | 18 |
| SDAQ_AI7_AI15_DIFF | 7 | SDAQ_AI11_SE | 19 |
| SDAQ_AI0_SE | 8 | SDAQ_AI12_SE | 20 |
| SDAQ_AI1_SE | 9 | SDAQ_AI13_SE | 21 |
| SDAQ_AI2_SE | 10 | SDAQ_AI14_SE | 22 |
| SDAQ_AI3_SE | 11 | SDAQ_AI15_SE | 23 |
| Purpose | Named values |
|---|---|
| Output channels | SDAQ_AO0 / SDAQ_AO1 in C; AOChannel.AO0 / AOChannel.AO1 in wrappers. |
| AI acquisition mode | SDAQ_CONTINUOUS=0 / SDAQ_FINITE=1 in C; AcquisitionMode.Continuous / .Finite in wrappers. |
| AO generation mode | The 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
C
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <windows.h>
#include "signaldaq.h"
static int32_t report(int32_t status) {
char message[512] = {0};
sdaq_status_message(status, message, sizeof message);
fprintf(stderr, "SDK status %ld: %s\n", (long)status, message);
return status;
}
static void save_cleanup(const char *label, int32_t status, int32_t *result) {
if (status == SDAQ_OK) return;
fprintf(stderr, "%s\n", label);
report(status);
if (*result == SDAQ_OK) *result = status;
}
#define TRY(call) do { int32_t st_ = (call); \
if (st_ != SDAQ_OK) return report(st_); } while (0)
static int32_t run_example(uint32_t handle) {
uint32_t channel = SDAQ_AI0_SE;
double volts = 0;
TRY(sdaq_ai_single_read(handle, &channel, 1, &volts));
printf("AI0: %.4f V\n", volts);
return SDAQ_OK;
}
int main(void) {
uint32_t handle = 0;
int32_t status = sdaq_open_simulated(&handle);
if (status != SDAQ_OK) { report(status); return 1; }
int32_t result = run_example(handle);
save_cleanup("Stop AI", sdaq_ai_stop(handle), &result);
save_cleanup("Close", sdaq_close(handle), &result);
return result == SDAQ_OK ? 0 : 1;
}
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
C
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <windows.h>
#include "signaldaq.h"
static int32_t report(int32_t status) {
char message[512] = {0};
sdaq_status_message(status, message, sizeof message);
fprintf(stderr, "SDK status %ld: %s\n", (long)status, message);
return status;
}
static void save_cleanup(const char *label, int32_t status, int32_t *result) {
if (status == SDAQ_OK) return;
fprintf(stderr, "%s\n", label);
report(status);
if (*result == SDAQ_OK) *result = status;
}
#define TRY(call) do { int32_t st_ = (call); \
if (st_ != SDAQ_OK) return report(st_); } while (0)
static int32_t run_example(uint32_t handle) {
uint32_t channel = SDAQ_AI0_SE, count = 0;
double actual_rate, volts[100];
TRY(sdaq_ai_configure(handle, &channel, 1, 1000, SDAQ_FINITE, 100, &actual_rate));
printf("Nominal rate: %g S/s/channel\n", actual_rate);
TRY(sdaq_ai_start(handle));
int32_t status = sdaq_ai_read(handle, volts, 100, 100, &count);
printf("Samples returned, including any partial result: %lu\n", (unsigned long)count);
if (status != SDAQ_OK && status != SDAQ_END_OF_ACQUISITION) return report(status);
if (count) printf("First voltage: %g V\n", volts[0]);
status = sdaq_ai_read(handle, volts, 1, 100, &count);
printf("End status: %ld; remaining samples: %lu\n", (long)status, (unsigned long)count);
if (status != SDAQ_END_OF_ACQUISITION) return report(status ? status : SDAQ_INTERNAL);
return SDAQ_OK;
}
int main(void) {
uint32_t handle = 0;
int32_t status = sdaq_open_simulated(&handle);
if (status != SDAQ_OK) { report(status); return 1; }
int32_t result = run_example(handle);
save_cleanup("Stop AI", sdaq_ai_stop(handle), &result);
save_cleanup("Close", sdaq_close(handle), &result);
return result == SDAQ_OK ? 0 : 1;
}
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
C
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <windows.h>
#include "signaldaq.h"
static int32_t report(int32_t status) {
char message[512] = {0};
sdaq_status_message(status, message, sizeof message);
fprintf(stderr, "SDK status %ld: %s\n", (long)status, message);
return status;
}
static void save_cleanup(const char *label, int32_t status, int32_t *result) {
if (status == SDAQ_OK) return;
fprintf(stderr, "%s\n", label);
report(status);
if (*result == SDAQ_OK) *result = status;
}
#define TRY(call) do { int32_t st_ = (call); \
if (st_ != SDAQ_OK) return report(st_); } while (0)
static int32_t run_example(uint32_t handle) {
uint32_t channel = SDAQ_AI0_SE, count = 0;
int32_t single_code, codes[100];
double actual_rate;
TRY(sdaq_ai_single_read_codes(handle, &channel, 1, &single_code));
printf("Single ADC code: %ld\n", (long)single_code);
TRY(sdaq_ai_configure(handle, &channel, 1, 1000, SDAQ_FINITE, 100, &actual_rate));
TRY(sdaq_ai_start(handle));
int32_t status = sdaq_ai_read_codes(handle, codes, -1, 100, &count);
printf("Decoded samples: %lu\n", (unsigned long)count);
if (count) printf("First ADC code: %ld\n", (long)codes[0]);
if (status != SDAQ_OK && status != SDAQ_END_OF_ACQUISITION) return report(status);
return SDAQ_OK;
}
int main(void) {
uint32_t handle = 0;
int32_t status = sdaq_open_simulated(&handle);
if (status != SDAQ_OK) { report(status); return 1; }
int32_t result = run_example(handle);
save_cleanup("Stop AI", sdaq_ai_stop(handle), &result);
save_cleanup("Close", sdaq_close(handle), &result);
return result == SDAQ_OK ? 0 : 1;
}
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
C
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <windows.h>
#include "signaldaq.h"
static int32_t report(int32_t status) {
char message[512] = {0};
sdaq_status_message(status, message, sizeof message);
fprintf(stderr, "SDK status %ld: %s\n", (long)status, message);
return status;
}
static void save_cleanup(const char *label, int32_t status, int32_t *result) {
if (status == SDAQ_OK) return;
fprintf(stderr, "%s\n", label);
report(status);
if (*result == SDAQ_OK) *result = status;
}
#define TRY(call) do { int32_t st_ = (call); \
if (st_ != SDAQ_OK) return report(st_); } while (0)
static int32_t run_example(uint32_t handle) {
enum { samples_per_cycle = 256 };
const double pi = 3.14159265358979323846;
uint32_t channel = SDAQ_AO0;
double waveform[samples_per_cycle], actual_rate;
for (int i = 0; i < samples_per_cycle; ++i)
waveform[i] = 2.5 + 2.0 * sin(2 * pi * i / samples_per_cycle);
TRY(sdaq_ao_configure_onboard(handle, &channel, 1, 10000, samples_per_cycle, &actual_rate));
printf("Cycle frequency: %g Hz\n", actual_rate / samples_per_cycle);
TRY(sdaq_ao_write(handle, waveform, samples_per_cycle));
TRY(sdaq_ao_start(handle));
Sleep(250);
return SDAQ_OK;
}
int main(void) {
uint32_t handle = 0;
int32_t status = sdaq_open_simulated(&handle);
if (status != SDAQ_OK) { report(status); return 1; }
int32_t result = run_example(handle);
save_cleanup("Stop AO", sdaq_ao_stop(handle), &result);
uint32_t output = SDAQ_AO0;
double zero = 0.0;
save_cleanup("Zero owned outputs", sdaq_ao_single_write(handle, &output, 1, &zero), &result);
save_cleanup("Close", sdaq_close(handle), &result);
return result == SDAQ_OK ? 0 : 1;
}
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
C
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <windows.h>
#include "signaldaq.h"
static int32_t report(int32_t status) {
char message[512] = {0};
sdaq_status_message(status, message, sizeof message);
fprintf(stderr, "SDK status %ld: %s\n", (long)status, message);
return status;
}
static void save_cleanup(const char *label, int32_t status, int32_t *result) {
if (status == SDAQ_OK) return;
fprintf(stderr, "%s\n", label);
report(status);
if (*result == SDAQ_OK) *result = status;
}
#define TRY(call) do { int32_t st_ = (call); \
if (st_ != SDAQ_OK) return report(st_); } while (0)
static int32_t run_example(uint32_t handle) {
uint32_t channel = SDAQ_AO0, single_code = 32768, waveform[1024];
double actual_rate;
TRY(sdaq_ao_single_write_codes(handle, &channel, 1, &single_code));
for (int i = 0; i < 1024; ++i) waveform[i] = (i / 64) % 2 == 0 ? 13107u : 39321u;
TRY(sdaq_ao_configure(handle, &channel, 1, 10000, SDAQ_FINITE, 1024, &actual_rate));
TRY(sdaq_ao_write_codes(handle, waveform, 1024));
TRY(sdaq_ao_start(handle));
ULONGLONG deadline = GetTickCount64() + 5000;
for (;;) {
uint32_t code, enabled, running;
double estimated_volts;
TRY(sdaq_ao_status(handle, &channel, 1, &code, &estimated_volts, &enabled, &running));
if (!running) break;
if (GetTickCount64() >= deadline) return report(SDAQ_TIMEOUT);
Sleep(10);
}
printf("Finite waveform stopped\n");
return SDAQ_OK;
}
int main(void) {
uint32_t handle = 0;
int32_t status = sdaq_open_simulated(&handle);
if (status != SDAQ_OK) { report(status); return 1; }
int32_t result = run_example(handle);
save_cleanup("Stop AO", sdaq_ao_stop(handle), &result);
uint32_t output = SDAQ_AO0;
double zero = 0.0;
save_cleanup("Zero owned outputs", sdaq_ao_single_write(handle, &output, 1, &zero), &result);
save_cleanup("Close", sdaq_close(handle), &result);
return result == SDAQ_OK ? 0 : 1;
}
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
C
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <windows.h>
#include "signaldaq.h"
static int32_t report(int32_t status) {
char message[512] = {0};
sdaq_status_message(status, message, sizeof message);
fprintf(stderr, "SDK status %ld: %s\n", (long)status, message);
return status;
}
static void save_cleanup(const char *label, int32_t status, int32_t *result) {
if (status == SDAQ_OK) return;
fprintf(stderr, "%s\n", label);
report(status);
if (*result == SDAQ_OK) *result = status;
}
#define TRY(call) do { int32_t st_ = (call); \
if (st_ != SDAQ_OK) return report(st_); } while (0)
static int32_t run_example(uint32_t handle) {
uint32_t owned_banks[] = { SDAQ_DIO_BANK_A, SDAQ_DIO_BANK_B }, input_directions[] = { SDAQ_DIO_INPUT, SDAQ_DIO_INPUT };
TRY(sdaq_dio_configure_direction(handle, owned_banks, input_directions, 2));
uint32_t banks[] = { SDAQ_DIO_BANK_A, SDAQ_DIO_BANK_B };
uint32_t directions[] = { SDAQ_DIO_OUTPUT, SDAQ_DIO_OUTPUT }, values[] = { 85, 3 };
TRY(sdaq_dio_configure_direction(handle, banks, directions, 2));
TRY(sdaq_dio_single_write(handle, banks, values, NULL, 2));
uint32_t bank = SDAQ_DIO_BANK_A, value = 0, mask = 1;
TRY(sdaq_dio_single_write(handle, &bank, &value, &mask, 1));
uint32_t reversed[] = { SDAQ_DIO_BANK_B, SDAQ_DIO_BANK_A }, pins[2];
TRY(sdaq_dio_single_read(handle, reversed, 2, pins));
printf("Pin snapshot B, A: %lu, %lu\n", (unsigned long)pins[0], (unsigned long)pins[1]);
uint32_t latches[2], reported_directions[2], running[2];
TRY(sdaq_dio_status(handle, banks, 2, latches, reported_directions, running));
printf("Output latches A, B: %lu, %lu\n", (unsigned long)latches[0], (unsigned long)latches[1]);
return SDAQ_OK;
}
int main(void) {
uint32_t handle = 0;
int32_t status = sdaq_open_simulated(&handle);
if (status != SDAQ_OK) { report(status); return 1; }
int32_t result = run_example(handle);
uint32_t cleanup_banks[] = { SDAQ_DIO_BANK_A, SDAQ_DIO_BANK_B }, cleanup_directions[] = { SDAQ_DIO_INPUT, SDAQ_DIO_INPUT };
save_cleanup("Return owned banks to Input", sdaq_dio_configure_direction(handle, cleanup_banks, cleanup_directions, 2), &result);
save_cleanup("Close", sdaq_close(handle), &result);
return result == SDAQ_OK ? 0 : 1;
}
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
C
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <windows.h>
#include "signaldaq.h"
static int32_t report(int32_t status) {
char message[512] = {0};
sdaq_status_message(status, message, sizeof message);
fprintf(stderr, "SDK status %ld: %s\n", (long)status, message);
return status;
}
static void save_cleanup(const char *label, int32_t status, int32_t *result) {
if (status == SDAQ_OK) return;
fprintf(stderr, "%s\n", label);
report(status);
if (*result == SDAQ_OK) *result = status;
}
#define TRY(call) do { int32_t st_ = (call); \
if (st_ != SDAQ_OK) return report(st_); } while (0)
static int32_t run_example(uint32_t handle) {
uint32_t owned_banks[] = { SDAQ_DIO_BANK_B }, input_directions[] = { SDAQ_DIO_INPUT };
TRY(sdaq_dio_configure_direction(handle, owned_banks, input_directions, 1));
uint32_t bank = SDAQ_DIO_BANK_B, direction = SDAQ_DIO_INPUT, count = 0, values[17];
double actual;
TRY(sdaq_dio_configure(handle, &bank, &direction, 1, SDAQ_DIO_SEVEN_BIT,
1000, SDAQ_FINITE, 17, &actual));
TRY(sdaq_dio_start(handle));
int32_t status = sdaq_dio_read(handle, values, -1, 17, &count);
printf("Nominal rate: %g; samples including partial data: %lu\n", actual, (unsigned long)count);
if (status != SDAQ_OK && status != SDAQ_END_OF_ACQUISITION) return report(status);
status = sdaq_dio_read(handle, values, 1, 17, &count);
printf("End status: %ld; count: %lu\n", (long)status, (unsigned long)count);
if (status != SDAQ_END_OF_ACQUISITION || count != 0) return report(status ? status : SDAQ_INTERNAL);
return SDAQ_OK;
}
int main(void) {
uint32_t handle = 0;
int32_t status = sdaq_open_simulated(&handle);
if (status != SDAQ_OK) { report(status); return 1; }
int32_t result = run_example(handle);
save_cleanup("Stop DIO", sdaq_dio_stop(handle), &result);
uint32_t cleanup_banks[] = { SDAQ_DIO_BANK_B }, cleanup_directions[] = { SDAQ_DIO_INPUT };
save_cleanup("Return owned banks to Input", sdaq_dio_configure_direction(handle, cleanup_banks, cleanup_directions, 1), &result);
save_cleanup("Close", sdaq_close(handle), &result);
return result == SDAQ_OK ? 0 : 1;
}
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
C
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <windows.h>
#include "signaldaq.h"
static int32_t report(int32_t status) {
char message[512] = {0};
sdaq_status_message(status, message, sizeof message);
fprintf(stderr, "SDK status %ld: %s\n", (long)status, message);
return status;
}
static void save_cleanup(const char *label, int32_t status, int32_t *result) {
if (status == SDAQ_OK) return;
fprintf(stderr, "%s\n", label);
report(status);
if (*result == SDAQ_OK) *result = status;
}
#define TRY(call) do { int32_t st_ = (call); \
if (st_ != SDAQ_OK) return report(st_); } while (0)
static int32_t run_example(uint32_t handle) {
uint32_t owned_banks[] = { SDAQ_DIO_BANK_A }, input_directions[] = { SDAQ_DIO_INPUT };
TRY(sdaq_dio_configure_direction(handle, owned_banks, input_directions, 1));
uint32_t bank=SDAQ_DIO_BANK_A, direction=SDAQ_DIO_OUTPUT, values[17];double actual;
TRY(sdaq_dio_configure(handle, &bank, &direction, 1, SDAQ_DIO_SEVEN_BIT, 1000, SDAQ_FINITE, 17, &actual));
for (int i=0;i<17;i++) values[i]=i%2?127u:0u;
TRY(sdaq_dio_write(handle, values, 17));TRY(sdaq_dio_start(handle));
ULONGLONG began=GetTickCount64();
for (;;) {
uint32_t latch, reported_direction, running;
TRY(sdaq_dio_status(handle, &bank, 1, &latch, &reported_direction, &running));
if (!running) break;
if (GetTickCount64()-began>=5000) return report(SDAQ_TIMEOUT);
Sleep(2);
}
printf("Generation stopped; nominal rate: %g\n", actual);
return SDAQ_OK;
}
int main(void) {
uint32_t handle = 0;
int32_t status = sdaq_open_simulated(&handle);
if (status != SDAQ_OK) { report(status); return 1; }
int32_t result = run_example(handle);
save_cleanup("Stop DIO", sdaq_dio_stop(handle), &result);
uint32_t cleanup_banks[] = { SDAQ_DIO_BANK_A }, cleanup_directions[] = { SDAQ_DIO_INPUT };
save_cleanup("Return owned banks to Input", sdaq_dio_configure_direction(handle, cleanup_banks, cleanup_directions, 1), &result);
save_cleanup("Close", sdaq_close(handle), &result);
return result == SDAQ_OK ? 0 : 1;
}
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
C
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <windows.h>
#include "signaldaq.h"
static int32_t report(int32_t status) {
char message[512] = {0};
sdaq_status_message(status, message, sizeof message);
fprintf(stderr, "SDK status %ld: %s\n", (long)status, message);
return status;
}
static void save_cleanup(const char *label, int32_t status, int32_t *result) {
if (status == SDAQ_OK) return;
fprintf(stderr, "%s\n", label);
report(status);
if (*result == SDAQ_OK) *result = status;
}
#define TRY(call) do { int32_t st_ = (call); \
if (st_ != SDAQ_OK) return report(st_); } while (0)
static int32_t run_example(uint32_t handle) {
uint32_t owned_banks[] = { SDAQ_DIO_BANK_A, SDAQ_DIO_BANK_B }, input_directions[] = { SDAQ_DIO_INPUT, SDAQ_DIO_INPUT };
TRY(sdaq_dio_configure_direction(handle, owned_banks, input_directions, 2));
uint32_t banks[]={SDAQ_DIO_BANK_A,SDAQ_DIO_BANK_B}, directions[]={SDAQ_DIO_OUTPUT,SDAQ_DIO_INPUT};
double actual;uint32_t values[17],inputs[17],count=0;
TRY(sdaq_dio_configure(handle,banks,directions,2,SDAQ_DIO_FOUR_BIT,1000,SDAQ_FINITE,17,&actual));
for(int i=0;i<17;i++) values[i]=(uint32_t)(i%16);
TRY(sdaq_dio_write(handle,values,17));TRY(sdaq_dio_start(handle));
int32_t status=sdaq_dio_read(handle,inputs,-1,17,&count);
printf("Input samples including partial data: %lu\n",(unsigned long)count);
if(status!=SDAQ_OK&&status!=SDAQ_END_OF_ACQUISITION) return report(status);
return SDAQ_OK;
}
int main(void) {
uint32_t handle = 0;
int32_t status = sdaq_open_simulated(&handle);
if (status != SDAQ_OK) { report(status); return 1; }
int32_t result = run_example(handle);
save_cleanup("Stop DIO", sdaq_dio_stop(handle), &result);
uint32_t cleanup_banks[] = { SDAQ_DIO_BANK_A, SDAQ_DIO_BANK_B }, cleanup_directions[] = { SDAQ_DIO_INPUT, SDAQ_DIO_INPUT };
save_cleanup("Return owned banks to Input", sdaq_dio_configure_direction(handle, cleanup_banks, cleanup_directions, 2), &result);
save_cleanup("Close", sdaq_close(handle), &result);
return result == SDAQ_OK ? 0 : 1;
}
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
C
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <windows.h>
#include "signaldaq.h"
static int32_t report(int32_t status) {
char message[512] = {0};
sdaq_status_message(status, message, sizeof message);
fprintf(stderr, "SDK status %ld: %s\n", (long)status, message);
return status;
}
static void save_cleanup(const char *label, int32_t status, int32_t *result) {
if (status == SDAQ_OK) return;
fprintf(stderr, "%s\n", label);
report(status);
if (*result == SDAQ_OK) *result = status;
}
#define TRY(call) do { int32_t st_ = (call); \
if (st_ != SDAQ_OK) return report(st_); } while (0)
static int32_t run_example(uint32_t handle) {
uint32_t owned_banks[] = { SDAQ_DIO_BANK_A }, input_directions[] = { SDAQ_DIO_INPUT };
TRY(sdaq_dio_configure_direction(handle, owned_banks, input_directions, 1));
uint32_t line=SDAQ_LINE_A6,edge=SDAQ_EDGE_RISING,count=0,gate_ms=100,hz=0;
TRY(sdaq_counter_configure(handle,&line,&edge,1));TRY(sdaq_counter_reset(handle,&line,1));
Sleep(100);TRY(sdaq_counter_read(handle,&line,1,&count));
printf("Accumulated edges: %lu\n",(unsigned long)count);
TRY(sdaq_counter_read_frequency(handle,&line,&gate_ms,1,&count,&hz));
printf("100 ms count: %lu; frequency: %lu Hz\n",(unsigned long)count,(unsigned long)hz);
return SDAQ_OK;
}
int main(void) {
uint32_t handle = 0;
int32_t status = sdaq_open_simulated(&handle);
if (status != SDAQ_OK) { report(status); return 1; }
int32_t result = run_example(handle);
uint32_t cleanup_banks[] = { SDAQ_DIO_BANK_A }, cleanup_directions[] = { SDAQ_DIO_INPUT };
save_cleanup("Return owned banks to Input", sdaq_dio_configure_direction(handle, cleanup_banks, cleanup_directions, 1), &result);
save_cleanup("Close", sdaq_close(handle), &result);
return result == SDAQ_OK ? 0 : 1;
}
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
C
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <windows.h>
#include "signaldaq.h"
static int32_t report(int32_t status) {
char message[512] = {0};
sdaq_status_message(status, message, sizeof message);
fprintf(stderr, "SDK status %ld: %s\n", (long)status, message);
return status;
}
static void save_cleanup(const char *label, int32_t status, int32_t *result) {
if (status == SDAQ_OK) return;
fprintf(stderr, "%s\n", label);
report(status);
if (*result == SDAQ_OK) *result = status;
}
#define TRY(call) do { int32_t st_ = (call); \
if (st_ != SDAQ_OK) return report(st_); } while (0)
static int32_t run_example(uint32_t handle) {
uint32_t owned_banks[] = { SDAQ_DIO_BANK_A }, input_directions[] = { SDAQ_DIO_INPUT };
TRY(sdaq_dio_configure_direction(handle, owned_banks, input_directions, 1));
uint32_t a=SDAQ_LINE_A6,b=SDAQ_LINE_A5,mode=SDAQ_ENCODER_X4;int32_t position=0;
TRY(sdaq_encoder_configure(handle,&a,&b,&mode,1));TRY(sdaq_encoder_reset(handle,&a,1));
Sleep(100);TRY(sdaq_encoder_read(handle,&a,1,&position));
printf("Encoder position: %ld counts\n",(long)position);
return SDAQ_OK;
}
int main(void) {
uint32_t handle = 0;
int32_t status = sdaq_open_simulated(&handle);
if (status != SDAQ_OK) { report(status); return 1; }
int32_t result = run_example(handle);
uint32_t cleanup_banks[] = { SDAQ_DIO_BANK_A }, cleanup_directions[] = { SDAQ_DIO_INPUT };
save_cleanup("Return owned banks to Input", sdaq_dio_configure_direction(handle, cleanup_banks, cleanup_directions, 1), &result);
save_cleanup("Close", sdaq_close(handle), &result);
return result == SDAQ_OK ? 0 : 1;
}
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
C
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <windows.h>
#include "signaldaq.h"
static int32_t report(int32_t status) {
char message[512] = {0};
sdaq_status_message(status, message, sizeof message);
fprintf(stderr, "SDK status %ld: %s\n", (long)status, message);
return status;
}
static void save_cleanup(const char *label, int32_t status, int32_t *result) {
if (status == SDAQ_OK) return;
fprintf(stderr, "%s\n", label);
report(status);
if (*result == SDAQ_OK) *result = status;
}
#define TRY(call) do { int32_t st_ = (call); \
if (st_ != SDAQ_OK) return report(st_); } while (0)
static int32_t run_example(uint32_t handle) {
uint32_t owned_banks[] = { SDAQ_DIO_BANK_A }, input_directions[] = { SDAQ_DIO_INPUT };
TRY(sdaq_dio_configure_direction(handle, owned_banks, input_directions, 1));
uint32_t line=SDAQ_LINE_A6,mode=SDAQ_TIME_PERIOD,edge=SDAQ_EDGE_RISING;
uint32_t ticks=0,us=0,tick_hz=0,prescaler=0;
TRY(sdaq_time_configure(handle,&line,&mode,&edge,1));TRY(sdaq_time_reset(handle,&line,1));
TRY(sdaq_time_read(handle,&line,1,&ticks,&us,&tick_hz,&prescaler));
printf("Period: %lu us; ticks/tick_hz: %g s\n",(unsigned long)us,(double)ticks/tick_hz);
return SDAQ_OK;
}
int main(void) {
uint32_t handle = 0;
int32_t status = sdaq_open_simulated(&handle);
if (status != SDAQ_OK) { report(status); return 1; }
int32_t result = run_example(handle);
uint32_t cleanup_banks[] = { SDAQ_DIO_BANK_A }, cleanup_directions[] = { SDAQ_DIO_INPUT };
save_cleanup("Return owned banks to Input", sdaq_dio_configure_direction(handle, cleanup_banks, cleanup_directions, 1), &result);
save_cleanup("Close", sdaq_close(handle), &result);
return result == SDAQ_OK ? 0 : 1;
}
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
C
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <windows.h>
#include "signaldaq.h"
static int32_t report(int32_t status) {
char message[512] = {0};
sdaq_status_message(status, message, sizeof message);
fprintf(stderr, "SDK status %ld: %s\n", (long)status, message);
return status;
}
static void save_cleanup(const char *label, int32_t status, int32_t *result) {
if (status == SDAQ_OK) return;
fprintf(stderr, "%s\n", label);
report(status);
if (*result == SDAQ_OK) *result = status;
}
#define TRY(call) do { int32_t st_ = (call); \
if (st_ != SDAQ_OK) return report(st_); } while (0)
static int32_t run_example(uint32_t handle) {
uint32_t owned_banks[] = { SDAQ_DIO_BANK_A }, input_directions[] = { SDAQ_DIO_INPUT };
TRY(sdaq_dio_configure_direction(handle, owned_banks, input_directions, 1));
uint32_t line=SDAQ_LINE_A6,frequency=1000,actual=0;double duty=0.25,reported_duty=0;
TRY(sdaq_pwm_configure(handle,&line,&frequency,&duty,1));
duty=0.5;TRY(sdaq_pwm_write(handle,&line,&duty,1));
TRY(sdaq_pwm_status(handle,&line,1,&actual,&reported_duty));
printf("Actual timer frequency: %lu Hz; duty: %g\n",(unsigned long)actual,reported_duty);
Sleep(100);duty=0;TRY(sdaq_pwm_write(handle,&line,&duty,1));
return SDAQ_OK;
}
int main(void) {
uint32_t handle = 0;
int32_t status = sdaq_open_simulated(&handle);
if (status != SDAQ_OK) { report(status); return 1; }
int32_t result = run_example(handle);
uint32_t cleanup_banks[] = { SDAQ_DIO_BANK_A }, cleanup_directions[] = { SDAQ_DIO_INPUT };
save_cleanup("Return owned banks to Input", sdaq_dio_configure_direction(handle, cleanup_banks, cleanup_directions, 1), &result);
save_cleanup("Close", sdaq_close(handle), &result);
return result == SDAQ_OK ? 0 : 1;
}
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
C
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <windows.h>
#include "signaldaq.h"
static int32_t report(int32_t status) {
char message[512] = {0};
sdaq_status_message(status, message, sizeof message);
fprintf(stderr, "SDK status %ld: %s\n", (long)status, message);
return status;
}
static void save_cleanup(const char *label, int32_t status, int32_t *result) {
if (status == SDAQ_OK) return;
fprintf(stderr, "%s\n", label);
report(status);
if (*result == SDAQ_OK) *result = status;
}
#define TRY(call) do { int32_t st_ = (call); \
if (st_ != SDAQ_OK) return report(st_); } while (0)
static int32_t run_example(uint32_t handle) {
uint32_t owned_banks[] = { SDAQ_DIO_BANK_A }, input_directions[] = { SDAQ_DIO_INPUT };
TRY(sdaq_dio_configure_direction(handle, owned_banks, input_directions, 1));
uint32_t sent=0,actual=0;
TRY(sdaq_pulse_train_run(handle,SDAQ_LINE_A6,SDAQ_LINE_UNUSED,SDAQ_LEVEL_LOW,
1000,0.5,100,0,0,0,&sent,&actual));
printf("Pulses sent: %lu; initial actual timer frequency: %lu Hz\n",(unsigned long)sent,(unsigned long)actual);
return SDAQ_OK;
}
int main(void) {
uint32_t handle = 0;
int32_t status = sdaq_open_simulated(&handle);
if (status != SDAQ_OK) { report(status); return 1; }
int32_t result = run_example(handle);
uint32_t cleanup_banks[] = { SDAQ_DIO_BANK_A }, cleanup_directions[] = { SDAQ_DIO_INPUT };
save_cleanup("Return owned banks to Input", sdaq_dio_configure_direction(handle, cleanup_banks, cleanup_directions, 1), &result);
save_cleanup("Close", sdaq_close(handle), &result);
return result == SDAQ_OK ? 0 : 1;
}
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
C
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <windows.h>
#include "signaldaq.h"
static int32_t report(int32_t status) {
char message[512] = {0};
sdaq_status_message(status, message, sizeof message);
fprintf(stderr, "SDK status %ld: %s\n", (long)status, message);
return status;
}
static void save_cleanup(const char *label, int32_t status, int32_t *result) {
if (status == SDAQ_OK) return;
fprintf(stderr, "%s\n", label);
report(status);
if (*result == SDAQ_OK) *result = status;
}
#define TRY(call) do { int32_t st_ = (call); \
if (st_ != SDAQ_OK) return report(st_); } while (0)
static int32_t run_example(uint32_t handle) {
uint32_t owned_banks[] = { SDAQ_DIO_BANK_A }, input_directions[] = { SDAQ_DIO_INPUT };
TRY(sdaq_dio_configure_direction(handle, owned_banks, input_directions, 1));
uint32_t sent=0,actual=0;
TRY(sdaq_pulse_train_run(handle,SDAQ_LINE_A6,SDAQ_LINE_A5,SDAQ_LEVEL_HIGH,
1000,0.5,1000,10,200,400,&sent,&actual));
printf("Pulses sent: %lu; initial actual timer frequency: %lu Hz\n",(unsigned long)sent,(unsigned long)actual);
return SDAQ_OK;
}
int main(void) {
uint32_t handle = 0;
int32_t status = sdaq_open_simulated(&handle);
if (status != SDAQ_OK) { report(status); return 1; }
int32_t result = run_example(handle);
uint32_t cleanup_banks[] = { SDAQ_DIO_BANK_A }, cleanup_directions[] = { SDAQ_DIO_INPUT };
save_cleanup("Return owned banks to Input", sdaq_dio_configure_direction(handle, cleanup_banks, cleanup_directions, 1), &result);
save_cleanup("Close", sdaq_close(handle), &result);
return result == SDAQ_OK ? 0 : 1;
}
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.
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.
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.
| Native C declaration | Result |
|---|---|
| int32_t sdaq_firmware_open(const uint8_t *package, uint32_t bytes, const char *serial, uint32_t *session); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_firmware_step(uint32_t session, uint32_t *progress, uint32_t *flags); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_firmware_close(uint32_t session); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_version(uint32_t *abi, uint32_t *version); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_error_message(char *text, uint32_t capacity); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_status_message(int32_t status, char *text, uint32_t capacity); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_device_count(uint32_t *count); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_device_serial(uint32_t index, char *serial, uint32_t capacity); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_open(const char *serial, uint32_t *handle); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_open_simulated(uint32_t *handle); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_close(uint32_t handle); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_command(uint32_t handle, uint32_t command, const uint8_t *payload, uint32_t payload_bytes, uint8_t *response, uint32_t response_capacity, uint32_t *response_bytes, uint32_t timeout_ms); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ai_raw_read(uint32_t handle, uint8_t *data, uint32_t capacity_bytes, uint32_t *read_bytes, uint32_t timeout_ms); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ao_raw_write(uint32_t handle, const uint8_t *data, uint32_t bytes, uint32_t timeout_ms); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ai_single_read(uint32_t handle, const uint32_t *input_channels, uint32_t channel_count, double *volts); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ai_single_read_codes(uint32_t handle, const uint32_t *input_channels, uint32_t channel_count, int32_t *codes); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ai_configure(uint32_t handle, const uint32_t *input_channels, uint32_t channel_count, uint32_t requested_samples_per_second_per_channel, uint32_t acquisition_mode_finite_continuous, uint32_t total_finite_acquisition_samples_per_channel, double *actual_nominal_samples_per_second_per_channel); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ai_start(uint32_t handle); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ai_read(uint32_t handle, double *volts, int32_t samples_to_read_per_channel, uint32_t output_capacity_samples_per_channel, uint32_t *samples_read_per_channel); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ai_read_codes(uint32_t handle, int32_t *codes, int32_t samples_to_read_per_channel, uint32_t output_capacity_samples_per_channel, uint32_t *samples_read_per_channel); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ai_stop(uint32_t handle); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ao_single_write(uint32_t handle, const uint32_t *output_channels, uint32_t channel_count, const double *volts); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ao_single_write_codes(uint32_t handle, const uint32_t *output_channels, uint32_t channel_count, const uint32_t *codes); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ao_status(uint32_t handle, const uint32_t *output_channels, uint32_t channel_count, uint32_t *codes, double *estimated_volts, uint32_t *output_enabled, uint32_t *waveform_running); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ao_configure(uint32_t handle, const uint32_t *output_channels, uint32_t channel_count, uint32_t requested_samples_per_second_per_channel, uint32_t generation_mode_finite_continuous, uint32_t finite_samples_per_channel, double *actual_samples_per_second_per_channel); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ao_configure_onboard(uint32_t handle, const uint32_t *output_channels, uint32_t channel_count, uint32_t requested_samples_per_second_per_channel, uint32_t waveform_samples_per_channel, double *actual_samples_per_second_per_channel); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ao_write(uint32_t handle, const double *volts, uint32_t samples_per_channel); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ao_write_codes(uint32_t handle, const uint32_t *codes, uint32_t samples_per_channel); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ao_start(uint32_t handle); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_ao_stop(uint32_t handle); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_dio_configure_direction(uint32_t handle, const uint32_t *dio_banks, const uint32_t *directions, uint32_t bank_count); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_dio_single_write(uint32_t handle, const uint32_t *dio_banks, const uint32_t *output_bits, const uint32_t *write_masks, uint32_t bank_count); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_dio_single_read(uint32_t handle, const uint32_t *dio_banks, uint32_t bank_count, uint32_t *input_bits); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_dio_configure(uint32_t handle, const uint32_t *dio_banks, const uint32_t *directions, uint32_t bank_count, uint32_t width, uint32_t requested_samples_per_second, uint32_t acquisition_mode_finite_continuous, uint32_t finite_samples_per_bank, double *actual_samples_per_second); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_dio_start(uint32_t handle); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_dio_stop(uint32_t handle); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_dio_write(uint32_t handle, const uint32_t *output_bits, uint32_t samples_per_bank); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_dio_read(uint32_t handle, uint32_t *input_bits, int32_t samples_to_read_per_bank, uint32_t output_capacity_samples_per_bank, uint32_t *samples_read_per_bank); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_dio_status(uint32_t handle, const uint32_t *dio_banks, uint32_t bank_count, uint32_t *output_bits, uint32_t *directions, uint32_t *stream_running); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_counter_configure(uint32_t handle, const uint32_t *lines, const uint32_t *edges, uint32_t line_count); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_counter_read(uint32_t handle, const uint32_t *lines, uint32_t line_count, uint32_t *counts); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_counter_reset(uint32_t handle, const uint32_t *lines, uint32_t line_count); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_counter_read_frequency(uint32_t handle, const uint32_t *lines, const uint32_t *gate_ms, uint32_t line_count, uint32_t *counts, uint32_t *frequency_hz); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_encoder_configure(uint32_t handle, const uint32_t *lines_a, const uint32_t *lines_b, const uint32_t *modes, uint32_t encoder_count); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_encoder_read(uint32_t handle, const uint32_t *lines_a, uint32_t encoder_count, int32_t *positions); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_encoder_reset(uint32_t handle, const uint32_t *lines_a, uint32_t encoder_count); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_time_configure(uint32_t handle, const uint32_t *lines, const uint32_t *modes, const uint32_t *edges, uint32_t line_count); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_time_read(uint32_t handle, const uint32_t *lines, uint32_t line_count, uint32_t *ticks, uint32_t *microseconds, uint32_t *tick_hz, uint32_t *prescalers); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_time_reset(uint32_t handle, const uint32_t *lines, uint32_t line_count); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_pwm_configure(uint32_t handle, const uint32_t *lines, const uint32_t *frequency_hz, const double *duties, uint32_t line_count); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_pwm_write(uint32_t handle, const uint32_t *lines, const double *duties, uint32_t line_count); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_pwm_status(uint32_t handle, const uint32_t *lines, uint32_t line_count, uint32_t *actual_frequency_hz, double *actual_duties); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_pulse_train_run(uint32_t handle, uint32_t line, uint32_t direction_line, uint32_t direction_value, uint32_t frequency_hz, double duty, uint32_t pulses, uint32_t direction_setup_us, uint32_t start_frequency_hz, uint32_t acceleration_hz_per_s, uint32_t *pulses_sent, uint32_t *actual_frequency_hz); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_codes_to_volts(const int32_t *codes, const double *volts_per_code, const double *offset_volts, uint32_t channel_count, uint32_t samples_per_channel, double *volts); | Signed status; output pointers contain data. Caller owns memory. |
| int32_t sdaq_voltage_to_code(double volts, double codes_per_volt, double offset_codes, double minimum_volts, double maximum_volts, uint32_t minimum_code, uint32_t maximum_code, uint32_t *code); | Signed status; output pointers contain data. Caller owns memory. |
| Parameter names | Meaning |
|---|---|
| handle | Explicit 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 / inputChannels | Ordered list of 1 to 24 unique input selections. |
| output_channels / outputChannels | Ordered list of one or two unique outputs. |
| channel_count | Explicit selected-channel count in C; inferred from the selected array by Python/C#. |
| requested_samples_per_second_per_channel / requestedSamplesPerSecondPerChannel | Requested sampling rate per channel, unsigned 32 bit integer. |
| acquisition_mode_finite_continuous / acquisitionModeFiniteContinuous | AI AcquisitionMode or the C SDAQ_FINITE / SDAQ_CONTINUOUS constant. |
| total_finite_acquisition_samples_per_channel / totalFiniteAcquisitionSamplesPerChannel | AI sample total per channel; positive in finite mode, ignored in continuous mode. |
| generation_mode_finite_continuous / generationModeFiniteContinuous | AO GenerationMode or the C finite / continuous constant. |
| finite_samples_per_channel / finiteSamplesPerChannel | AO finite total per channel, unsigned 32 bit; ignored in continuous mode. |
| waveform_samples_per_channel / waveformSamplesPerChannel | Positive onboard cycle length per channel, within reported capacity. |
| actual_nominal_samples_per_second_per_channel | C double output pointer for configured nominal AI rate. |
| actual_samples_per_second_per_channel | C double output pointer for configured AO rate. |
| samples_to_read_per_channel / samplesToReadPerChannel | Positive sample count or minus one; zero and below minus one are invalid. |
| output_capacity_samples_per_channel | C output buffer capacity measured per channel. |
| samples_read_per_channel | Complete scans returned, including on error: C output pointer, Python third tuple element, or C# out samplesReadPerChannel. |
| samples_per_channel | C waveform input count measured per channel. |
| volts | Voltage-only AI output or calibrated AO input. Single/stream Read no longer also return codes. |
| codes | AI decoded signed I32 sample array from *_read_codes; AO unsigned U32 DAC array for *_write_codes. These are not packet-byte arrays. |
| estimated_volts | C double output array containing estimated AO voltages. |
| output_enabled / waveform_running | C uint32 output Boolean arrays, one entry per selected output. |
| capacity_bytes / capacityBytes | Raw read capacity, 512 to 16777216 bytes. |
| data / bytes | Raw byte buffer. C bytes is the supplied raw write byte count, 1 to 16777216. |
| read_bytes | C uint32 output pointer receiving the actual raw read count. |
| timeout_ms / timeoutMs | Raw 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 name | Value | Native status name | Value |
|---|---|---|---|
| SDAQ_OK | 0 | SDAQ_BUSY | -6 |
| SDAQ_END_OF_ACQUISITION | 1 | SDAQ_BUFFER_TOO_SMALL | -7 |
| SDAQ_INVALID_ARGUMENT | -1 | SDAQ_INVALID_HANDLE | -8 |
| SDAQ_IO | -2 | SDAQ_OVERFLOW | -9 |
| SDAQ_TIMEOUT | -3 | SDAQ_INTERNAL | -10 |
| SDAQ_NOT_FOUND | -4 | SDAQ_UNSUPPORTED | -11 |
| SDAQ_PROTOCOL | -5 | SDAQ_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.
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 count | Behavior |
|---|---|
| Positive N | Wait for N complete scans, or the finite tail at completion. |
| Minus one in continuous mode | Immediately return currently buffered scans, up to capacity. Zero scans can be a successful result. |
| Minus one in finite mode | Wait for completion and return all unread scans. C capacity must hold all of them. |
| Zero or below minus one | Invalid argument. |
| Completed and drained finite acquisition | Return 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.
| Mode | Sequence and behavior |
|---|---|
| Finite | Configure a positive total, Write prefill, Start, continue writing if needed, wait for completion, Stop. |
| Continuous | Configure, Write prefill, Start, continue Write, Stop on application cancellation. |
| Onboard repeat | Configure 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.
| Interface | Data units | Packet handling |
|---|---|---|
| AI Read Codes / AO Write Codes | Decoded I32 ADC or U32 DAC values; counts per channel | SDK handles packet decoding/encoding and managed streaming. |
| AI Raw Read / AO Raw Write | U8 packet bytes; lengths/capacities in bytes | Caller 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.
| Enum | Named values |
|---|---|
| DIOBank | A=0, B=1 |
| DIODirection | Input=0, Output=1 |
| DIOWidth | FourBit=4, SevenBit=7 |
| 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 |
| DigitalEdge | Rising=0, Falling=1, Both=2 |
| DigitalLevel | Low=0, High=1 |
| EncoderMode | X2=2, X4=4 |
| TimeMode | Period=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 request | Behavior |
|---|---|
| Positive N | Wait for N samples per input bank or the finite tail. Preserve returned partial samples on error. |
| -1 in Finite | Read all remaining finite samples; bounded by the wrapper single-call allocation limit. |
| -1 in Continuous | Return currently buffered samples without waiting. |
| After finite data drains | Return 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.