-
Notifications
You must be signed in to change notification settings - Fork 0
/
drift.pas
114 lines (86 loc) · 2.53 KB
/
drift.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
unit Drift;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, graphics;
procedure Drift_Init;
procedure Drift_Reset;
procedure Drift_Reset2;
procedure Drift_NewImage;
var
driftFlag: boolean;
implementation
uses Main, global;
//******************************************************************************
// Open
//******************************************************************************
procedure Drift_Init;
begin
// place holder
end;
//******************************************************************************
// Reset
//******************************************************************************
procedure Drift_Reset;
begin
// init
RAp.drift := 0.0;
DECp.drift := 0.0;
driftFlag := false;
Main_Form.driftCorrectionRA_Edit.Font.color := clRed;
Main_Form.driftCorrectionDEC_Edit.Font.color := clRed;
if not ATrackRunning then exit;
if (Main_Form.DriftCorrection_BCButton.down) then
begin
driftFlag := true;
Main_Form.driftCorrectionRA_Edit.Font.color := clLime;
Main_Form.driftCorrectionDEC_Edit.Font.color := clLime;
end;
end;
procedure Drift_Reset2;
begin
RAp.drift := 0.0;
DECp.drift := 0.0;
end;
//******************************************************************************
// New image
//******************************************************************************
procedure Drift_NewImage;
var
r,r1: double;
begin
// first image
if nSec = 0 then exit;
// RA drift
// drift distance of the image - centering rate * centering interval
r := RAp.ImageDrift - RAp.centDistanceMoved;
// drift correction
// a + means too slow and need to speed up (positive rate correction)
// a - means too fast and need to slow down (negative rate correction)
r := r / nSec;
// limit
r1 := StrToFloatDef(Main_Form.DriftCorrectionRateLimitRA_MaskEdit.EditText,0.00010);
if abs(r) > r1 then
if r < 0 then
r := -r1
else
r := r1;
// update drift rate
RAp.drift := RAp.drift + r;
// DEC drift
r := DECp.ImageDrift - DECp.centDistanceMoved;
// drift correction
// a + means too slow and need to speed up (positive rate correction)
// a - means too fast and need to slow down (negative rate correction)
r := -r / nSec;
// limit
r1 := StrToFloatDef(Main_Form.DriftCorrectionRateLimitDEC_MaskEdit.EditText,0.00100);
if abs(r) > r1 then
if r < 0 then
r := -r1
else
r := r1;
// update drift rate
DECp.drift := DECp.drift + r;
end;
end.