| libvkdaq VKINGING DAQ Library API Reference |

Loading...
Searching...
No Matches
Continuous output of fixed waveform
Temporary task flow chart

Note
  Steps:
  1.Create task. VkDaqCreateTask
  2.Create analog output channel VkDaqCreateAIAccelChan
  3.Set sampling clock VkDaqCfgSampClkTiming
  4.Start task VkDaqStartTask
  5.Set fixed waveform task data VkDaqSetTaskData
  6.Stop task VkDaqStopTask
  7.Clear task VkDaqClearTask

Example of Continuous output of fixed waveform Process Diagram

C language reference
#include <iostream>
#include <stdio.h>
#include "libvkdaq.h"
#define CH_NAME "dev1/AOUT1"
#define PI 3.14159265358979323846
#define SAMPLING_FREQUENCY 10000 //1~32768
#define WAVE_AMPLITUDE 5 //0~9
#define WAVE_FREQUENCY 10
#define WAVE_PHASE 0 //0~360
#define WAVE_OFFSET 0
#define DAQmxFailed(error) ((error)<0)
#define VkDaqErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int main(int argc, char* argv[])
{
int i = 0;
int32_t error = 0;
const char* taskHandle = "VkDaqTaskHandledac";
double* data = new double[SAMPLING_FREQUENCY];
// Sin Wave
for (i = 0; i < SAMPLING_FREQUENCY; i++)
data[i] = WAVE_AMPLITUDE * sin((double)i / (SAMPLING_FREQUENCY / WAVE_FREQUENCY + (WAVE_PHASE / 360)) * 2.0 * PI) + WAVE_OFFSET;
// VkDaq Configure Code
VkDaqErrChk(VkDaqCreateTask(taskHandle));
VkDaqErrChk(VkDaqCreateAOVoltageChan(taskHandle, CH_NAME, "", -9, 9, VkDaq_Val_Volts, ""));
VkDaqErrChk(VkDaqCfgSampClkTiming(taskHandle, VkDaq_Val_ClkSrc_OnBoardClk, SAMPLING_FREQUENCY, 0, VkDaq_Val_ContSamps, SAMPLING_FREQUENCY));
// VkDaq Start Code
VkDaqErrChk(VkDaqStartTask(taskHandle));
// VkDaq Write Code
VkDaqErrChk(VkDaqSetTaskData(taskHandle, data, SAMPLING_FREQUENCY, 0, 1, 1));
printf("Generate success\n");
Error:
if (DAQmxFailed(error))
printf("VkDaq Error: %s\n", VkDaqGetLastErrorInfo());
if (taskHandle != 0) {
VkDaqStopTask(taskHandle);
VkDaqClearTask(taskHandle);
}
delete[] data;
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}
VkDaqClearTask
int32_t VkDaqClearTask(const char *task)
Clear task.
VkDaqCreateAOVoltageChan
int32_t VkDaqCreateAOVoltageChan(const char *task, const char *chans, const char *reserved1, double minVal, double maxVal, int32_t units, const char *reserved2)
Create DAC channel.
VkDaqCreateTask
int32_t VkDaqCreateTask(const char *task)
Create task.
VkDaqStartTask
int32_t VkDaqStartTask(const char *task)
Start task.
VkDaqStopTask
int32_t VkDaqStopTask(const char *task)
Stop task.
VkDaqGetLastErrorInfo
const char * VkDaqGetLastErrorInfo(void)
Get the error message of the last execution.
VkDaqSetTaskData
int32_t VkDaqSetTaskData(const char *task, const double dat[], int32_t sampsPerChan, int32_t fillmode, int32_t autoStart, double timeout)
Set task data.
VkDaqCfgSampClkTiming
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...