07-09-2013 12:58 PM
Hi all,
I am delveloping a very simple CVI program to control digital channels. The program will be used in another computer with pci6713 card installed and labview 7.1 & traditional DAQ installed. I made the distribution including the DAQmx9.7 driver as well as the CVI runtime but the CVI program running in the destiantion computer doesn't work, it crashes when it writes to the channel. The problem is solved by installing the DAQmx 9.7 driver. Now it won't crash any more. However, sometimes when I write to some channels, the error message popped up and tells that the channel was reserved. Is that because in the MAX the device was assigned to traditioanl DAQ? What should I do in the MAX to make it work for my CVI and not affecting the labview code which is usining tradtional DAQ for the same device?
07-09-2013 05:49 PM
This may be related to the known issue discussed in this KnowledgeBase Article: How to Re-associate Your Traditional DAQ Device With The DAQmx Driver.
07-09-2013 05:59 PM - edited 07-09-2013 06:02 PM
OK. It seems work. But I still have a problem. In my CVI, I control the external LED on/off by setting a digital HIGH/LOW, but why it only works for once, i.e. when I switch the button (so the callback will send TRUE boolean to the terminal), it will lit the LED. But it doesn't work any more if I switch the button again.
p..s in the callback function, I put message popup there, and it does popup the message with the correct value of the button so it means it can trigger the callback without any problem.
07-10-2013 11:19 AM
I can't think of any obvious reason this would not work. Do you have any code that you could post?
07-10-2013 11:40 AM
Here is the code
#include <userint.h>
#include "iface.h"
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int write_onoff(uInt8 HL, const char linename[])
{
int error=0; // error code (initialized to zero i.e. no error)
TaskHandle taskHandle=0; // task ID for DAQmx
char errBuff[2048]={'\0'}; // error message
/*********************************************/
// DAQmx Configure Code
/*********************************************/
SetWaitCursor(1);
DAQmxErrChk(DAQmxCreateTask("", &taskHandle));
DAQmxErrChk(DAQmxCreateDOChan(taskHandle, linename, "", DAQmx_Val_ChanPerLine ));
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk(DAQmxStartTask(taskHandle));
/*********************************************/
// DAQmx Write Code
/*********************************************/
DAQmxErrChk(DAQmxWriteDigitalU8(taskHandle, 1, 1, 10.0, DAQmx_Val_GroupByChannel, &HL, NULL, NULL));
Error:
SetWaitCursor(0);
if (DAQmxFailed(error)) DAQmxGetExtendedErrorInfo(errBuff, 2048);
if (taskHandle!=0)
{
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
}
if (DAQmxFailed(error)) MessagePopup("DAQmx Error", errBuff);
return error;
} // end write_digital_line
int CVICALLBACK test (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
uInt8 onoff=0;
if (event==EVENT_COMMIT)
{
GetCtrlVal(panel, control, &onoff);
write_onoff(onoff, "Dev1/port0/line0");
}
return 0; // return 0 to tell the system the message has been handled
}