Quantcast
Channel: Digital I/O topics
Viewing all articles
Browse latest Browse all 2167

usb-6009

$
0
0

Hello guys,

 

 

I'm new to DAQmx base and have some doubts.

 

First of all I'm running Scientific Linux 6.7, DAQmx base 14.0, Eclipe IDE and USB-6009 device.

 

Device communication is ok and my program is copiling and running.

 

 

My program has two tasks, each one with a DO channel.

The problem is that when a write data to the DO channel of one task the DO channel of the other task is also being affected.

 

Best regards,

Fernando

 

Follows my code:

 

#include <NIDAQmxBase.h>

#include <stdio.h>

#include <termios.h>

#include <unistd.h>

#include <fcntl.h>

 

 

#define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }

 

int main (int argc, char *argv[])

{

   // Task parameters

   int32       error = 0;

   TaskHandle  DO_task = 0;

   TaskHandle  DO_data_task = 0;

 

   char        errBuff[2048];

 

   // Channel parameters

   const char  DO_led[] = "Dev1/port0/line2";

   const char  DO_data[] = "Dev1/port0/line1";

 

   // Read parameters

   uInt32      data [1];

   int32       byte_conter;

 

   // Create Digital Input (DO) Task and Channel

   DAQmxErrChk (DAQmxBaseCreateTask ("", &DO_task));

   DAQmxErrChk (DAQmxBaseCreateDOChan(DO_task,DO_led,"",DAQmx_Val_ChanForAllLines));

 

   // Start Task (configure port)

   DAQmxErrChk (DAQmxBaseStartTask (DO_task));

 

   // Create Digital Input (DO) Task and Channel

   DAQmxErrChk (DAQmxBaseCreateTask ("", &DO_data_task));

   DAQmxErrChk (DAQmxBaseCreateDOChan(DO_data_task,DO_data,"",DAQmx_Val_ChanForAllLines));

 

   // Start Task (configure port)

   DAQmxErrChk (DAQmxBaseStartTask (DO_data_task));

 

  

   // write to port

   data[0]=0xFF;

   //DAQmxErrChk (DAQmxBaseWriteDigitalU32(DO_data_task,1,1,10.0,DAQmx_Val_GroupByChannel,data,& byte_conter,NULL));

   DAQmxErrChk(DAQmxBaseWriteDigitalScalarU32 (DO_data_task, 1, 10.0, 0xFFFF, NULL));

 

   // write to port

   data[0]=0x0;

   //DAQmxErrChk (DAQmxBaseWriteDigitalU32(DO_task,1,1,10.0,DAQmx_Val_GroupByChannel,data,&byte_ conter,NULL));

   DAQmxErrChk(DAQmxBaseWriteDigitalScalarU32 (DO_task, 1, 10.0, 0x0000, NULL));

 

 

Error:

 

   if (DAQmxFailed (error))

      DAQmxBaseGetExtendedErrorInfo (errBuff, 2048);

 

   if (DI_task != 0)

   {

      DAQmxBaseStopTask (DI_task);

      DAQmxBaseClearTask (DI_task);

   }

 

   if (error)

      printf ("DAQmxBase Error %ld: %s\n", error, errBuff);

 

   return 0;

}


Viewing all articles
Browse latest Browse all 2167

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>