Commit 934a1a1f authored by Jörg Weingrill's avatar Jörg Weingrill
Browse files

refactoring

parent 13fd8025
......@@ -7,12 +7,12 @@ VAR
pressure_voltage: REAL;
dewar_pressure: REAL;
dewar_temperature1,
dewar_temperature2,
dewar_temperature3: REAL;
cold_head_temperature,
ccd_temperature1,
ccd_temperature2: REAL;
dewar_setpoint: REAL := -110.0;
avg_temperature: REAL;
ccd_temperature: REAL;
avg_pressure: REAL;
heater_value: LREAL;
fbPIRegler: FB_BasicPID;
......@@ -48,16 +48,16 @@ END_VAR
pressure_voltage := F_YREAL(GVL_Telescope.pressure_raw, 0, 32767, 0.0, 10.0);
dewar_pressure := LREAL_TO_REAL(EXPT(10.0, (1.5*pressure_voltage - 12.0)));
//temperature control using PID function block
dewar_temperature1 := GVL_ThermoControl.Temperature_raw1 / 100.0;
dewar_temperature2 := GVL_ThermoControl.Temperature_raw2 / 100.0 - 1.2;
dewar_temperature3 := GVL_ThermoControl.Temperature_raw3 / 100.0 + 1.2;
cold_head_temperature := GVL_ThermoControl.Temperature_raw1 / 100.0;
ccd_temperature1 := GVL_ThermoControl.Temperature_raw2 / 100.0 - 1.2;
ccd_temperature2 := GVL_ThermoControl.Temperature_raw3 / 100.0 + 1.2;
//dewar_temperature1 // cold head
//dewar_temperature3 := dewar_temperature2 - 2.3;
//dewar_temperature4 := -200; // broken
//dewar_temperature5 := 0; // broken
fbTimeAverage(IN := 0.5*dewar_temperature2 + 0.5*dewar_temperature3,
AVG => avg_temperature);
fbTimeAverage(IN := 0.5*ccd_temperature1 + 0.5*ccd_temperature2,
AVG => ccd_temperature);
fbDewarpressure(IN := dewar_pressure, PT := T#30S, AVG => avg_pressure);
......@@ -69,11 +69,11 @@ ELSIF avg_pressure < 5E-5 THEN // we don't need any heater, we are still cooling
heater_mode := E_ThermoMode.heater_off;
END_IF
IF avg_temperature < dewar_setpoint+0.01 THEN // we are in target range of the PID loop
IF ccd_temperature < dewar_setpoint+0.01 THEN // we are in target range of the PID loop
heater_mode := E_ThermoMode.heater_pid;
END_IF
IF avg_temperature > 25.0 THEN
IF ccd_temperature > 25.0 THEN
heater_mode := E_ThermoMode.heater_off;
END_IF
......@@ -93,7 +93,7 @@ Tn := 1.0 * Tg;
Tv := 0.5 * Tu;
fbPIRegler(fSetpointValue := dewar_setpoint,
fActualValue := avg_temperature,
fActualValue := ccd_temperature,
bReset := heater_mode <> E_ThermoMode.heater_pid,
fCtrlCycleTime := 0.1, //0.002,
fKp := Kp, //6169.1542,
......@@ -108,8 +108,8 @@ CASE heater_mode OF
E_ThermoMode.heater_on:
heater_value := LREAL_TO_INT(heater_max);
E_ThermoMode.heater_simple:
IF avg_temperature < dewar_setpoint THEN
heater_value := (dewar_setpoint -avg_temperature) * 30000.0;
IF ccd_temperature < dewar_setpoint THEN
heater_value := (dewar_setpoint -ccd_temperature) * 30000.0;
ELSE
heater_value := 0.0;
END_IF
......@@ -128,31 +128,31 @@ DewarPressureEvent( Trigger := (dewar_pressure < 1E-8) OR (dewar_pressure > 1E-4
OffMessage := 'OK',
OffLevel := ADSLOG_MSGTYPE_HINT);
Temperature1Event( Trigger := (dewar_temperature1 < -180.0) OR (dewar_temperature1 > 40.0),
Temperature1Event( Trigger := (cold_head_temperature < -180.0) OR (cold_head_temperature > 40.0),
Level := ADSLOG_MSGTYPE_WARN,
FormatString := 'Cold head temperature out of range: %s',
OnMessage := LREAL_TO_STRING(dewar_temperature1),
OnMessage := LREAL_TO_STRING(cold_head_temperature),
OffMessage := 'OK',
OffLevel := ADSLOG_MSGTYPE_HINT);
Temperature2Event( Trigger := (dewar_temperature2 < -180.0) OR (dewar_temperature2 > 40.0),
Temperature2Event( Trigger := (ccd_temperature1 < -180.0) OR (ccd_temperature1 > 40.0),
Level := ADSLOG_MSGTYPE_WARN,
FormatString := 'Dewar temperature2 out of range: %s',
OnMessage := LREAL_TO_STRING(dewar_temperature2),
OnMessage := LREAL_TO_STRING(ccd_temperature1),
OffMessage := 'OK',
OffLevel := ADSLOG_MSGTYPE_HINT);
Temperature3Event( Trigger := (dewar_temperature3 < -180.0) OR (dewar_temperature3 > 40.0),
Temperature3Event( Trigger := (ccd_temperature2 < -180.0) OR (ccd_temperature2 > 40.0),
Level := ADSLOG_MSGTYPE_WARN,
FormatString := 'Dewar temperature3 out of range: %s',
OnMessage := LREAL_TO_STRING(dewar_temperature3),
OnMessage := LREAL_TO_STRING(ccd_temperature2),
OffMessage := 'OK',
OffLevel := ADSLOG_MSGTYPE_HINT);
HTMLTimer(IN := TRUE AND NOT HTMLTimer.Q, PT := T#5M);
pressurestring := CONCAT('Dewar Pressure$T', LREAL_TO_FMTESTR(avg_pressure, 2, TRUE));
temperaturestring := CONCAT('<br>$NDewar Temperature$T', LREAL_TO_FMTSTR(avg_temperature ,2, TRUE));
coldheadstring := CONCAT('<br>$NCold Head$T', LREAL_TO_FMTSTR(dewar_temperature1, 2, TRUE));
temperaturestring := CONCAT('<br>$NDewar Temperature$T', LREAL_TO_FMTSTR(ccd_temperature ,2, TRUE));
coldheadstring := CONCAT('<br>$NCold Head$T', LREAL_TO_FMTSTR(cold_head_temperature, 2, TRUE));
setpointstring := CONCAT('<br>$NDewar Setpoint$T', LREAL_TO_FMTSTR(dewar_setpoint, 2, TRUE));
HTMLLog(Trigger := HTMLTimer.Q,
sPathName := 'C:\inetpub\wwwroot\thermocontrol.html',
......@@ -161,66 +161,7 @@ HTMLLog(Trigger := HTMLTimer.Q,
]]></ST>
</Implementation>
<LineIds Name="ThermoControl">
<LineId Id="5" Count="0" />
<LineId Id="7" Count="0" />
<LineId Id="10" Count="0" />
<LineId Id="6" Count="0" />
<LineId Id="24" Count="0" />
<LineId Id="26" Count="1" />
<LineId Id="60" Count="0" />
<LineId Id="30" Count="0" />
<LineId Id="58" Count="1" />
<LineId Id="167" Count="0" />
<LineId Id="165" Count="1" />
<LineId Id="254" Count="0" />
<LineId Id="89" Count="0" />
<LineId Id="530" Count="2" />
<LineId Id="538" Count="0" />
<LineId Id="534" Count="0" />
<LineId Id="536" Count="1" />
<LineId Id="533" Count="0" />
<LineId Id="591" Count="0" />
<LineId Id="590" Count="0" />
<LineId Id="592" Count="1" />
<LineId Id="365" Count="3" />
<LineId Id="372" Count="3" />
<LineId Id="638" Count="1" />
<LineId Id="634" Count="1" />
<LineId Id="640" Count="0" />
<LineId Id="636" Count="1" />
<LineId Id="631" Count="0" />
<LineId Id="579" Count="0" />
<LineId Id="649" Count="1" />
<LineId Id="648" Count="0" />
<LineId Id="581" Count="8" />
<LineId Id="255" Count="0" />
<LineId Id="90" Count="1" />
<LineId Id="110" Count="0" />
<LineId Id="98" Count="0" />
<LineId Id="111" Count="0" />
<LineId Id="99" Count="0" />
<LineId Id="105" Count="4" />
<LineId Id="104" Count="0" />
<LineId Id="93" Count="0" />
<LineId Id="92" Count="0" />
<LineId Id="64" Count="0" />
<LineId Id="46" Count="0" />
<LineId Id="40" Count="0" />
<LineId Id="47" Count="0" />
<LineId Id="191" Count="5" />
<LineId Id="221" Count="0" />
<LineId Id="198" Count="5" />
<LineId Id="222" Count="0" />
<LineId Id="204" Count="5" />
<LineId Id="223" Count="0" />
<LineId Id="215" Count="0" />
<LineId Id="210" Count="4" />
<LineId Id="224" Count="0" />
<LineId Id="287" Count="0" />
<LineId Id="62" Count="0" />
<LineId Id="294" Count="1" />
<LineId Id="370" Count="1" />
<LineId Id="288" Count="3" />
<LineId Id="1002" Count="113" />
<LineId Id="431" Count="0" />
</LineIds>
</POU>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment