04-17-2011 07:51 AM
I wrote this code in order to output a train bits continuously.The code is:
#include <NIDAQmx.h>
#include <ansi_c.h>
#include <cvirte.h>
#include <userint.h>
#include "test_6535.h"
#include "toolbox.h"
//==============================================================================
// Constants
//==============================================================================
// Types
//==============================================================================
// Static global variables
static int panelHandle;
//==============================================================================
// Static functions
//==============================================================================
// Global variables
//==============================================================================
// Global functions
#define NUM_SAMPLES 100
/// HIFN The main entry-point function.
int main (int argc, char *argv[])
{
float64 adDutyCycle[1], adFreq[1];
int32 iSampleWritten;
uInt8 abArray[NUM_SAMPLES];
TaskHandle gTaskHandle;
int error = 0, i = 0;
unsigned __int64 ui64Samples = NUM_SAMPLES;
for (i = 0; i < sizeof (abArray); i++)
{
if (i % 2)
{
abArray[i] = 0;
}
else
{
abArray[i] = 1;
}
}
adDutyCycle[0] = 10.;
adFreq[0] = 1920;
DAQmxCreateTask ("",&gTaskHandle);
error = DAQmxCreateDOChan (gTaskHandle, "6535/port0/line3", "",
DAQmx_Val_ChanPerLine);
error = DAQmxSetTimingAttribute (gTaskHandle,
DAQmx_SampQuant_SampMode,
DAQmx_Val_ContSamps);
error = DAQmxSetTimingAttribute (gTaskHandle, DAQmx_SampClk_Rate,
2500.);
error = DAQmxSetTimingAttribute (gTaskHandle,
DAQmx_SampQuant_SampPerChan, ui64Samples);
error = DAQmxWriteDigitalLines (gTaskHandle, sizeof (abArray), 1,
10.0, DAQmx_Val_GroupByChannel,
abArray, &iSampleWritten, 0);
while (1)
{
ProcessSystemEvents ();
}
return 0;
}
The program executes DAQmxWriteDigitalLines only once and than stops transmitting.
My question is:
What I need to do in order to transmit the data continuously?
Best regards
Etai.
04-18-2011 10:50 AM
Are you working from an example program or is this some code you wrote? The function help for ProcessSystemEvents suggests a piece of code (below) to run continuously.
while (!done)
{
ProcessSystemEvents ();
RunAdditionalStep ();
}
Also, there are some continuous digital examples in the DAQmx folder that should have been installed with the software. Start Menu » National Instruments » NI-DAQ » Text Based Code Support » ANSI C