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

Introduction of TCSCommand

parent 930d7af8
......@@ -27,6 +27,9 @@
<Compile Include="DUTs\ST_DomeStruct.TcDUT">
<SubType>Code</SubType>
</Compile>
<Compile Include="DUTs\E_TCSCommand.TcDUT">
<SubType>Code</SubType>
</Compile>
<Compile Include="GlobalTextList.TcGTLO">
<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.12">
<DUT Name="E_TCSCommand" Id="{455814c6-4fba-4cec-90aa-a71c1d2a50ea}">
<Declaration><![CDATA[{attribute 'qualified_only'}
{attribute 'strict'}
TYPE E_TCSCommand :
(
no_command := 0,
gohome,
park,
track,
goto,
stop,
east,
west
);
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
\ No newline at end of file
......@@ -3,8 +3,18 @@
<POU Name="TelescopeControl" Id="{6a4f2e3a-c9ee-4352-b4f6-4f9d94b2c472}" SpecialFunc="None">
<Declaration><![CDATA[PROGRAM TelescopeControl
VAR
// manual or automatic operation of the telescope
telescope_mode : E_TelescopeMode;
jd, altitude, azimut, lst,
// actual command from the TCS
TCS_command: E_TCSCommand;
// current Julian Date calculated from system time
jd,
// altitude of the telescope pointing
altitude,
// azimut of the telescope pointing
azimut,
// local siderial time calculated from Julian date
lst,
// values calulated when ra and dec are set by TCS
altitude_calc, azimut_calc: LREAL;
......@@ -17,17 +27,28 @@ VAR
Declination_current,
// difference between motor encoder and absolute encoder
Declination_lag: LREAL;
// true, if declination lag exceeds error boundaries
Declination_lagerror: BOOL;
// current set coordinates
Declination_set: LREAL := -720.0;
// current velocity
Declination_velocity: LREAL := 0.0;
// True if Move has been executed
DeclinationDone: BOOL;
Declination_execute: RS;
//Declination_execute: RS;
// True if motor controller reports an arror
DeclinationAxisError,
// true if axis has been calibrated
DeclinationCalibrated: BOOL;
// true if axis is moving
DeclinationBusy: BOOL;
DeclinationActive: BOOL;
//DeclinationActive: BOOL;
// True if calibration has been aborted
DeclinationAborted: BOOL;
// true if general error in the axis control occured
DeclinationError: BOOL;
// error id from axis controller
DeclinationErrorID: UDINT;
(* Richt Ascension section *)
......@@ -66,7 +87,7 @@ VAR
poweron_delay: TON;
homing_pulse: TP;
tracking_delay: TON;
//tracking_delay: TON;
(* calibration_offset,
calibration_factor : LREAL;
......@@ -126,7 +147,8 @@ see https://gitlab.aip.de/bmk10k/telescope_firmware/snippets/5
TCSparkEvent,
TCSgotoEvent,
TCStrackEvent,
TCSstopEvent: FB_Eventlog;
TCSstopEvent,
AltitudeEvent: FB_Eventlog;
END_VAR
VAR_OUTPUT
// TRUE, IF telescope can be operated
......@@ -181,6 +203,7 @@ VAR CONSTANT
hourangle_home: LREAL := 355.0;
lag_error : LREAL := 0.1;
position_error : LREAL := 10.0/3600.0;
END_VAR
]]></Declaration>
<Implementation>
......@@ -231,21 +254,21 @@ END_IF
hourangle_real := F_AbsoluteDecoder(GVL_Telescope.hourangle_encoder, 95.12787, 262144);
rightascension_current := MODABS(lst*15.0 - hourangle_real, 360.0);
hadec2altaz(ha := hourangle_real,
dec := declination_real,
lat := latitude,
alt => altitude,
az => azimut);
hadec2altaz( ha := hourangle_real,
dec := declination_real,
lat := latitude,
alt => altitude,
az => azimut);
eq2hor(ra := ra,
Dec := de,
JD := jd,
LAT := latitude,
LON := longitude,
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,
az => azimut_calc,
ha => Hourangle_calc);
poweron_delay(IN := TRUE, PT := T#1S, Q =>);
homing_pulse(IN := poweron_delay.Q, PT := T#1S, Q =>);
......@@ -328,41 +351,65 @@ IF telescope_mode = E_TelescopeMode.manual THEN
stAxis := GVL_Telescope.HourAxisRef );
END_IF
// set TCS_command according to state variables ordered by precedence
IF track THEN
TCS_command := E_TCSCommand.track;
ELSIF goto THEN
TCS_command := E_TCSCommand.goto;
ELSIF gohome THEN
TCS_command := E_TCSCommand.gohome;
ELSIF park THEN
TCS_command := E_TCSCommand.park;
ELSIF east THEN
TCS_command := E_TCSCommand.east;
ELSIF west THEN
TCS_command := E_TCSCommand.west;
ELSIF stop THEN
TCS_command := E_TCSCommand.stop;
ELSE
TCS_command := E_TCSCommand.no_command;
END_IF
(* automatic section *********************************)
//tracking_delay(IN := GVL_Telescope.Option2, PT := T#1S);
IF telescope_mode = E_TelescopeMode.automatic THEN
IF declination_lagerror OR Hourangle_lagerror THEN
power := FALSE;
TCS_command := E_TCSCommand.no_command;
END_IF
IF gohome THEN // goto home position
IF TCS_command = E_TCSCommand.gohome THEN // goto home position
track := FALSE;
goto := FALSE;
Declination_set := declination_park;
Hourangle_set := hourangle_park;
Hourangle_velocity := position_velocity;
Declination_velocity := position_velocity;
END_IF
IF park THEN // goto park position
IF TCS_command = E_TCSCommand.park THEN // goto park position
track := FALSE;
goto := FALSE;
Declination_set := declination_park;
Declination_velocity := position_velocity;
Hourangle_set := hourangle_park;
Hourangle_velocity := position_velocity;
Declination_velocity := position_velocity;
END_IF
IF track THEN // move telescope to last ra/de and start tracking.
IF TCS_command = E_TCSCommand.track THEN // move telescope to last ra/de and start tracking.
goto := FALSE;
// TODO: move telescope first
Declination_set := de;
//Hourangle_set := lst - ra;
Hourangle_set := 270.0;
Declination_velocity := 0.0;
Hourangle_velocity := siderial_velocity;
IF ABS(Declination_current - de) > position_error THEN
Declination_velocity := position_velocity;
Declination_set := de;
ELSE
Declination_velocity := 0.0;
END_IF
IF ABS(rightascension_current - ra) > position_error THEN
Hourangle_velocity := position_velocity;
Hourangle_set := MODABS(lst*15.0 - hourangle_real, 360.0);
ELSE
Hourangle_velocity := siderial_velocity;
Hourangle_set := 270.0;
END_IF
END_IF
IF goto THEN // move telescope to tau/de and stop there. Set track to false, if true. False: no effect.
IF TCS_command = E_TCSCommand.goto THEN // move telescope to tau/de and stop there. Set track to false, if true. False: no effect.
track := FALSE;
// TODO: check altitude
Declination_set := de;
......@@ -371,27 +418,23 @@ IF telescope_mode = E_TelescopeMode.automatic THEN
ELSIF ra >= 0.0 AND ra < 360.0 THEN
Hourangle_set := Hourangle_calc;
END_IF
Declination_velocity := position_velocity;
Hourangle_velocity := position_velocity;
IF DeclinationDone THEN
goto := FALSE;
END_IF
END_IF
IF stop THEN
IF TCS_command = E_TCSCommand.stop THEN
goto := FALSE;
track := FALSE;
// (boolean, true: Stop motion of telescope immediately, set goto and track to false. false: Allow motion of telescope again via track/goto).
END_IF
// Setting allowed only if telescope is not moving.
IF east THEN
IF TCS_command = E_TCSCommand.east THEN
IF west_of_pier THEN
east := FALSE;
// move telescope to west of pier
END_IF
END_IF
// Setting allowed only if telescope is not moving.
IF west THEN
IF TCS_command = E_TCSCommand.west THEN
IF east_of_pier THEN
west := FALSE;
// move telescope to east of pier
......@@ -527,7 +570,17 @@ TCSstopEvent( Trigger := stop,
OnMessage := 'commencing',
OffMEssage := 'completed',
OffLevel := ADSLOG_MSGTYPE_HINT);
TCSstopEvent( Trigger := stop,
Level := ADSLOG_MSGTYPE_WARN,
FormatString := 'STOP %s',
OnMessage := 'commencing',
OffMEssage := 'completed',
OffLevel := ADSLOG_MSGTYPE_HINT);
AltitudeEvent( Trigger := altitude_calc<0.0,
Level := ADSLOG_MSGTYPE_WARN,
FormatString := '%s',
OnMessage := 'Target below horizon',
OffMEssage := '');
GVL_MainControl.ControlLamp := DeclinationError OR HourangleError OR
Declination_lagerror OR Hourangle_lagerror OR
DeclinationAxisError OR HourangleAxisError;]]></ST>
......@@ -607,31 +660,40 @@ GVL_MainControl.ControlLamp := DeclinationError OR HourangleError OR
<LineId Id="106" Count="13" />
<LineId Id="273" Count="1" />
<LineId Id="120" Count="11" />
<LineId Id="1498" Count="1" />
<LineId Id="1501" Count="0" />
<LineId Id="1527" Count="2" />
<LineId Id="1513" Count="0" />
<LineId Id="1526" Count="0" />
<LineId Id="1547" Count="1" />
<LineId Id="1520" Count="5" />
<LineId Id="1511" Count="0" />
<LineId Id="1519" Count="0" />
<LineId Id="1509" Count="0" />
<LineId Id="333" Count="0" />
<LineId Id="335" Count="0" />
<LineId Id="337" Count="0" />
<LineId Id="540" Count="0" />
<LineId Id="963" Count="1" />
<LineId Id="1530" Count="0" />
<LineId Id="962" Count="0" />
<LineId Id="541" Count="0" />
<LineId Id="545" Count="1" />
<LineId Id="543" Count="0" />
<LineId Id="737" Count="1" />
<LineId Id="746" Count="1" />
<LineId Id="544" Count="0" />
<LineId Id="547" Count="1" />
<LineId Id="550" Count="1" />
<LineId Id="734" Count="2" />
<LineId Id="742" Count="0" />
<LineId Id="734" Count="0" />
<LineId Id="1531" Count="0" />
<LineId Id="735" Count="1" />
<LineId Id="549" Count="0" />
<LineId Id="552" Count="0" />
<LineId Id="556" Count="0" />
<LineId Id="553" Count="0" />
<LineId Id="753" Count="0" />
<LineId Id="910" Count="0" />
<LineId Id="912" Count="1" />
<LineId Id="751" Count="0" />
<LineId Id="741" Count="0" />
<LineId Id="1532" Count="0" />
<LineId Id="1536" Count="8" />
<LineId Id="1546" Count="0" />
<LineId Id="1545" Count="0" />
<LineId Id="554" Count="0" />
<LineId Id="557" Count="0" />
<LineId Id="560" Count="0" />
......@@ -640,10 +702,8 @@ GVL_MainControl.ControlLamp := DeclinationError OR HourangleError OR
<LineId Id="1296" Count="1" />
<LineId Id="1299" Count="1" />
<LineId Id="1298" Count="0" />
<LineId Id="1301" Count="0" />
<LineId Id="750" Count="0" />
<LineId Id="744" Count="0" />
<LineId Id="1223" Count="2" />
<LineId Id="559" Count="0" />
<LineId Id="561" Count="1" />
<LineId Id="564" Count="0" />
......@@ -722,7 +782,7 @@ GVL_MainControl.ControlLamp := DeclinationError OR HourangleError OR
<LineId Id="1187" Count="0" />
<LineId Id="1186" Count="0" />
<LineId Id="1209" Count="0" />
<LineId Id="930" Count="0" />
<LineId Id="1485" Count="10" />
<LineId Id="5" Count="0" />
<LineId Id="1279" Count="1" />
</LineIds>
......
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