#include <stdio.h>
#include "libvkdaq.h"
#define VkDaqErrChk(functionCall) if( VkDaqFailed(error=(functionCall)) ) goto Error; else
int main(void)
{
TaskHandle taskHandle = "VkDaqTaskHandle";
float64 data[1000];
int64 total = 0;
int32 error = 0;
int32 read = 0;
VkDaqErrChk(
VkDaqCreateAIAccelChan(taskHandle,
"dev1/AIN1",
"", VkDaq_Val_SingleEnded, 0, 100, VkDaq_Val_AccelUnit_g, 0.05, DAQmx_Val_SignalType_IEPE,
""));
VkDaqErrChk(
VkDaqCfgSampClkTiming(taskHandle, VkDaq_Val_ClkSrc_OnBoardClk, 10000, VkDaq_Val_Rising, VkDaq_Val_ContSamps, 0));
printf("Acquiring samples continuously.\n");
while (true) {
read =
VkDaqGetTaskData(taskHandle, data, 1000, VkDaq_Val_GroupByScanNumber, 1);
if (read > 0) {
printf("Acquired %d samples. Total %lld\r", read, total += read);
fflush(stdout);
}
}
Error:
if (VkDaqFailed(error))
if (taskHandle != 0) {
}
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}
int32_t VkDaqClearTask(const char *task)
Clear task.
int32_t VkDaqCreateAIAccelChan(const char *task, const char *chans, const char *reserved1, int32_t terminalConfig, double minVal, double maxVal, int32_t units, double sensitivity, int32_t signalType, const char *reserved2)
Create acceleration measurement channel.
int32_t VkDaqCreateTask(const char *task)
Create task.
int32_t VkDaqStartTask(const char *task)
Start task.
int32_t VkDaqStopTask(const char *task)
Stop task.
const char * VkDaqGetLastErrorInfo(void)
Get the error message of the last execution.
int32_t VkDaqGetTaskData(const char *task, double dat[], int32_t sampsPerChan, int32_t fillmode, double timeout)
Get task data.
int32_t VkDaqCfgSampClkTiming(const char *task, int32_t source, double samplingFrequency, int32_t reserved, int32_t sampleMode, int32_t sampsPerChanToAcquire)
Set the source of the sampling clock, the rate of the sampling clock, and the number of samples to be...