Hi all, I have a problem about the acquisition of signals using CVI and NIDaqMx libraries.
I would like to create a DLL in order to use it in LabView RT Module to acquire data as doubles.
I've already written some lines of code, but I think something is wrong or missing. In fact when I run it, I always acquire a strange value (2e17), surely wrong.
I add the code below... Can you help me?
/ Include files
#include "acquisizione.h"
#include <cvirte.h>
#include <userint.h>
#include <ansi_c.h>
#include <NIDAQmx.h>
TaskHandle input=-1;
float64 datain [10000];
// GLOBAL FUNCTIONS
void init_acq(int samples_in)
{
// TASK
DAQmxCreateTask(TASK_NAME,&input);
DAQmxAddGlobalChansToTask (input, "Voltage"); // Da mettere quì o dopo??
// CHANNEL
DAQmxCreateAIVoltageChan (input, "Dev1/ai0", "Voltage", DAQmx_Val_Cfg_Default, -10, 12,
DAQmx_Val_Volts,"NULL");
// Attributes
DAQmxSetChanAttribute (input, "Voltage", DAQmx_AI_Voltage_Units, DAQmx_Val_Volts, datain);
// TIMING
DAQmxCfgSampClkTiming (input, "/Dev1/ai/SampleClock", samples_in, DAQmx_Val_Rising,
DAQmx_Val_FiniteSamps, samples_in);
DAQmxSetTimingAttribute (input, DAQmx_SampQuant_SampMode, DAQmx_Val_FiniteSamps);
DAQmxSetTimingAttribute (input, DAQmx_SampTimingType, DAQmx_Val_SampClk);
// READ
DAQmxReadAnalogF64 (input, DAQmx_Val_Auto, 10.0, DAQmx_Val_GroupByChannel, datain, samples_in, 0,
0);
DAQmxSetReadAttribute (input, DAQmx_Read_RelativeTo, DAQmx_Val_CurrReadPos);
DAQmxSetReadAttribute (input, DAQmx_Read_ChannelsToRead, "Voltage");
DAQmxSetReadAttribute (input, DAQmx_Read_OverWrite, DAQmx_Val_DoNotOverwriteUnreadSamps);
}
float64 read_acq(int i)
{
return datain[i-1];
}
void start_acq (void)
{
DAQmxStartTask (input);
}
void stop_acq (void)
{
DAQmxStopTask(input);
}
void clear_acq (void)
{
DAQmxClearTask (input);
}Thanks for the future answers.