Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

USB-6008 with Mac OSX (Tiger) using NI-DAQmx Base

I have NI USB-6008 on INTEL MacBook Pro running Mac OSX Tiger. I installed the latest NI-DAQmx Base software from NI.

I am using X-Code 2.4.1 to develop C, standalone application that will move to next sample Gilson FC2004 Fraction Collector, by sending digital signal.

Signal will be triggered by digital encoder (Bourns EN series optical encoder). I am using provided example program to read from chan[] = "/Dev1/ctr0"; encoder is connected to Terminal number 29 (PFI0) on USB-6008 board.


I am planning to connect Gilson FC2004 instrument to Terminal 32 (GND) and terminal 17 (P0.0).



I am using chan[] = "Dev1/port0/line0";
Q1. Is this correct?


Q2. Do I have to use
DAQmxBaseWriteDigitalU32 function or DAQmxBaseWriteDigitalU8 ???


//To test digital output I am using this example code from NI:

//Cut below this line

*********************************************************************/
#include "NIDAQmxBase.h"
#include

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


int main (int argc, char *argv[])
{
// Task parameters
int32 error = 0;
TaskHandle taskHandle = 0;
char errBuff[2048];

// Channel parameters

//DAQmx terminals start with a leading slash but DAQmx physical channels do not.
// The software uses "port0/line3" to represent P0.3. So "Dev1/port0/line0" is for Terminal 17 in USB-6008 board.

char chan[] = "Dev1/port0/line0";

// Write parameters
uInt32 w_data [1];
int32 written;


// Create Digital Output (DO) Task and Channel
DAQmxErrChk (DAQmxBaseCreateTask ("", &taskHandle));
DAQmxErrChk (DAQmxBaseCreateDOChan(taskHandle,chan,"",DAQmx_Val_ChanForAllLines));

// Start Task (configure port)
DAQmxErrChk (DAQmxBaseStartTask (taskHandle));

// Write 0x55 to port(s)
// Only 1 sample per channel supported for static DIO
// Autostart ON

w_data[0] = 0x55;

printf("Data to write: 0x%X\n", w_data[0]);

DAQmxErrChk (DAQmxBaseWriteDigitalU32(taskHandle,1,1,10.0,DAQmx_Val_GroupByChannel,w_data,&written,NULL));


Error:

if (DAQmxFailed (error))
DAQmxBaseGetExtendedErrorInfo (errBuff, 2048);

if (taskHandle != 0)
{
DAQmxBaseStopTask (taskHandle);
DAQmxBaseClearTask (taskHandle);
}

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

return 0;
}
0 Kudos
Message 1 of 4
(4,374 Views)

Hi Andrei,

1. In your directory, there should be a file named “lsdaq” that lists all the devices compatible with DAQmx base and list them by device syntax (i.e. “dev1”)

2. From the NI-DAQmx Base 2.x C Function Reference Help, the DAQmxBaseWriteDigitalU8 states “Writes multiple eight-bit unsigned integer samples to a task that contains one or more digital output channels. Use this format for devices with up to 8 lines per port.” The DAQmxBaseWriteDigitalU32 is identical but is “for devices with up to 32 lines per port.” The USB-6008/9 only has 8 lines per port (as do most devices), so use the DAQmxBaseWriteDigitalU8 function.

I hope that gets you started.

Mark E.
Precision DC Product Support Engineer
National Instruments

0 Kudos
Message 2 of 4
(4,344 Views)
Dear Mark,

Thank you for the information.
Output from lsdaq shows Dev1.
Q. What is the exact syntax for line connected to terminal 17 of the USB-6008?
I was planning to use
"Dev1/port0/line0"

Thanks again,

Andrei

Message 3 of 4
(4,337 Views)

Hi Andrei,

That should be the right syntax. The way to see many details about your product is in the NI USB-6008/6009 User Guide and Specifications. It has pinouts, descriptions of the channels, and a lot of other information that can answer many questions you might have, etc.

Also, there is built-in error handling, which will give you descriptive message (usually) that indicate what is wrong and how to fix it. So if the syntax happened to not work, it should give you an indication of how to fix it.

Best of luck with your application.

Where Can I Find NI-DAQmx Base Examples?

Mark E.
Precision DC Product Support Engineer
National Instruments

0 Kudos
Message 4 of 4
(4,320 Views)