03-04-2009 08:04 AM
I m new to this forum and to National Instruments programming, so if this is not posted to the best board, please direct me to the best one.
I am writing a program in C++ on a Macintosh, driving a USB-6008 to control my heating and cooling system. My code, included below, is rather closely derived from WriteDigPort.cpp included with the examples. The forst problem is, it is unreliable at opening the channel. With a probability of about 1/3, the call to DAQmxBaseCreateDOChan gives an error of -200170, "Physical channel specified does not exist on this device". The erratic nature of this error, on consecutive runs a few minutes apart without unplugging or rebooting anything, is really confusing. Should i be looking for warranty service on my device?
I am using NI-DAQmx_Base_2.1.0 under MacOS 10.4.10.
// Task parameters
int32 error = 0;
TaskHandle taskHandle = 0;
char errBuff[2048];
// Channel parameters
char chan[] = "Dev1/port0";
// Write parameters
uInt32 w_data [1];
int32 written;
uInt32 data = 0;
void BlinkLED() {
int i;
// Create Digital Output (DO) Task and Channel
DAQmxErrChk (DAQmxBaseCreateTask ("", &taskHandle));
do {
int error;
bool bad;
error = DAQmxBaseCreateDOChan(taskHandle,chan,"",DAQmx_Val_ChanForAllLines);
if (bad=DAQmxFailed (error)){
DAQmxBaseGetExtendedErrorInfo (errBuff, 2048);
if (error)
printf ("DAQmxBase Error %d: %s\n", error, errBuff);
}
usleep(500000);
} while bad;
for (i=0; i<2; i++) {
w_data[0] = data;
printf("Data to write: 0x%X\n", w_data[0]);
DAQmxErrChk (DAQmxBaseWriteDigitalU32(taskHandle,1,1,10.0,DAQmx_Val_GroupByChannel,w_data,&written,NULL));
sleep(1);
data = data ^ 0xff;
}
Error:
if (DAQmxFailed (error))
DAQmxBaseGetExtendedErrorInfo (errBuff, 2048);
if (taskHandle != 0)
{
DAQmxBaseStopTask (taskHandle);
DAQmxBaseClearTask (taskHandle);
}
if (error)
printf ("DAQmxBase Error %d: %s\n", error, errBuff);
}
03-05-2009 01:38 PM
Hi
Does your program work properly without throwing any errors the other 2/3 of the time? If so, does anything change in the system when it gives the error of 200170? When you run an example (like the DAQmxBaseCreateDOChan) do you see this error occur intermittently? I see in your program that the channel specified is Dev1/port0. Is Dev1 the correct device name?
I found an article that may help explain this issue so I would recommend to check it out.
Using a USB-6008 / 6009 / 6501 in MAX, and Switching Firmware Between NI-DAQmx and NI-DAQmx Base
http://digital.ni.com/public.nsf/websearch/1448A8AC665EE0EA8625703F004A4410?OpenDocument
Also, you do not necessarily need it but there is a newer DAQmx base driver available for download on our Website compatible with Mac OS X 10.4 (Tiger) on Intel or PowerPC (10.4.8 or later)
NI-DAQmx Base 3.2 - Mac OS X
http://joule.ni.com/nidu/cds/view/p/id/1078/lang/en