Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Continous Digital In with PCI-6221

Hi Folks!

I'm havin some trouble reading a digital signal with a PCI-6221 card (m-series).
I'm just not able to read the signal continously with the onbaord sample clock. I tried the function
DAQmxCfgChangeDetectionTiming
which works fine and reads the signal continously. But much too often, as it seems.
And i want to read the signals together with my sampleclock because another analog signal is also read with the sampleclock.
I've been at a point where i thought that no internal triggering is possible. But it works fine in MAX. Das MAX also use the DAQmxCfgChangeDetectionTiming function and not the sample clock?

Here is my code:
// DigitalAnalog.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
//

#include
#include "nidaqmx.h"
#include


int main()
{
TaskHandle InputTask = 0;
float expectedamplitude=5.0;
float samplerate=2;
const int buffersize=4095;
float timeout=5.0;
int errorcode=0;
uInt8 digarray[buffersize];
int32 digread=0;
int32 numBytesperSamp;

DAQmxCreateTask("InputTask", &InputTask);

//create analog input channel
//DAQmxCreateAIVoltageChan(InputTask, "dev1/ai0" /*frequenzgeneraor*/, "", DAQmx_Val_RSE, (-1)*expectedamplitude, expectedamplitude, DAQmx_Val_Volts, NULL);
//if (errorcode!=0)
// printf("Error creating the analog channel!\n");

//create digital input channel
DAQmxCreateDIChan(InputTask, "dev1/port0/line0", "", DAQmx_Val_ChanPerLine);
if (errorcode!=0)
printf("Error creating the digital channel!\n");

//create clock
//DAQmxCfgSampClkTiming(InputTask, "", samplerate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, buffersize);
//if (errorcode!=0)
// printf("Error setting up the sample clock!\n");

DAQmxCfgChangeDetectionTiming (InputTask, "dev1/port0/line0", "", DAQmx_Val_ContSamps, buffersize);

printf("Task is launched!\n");
DAQmxStartTask(InputTask);
while(!_kbhit())
{
errorcode=DAQmxReadDigitalU8(InputTask, -1, timeout, DAQmx_Val_GroupByScanNumber, digarray, buffersize, &digread, NULL);
if (errorcode!=0)
{
printf("Error reading the digital value: %i\n", errorcode);
break;
}
printf("digread: %i", digread);
if (digread>0)
{
printf("Eingelesen: %i\n", digarray[0]);
}

}

getche();
return 0;
}

Greetings from good ole Germany!
0 Kudos
Message 1 of 1
(3,329 Views)