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

Multiple improvements and bugfixes

Stop condition in AxisJog, EQ2HOR2 function block added, ConvertEnvironment calculates Wind max and average, wind control for dome deactivated, declinationslimit improved, LREAL_TO_FMTESTR added, Thermocontrol,: added coldhead info for html,
parent 9922939d
WSB
LAPTOP-O4DSP8K9
11616
637015608563047748
azcam
AIP2
6140
637020886902494410
......@@ -1487,8 +1487,8 @@ External Setpoint Generation:
<Name>HourAxis</Name>
<AxisPara>
<General UnitName="°"/>
<Dynamic AccelerationMaximum="160" DecelerationMaximum="160" Acceleration="9" Deceleration="9" Jerk="7.36538"/>
<Velo RefSearch="0.261880121330377" RefSync="0.261880121330377" SlowManual="1.30940060665188" FastManual="7.8564036399113" Fast="26.1880121330377" Maximum="26.188"/>
<Dynamic AccelerationMaximum="160" DecelerationMaximum="160" Acceleration="10" Deceleration="10" Jerk="7.36538"/>
<Velo RefSearch="1" RefSync="1" SlowManual="1" FastManual="3" Fast="26.1880121330377" Maximum="10"/>
<OtherSettings AllowMotionCmdToSlave="true" PulseDistancePos="1" PulseDistanceNeg="1"/>
</AxisPara>
<Encoder Name="Enc" EncType="8">
......@@ -1686,9 +1686,9 @@ External Setpoint Generation:
<Axis Id="2" CreateSymbols="true" AxisType="1">
<Name>DeclinationAxis</Name>
<AxisPara>
<General UnitName="°"/>
<General UnitName="°" UnitFlags="#x00000004"/>
<Dynamic AccelerationMaximum="160" DecelerationMaximum="160" Acceleration="10" Deceleration="10" Jerk="5"/>
<Velo RefSearch="5" RefSync="5" SlowManual="1" FastManual="10" Fast="261.575656435389" Maximum="20"/>
<Velo RefSearch="1" RefSync="1" SlowManual="1" FastManual="3" Fast="261.575656435389" Maximum="10"/>
<OtherSettings AllowMotionCmdToSlave="true" PulseDistancePos="1" PulseDistanceNeg="1"/>
</AxisPara>
<Encoder Name="Enc" EncType="8">
......@@ -1888,7 +1888,7 @@ External Setpoint Generation:
<Axis Id="3" CreateSymbols="true" AxisType="2">
<Name>DomeAzimuth</Name>
<AxisPara>
<General UnitName="°"/>
<General UnitName="°" UnitFlags="#x00000004"/>
<Velo SlowManual="50" FastManual="100" Fast="100" Maximum="100"/>
<PositionAreaControl Range="2"/>
<TargetPosControl Range="1"/>
......@@ -1896,7 +1896,7 @@ External Setpoint Generation:
<Discrete BreakDistancePos="1" BreakDistanceNeg="1" BreakDelayPos="0.5" BreakDelayNeg="0.5"/>
</AxisPara>
<Encoder Name="Enc" EncType="4">
<EncPara ScaleFactorNumerator="0.02767314622" MaxCount="#x0000ffff">
<EncPara ScaleFactorNumerator="360" ScaleFactorDenominator="13050" ToleranceWndModuloStart="0.5" MaxCount="#x0000ffff">
<Inc RefMode="2" RefSoftSyncMask="#x0000ffff"/>
</EncPara>
<Vars VarGrpType="1">
......@@ -2096,6 +2096,11 @@ Drive Status 4 (manually linked):
<Comment><![CDATA[ manual operation]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>GVL_Environment.rawWindSpeed1</Name>
<Comment><![CDATA[ Weather Station 1]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>GVL_Dome.DomeAxisRef.NcToPlc</Name>
<Type GUID="{6A65C767-34E5-42BF-AD87-E1A503EAC7BE}" Namespace="MC">NCTOPLC_AXIS_REF</Type>
......@@ -2139,11 +2144,6 @@ External Setpoint Generation:
]]></Comment>
</SubVar>
</Var>
<Var>
<Name>GVL_Environment.rawWindSpeed1</Name>
<Comment><![CDATA[ Weather Station 1]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>GVL_Environment.rawWindDirection1</Name>
<Type>INT</Type>
......@@ -2255,9 +2255,9 @@ External Setpoint Generation:
<Type>UINT</Type>
</Var>
<Var>
<Name>GVL_ThermoControl.Temperature_raw1</Name>
<Comment><![CDATA[ Coldhead]]></Comment>
<Type>INT</Type>
<Name>GVL_Telescope.hourangle_encoder</Name>
<Comment><![CDATA[ Baumer Encoder external reference]]></Comment>
<Type>UDINT</Type>
</Var>
<Var>
<Name>GVL_Telescope.HourAxisRef.NcToPlc</Name>
......@@ -2346,14 +2346,14 @@ External Setpoint Generation:
</SubVar>
</Var>
<Var>
<Name>GVL_Telescope.hourangle_encoder</Name>
<Name>GVL_Telescope.declination_encoder</Name>
<Comment><![CDATA[ Baumer Encoder external reference]]></Comment>
<Type>UDINT</Type>
</Var>
<Var>
<Name>GVL_Telescope.declination_encoder</Name>
<Comment><![CDATA[ Baumer Encoder external reference]]></Comment>
<Type>UDINT</Type>
<Name>GVL_ThermoControl.Temperature_raw1</Name>
<Comment><![CDATA[ Coldhead]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>GVL_ThermoControl.Temperature_raw2</Name>
......@@ -2597,7 +2597,6 @@ External Setpoint Generation:
<DcMode>53796e6368726f6e00000000000000004672656552756e2f534d2d53796e6368726f6e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</DcMode>
<DcMode>4443000000000000000000000000000044432d53796e6368726f6e000000000000000000000000000000000000000000000000000000000000000000000020030100000000000000000000000000000000000000000000000000000000000000</DcMode>
<DcMode>4443494e00000000000000000000000044432d53796e6368726f6e2028696e7075742062617365642900000000000000000000000000000000000000000020030100000000000000000001000000000000000000000000000000000000000000</DcMode>
<MBoxUserCmdData>02000300090000000e0000000300000000000000000000000000000000000000200080010100000001456e61626c65204320726573657400</MBoxUserCmdData>
<MBoxUserCmdData>0200030009000000130000000300000000000000000000000000000000000000200080020100000001456e61626c652065787465726e20726573657400</MBoxUserCmdData>
<Pdo Name="ENC Inputs" Index="#x1a00" Flags="#x0010">
<ExcludePdo>#x1a01</ExcludePdo>
......@@ -6657,6 +6656,7 @@ Bit1: Value bigger/equal Limit2]]></Comment>
<MBoxUserCmdData>020005001800000011000000000000000000000000000000000000000000000003400282000000000c000c0001000000f401e803bc02000056656c6f63697479206f6273657276657200</MBoxUserCmdData>
<MBoxUserCmdData>020005000a0000001700000000000000000000000000000000000000000000000340d6800000000003004443204c696e6b20636f6e6e656374696f6e206d6f646500</MBoxUserCmdData>
<MBoxUserCmdData>020005000a00000014000000000000000000000000000000000000000000000003402f81000000001c00446973706c61792076616c7565206c696e65203200</MBoxUserCmdData>
<MBoxUserCmdData>020005000a0000001b000000000000000000000000000000000000000000000003405e810000000000004572726f72207265616374696f6e20636f6e74726f6c20776f726400</MBoxUserCmdData>
<Pdo Name="AT" Index="#x0010" Flags="#x0001" SyncMan="3">
<Entry Name="Drive status word" Index="#x0087" Flags="#x00000800">
<Type>UINT</Type>
......
......@@ -87,6 +87,9 @@
<Compile Include="POUs\FunctionBlocks\FB_EQ2HOR.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\FunctionBlocks\FB_EQ2HOR2.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\FunctionBlocks\FB_EventLog.TcPOU">
<SubType>Code</SubType>
</Compile>
......@@ -138,6 +141,9 @@
<Compile Include="POUs\F_YREAL.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\LREAL_TO_FMTESTR.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\MAIN.TcPOU">
<SubType>Code</SubType>
</Compile>
......
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.17">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
<GVL Name="GVL_Dome" Id="{8410bcc3-97cb-4334-927b-71c02664ab1a}">
<Declaration><![CDATA[{attribute 'qualified_only'}
VAR_GLOBAL
......
......@@ -28,16 +28,19 @@ VAR
WindEvent,
HumidityEvent,
PrecepationEvent: FB_Eventlog;
WindAverage,
PrecepationAverage: FB_TimeAverage;
avg_wind, max_wind: REAL;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[(* convert raw Sensor values to real values *)
WindSpeed1 := F_YREAL(GVL_Environment.rawWindSpeed1, 0, 32767, 0.0, 60.0); // m/s
WindDirection1 := F_YREAL(GVL_Environment.rawWindDirection1, 0, 32767, 0.0, 360.0); // °
Temperature1 := F_YREAL(GVL_Environment.rawTemperature1, 0, 32767, -40.0, 60.0); // °C
Temperature1 := F_YREAL(GVL_Environment.rawTemperature1, 0, 32767, -40.0, 60.0); // °C -40...80?
Humidity1 := F_YREAL(GVL_Environment.rawHumidity1, 0, 32767, 0.0, 100.0); // %
Pressure1 := F_YREAL(GVL_Environment.rawPressure1, 0, 32767, 800.0, 1060.0); // mBar
Brightness1 := F_YREAL(GVL_Environment.rawBrightness1, 0, 32767, 1.0, 120000.0); // Lux
Pressure1 := F_YREAL(GVL_Environment.rawPressure1, 0, 32767, 300.0, 800.0); // mBar 300...1100? 800..1060?
Brightness1 := F_YREAL(GVL_Environment.rawBrightness1, 0, 32767, 1.0, 150000.0); // Lux
LightDirection1 := F_YREAL(GVL_Environment.rawLightDirection1, 0, 32767, 0.0, 360.0); // °
Precipation1 := F_YREAL(GVL_Environment.rawPrecipation1, 0, 32767, 0.001, 100.0); // mm/h
......@@ -46,7 +49,7 @@ WindDirection2 := F_YREAL(GVL_Environment.rawWindDirection2, 0, 32767, 0.0, 3
Temperature2 := F_YREAL(GVL_Environment.rawTemperature2, 0, 32767, -40.0, 60.0); // °C
Humidity2 := F_YREAL(GVL_Environment.rawHumidity2, 0, 32767, 0.0, 100.0); // %
Pressure2 := F_YREAL(GVL_Environment.rawPressure2, 0, 32767, 800.0, 1060.0); // mBar
Brightness2 := F_YREAL(GVL_Environment.rawBrightness2, 0, 32767, 1.0, 120000.0); // Lux
Brightness2 := F_YREAL(GVL_Environment.rawBrightness2, 0, 32767, 1.0, 150000.0); // Lux
LightDirection2 := F_YREAL(GVL_Environment.rawLightDirection2, 0, 32767, 0.0, 360.0); // °
Precipation2 := F_YREAL(GVL_Environment.rawPrecipation2, 0, 32767, 0.001, 100.0); // mm/h
......@@ -62,7 +65,9 @@ END_IF
TemperatureDome := F_YREAL(GVL_Environment.rawTemperatureDome, 0, 32767, -30.0, 70.0); // °C
HumidityDome := F_YREAL(GVL_Environment.rawHumidityDome, 0, 32767, 0.0, 100.0); // %
WindEvent( Trigger := MAX(WindSpeed1, WindSpeed2) > 10.0,
WindAverage(IN := WindSpeed, PT := T#5M, AVG => avg_wind, MAXAVG => max_wind);
PrecepationAverage(IN := MAX(Precipation1, Precipation2), PT := T#2M);
WindEvent( Trigger := avg_wind > 10.0,
Level := ADSLOG_MSGTYPE_WARN,
FormatString := 'Wind Speed: %s',
OnMessage := LREAL_TO_STRING(MAX(WindSpeed1, WindSpeed2)),
......@@ -76,7 +81,7 @@ HumidityEvent( Trigger := MAX(Humidity1, Humidity2) > 80.0,
OffMessage := 'OK',
OffLevel := ADSLOG_MSGTYPE_HINT);
PrecepationEvent( Trigger := MAX(Precipation1, Precipation2) > 0.3,
PrecepationEvent( Trigger := PrecepationAverage.AVG > 0.3,
Level := ADSLOG_MSGTYPE_WARN,
FormatString := 'Precepation: %s',
OnMessage := LREAL_TO_STRING( MAX(Precipation1, Precipation2)),
......@@ -104,6 +109,7 @@ PrecepationEvent( Trigger := MAX(Precipation1, Precipation2) > 0.3,
<LineId Id="194" Count="0" />
<LineId Id="68" Count="0" />
<LineId Id="71" Count="1" />
<LineId Id="230" Count="1" />
<LineId Id="143" Count="20" />
<LineId Id="2" Count="0" />
</LineIds>
......
......@@ -15,6 +15,7 @@ VAR
ReadCycle: BOOL;
Azimuth_set,
Azimuth_current: LREAL;
move_azimuth, stop_azimuth: BOOL;
END_VAR
]]></Declaration>
<Implementation>
......@@ -26,18 +27,19 @@ IF DomeState.0 THEN
GVL_Dome.FlapOpened := DomeState.3;
GVL_Dome.FlapClosed := DomeState.4;
END_IF
(*
IF ABS(ConvertEnvironment.WindDirection - Azimuth_current) > 150.0 THEN
Azimuth_set := ConvertEnvironment.WindDirection;
END_IF
*)
DomeAxis(bPowerEnable := TRUE,
bEnable_Positive := TRUE,
bEnable_Negative := TRUE,
bMoveAbsExec := FALSE, //ConvertEnvironment.WindSpeed > 15.0,
bEnable_Positive := Azimuth_current < 360.0,
bEnable_Negative := Azimuth_current >= 0.0,
bMoveAbsExec := ABS(Azimuth_set - Azimuth_current) > 1.0, //ConvertEnvironment.WindSpeed > 15.0,
fMoveAbsPos := Azimuth_set,
fMoveAbsVelo := 3.0,
bStop := ConvertEnvironment.WindSpeed < 10.0,
bStop := stop_azimuth,
fActPos => Azimuth_current,
stAxis := GVL_Dome.DomeAxisRef);
......@@ -109,6 +111,7 @@ DomeLog(Trigger := bError,
<LineId Id="310" Count="0" />
<LineId Id="312" Count="1" />
<LineId Id="289" Count="0" />
<LineId Id="365" Count="0" />
<LineId Id="291" Count="3" />
<LineId Id="296" Count="2" />
<LineId Id="307" Count="0" />
......
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.17">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
<POU Name="F_DeclinationLimit" Id="{63bf7f2c-aa22-4403-8fe6-705497e9da03}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION F_DeclinationLimit : LREAL
VAR_INPUT
// observers latitude in degrees from -90.0 ... +90.0
latitude: LREAL;
west_of_pier: BOOL;
// positive is true for the positive (upper) limit, false for the ngeative (lower) limit
positive: BOOL := TRUE;
END_VAR
......@@ -13,17 +14,17 @@ END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[(* returns the limits for the declination *)
IF latitude >= 0.0 THEN
IF west_of_pier THEN
IF positive THEN
F_DeclinationLimit := 90.0;
F_DeclinationLimit := 270.0 - latitude;
ELSE
F_DeclinationLimit := -90.0 + latitude;
F_DeclinationLimit := 90.0 - latitude;
END_IF
ELSE // negative latitude
ELSE // east_of_pier
IF positive THEN
F_DeclinationLimit := 90.0 - latitude;
F_DeclinationLimit := 90.0 + latitude;
ELSE
F_DeclinationLimit := -90.0;
F_DeclinationLimit := 270.0 + latitude;
END_IF
END_IF
]]></ST>
......
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.12">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
<POU Name="FB_AxisJog" Id="{fb989a3e-caa4-4410-9164-68fdd76c828e}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_AxisJog
VAR_INPUT
......@@ -9,7 +9,7 @@ VAR_INPUT
bEnable_Negative: BOOL := TRUE;
fPowerOverride: LREAL := 100;
bReset: BOOL;
bStop: BOOL := FALSE;
bForward: BOOL;
bBackward: BOOL;
END_VAR
......@@ -44,7 +44,6 @@ VAR
// StartTrig: R_TRIG;
nstate: INT;
nLaststate: INT;
bStop: BOOL := FALSE;
END_VAR
VAR_IN_OUT
......@@ -87,11 +86,11 @@ fbMCReset(
AxMcJog(
JogForward := bForward,
JogBackwards := bBackward,
Mode := MC_JOGMODE_STANDARD_SLOW,
Mode := MC_JOGMODE_STANDARD_FAST,
Position := fActPos,
Velocity := fActVelo,
Acceleration := 0,
Deceleration := 0,
Acceleration := 5,
Deceleration := 100,
Jerk := 0,
Done => AxMcJogOut.Done,
Busy => AxMcJogOut.Busy,
......
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.17">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
<POU Name="FB_EQ2HOR" Id="{2aaa455b-6325-4dbe-b61c-a8cfdf369fe1}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_EQ2HOR
VAR_INPUT
......@@ -106,7 +106,7 @@ Calculate LOCAL MEAN SIDEREAL TIME *)
lmst := ct2lst(lon, jd); // get LST (in hours) - note:this is independent of time zone since giving jd
lmst := lmst*h2d ; //convert LMST to degrees (btw, this is the RA of the zenith)
// calculate local APPARENT sidereal time
last := lmst + d_psi *COS(eps)/3600.0 ; //add correction in degrees
last := lmst + d_psi *COS(eps*d2r)/3600.0 ; //add correction in degrees
(******************************************************************************
Find hour angle (in DEGREES) *)
......
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
<POU Name="FB_EQ2HOR2" Id="{7b34f02a-1435-4300-8153-5c49f62d1b5b}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_EQ2HOR2
VAR_INPUT
// right ascension in degrees
alpha: LREAL;
// declination in degrees
delta: LREAL;
// longitude in degrees
lon: LREAL;
// latitude in degrees
lat: LREAL;
// Julian Days
JD: LREAL;
END_VAR
VAR_OUTPUT
// altitude in degrees
alt: LREAL;
// azimuth in degrees
az: LREAL;
// hour angle in degreesss
ha: LREAL;
END_VAR
VAR
lst: LREAL;
sinalt, sinaz, cosaz, az2: LREAL;
END_VAR
VAR CONSTANT
d2r: LREAL := PI/180.0;
r2d: LREAL := 180.0/PI;
h2r: LREAL := PI/12.0;
h2d: LREAL := 15.0;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[lst := ct2lst(lon, jd);
ha := MODABS(lst*15.0 - alpha, 360.0);
sinalt := (SIN(delta*d2r)*SIN(lat*d2r)) + (COS(delta*d2r)*COS(lat*d2r)*COS(ha*d2r));
alt := ASIN(sinalt) * r2d;
sinaz := -SIN(ha*d2r)*COS(delta*d2r)/COS(alt*d2r);
az := ASIN(sinaz) * r2d;
cosaz := (SIN(delta*d2r) - SIN(lat*d2r)*sinalt)/(COS(lat*d2r)*COS(alt*d2r));
az2 := ACOS(cosaz) * r2d;]]></ST>
</Implementation>
<LineIds Name="FB_EQ2HOR2">
<LineId Id="9" Count="0" />
<LineId Id="16" Count="0" />
<LineId Id="18" Count="0" />
<LineId Id="26" Count="1" />
<LineId Id="24" Count="0" />
<LineId Id="28" Count="0" />
<LineId Id="23" Count="0" />
<LineId Id="50" Count="0" />
</LineIds>
</POU>
</TcPlcObject>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
<POU Name="LREAL_TO_FMTESTR" Id="{87e8e94a-e4ab-4792-8032-2087ad1cc7b1}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION LREAL_TO_FMTESTR : STRING
VAR_INPUT
in : LREAL; // 1.19412572985311e-6
iPrecision : INT := 2;
bRound : BOOL := TRUE;
END_VAR
VAR
lstring: STRING;
ppos: INT;
epos: INT;
mantisse: LREAL;
exponent: STRING;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[lstring := LREAL_TO_STRING(in);
ppos := FIND(lstring, '.');
epos := FIND(lstring, 'e');
IF epos = 0 OR ppos = 0 THEN
LREAL_TO_FMTESTR := LREAL_TO_FMTSTR(in, iPrecision, bRound);
RETURN;
END_IF
mantisse := STRING_TO_LREAL(LEFT(lstring, epos-1)); // 1.19412572985311
exponent := RIGHT(lstring, LEN(lstring)-epos+1); // e-6
LREAL_TO_FMTESTR := CONCAT(LREAL_TO_FMTSTR(mantisse,iPrecision, bRound), exponent);]]></ST>
</Implementation>
<LineIds Name="LREAL_TO_FMTESTR">
<LineId Id="7" Count="0" />
<LineId Id="22" Count="0" />
<LineId Id="14" Count="0" />
<LineId Id="18" Count="1" />
<LineId Id="21" Count="0" />
<LineId Id="20" Count="0" />
<LineId Id="26" Count="0" />
<LineId Id="28" Count="0" />
<LineId Id="13" Count="0" />
</LineIds>
</POU>
</TcPlcObject>
\ No newline at end of file
......@@ -58,7 +58,7 @@ DomeLightEvent( Trigger := GVL_MainControl.LightDome,
<LineId Id="24" Count="2" />
<LineId Id="5" Count="0" />
<LineId Id="39" Count="0" />
<LineId Id="61" Count="0" />
<LineId Id="76" Count="0" />
<LineId Id="41" Count="3" />
<LineId Id="40" Count="0" />
<LineId Id="50" Count="0" />
......
......@@ -16,17 +16,17 @@ VAR
// local siderial time calculated from Julian date
lst,
// values calulated when ra and dec are set by TCS
altitude_calc, azimut_calc: LREAL;
altitude_calc, azimuth_calc: LREAL;
(* Declination section *)
fbDeclinationAxis: FB_Axis;
fbDeclinationAxisJog: FB_AxisJog;
// absolute encoder value of the declination axis
Declination_absolute,
Declination_absolute: LREAL;
// encoder value of the declination axis derived from absolute encoder in [-90 ... 0 ... +90]
Declination_real,
Declination_real: LREAL;
// encoder value from the motor
Declination_current,
Declination_current: LREAL;
// difference between motor encoder and absolute encoder
Declination_lag: LREAL;
// true, if declination lag exceeds error boundaries
......@@ -79,6 +79,7 @@ VAR
fbTime: FB_LocalSystemTime := ( bEnable := TRUE, dwCycle := 1);
SUNPOS: FB_SUNPOS;
eq2hor: FB_EQ2HOR;
eq2hor2: FB_EQ2HOR2;
hadec2altaz: FB_HADEC2ALTAZ;
AxDecMcHome: MC_Home; // FIXME MC_Home does not serve the Done and Busy signals!
......@@ -176,7 +177,7 @@ VAR_OUTPUT
tracktime: LREAL;
// True: telescope is calibrated
homed: BOOL;
testing: BOOL := TRUE;
END_VAR
VAR CONSTANT
(* Potsdam:
......@@ -203,7 +204,7 @@ VAR CONSTANT
// TODO: change to final value
hourangle_home: LREAL := 355.0;
lag_error : LREAL := 0.1;
lag_error : LREAL := 0.5;
position_error : LREAL := 10.0/3600.0;
END_VAR
]]></Declaration>
......@@ -214,7 +215,10 @@ IF fbTime.bValid THEN
jd := DateTime2JD(fbTime.systemTime);
END_IF
lst := CT2LST(longitude, jd);
IF testing THEN
ra := lst*15.0;
de := latitude;
END_IF
// set reset state either by hardware (key pressed) or by software (set by e.g. tcs)
reset := softreset OR GVL_Telescope.Key2;
IF softreset THEN
......@@ -240,16 +244,21 @@ END_IF
//F_Y(GVL_Telescope.declination_encoder, 98887, 229833, 90, -90);
// Declination +90° ... 98887
Declination_absolute := F_AbsoluteDecoder(GVL_Telescope.declination_encoder, 45.41473388671875, 262144);
Declination_absolute := 360.0 - F_AbsoluteDecoder(GVL_Telescope.declination_encoder, 45.41473388671875, 262144);
hourangle_absolute := F_AbsoluteDecoder(GVL_Telescope.hourangle_encoder, 95.12787, 262144);
// GVL_Telescope.declination_encoder<98887 OR GVL_Telescope.declination_encoder > 229833; --> west of pier
west_of_pier := (hourangle_absolute > 270.0);
east_of_pier := NOT west_of_pier;
IF Declination_absolute > 90.0 THEN
Declination_real := 180.0 - Declination_absolute;
hourangle_real := hourangle_absolute;
ELSE
Declination_real := Declination_absolute;
IF west_of_pier THEN
Declination_real := 180.0 - Declination_absolute; // OK
hourangle_real := hourangle_absolute; // OK
ELSE // west_of_pier
IF Declination_absolute>180.0 THEN
Declination_real := Declination_absolute - 360.0;
ELSE
Declination_real := Declination_absolute;
END_IF
hourangle_real := hourangle_absolute - 180.0;
END_IF
rightascension_current := MODABS(lst*15.0 - hourangle_real, 360.0);
......@@ -259,17 +268,26 @@ hadec2altaz( ha := hourangle_real,
lat := latitude,
alt => altitude,
az => azimut);
(*
eq2hor( ra := ra,
Dec := de,
JD := jd,
LAT := latitude,
LON := longitude,
ALTITUDE := height,
alt => altitude_calc,
az => azimut_calc,
ha => Hourangle_calc);
alt => altitude_calc, //worng
az => azimut_calc, //wrong
ha => Hourangle_calc); //wrong
*)
eq2hor2(alpha := ra,
delta := de,
lon := longitude,
lat := latitude,
JD := jd,
alt => altitude_calc,
az => azimuth_calc,
ha => hourangle_calc);
poweron_delay(IN := TRUE, PT := T#1S, Q =>);
homing_pulse(IN := poweron_delay.Q, PT := T#1S, Q =>);
HomeTrigger(CLK := (calibrate OR homing_pulse.Q OR power OR gohome OR park) AND (GVL_Telescope.Option1 OR GVL_Telescope.Option2), Q =>);
......@@ -320,12 +338,13 @@ AxHourMcHome(Execute := HomeTrigger.Q,
IF telescope_mode = E_TelescopeMode.manual THEN
fbDeclinationAxisJog(
bPowerEnable := GVL_Telescope.Option1,
bEnable_Positive := declination_real <= F_DeclinationLimit(latitude, TRUE),
bEnable_Negative := declination_real >= F_DeclinationLimit(latitude, FALSE),
bEnable_Positive := declination_absolute <= F_DeclinationLimit(latitude, west_of_pier, TRUE),
bEnable_Negative := declination_absolute >= F_DeclinationLimit(latitude, west_of_pier, FALSE),
fPowerOverride := 100,
bReset := reset,
bForward := GVL_Telescope.declination_plus,
bBackward := GVL_Telescope.declination_minus,
bStop := Declination_lagerror,
bForward := SEL(west_of_pier, GVL_Telescope.declination_plus, GVL_Telescope.declination_minus),
bBackward := SEL(west_of_pier, GVL_Telescope.declination_minus, GVL_Telescope.declination_plus),
bBusy => DeclinationBusy,
bErr => DeclinationError,
bAxError => DeclinationAxisError,
......@@ -336,10 +355,11 @@ IF telescope_mode = E_TelescopeMode.manual THEN
fbHourAxisJog(
bPowerEnable := GVL_Telescope.Option1,
bEnable_Positive := TRUE, // hourangle_real >= F_HourangleLimit(west_of_pier, TRUE),
bEnable_Negative := TRUE, //hourangle_real <= F_HourangleLimit(west_of_pier, FALSE),
bEnable_Positive := hourangle_absolute<=360.0,
bEnable_Negative := hourangle_absolute>=180.0 OR (hourangle_absolute<5.0), // allow for overshoot
fPowerOverride := 100,
bReset := GVL_Telescope.Key2,
bReset := reset,
bStop := Hourangle_lagerror,
bForward := GVL_Telescope.hour_plus,
bBackward := GVL_Telescope.hour_minus,
bBusy => HourangleBusy,
......@@ -441,8 +461,8 @@ IF telescope_mode = E_TelescopeMode.automatic THEN
END_IF
END_IF
fbDeclinationAxis(bPowerEnable := power,
bEnable_Positive := declination_real <= F_DeclinationLimit(latitude, TRUE),
bEnable_Negative := declination_real >= F_DeclinationLimit(latitude, FALSE),
bEnable_Positive := TRUE, //declination_real <= F_DeclinationLimit(latitude, west_of_pier, TRUE),
bEnable_Negative := TRUE, //declination_real >= F_DeclinationLimit(latitude, west_of_pier, FALSE),
bReset := reset,
bMoveAbsExec := gohome OR park OR goto, // TODO gohome or park or goto
fMoveAbsPos := Declination_set,
......@@ -592,6 +612,9 @@ GVL_MainControl.ControlLamp := DeclinationError OR HourangleError OR
<LineId Id="354" Count="0" />
<LineId Id="65" Count="0" />
<LineId Id="642" Count="0" />
<LineId Id="2005" Count="0" />
<LineId Id="2007" Count="0" />
<LineId Id="2006" Count="0" />
<LineId Id="628" Count="1" />
<LineId Id="643" Count="0" />
<LineId Id="646" Count="0" />
......@@ -614,10 +637,16 @@ GVL_MainControl.ControlLamp := DeclinationError OR HourangleError OR
<LineId Id="68" Count="0" />
<LineId Id="1578" Count="0" />
<LineId Id="1576" Count="1" />
<LineId Id="1575" Count="0" />
<LineId Id="2012" Count="0" />
<LineId Id="1579" Count="0" />