|
#include <rs232.h>
|
|
#include <ansi_c.h>
|
|
#include "inst.h"
|
|
#include <utility.h>
|
|
#include "var.h"
|
|
|
|
/**
|
|
* @brief read TEMP
|
|
* @param [in]
|
|
* @return 0
|
|
* @date 27/05/2014
|
|
*
|
|
*/
|
|
|
|
int read_TEMP(float* temp_batt,float* temp_ext, float* rh)
|
|
{
|
|
char buffer [256];
|
|
if(instrument[INST_TEMP].present==1)
|
|
{
|
|
ComWrt (instrument[INST_TEMP].port.numCOM,"1" , strlen("1") );
|
|
ComRdTerm (instrument[INST_TEMP].port.numCOM,buffer ,255 ,'\r' );
|
|
buffer[5]='\0';
|
|
sscanf(buffer,"%f",temp_batt);
|
|
ComWrt (instrument[INST_TEMP].port.numCOM,"2" , strlen("2") );
|
|
ComRdTerm (instrument[INST_TEMP].port.numCOM,buffer ,255 ,'\r' );
|
|
buffer[5]='\0';
|
|
sscanf(buffer,"%f",temp_ext);
|
|
}
|
|
return 0;
|
|
}
|
|
/**
|
|
* @brief init TEMP
|
|
* @param [in]
|
|
* @return 0
|
|
* @date 27/05/2014
|
|
*
|
|
*/
|
|
|
|
int init_TEMP(int inst)
|
|
{
|
|
char buffer [1024];
|
|
int err;
|
|
int nbbitlu;
|
|
int i;
|
|
instrument[inst].present=0;
|
|
instrument[inst].actif =0;
|
|
save_LOG("INSTRUMENT TEMP");
|
|
err=OpenComConfig (instrument[inst].port.numCOM, "", instrument[inst].port.baudRate, 0, 8, 1, 32767, 512) ;
|
|
if(!err)
|
|
{
|
|
|
|
//CLEAR BUFF
|
|
nbbitlu=1;
|
|
while(GetInQLen (instrument[inst].port.numCOM))
|
|
ComRd (instrument[inst].port.handle,buffer ,GetInQLen (instrument[inst].port.numCOM) );
|
|
//IDQUERY
|
|
for (i=0;i<255;++i)
|
|
instrument[inst].port.instrDescr[i]='\0';
|
|
ComWrt (instrument[inst].port.numCOM,"*" , strlen("*") );
|
|
err=ComRdTerm (instrument[inst].port.numCOM,instrument[inst].port.instrDescr ,255 ,'\r' );
|
|
if(err<=0)
|
|
{
|
|
sprintf(instrument[inst].port.instrDescr,"TEMP FAIL");
|
|
save_LOG(" FAIL");
|
|
return -1;
|
|
}
|
|
instrument[inst].present=1;
|
|
instrument[inst].actif =1;
|
|
SetCtrlAttribute (T_panel[PANEL_MEASURE].panel,P_MEASURE_TEMP_BATT,ATTR_VISIBLE, 1);
|
|
SetCtrlAttribute (T_panel[PANEL_MEASURE].panel,P_MEASURE_TEMP_EXT,ATTR_VISIBLE, 1);
|
|
save_LOG( instrument[INST_TEMP].port.instrDescr);
|
|
return 0;
|
|
}
|
|
sprintf(instrument[inst].port.instrDescr,"TEMP FAIL");
|
|
save_LOG(" FAIL");
|
|
return -1;
|
|
}
|
|
/**
|
|
* @brief cmd_SMU_curr
|
|
* @param [in] volt consigne de tension en volt
|
|
* @param [in] curr consigne de courant en ampere
|
|
* @return 0
|
|
* @date 17/11/2014
|
|
*
|
|
*/
|
|
int cmd_SMU_curr (float volt,float curr)
|
|
{
|
|
char message [256];
|
|
char reponse [256];
|
|
int nbbitlu;
|
|
float test;
|
|
if(volt!=0.0 || curr!=0.0)
|
|
{
|
|
|
|
sprintf(message,":SOUR:FUNC?");
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
inst_ReadInstrData (instrument[INST_SMU].port.handle, 70,reponse, &nbbitlu);
|
|
if(strncmp("CURR",reponse,4)!=0)
|
|
{
|
|
sprintf(message,":SOUR:FUNC CURR"); // current source
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
|
|
}
|
|
|
|
|
|
//PROTECTION
|
|
sprintf(message,"VOLT:PROT?");
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
inst_ReadInstrData (instrument[INST_SMU].port.handle, 70,reponse, &nbbitlu);
|
|
if(atof(reponse)!=volt)
|
|
{
|
|
sprintf(message,"VOLT:PROT %2.4E",volt);
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
sprintf(message,":SENS:VOLT:RANG %2.4E",volt);
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
sprintf(message,":SENS:VOLT:PROT %2.4E",volt);
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
}
|
|
//CURR
|
|
sprintf(message,":SOUR:CURR:LEV?");
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
inst_ReadInstrData (instrument[INST_SMU].port.handle, 70,reponse, &nbbitlu);
|
|
test=atof(reponse);
|
|
if(test!=curr)
|
|
{
|
|
sprintf(message,":SOUR:CURR:LEV %2.4E",curr);
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
}
|
|
sprintf(message,"OUTP?");
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
inst_ReadInstrData (instrument[INST_SMU].port.handle, 70,reponse, &nbbitlu);
|
|
if(atoi(reponse)!=1)
|
|
{
|
|
sprintf(message,"OUTP ON");
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
}
|
|
} else
|
|
{
|
|
sprintf(message,"OUTP OFF");
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
}
|
|
return 0;
|
|
}
|
|
/**
|
|
* @brief cmd_SMU_Read
|
|
* @param [in] volt consigne de tension en volt
|
|
* @param [in] curr consigne de courant en ampere
|
|
|
|
* @return 0
|
|
* @date 05/10/2011
|
|
*
|
|
*/
|
|
int cmd_SMU_Read (double *volt,double *curr)
|
|
{
|
|
char message [256];
|
|
//SMU K2400
|
|
struct S_rep_smu
|
|
{
|
|
char tension[13];
|
|
char sep1;
|
|
char courant[13];
|
|
char sep2;
|
|
char resistance[13];
|
|
char sep3;
|
|
char temps[13];
|
|
char sep4;
|
|
char status[13];
|
|
char sep5;
|
|
};
|
|
|
|
union U_rep_smu
|
|
{
|
|
char brut[70];
|
|
struct S_rep_smu rep_smu;
|
|
};
|
|
union U_rep_smu reponse;
|
|
int nbbitlu;
|
|
|
|
sprintf(message,":SENS:FUNC:CONC?");
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
inst_ReadInstrData (instrument[INST_SMU].port.handle, 70,reponse.brut, &nbbitlu);
|
|
if(atoi(reponse.brut)==0)
|
|
{
|
|
sprintf(message,":SENS:FUNC:CONC ON");
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
|
|
}
|
|
|
|
sprintf(message,":SENS:FUNC?");
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
inst_ReadInstrData (instrument[INST_SMU].port.handle, 70,reponse.brut, &nbbitlu);
|
|
if(strncmp("\"VOLT:DC\",\"CURR:DC\"",reponse.brut,19)!=0)
|
|
{
|
|
sprintf(message,":FUNC 'VOLT', 'CURR'");
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(message,":READ?");
|
|
inst_WriteInstrData (instrument[INST_SMU].port.handle,message );
|
|
inst_ReadInstrData (instrument[INST_SMU].port.handle, 70,reponse.brut, &nbbitlu);
|
|
*volt=atof(reponse.rep_smu.tension);
|
|
*curr=atof(reponse.rep_smu.courant);
|
|
|
|
return 0;
|
|
}
|
|
/**
|
|
* @brief cmd_load
|
|
* @param [in] volt consigne de tension en volt
|
|
* @param [in] curr consigne de courant en ampere
|
|
* @param [in] etat 1 ON
|
|
* @return 0
|
|
* @date 05/10/2011
|
|
*
|
|
*/
|
|
int cmd_load (float volt,float curr,int etat)
|
|
{
|
|
int language;
|
|
int handle;
|
|
char message [256];
|
|
char message_LOG [256];
|
|
|
|
if(instrument[INST_LOAD].present==1)
|
|
{
|
|
handle=instrument[INST_LOAD].port.handle;
|
|
language=instrument[INST_LOAD].port.language;
|
|
|
|
sprintf(message,"VOLT %2.4E",volt);
|
|
if (language==ARPS)
|
|
{
|
|
sprintf(message,"VSET %2.3fV",volt);
|
|
}
|
|
inst_WriteInstrData (handle,message);
|
|
|
|
sprintf(message,"CURR %2.4E",curr);
|
|
if (language==ARPS)
|
|
{
|
|
sprintf(message,"ISET %2.3fA",curr);
|
|
}
|
|
inst_WriteInstrData (handle,message);
|
|
sprintf(message,"INP %d",etat);
|
|
if (language==ARPS)
|
|
{
|
|
sprintf(message,"OUT %d",etat); //a v?rifier
|
|
}
|
|
inst_WriteInstrData (handle,message);
|
|
if(Ctrl.verbose)
|
|
{
|
|
sprintf (message_LOG," LOAD volt=%f curr=%f etat=%d", volt, curr,etat);
|
|
save_LOG(message_LOG);
|
|
}
|
|
SetCtrlVal (T_panel[PANEL_MEASURE].panel,P_MEASURE_LOAD_V,volt);
|
|
SetCtrlVal (T_panel[PANEL_MEASURE].panel,P_MEASURE_LOAD_I,curr);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
/**
|
|
* @brief gestion de l'alimentation
|
|
* @param[in] tension en Volt de l'alimentation
|
|
* @param[in] courant en ampere
|
|
* @param[in] etat 1 ON
|
|
* @return 0
|
|
* @date 22/05/2014
|
|
*
|
|
*/
|
|
int cmd_power(float volt,float curr,int etat)
|
|
{
|
|
int language;
|
|
int handle;
|
|
char message[1024];
|
|
char message_LOG[1024];
|
|
if(instrument[INST_POWER].present==1)
|
|
{
|
|
handle=instrument[INST_POWER].port.handle;
|
|
language=instrument[INST_POWER].port.language;
|
|
|
|
sprintf(message,"CURR %2.2E",curr);
|
|
if (language==ARPS)
|
|
{
|
|
sprintf(message,"ISET %2.3fA",curr);
|
|
}
|
|
inst_WriteInstrData (handle,message );
|
|
sprintf(message,"VOLT %2.2E",volt);
|
|
if (language==ARPS)
|
|
{
|
|
sprintf(message,"VSET %2.3fV",volt);
|
|
}
|
|
inst_WriteInstrData (handle,message );
|
|
sprintf(message,"OUTP %d",etat);
|
|
if (language==ARPS)
|
|
{
|
|
sprintf(message,"OUT %d",etat); //a v?rifier
|
|
}
|
|
inst_WriteInstrData (handle,message );
|
|
}
|
|
|
|
if(Ctrl.verbose)
|
|
{
|
|
sprintf (message_LOG," POWER volt=%f curr=%f etat=%d", volt, curr,etat);
|
|
save_LOG(message_LOG);
|
|
}
|
|
SetCtrlVal (T_panel[PANEL_MEASURE].panel,P_MEASURE_POWER_V,volt);
|
|
SetCtrlVal (T_panel[PANEL_MEASURE].panel,P_MEASURE_POWER_I,curr);
|
|
|
|
return 0;
|
|
}
|
|
/**
|
|
* @brief cmd_display_text
|
|
* @param [IN] instrum
|
|
* @param [IN] string
|
|
* @return 0
|
|
* @date 12/01/2011
|
|
*
|
|
*/
|
|
int cmd_display_text(int inst,char* txt)
|
|
{
|
|
//char message[256];
|
|
// if(instrument[inst].present==1)
|
|
// {
|
|
// sprintf(message,":DISP:TEXT:DATA \"%s\"",txt);
|
|
// inst_WriteInstrData (instrument[inst].port.handle,message );
|
|
// }
|
|
return 0;
|
|
}
|
|
/**
|
|
* @brief read YOKOGAWA volt out
|
|
* @return 0
|
|
* @date 10/12/2010
|
|
*
|
|
*/
|
|
|
|
int read_PM_volt(double *volt)
|
|
{
|
|
//char buffer [1024];
|
|
//char message [1024];
|
|
//char message_LOG [1024];
|
|
//int nboctet;
|
|
//int handle;
|
|
//int i;
|
|
// if(instrument[INST_PM].present==1)
|
|
// {
|
|
// handle=instrument[INST_PM].port.handle;
|
|
// sprintf(message,":NUMERIC:NORMAL:VALUE?");
|
|
// inst_WriteInstrData (handle,message);
|
|
// inst_ReadInstrData (handle, 1024,buffer, &nboctet);
|
|
// if(buffer[0]=='I')
|
|
// {
|
|
// Delay(0.5);
|
|
// inst_WriteInstrData (handle,message);
|
|
// inst_ReadInstrData (handle, 1024,buffer, &nboctet);
|
|
// if(buffer[0]=='I')
|
|
// {
|
|
// cmd_PM_CAL_V(2,consigne[0].Vout*1.5) ;
|
|
// Delay(0.5);
|
|
// inst_WriteInstrData (handle,message);
|
|
// inst_ReadInstrData (handle, 1024,buffer, &nboctet);
|
|
// }
|
|
//
|
|
// }
|
|
// if(buffer[0]=='N')
|
|
// {
|
|
// i=0;
|
|
// do
|
|
// { if(Ctrl.stop==1)
|
|
// return 1;
|
|
// ++i;
|
|
// Delay(0.5);
|
|
// inst_WriteInstrData (handle,message);
|
|
// inst_ReadInstrData (handle, 1024,buffer, &nboctet);
|
|
// if (i>20)
|
|
// {
|
|
// Ctrl.stop=1;
|
|
// sprintf (message_LOG,"STOP ERROR READ PM volt=%f buffer: %s", *volt,buffer);
|
|
// save_LOG(message_LOG);
|
|
// return -1;
|
|
// }
|
|
// }while(buffer[0]=='N');
|
|
//
|
|
// }
|
|
// *volt=atof(buffer);
|
|
// SetCtrlVal (T_panel[PANEL_MEASURE].panel,P_MEASURE_DCDCout_V,*volt);
|
|
// if(Ctrl.verbose || *volt==0.0)
|
|
// {
|
|
// sprintf (message_LOG," READ PM volt=%f buffer: %s", *volt,buffer);
|
|
// save_LOG(message_LOG);
|
|
// }
|
|
// }
|
|
return 0;
|
|
}
|
|
/**
|
|
* @brief read_PM_YOKOGAWA
|
|
* @return 0
|
|
* @date 10/10/2013
|
|
*
|
|
*/
|
|
int read_PM_YOKOGAWA(double *Vin,double *Iin,double *Pin,
|
|
double *Vout,double *Iout,double *Pout,double *V3,double *V4,double *I3,double *I4,double *P3,double *P4)
|
|
{
|
|
|
|
char buffer [1024];
|
|
char message [1024];
|
|
int nboctet;
|
|
int handle;
|
|
|
|
|
|
if(instrument[INST_PM].present==1)
|
|
{
|
|
|
|
handle=instrument[INST_PM].port.handle;
|
|
sprintf(message,":NUMERIC:NORMAL:VALUE?");
|
|
inst_WriteInstrData (handle,message);
|
|
inst_ReadInstrData (handle, 1024,buffer, &nboctet);
|
|
sscanf(buffer,"%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf"
|
|
,Vin,Iin,Pin
|
|
,Vout,Iout,Pout
|
|
,V3,I3,P3
|
|
,V4,I4,P4);
|
|
if(Ctrl.verbose)
|
|
{
|
|
sprintf (message," READ PM %f,%f,%f,%f,%f,%f",*Vin,*Iin,*Pin
|
|
,*Vout,*Iout,*Pout);
|
|
save_LOG(message);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
}
|
|
/**
|
|
* @brief read_PM_YOKOGAWA
|
|
* @return 0
|
|
* @date 10/12/2010
|
|
*
|
|
*/
|
|
int read_Cal_PM_YOKOGAWA(double *CalVin,double *CalIin,
|
|
double *CalVout,double *CalIout)
|
|
{
|
|
//
|
|
//char buffer [1024];
|
|
//char message [1024];
|
|
//int nboctet;
|
|
//int handle;
|
|
//
|
|
// if(instrument[INST_PM].present==1)
|
|
// {
|
|
//
|
|
// handle=instrument[INST_PM].port.handle;
|
|
// sprintf(message,":INPUT:CURRENT:RANGE?");
|
|
// inst_WriteInstrData (handle,message);
|
|
// inst_ReadInstrData (handle, 1024,buffer, &nboctet);
|
|
// sscanf(buffer,":CURR:RANG:ELEM %lf;ELEM2 %lf"
|
|
// ,CalIin,CalIout);
|
|
// sprintf(message,":INPUT:VOLTAGE:RANGE?");
|
|
// inst_WriteInstrData (handle,message);
|
|
// inst_ReadInstrData (handle, 1024,buffer, &nboctet);
|
|
// sscanf(buffer,":VOLT:RANG:ELEM %lf;ELEM2 %lf"
|
|
// ,CalVin,CalVout);
|
|
// if(Ctrl.verbose)
|
|
// {
|
|
// sprintf (message," READ CAL PM %f,%f,%f,%f",*CalVin,*CalIin,*CalVout,*CalIout);
|
|
// save_LOG(message);
|
|
// }
|
|
//
|
|
// }
|
|
//
|
|
|
|
return 0;
|
|
}
|
|
/**
|
|
* @brief Calibre Power Meter volt
|
|
* @return 0
|
|
* @date 23/09/2011
|
|
*
|
|
*/
|
|
int cmd_PM_CAL_V(int element,double setting)
|
|
{
|
|
//char message [1024];
|
|
//double valeur;
|
|
// if(instrument[INST_PM].present==1)
|
|
// {
|
|
//
|
|
// //15, 30, 60, 100, 150, 300, 600, 1000
|
|
//
|
|
// if(setting<=15)
|
|
// valeur=15;
|
|
// else
|
|
// if(setting<=30)
|
|
// valeur=30;
|
|
// else
|
|
// if(setting<=60)
|
|
// valeur=60;
|
|
// else
|
|
// if(setting<=100)
|
|
// valeur=100;
|
|
// else
|
|
// if(setting<=150)
|
|
// valeur=150;
|
|
// else
|
|
// if(setting<=300)
|
|
// valeur=300;
|
|
// else
|
|
// if(setting<=600)
|
|
// valeur=600;
|
|
// else
|
|
// valeur=1000;
|
|
// sprintf(message,":INPUT:VOLTAGE:RANGE:ELEMENT%d %1.4E",element,valeur);
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
//
|
|
// }
|
|
return 0;
|
|
}
|
|
/**
|
|
* @brief init_SAS
|
|
* @param [in]
|
|
* @return 0
|
|
* @date 20/05/2014
|
|
*
|
|
*/
|
|
int init_SAS(int inst)
|
|
{
|
|
return 0;
|
|
}
|
|
/**
|
|
* @brief init_SMU
|
|
* @param [in]
|
|
* @return 0
|
|
* @date 20/05/2014
|
|
*
|
|
*/
|
|
int init_SMU(int inst)
|
|
{
|
|
char message[256];
|
|
instrument[inst].present=0;
|
|
instrument[inst].actif =0;
|
|
if(instrument[inst].port.typeCOM>-1 )
|
|
if(initcom (&instrument[inst].port))
|
|
{
|
|
|
|
save_LOG("SMU FAIL");
|
|
} else
|
|
{
|
|
instrument[inst].present=1;
|
|
instrument[inst].actif =1;
|
|
save_LOG(fnct_ID_inst(inst,message));
|
|
initcom(&instrument[inst].port);
|
|
if(instrument[inst].port.language==SCPI)
|
|
{
|
|
sprintf(message,"*RST");
|
|
inst_WriteInstrData (instrument[inst].port.handle,message );
|
|
}
|
|
init_type_inst(inst);
|
|
cmd_display_text(inst,"T_BATT");
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
/**
|
|
* @brief init LOAD
|
|
* @param [in] num_LOAD numeroLOAD
|
|
* @return 0
|
|
* @date 23/09/2011
|
|
*
|
|
*/
|
|
int init_LOAD(int inst_load)
|
|
{
|
|
char message [1024];
|
|
char message_LOG [1024];
|
|
instrument[inst_load].present=0;
|
|
instrument[inst_load].actif =0;
|
|
sprintf(message,"LOAD");
|
|
if(instrument[inst_load].port.typeCOM>-1 )
|
|
if(initcom (&instrument[inst_load].port))
|
|
{
|
|
sprintf (message_LOG,"INSTRUMENT %s ",message);
|
|
save_LOG(message_LOG);
|
|
save_LOG(" FAIL");
|
|
} else
|
|
{
|
|
instrument[inst_load].present=1;
|
|
instrument[inst_load].actif =1;
|
|
sprintf (message_LOG,"INSTRUMENT %s ",message);
|
|
save_LOG(message_LOG);
|
|
init_type_inst(inst_load);
|
|
|
|
if(strcmp (instrument[inst_load].constructeur,"HOECHERL&HACKL")==0)
|
|
{
|
|
instrument[inst_load].type=HHZS;
|
|
instrument[inst_load].port.language=SCPI;
|
|
save_LOG("---");
|
|
}
|
|
else if(strcmp (instrument[inst_load].constructeur,"HEWLETT-PACKARD")==0)
|
|
{
|
|
if(strcmp (instrument[inst_load].model,"6060B")==0)
|
|
{
|
|
instrument[inst_load].type=LOAD6060B;
|
|
instrument[inst_load].port.language=SCPI;
|
|
save_LOG("---");
|
|
}
|
|
else
|
|
save_LOG("ATTENTION POWER ?");
|
|
}
|
|
else if(instrument[inst_load].port.instrDescr[0]=='?')
|
|
{
|
|
instrument[inst_load].port.language=ARPS;
|
|
sprintf(instrument[inst_load].model,"PLZ1003W");
|
|
sprintf (message_LOG,"%s ",instrument[inst_load].model);
|
|
save_LOG(message_LOG);
|
|
instrument[inst_load].type=PLZ;
|
|
sprintf(message,"PSET 900W");
|
|
inst_WriteInstrData (instrument[inst_load].port.handle,message);
|
|
sprintf(message,"CCRANGE 0");//Curr LOW gamme
|
|
inst_WriteInstrData (instrument[inst_load].port.handle,message);
|
|
save_LOG(" Curr LOW gamme 20A");
|
|
sprintf(message,"CV 0");//CV OFF
|
|
save_LOG(" CV OFF");
|
|
inst_WriteInstrData (instrument[inst_load].port.handle,message);
|
|
sprintf(message,"CCR 1");//CC ON
|
|
inst_WriteInstrData (instrument[inst_load].port.handle,message);
|
|
save_LOG(" CC ON");
|
|
save_LOG("---");
|
|
}
|
|
|
|
}
|
|
return 0;
|
|
}
|
|
/**
|
|
* @brief init POWER
|
|
* @param [in] num_power numero power
|
|
* @return 0
|
|
* @date 23/09/2011
|
|
*
|
|
*/
|
|
int init_POWER(int inst_power)
|
|
{
|
|
char message [1024];
|
|
char message_LOG [1024];
|
|
instrument[inst_power].present=0;
|
|
instrument[inst_power].actif =0;
|
|
sprintf(message,"POWER");
|
|
if(instrument[inst_power].port.typeCOM>-1 )
|
|
if(initcom (&instrument[inst_power].port))
|
|
{
|
|
sprintf (message_LOG,"INSTRUMENT %s ",message);
|
|
save_LOG(message_LOG);
|
|
save_LOG(" FAIL");
|
|
} else
|
|
{
|
|
instrument[inst_power].present=1;
|
|
instrument[inst_power].actif =1;
|
|
sprintf (message_LOG,"INSTRUMENT %s ",message);
|
|
save_LOG(message_LOG);
|
|
init_type_inst(inst_power);
|
|
|
|
if(strcmp (instrument[inst_power].constructeur,"HEWLETT-PACKARD")==0)
|
|
{
|
|
if(strcmp (instrument[inst_power].model,"6032A")==0)
|
|
{
|
|
instrument[inst_power].type=SPS6032A;
|
|
|
|
save_LOG("---");
|
|
}
|
|
}
|
|
if(instrument[inst_power].port.language==ARPS)
|
|
{
|
|
if(strncmp (instrument[inst_power].port.instrDescr,"ID XFR20-60 Version 1.03FG",strlen("ID XFR20-60 Version 1.03FG"))==0)
|
|
{
|
|
instrument[inst_power].type=XFR20_60;
|
|
sprintf(message,"RST");
|
|
inst_WriteInstrData (instrument[inst_power].port.handle,message );
|
|
sprintf(message,"CLR");
|
|
inst_WriteInstrData (instrument[inst_power].port.handle,message );
|
|
sprintf(message,"OUT OFF");
|
|
inst_WriteInstrData (instrument[inst_power].port.handle,message );
|
|
save_LOG("---");
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* @brief init Power Meter
|
|
* @return 0
|
|
* @date 19/10/2012
|
|
*
|
|
*/
|
|
int init_PM_measure(void)
|
|
{
|
|
//char message [1024];
|
|
//if(instrument[INST_PM].present==1)
|
|
// {
|
|
// sprintf(message,":NUM:ITEM1 UDC,2;:NUM:ITEM2 IDC,1;:NUM:ITEM3 P,1");
|
|
// if(strcmp (instrument[INST_PM].model,"760304-04-SV")==0) //WT3000
|
|
// sprintf(message,":NUM:ITEM1 U,2;:NUM:ITEM2 I,1;:NUM:ITEM3 P,1");
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
//
|
|
// sprintf(message,":NUM:ITEM4 UDC,1;:NUM:ITEM5 IDC,2;:NUM:ITEM6 P,2");
|
|
// if(strcmp (instrument[INST_PM].model,"760304-04-SV")==0) //WT3000
|
|
// sprintf(message,":NUM:ITEM4 U,1;:NUM:ITEM5 I,2;:NUM:ITEM6 P,2");
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
//
|
|
// sprintf(message,":NUM:ITEM7 UDC,3;:NUM:ITEM10 UDC,4;");
|
|
// if(strcmp (instrument[INST_PM].model,"760304-04-SV")==0) //WT3000
|
|
// sprintf(message,":NUM:ITEM7 U,3;:NUM:ITEM10 U,4;");
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
//
|
|
// if(strcmp (instrument[INST_PM].model,"760304-04-SV")==0) //WT3000
|
|
// {
|
|
// sprintf(message,":CURRent:MODE:ALL DC");
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
// sprintf(message,":VOLTage:MODE:ALL DC");
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
// }
|
|
// }
|
|
return 0;
|
|
}
|
|
/**
|
|
* @brief init Power Meter
|
|
* @return 0
|
|
* @date 23/09/2011
|
|
*
|
|
*/
|
|
int init_PM_CAL(void)
|
|
{
|
|
//char message [1024];
|
|
//double valeur,setting;
|
|
// if(instrument[INST_PM].present==1)
|
|
// {
|
|
// if(measure[0].CalVin_Auto==0)
|
|
// {
|
|
// //15, 30, 60, 100, 150, 300, 600, 1000
|
|
// setting=max(consigne[0].Vin_START,consigne[0].Vin_STOP);
|
|
// if(setting<=15)
|
|
// valeur=15;
|
|
// else
|
|
// if(setting<=30)
|
|
// valeur=30;
|
|
// else
|
|
// if(setting<=60)
|
|
// valeur=60;
|
|
// else
|
|
// if(setting<=100)
|
|
// valeur=100;
|
|
// else
|
|
// if(setting<=150)
|
|
// valeur=150;
|
|
// else
|
|
// if(setting<=300)
|
|
// valeur=300;
|
|
// else
|
|
// if(setting<=600)
|
|
// valeur=600;
|
|
// else
|
|
// valeur=1000;
|
|
// sprintf(message,":INPUT:VOLTAGE:RANGE:ELEMENT1 %1.4E",valeur);
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
// sprintf(message,"CAL VOLTAGE IN %1.1f V",valeur);
|
|
// save_LOG(message);
|
|
// }else
|
|
// {
|
|
// sprintf(message,":INPUT:VOLTAGE:AUTO:ELEMENT1 ON");
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
// sprintf(message,"CAL VOLTAGE IN AUTO");
|
|
// save_LOG(message);
|
|
// }
|
|
// if(measure[0].CalVout_Auto==0)
|
|
// {
|
|
// if(consigne[0].Vout_MAX<=15)
|
|
// valeur=15;
|
|
// else
|
|
// if(consigne[0].Vout_MAX<=30)
|
|
// valeur=30;
|
|
// else
|
|
// if(consigne[0].Vout_MAX<=60)
|
|
// valeur=60;
|
|
// else
|
|
// if(consigne[0].Vout_MAX<=100)
|
|
// valeur=100;
|
|
// else
|
|
// if(consigne[0].Vout_MAX<=150)
|
|
// valeur=150;
|
|
// else
|
|
// if(consigne[0].Vout_MAX<=300)
|
|
// valeur=300;
|
|
// else
|
|
// if(consigne[0].Vout_MAX<=600)
|
|
// valeur=600;
|
|
// else
|
|
// valeur=1000;
|
|
// sprintf(message,":INPUT:VOLTAGE:RANGE:ELEMENT2 %1.4E",valeur);
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
// sprintf(message,"CAL VOLTAGE OUT %1.1f V",valeur);
|
|
// save_LOG(message);
|
|
// }else
|
|
// {
|
|
// sprintf(message,":INPUT:VOLTAGE:AUTO:ELEMENT2 ON");
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
// sprintf(message,"CAL VOLTAGE OUT AUTO");
|
|
// save_LOG(message);
|
|
// }
|
|
// //currnet500 (mA), 1, 2, 5, 10, 20, 30
|
|
// if(measure[0].CalIin_Auto==0)
|
|
// {
|
|
// if(consigne[0].Iin_MAX<=0.5)
|
|
// valeur=0.5;
|
|
// else
|
|
// if(consigne[0].Iin_MAX<=1)
|
|
// valeur=1;
|
|
// else
|
|
// if(consigne[0].Iin_MAX<=2)
|
|
// valeur=2;
|
|
// else
|
|
// if(consigne[0].Iin_MAX<=5)
|
|
// valeur=5;
|
|
// else
|
|
// if(consigne[0].Iin_MAX<=10)
|
|
// valeur=10;
|
|
// else
|
|
// if(consigne[0].Iin_MAX<=20)
|
|
// valeur=20;
|
|
// else
|
|
// valeur=30;
|
|
// sprintf(message,":INPUT:CURRENT:RANGE:ELEMENT1 %1.4E",valeur);
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
// sprintf(message,"CAL CURRENT IN %1.1f A",valeur);
|
|
// save_LOG(message);
|
|
// }else
|
|
// {
|
|
// sprintf(message,":INPUT:CURRENT:AUTO:ELEMENT1 ON");
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
// sprintf(message,"CAL CURRENT IN AUTO");
|
|
// save_LOG(message);
|
|
// }
|
|
// if(measure[0].CalIout_Auto==0)
|
|
// {
|
|
// setting=max(consigne[0].Pout_START/min(consigne[0].Vout_START,consigne[0].Vout_STOP),consigne[0].Pout_STOP/min(consigne[0].Vout_START,consigne[0].Vout_STOP));
|
|
// if(setting<=0.5)
|
|
// valeur=0.5;
|
|
// else
|
|
// if(setting<=1)
|
|
// valeur=1;
|
|
// else
|
|
// if(setting<=2)
|
|
// valeur=2;
|
|
// else
|
|
// if(setting<=5)
|
|
// valeur=5;
|
|
// else
|
|
// if(setting<=10)
|
|
// valeur=10;
|
|
// else
|
|
// if(setting<=20)
|
|
// valeur=20;
|
|
// else
|
|
// valeur=30;
|
|
// sprintf(message,":INPUT:CURRENT:RANGE:ELEMENT2 %1.4E",valeur);
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
// sprintf(message,"CAL CURRENT OUT %1.1f A",valeur);
|
|
// save_LOG(message);
|
|
// }else
|
|
// {
|
|
// sprintf(message,":INPUT:CURRENT:AUTO:ELEMENT2 ON");
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
// sprintf(message,"CAL CURRENT OUT AUTO");
|
|
// save_LOG(message);
|
|
// }
|
|
//
|
|
// sprintf(message,":INPUT:VOLTAGE:AUTO:ELEMENT3 ON");
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
// sprintf(message,"CAL VOLTAGE 3 AUTO");
|
|
// save_LOG(message);
|
|
// sprintf(message,":INPUT:VOLTAGE:AUTO:ELEMENT4 ON");
|
|
// inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
// sprintf(message,"CAL VOLTAGE 4 AUTO");
|
|
// save_LOG(message);
|
|
// }
|
|
return 0;
|
|
}
|
|
/**
|
|
* @brief init Power Meter
|
|
* @param [in] num_PM numero PM
|
|
* @return 0
|
|
* @date 23/09/2011
|
|
*
|
|
*/
|
|
|
|
int init_PM(int inst_PM)
|
|
{
|
|
char message [1024];
|
|
char message_LOG [1024];
|
|
instrument[inst_PM].present=0;
|
|
instrument[inst_PM].actif =0;
|
|
sprintf(message,"PM");
|
|
if(instrument[inst_PM].port.typeCOM>-1 )
|
|
if(initcom (&instrument[inst_PM].port))
|
|
{
|
|
sprintf (message_LOG,"INSTRUMENT %s ",message);
|
|
|
|
save_LOG(" FAIL");
|
|
} else
|
|
{
|
|
instrument[inst_PM].present=1;
|
|
instrument[inst_PM].actif =1;
|
|
sprintf (message_LOG,"INSTRUMENT %s ",message);
|
|
save_LOG(message_LOG);
|
|
init_type_inst(inst_PM);
|
|
if(strcmp (instrument[inst_PM].constructeur,"YOKOGAWA")==0)
|
|
{
|
|
if(strcmp (instrument[inst_PM].model,"760304-04-SV")==0) //WT3000
|
|
{
|
|
instrument[inst_PM].type=WT3000;
|
|
save_LOG(" WT3000");
|
|
save_LOG(" VOLTAGE GAMME AUTO");
|
|
sprintf(message,":INPUT:VOLTAGE:AUTO:ALL ON");
|
|
Delay(1); //pb de demmarage avec WT3000
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
fnct_attente (5,"ATTENTE FIN CALIBRAGE TENSION WATTMETRE");
|
|
save_LOG(" CURRENT GAMME AUTO");
|
|
sprintf(message,":INPUT:CURRENT:AUTO:ALL ON");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
fnct_attente (5,"ATTENTE FIN CALIBRAGE COURANT WATTMETRE");
|
|
|
|
sprintf(message,":NUM:ITEM1 U,1;:NUM:ITEM2 I,1;:NUM:ITEM3 P,1");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
sprintf(message,":NUM:ITEM4 U,2;:NUM:ITEM5 I,2;:NUM:ITEM6 P,2");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
sprintf(message,":NUM:ITEM7 U,3;:NUM:ITEM8 I,3;:NUM:ITEM9 P,3");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
sprintf(message,":NUM:ITEM10 U,4;:NUM:ITEM11 I,4;:NUM:ITEM12 P,4");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
|
|
//ALL DC
|
|
sprintf(message,":CURRent:MODE:ALL DC");
|
|
inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
sprintf(message,":VOLTage:MODE:ALL DC");
|
|
inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
|
|
|
|
//display
|
|
sprintf(message,":MEASURE:EFFICIENCY:ETA1 P2,P1");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
sprintf(message,":DISPLAY:MODE NUMERIC");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
sprintf(message,":DISPLAY:NUMERIC:NORMAL:FORMAT VAL8");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
|
|
sprintf(message,":DISPLAY:NUMERIC:NORMAL:VAL8:ITEM4 U,2,TOTAL");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
sprintf(message,":DISPLAY:NUMERIC:NORMAL:VAL8:ITEM5 I,2,TOTAL");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
sprintf(message,":DISPLAY:NUMERIC:NORMAL:VAL8:ITEM6 P,2,TOTAL");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
sprintf(message,":DISPLAY:NUMERIC:NORMAL:VAL8:ITEM7 ETA1"); //?
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
sprintf(message,":DISPLAY:NUMERIC:NORMAL:VAL8:ITEM8 NONE");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
save_LOG("---");
|
|
|
|
|
|
}
|
|
else if(strcmp (instrument[inst_PM].model,"760101-04")==0) //WT1600
|
|
{
|
|
instrument[inst_PM].type=WT1600;
|
|
save_LOG(" WT1600");
|
|
sprintf(message,"*RST");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
|
|
|
|
sprintf(message,":NUM:ITEM1 UDC,2;:NUM:ITEM2 IDC,1;:NUM:ITEM3 P,1;:NUM:ITEM4 UDC,1;:NUM:ITEM5 IDC,2;:NUM:ITEM6 P,2;:NUM:ITEM7 UDC,3;:NUM:ITEM10 UDC,4");
|
|
inst_WriteInstrData (instrument[INST_PM].port.handle,message );
|
|
|
|
|
|
|
|
sprintf(message,":DISPLAY:NUMERIC:NORMAL:ITEM1 UDC,1");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
sprintf(message,":DISPLAY:NUMERIC:NORMAL:ITEM2 IDC,1");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
sprintf(message,":DISPLAY:NUMERIC:NORMAL:ITEM3 UDC,2");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
sprintf(message,":DISPLAY:NUMERIC:NORMAL:ITEM4 IDC,2");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
|
|
save_LOG(" VOLTAGE GAMME AUTO");
|
|
sprintf(message,":INPUT:VOLTAGE:AUTO:ALL ON");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
fnct_attente (5,"ATTENTE FIN CALIBRAGE TENSION WATTMETRE");
|
|
save_LOG(" CURRENT GAMME AUTO");
|
|
sprintf(message,":INPUT:CURRENT:AUTO:ALL ON");
|
|
inst_WriteInstrData (instrument[inst_PM].port.handle,message );
|
|
fnct_attente (5,"ATTENTE FIN CALIBRAGE COURANT WATTMETRE");
|
|
save_LOG("---");
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|