hi,
I need a help...
I am using a VISA test application (NI VISA) to communicate with our firmware through tcp/ip ....This includes a power supply control instructions.But whenever I run my code i am getting an error message-"error in viOpen.Timeout expired before operation completed"
But If I use the measurement and automation of labview n initialize with the ip address , the test app will work properly...
even if i close the measurement and automation after that it would work for some more time (10 minutes) n again will give the same error.
That means, I think , this measurement and automation program does some initialization ,or calls some functions which I miss in my test application.
Plz look into the problem...shall we need to do some initialization step before running the code in Visual C++ IDE.
I am attaching the code n the spylogs taken when time out occurs n when no timeout(with measurement and automation activated)...if anyone know the solution plz reply soon...I am in a hurry
thanks n regards
seren
//This is a simple program that sets a voltage, current, overvoltage, and the
//status of over current protection. All of the variables
//can be changed by the user.
#include "visa.h"
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
ViSession session,defrm;
ViStatus VISAstatus;
char statdsc[100];
char err[100];
char voltmeasurement[16]="0";
char currmeasurement[16]="0";
char overvoltmeasurement[16]="6";
int overcurron, ps_address =1;
float voltsetting,currsetting,overvoltsetting;
char add[]="TCPIP0::x.x.x.2";
//this variable controls the voltage
//it can be hard coded into the viPrintf command as well
voltsetting=3; //in volts
//this variable controls the current
//it can be hard coded into the viPrintf command as well
currsetting=1.5; //in amps
//these vaiables control the over voltage protection setting
//overvoltsetting=6; //in volts
//this variable controls the over current protection (1 for on, 0 for off);
overcurron=1;
//The default resource manager manages initializes the VISA system
VISAstatus=viOpenDefaultRM(&defrm);
if (VISAstatus!=VI_SUCCESS)
{
viStatusDesc(defrm,VISAstatus,statdsc);
printf("Error on viOpen: %s \n",statdsc);
exit(EXIT_FAILURE);
}
//opens a communication session with the instrument at address "add"
VISAstatus=viOpen(defrm,add,VI_NULL,timeout,&session);////error here
//VISAstatus=viOpen(defrm,add,VI_NULL,timeout,&session);
if (VISAstatus!=VI_SUCCESS)
{
viStatusDesc(session,VISAstatus,statdsc);
printf("Error on viOpen: %s \n",statdsc);
exit(EXIT_FAILURE);
}
viPrintf(session,"INST:SELECT %d \n",ps_address);
viPrintf(session,"SYST:ERR? \n");
Sleep(1000);
viScanf(session,"%t",&err);
printf("Error: %s \n",err);
//Set voltage
viPrintf(session,":VOLT %f \n",voltsetting);
//Set the over voltage level
// viPrintf(session,":VOLT

ROT:LEV %f \n",overvoltsetting);
//Turn on over current protection
//viPrintf(session,":CURR

ROT:STAT %d \n",overcurron);
//Set current level
viPrintf(session,":CURR %f \n",currsetting);
//Enable the output
viPrintf(session,"OUTP ON \n");
Sleep(500);
//measure the voltage
viPrintf(session, "MEAS:VOLT? \n");
//readback the voltage from the instrument
viScanf(session,"%s",&voltmeasurement);
//print out voltage measurement
printf("voltage measured to be: %s \n",voltmeasurement);
//measure the programmed current
viPrintf(session, ":CURRENT? \n");
//readback the current from the instrument
viScanf(session,"%s",&currmeasurement);
//print out current measurement
printf("current measured to be: %s \n",currmeasurement);
//measure the overvoltage
viPrintf(session, ":VOLT

ROT:LEV? \n");
//readback the overvoltage from the instrument
viScanf(session,"%s",&overvoltmeasurement);
//print out overvoltage measurement
printf("overvoltage measured to be: %s \n",overvoltmeasurement);
//check for errors
viPrintf(session,"SYST:ERR? \n");
Sleep(1000);
viScanf(session,"%t",&err);
printf("Error: %s \n",err);
//This frees up all of the resources
viClose(session);
viClose(defrm);
return EXIT_SUCCESS;
}