50 #define I_COUNT_MAX 2 //-- # of intervals before increasing I 51 #define I_COUNT_DEC 4 //-- # times longer to wait b4 decrementing 52 #define I_VALUE_MAX 40 //-- Max Integral Value - Limits overshoot 56 #define CONTROLED_BAND 15 //-- Temperature band around Target that 59 #define MAX_TEMP (50 * 2) //-- Max Temperature of 50 Degrees 82 const double pgain = 30;
83 const double dgain =0;
90 double epsilon = 0.01, i_inst;
94 static float pre_error = 0;
95 static float old_error = 0;
96 static float integral;
108 sprintf(buff,
"%.2lf", delta/10);
114 if ((fabs(error)> 0.5))
116 integral = integral + (error * dt);
117 if (fabs(integral) > 100)
123 derivative = (error - pre_error) / dt;
154 i_inst = error * OMUTHR.
PID_ki;
155 PID_I += (float)i_inst;
158 if (PID_I >= 100) PID_I = 100;
159 if (PID_I <= -100) PID_I = -100;
166 PID_D = (OMUTHR.
PID_kd * ((error - pre_error)*2));
173 output = OMUTHR.
PID_kp *(PID_P + PID_I - PID_D);
176 sprintf(buff,
"%.2lf %.2lf %.2lf %.2lf", output, PID_P, PID_I, PID_D);
267 float Calculate(
float TARGET,
float CURRENT,
float POWER)
273 if( (CURRENT - TARGET) >= 0.2 )
282 if(CURRENT != TARGET)
293 POWER = ((TARGET / CURRENT) * ((
float)
P_GAIN/4)) + (
Intergral * (float)
I_GAIN/4) + (((float)fabs(TARGET - CURRENT)) * ((
float)
D_GAIN/4)) ;
295 POWER = ((TARGET / CURRENT) * (
float)
P_GAIN) + (
Intergral * (
float)
I_GAIN) + (((
float)fabs(TARGET - CURRENT)) * (
float)
D_GAIN) ;
302 if( (CURRENT - TARGET) <= -0.2 )
303 POWER=POWER - (
float) 0.1;
313 if(POWER > 90) POWER = 90;
315 if(POWER <= 0) POWER = 0;
429 float PowerOn, PowerOff;
475 static int olddir = 1;
838 c = (int) (OMUTHR.
CoolAT * 10);
960 sprintf(Label,
"%.02lf", DeltaT/10);
967 if((PrgFile[0] != 0) | (
Master == 1))
979 sprintf(str,
"%.1lf", -15.00);
981 sprintf(str,
"%.1lf%%",35.00);
996 sprintf(str,
"%.1lf", -5.00);
998 sprintf(str,
"%.1lf%%",35.00);
1013 sprintf(str,
"%.1lf", 5.00);
1042 DeltaTPrec = (int) DeltaT;
1070 char ActTemp[16], buf[16];
1075 static unsigned long starttime;
1077 SYSTEM_POWER_STATUS status;
1091 if (ActTemp[1] != 0)
1108 starttime = GetTickCount()-1000;
1110 Status(
"Camera Re-Init in 60 sec");
1124 et = GetTickCount();
1125 x = labs(et - starttime)/1000.0;
1130 sprintf (buff,
"Camera Init in %.1lf sec", tout);
1214 sprintf(buf,
"%.1lf%%", CCD_Pwr);
1227 GetSystemPowerStatus( &status );
1229 switch (status.ACLineStatus)
1290 double t, TRef, DeltaT;
1292 int NumSamples, x, KUP = 4096;
1300 for (i=0; i<16; i++)
1307 OMUTHR.
ADVolt[i] = (66.66666666666666666 * (temp) - 273.16);
1310 for(x= KUP-1;x>0;x--)
1325 for(x=0;x<KUP/64;x++)
1329 AVGTemp += OMUTHR.
Temptemp[i*KUP+x];
1335 AVGTemp =AVGTemp / (NumSamples-1);
1340 sprintf(buf,
"%.1f", (
float)AVGTemp);
1440 sprintf(buf,
"%s",
"NA");
1445 sprintf(buf,
"%s",
"NA");
1458 sprintf(buf,
"%s",
"NA");
1529 OMUTHR.
ADVolt[i] = (66.66666666666666666 * (temp) - 273.16);
1530 sprintf(buf,
"%.1f", OMUTHR.
ADVolt[i]);
1535 sprintf(buf,
"%.3f", OMUTHR.
ADVolt[i]);
1564 sprintf(buf,
"%.2lf", DeltaT/10);
void FANPeltier(int mod)
FAN ON/OFF .
gui Gui
Graphic User Interface Structure.
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
int DB_InitCamera(int mod)
Initialize Camera Parameters. Procedure that initialize the CCD Camera.
optionini DOption
Options for DAS execution.
#define AMS2
AMS2 address.
int TRType
Type of thermo regulation (0=TRTCOOL, 1 = TRTHEAT, 2= TRTBOTH)
double LastMSZA
SZA of the previous measurement.
int PCPower
Power to the Peltier for Cooling.
void Task_AMSH(TIMEOUT_ID id, void *data)
AMS Home Task. Refresh the temperatures during DAS execution.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
das structure (contain all the previous structures) .
int REINITCCD
Flag for CCD re-Initialization: =0 - wait for countdown, =1 - Ready for re-init camera.
short OMU_TempReached
OMU presetted temperature reached -> = 1.
flag Flag
Structure for different flags.
#define MAX_PELTPOW
Max Power to the Peltier.
MOBJECT lbl_Par[11]
Parametric Labels of the Control Panel.
void AMS_PWM(int id, int on, int off)
set the on/off time on the PWM set the on/off time on the PWM.
void OMU_ChooseDir(int mod)
float Temperature[16]
Temperatures.
MOBJECT Albl_CS[4]
Active Control Panel Labels for Camera Status 4.
void Peltier(int mod)
Peltier ON/OFF .
#define AMSH_TASK_TIME
AMS Home.
void MObjectSetText(MOBJECT obj, const char *text)
int OMU_TemperatureHandle(void)
float CoolPT
Previous Temperature (DTA -> DC_CoolPT)
void Task_REFRESH_Temp(TIMEOUT_ID id, void *data)
Temperatures Task. Refresh the temperatures during DAS execution.
int PID_Calc(int mod, int pow)
int FlgSM_Stop
Steppers Motor Activity: 0 = Motors moving; 1 = Motors stopped.
#define LIM_PELTPOW
Limited Power to the Peltier.
float Calculate(float TARGET, float CURRENT, float POWER)
#define LIS_
Lampedusa Island Spectrometer - ENEA.
float CoolTT
Target Temperature (DTA -> DC_CoolTT)
int exec
= 0 -> PRG Execution Paused; = 1 -> PRG Execution Resumed
CTYPE double DLL DC_GetTemp(char *CurrentTemperature, int Scale, int Camera)
Procedure that allows you to read the temperature of the sensor. Procedure that allows you to read th...
void Task_LIS_Temp(TIMEOUT_ID id, void *data)
OMU Thermoregulation Task. Provide the thermoregulation of the Optical Mechanical Unit In addition al...
void OMU_DoPeltPow(int mod, int pow)
unsigned int data[576]
Conversion data buffer 64 samples * 8 channels * 2 bytes.
float CCDTemp
Actual CCD Temperature.
int ADTempTest
= 0 -> AD Converter results on the Control Panel; = 1 -> AD Converter Testing Phase(results on the co...
CTYPE void DLL DC_SetTemp(double TargetTemperature, int Scale, int Camera)
Procedure that turns the camera cooler on and allows you to set an operative temperature of the CCD...
#define TRTHEAT
Thermoregulation mode: heat only.
MOBJECT ledpelt[2]
Control Panel Leds for Peltier Activity.
#define TRTCOOL
Thermoregulation mode: cool only.
int PHPower
Power to the Peltier for Heating.
int PID_On
PID activation.
#define SPATRAM2
SPATRAM2 (with ATX power supply & HiresV)
int CoolPw
CCD Init Power.
float * Temptemp
Buffer for lis temperature.
int UPS_Battery
flag for UPS Battery: = 0 Normal Operation, 1 = working on UPS battery
void Status(char *tit)
Writes information's on the Status label .
int DeltaSZA
= 1 Delta SZA measurements activated, = 0 Continous measurements
float CoolTmp
Temporary temperature.
#define LISTEMP_TASK_TIME
spectrometer termoregulation
int ADPC104
0 –> Device PC104 exist, 1 –> PC104 DOESN'T exist
#define GASCODNG4
GASCODNG 4.
#define SPATRAM3
SPATRAM3.
MOBJECT Albl_LT[16]
Active Control Panel Labels for LIS Temperature 16.
#define CELSIUS
Return CCD temperature in Celsius.
CTYPE void DLL DC_SetPower(double CoolerPower, int Camera)
Procedure that allows you to set the cooler power. Procedure that allows you to set the power (%) of ...
#define TRTBOTH
Thermoregulation mode: cool and heat.
#define REFRESHTEMP_TASK_TIME
refresh of the spectrometer's temperatures.
controlpanel ContrPanel
Control Panel Structure.
int AMS_TrackOff(int id, int amot, int bmot)
tracking off Procedure for Stepper Motor tracking de-activation
float CoolAT
Actual Temperature (DTA -> DC_Temp)
void FANECU(int mod)
FAN ON/OFF .
#define AMS1
AMS1 address.
int AMS_chkbitsts(int id, int bitn)
check bit status Procedure for the determination of the bit number status.
int ExeDSZA
= 1 the measurements are performed, = 0 waiting for the next deltasza.
void OMU_AssignPow(int pow)
#define CCDTEMP_TASK_TIME
CCD temperature.
void D_rt(void)
D_readtemp_int callback .
CTYPE int DLL DC_CoolerStatus(int Camera)
Procedure that reports the activity status of the cooler.
int EqType
Spectrometer Type.
CTYPE double DLL DC_GetPower(int Camera)
Return current cooler power. Procedure that allows you to read the power (%) of the cooler currently ...
void AMS_PWM_Zero(int mod)
int refertemp
Flag to set the reference temp for thermo-regulation: 0 = AVGPINT; 1 = OPTIC; 2 = GRATING...
TIMEOUT_ID MAddTimeout(CARD32 tmout, TIMEOUT_CB cb, void *ud)
double ITemp
CCD Target Temperature.
double ADVolt[16]
PC104 AD samples reading array.
double TPelt
OMU Target Temperature.
OMU Thermoregulation structure .
int ReachTemp
Target Temperature status.
marconi Marconi
CCD Sensor struct.
void Task_CCD_Temp(TIMEOUT_ID id, void *data)
CCD Temperature Task. Provide the thermoregulation of the CCD sensor during DAS execution.
paramini Paramini
structure for the parameters defined in param.ini configuration file