| libvkdaq VKINGING 数据采集库 API 文档 |

载入中...
搜索中...
未找到
连续采集加速度数据
临时任务流程图

注解
  步骤：
  1.创建任务 VkDaqCreateTask
  2.创建加速度通道 VkDaqCreateAIAccelChan
  3.设置采样时钟 VkDaqCfgSampClkTiming
  4.开始任务 VkDaqStartTask
  5.获得任务数据 VkDaqGetTaskData
  6.停止任务 VkDaqStopTask
  7.清理任务 VkDaqClearTask

连续采集加速度数据流程图示例

C语言参考
#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;
// VkDaq Configure Code
VkDaqErrChk(VkDaqCreateTask(taskHandle));
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));
// VkDaq Start Code
VkDaqErrChk(VkDaqStartTask(taskHandle));
printf("Acquiring samples continuously.\n");
while (true) {
// VkDaq Read Code
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))
printf("VkDaq Error: %s\n", VkDaqGetLastErrorInfo());
if (taskHandle != 0) {
// VkDaq Stop Code
VkDaqStopTask(taskHandle);
VkDaqClearTask(taskHandle);
}
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}
VkDaqClearTask
int32_t VkDaqClearTask(const char *task)
清除任务
VkDaqCreateAIAccelChan
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)
创建加速度传感器通道
VkDaqCreateTask
int32_t VkDaqCreateTask(const char *task)
创建任务
VkDaqStartTask
int32_t VkDaqStartTask(const char *task)
开始任务
VkDaqStopTask
int32_t VkDaqStopTask(const char *task)
停止任务
VkDaqGetLastErrorInfo
const char * VkDaqGetLastErrorInfo(void)
获取最后一次执行的错误信息
VkDaqGetTaskData
int32_t VkDaqGetTaskData(const char *task, double dat[], int32_t sampsPerChan, int32_t fillmode, double timeout)
获取任务数据
VkDaqCfgSampClkTiming
int32_t VkDaqCfgSampClkTiming(const char *task, int32_t source, double samplingFrequency, int32_t reserved, int32_t sampleMode, int32_t sampsPerChanToAcquire)
设置采样时钟的来源、采样时钟的速率以及要采集或生成的采样数