#include <iostream>
#include <stdio.h>
#include "libvkdaq.h"
#define CH_NAME "dev1/AOUT1"
#define PI 3.14159265358979323846
#define SAMPLING_FREQUENCY 10000
#define WAVE_AMPLITUDE 5
#define WAVE_FREQUENCY 10
#define WAVE_PHASE 0
#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];
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;
VkDaqErrChk(
VkDaqCfgSampClkTiming(taskHandle, VkDaq_Val_ClkSrc_OnBoardClk, SAMPLING_FREQUENCY, 0, VkDaq_Val_ContSamps, SAMPLING_FREQUENCY));
printf("Generate success\n");
Error:
if (DAQmxFailed(error))
if (taskHandle != 0) {
}
delete[] data;
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}
int32_t VkDaqClearTask(const char *task)
Clear task.
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.
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 VkDaqSetTaskData(const char *task, const double dat[], int32_t sampsPerChan, int32_t fillmode, int32_t autoStart, double timeout)
Set 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...