I have written some code that works on my lap top but not on another computer.
I believe I have installed the drivers the same on both systems.
Problem: NI435X_Init and subsequent calls to NI435X_Normal_Scanning return -10240 (NoDriverError) returned.
The test panel for this product works! So I know that the drivers are installed correctly.
Further info:
Operating System: XP
Compiler: VC6++
Product: NI4350
my code: ( I call InitController and then I call GetValue )
int CNI_435x_ADC::InitController()
{
int status = SENSOR_STATUS_OK;
ViStatus error = VI_SUCCESS;
ViString resourceName[16];
int nistatus=0;
static int warncnt=0;
if(m_DAQsession!=NULL)
return status;
_stprintf((ViString)resourceName,_T("DAQ::%d"),m_ControllerAddress); // m_ControllerAddress is 1 (from Measurement & Automation)
if ((nistatus=NI435X_init ((ViString)resourceName, 1, 1, &m_DAQsession)) < NI435X_SUCCESS)
{
ViChar tmpvi[256];
NI435X_error_message(m_DAQsession,nistatus,tmpvi);
CString tmp;tmp.Format("NI435X_init %x(%d) %s",nistatus,nistatus,tmpvi);
if(warncnt++<5)
AfxMessageBox(tmp);
status = SENSOR_ERROR;
}
return status;
}
double CNI_435x_ADC::GetValue()
{
int status=SENSOR_STATUS_OK;
int nistatus=0;
ViString channelString[16];
ViInt16 mode = NI435X_VOLTAGE;
ViReal64 lowLimit=m_Min;
ViReal64 highLimit=m_Max;
ViReal64 scanBuffer=0.0;
static int warncnt=0;
_stprintf((ViString)channelString,_T("%d"),m_Channel);
if (nistatus=NI435X_Normal_Scanning(m_DAQsession,
(ViString)channelString,
mode, lowLimit, highLimit,
1, &scanBuffer) < NI435X_SUCCESS)
{
ViChar tmpvi[256];
NI435X_error_message(m_DAQsession,nistatus,tmpvi);
CString tmp;tmp.Format("NI435X_Normal_Scanning %x(%d) session ID %d %s",nistatus,nistatus,m_DAQsession,tmpvi);
if(warncnt++<5 && m_DAQsession!=NULL)
AfxMessageBox(tmp);
status = SENSOR_ERROR;
}
else
{
// convert to internal units (Temperature=celcuis,pressure=psi,...)
m_Value = GetValueFromCalTable(scanBuffer/m_UnitsConv);
// Remove error from the calibrated error values
m_Value = m_Value*m_Gain + m_Offset;
//m_Value = scanBuffer/m_UnitsConv;
}
return m_Value;
}
Thanks for your help
Matt