Skip to content

Commit 79d2450

Browse files
V1.1.21.0 Updates
- Made the Axis Calibration dialog modeless and had it close the settings dialog, so that the screen is less cluttered and you can use any controls. - Fixed a bug in ALT calibration that would incorrectly calculate the distance moved when it crossed the 0/360 degree boundary. - Stopped the calibration wizard from slewing the mount home when calibration is complete. - Cleared the inpout coordinates for Step 2.
1 parent c0fdf7e commit 79d2450

File tree

6 files changed

+136
-84
lines changed

6 files changed

+136
-84
lines changed

OATControl/DlgAxisCalibration.xaml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
xmlns:controls="clr-namespace:OATControl.Controls"
99
xmlns:converters="clr-namespace:OATControl.Converters"
1010
mc:Ignorable="d"
11-
Title=" Stepper Motor Calibration" MinHeight="390" Width="520" MinWidth="520" Height="390" WindowStyle="ToolWindow">
11+
Title=" Stepper Motor Calibration" MinHeight="400" Width="520" MinWidth="520" Height="400" WindowStyle="ToolWindow">
1212
<Window.Resources>
1313
<Style x:Key="ToggleButtonState" TargetType="ToggleButton" >
1414
<Setter Property="BorderBrush" Value="{StaticResource AccentBaseColorBrush}" />
@@ -216,12 +216,11 @@
216216
<RowDefinition Height="Auto"/>
217217
</Grid.RowDefinitions>
218218
<TextBlock Grid.Row="0" Text="Step 1: Plate solve" Margin="10" Style="{StaticResource TextBlockHeading}" TextWrapping="Wrap" />
219-
<TextBlock Grid.Row="1" Text="Take an image and plate solve it. Type the coordinates below, three numbers with spaces in each box." Style="{StaticResource TextBlockListItem}"/>
220-
221-
<TextBlock Grid.Row="4" Text="RA:" Style="{StaticResource TextBlockHeading}" Margin="40,0"/>
222-
<TextBox Grid.Row="4" Text="{Binding InputCoordinateRA, Mode=TwoWay}" Margin="110,13" Style="{StaticResource TextBorder}"/>
219+
<TextBlock Grid.Row="1" Text="Take an image and plate solve it. Type the coordinates below, three numbers with spaces in each box. If you have N.I.N.A. Monitoring enabled and are using N.I.N.A. to plate solve, they will auto-populate once the solution is found." Style="{StaticResource TextBlockListItem}" Margin="25,15"/>
220+
<TextBlock Grid.Row="4" Text="RA:" Style="{StaticResource TextBlockHeading}" Margin="40,0,40,0"/>
221+
<TextBox Grid.Row="4" Text="{Binding InputCoordinateRA, Mode=TwoWay}" Margin="110,5" Style="{StaticResource TextBorder}"/>
223222
<TextBlock Grid.Row="5" Text="DEC:" Style="{StaticResource TextBlockHeading}" Margin="40,0"/>
224-
<TextBox Grid.Row="5" Text="{Binding InputCoordinateDEC, Mode=TwoWay}" Margin="110,13" Style="{StaticResource TextBorder}"/>
223+
<TextBox Grid.Row="5" Text="{Binding InputCoordinateDEC, Mode=TwoWay}" Margin="110,5" Style="{StaticResource TextBorder}"/>
225224
<StackPanel Grid.Row="6" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,15,0,0">
226225
<Button Content="Continue" Style="{StaticResource AccentedSquareButtonStyle}" Margin="10,0" MinWidth="100" Command="{Binding ContinueCommand}" IsEnabled="{Binding CanContinue}"/>
227226
<Button Content="Cancel" Style="{StaticResource AccentedSquareButtonStyle}" Margin="10,0" MinWidth="100" Command="{Binding CancelCommand}" />
@@ -239,7 +238,7 @@
239238
<RowDefinition Height="Auto"/>
240239
</Grid.RowDefinitions>
241240
<TextBlock Grid.Row="0" Text="Step 2: Move Axis and plate solve" Margin="10" Style="{StaticResource TextBlockHeading}" TextWrapping="Wrap" />
242-
<TextBlock Grid.Row="1" Text="Use the controls to move the mount. Once done, take an image and plate solve it. Type the coordinates below, three numbers with spaces." Style="{StaticResource TextBlockListItem}"/>
241+
<TextBlock Grid.Row="1" Text="Use the controls below (or in the main view or MiniControl) to move the mount. Once done, take an image and plate solve it. Type the coordinates below, three numbers with spaces. If you have N.I.N.A. Monitoring enabled and are using N.I.N.A. to plate solve, they will auto-populate once the solution is found." Style="{StaticResource TextBlockListItem}" Margin="25,0,25,5"/>
243242

244243
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0" Visibility="{Binding IsPrimaryAxis, Converter={StaticResource VisibleIfPrimaryAxis}}">
245244
<controls:PushButton Width="36" Height="32" Direction="W" IsEnabled="{Binding MountConnected}" Command="{Binding ChangeSlewingStateCommand}" CommandParameter="{Binding LeftSlew}" />
@@ -285,10 +284,10 @@
285284
<TextBlock Grid.Row="3" Text="Axis will move a set amount (determined by selected distance) per click." Style="{StaticResource TextBlockListItem}" HorizontalAlignment="Center" Margin="0,25,0,10" Visibility="{Binding IsPrimaryAxis, Converter={StaticResource VisibleIfSecondaryAxis}}"/>
286285

287286
<TextBlock Grid.Row="4" Text="RA:" Style="{StaticResource TextBlockHeading}" Margin="40,0"/>
288-
<TextBox Grid.Row="4" Text="{Binding InputCoordinateRA, Mode=TwoWay}" Margin="110,13" Style="{StaticResource TextBorder}"/>
287+
<TextBox Grid.Row="4" Text="{Binding InputCoordinateRA, Mode=TwoWay}" Margin="110,5" Style="{StaticResource TextBorder}"/>
289288
<TextBlock Grid.Row="5" Text="DEC:" Style="{StaticResource TextBlockHeading}" Margin="40,0"/>
290-
<TextBox Grid.Row="5" Text="{Binding InputCoordinateDEC, Mode=TwoWay}" Margin="110,13" Style="{StaticResource TextBorder}"/>
291-
<StackPanel Grid.Row="6" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,15,0,0">
289+
<TextBox Grid.Row="5" Text="{Binding InputCoordinateDEC, Mode=TwoWay}" Margin="110,5" Style="{StaticResource TextBorder}"/>
290+
<StackPanel Grid.Row="6" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,20,0,0">
292291
<Button Content="Continue" Style="{StaticResource AccentedSquareButtonStyle}" Margin="10,0" MinWidth="100" Command="{Binding ContinueCommand}" IsEnabled="{Binding CanContinue}"/>
293292
<Button Content="Cancel" Style="{StaticResource AccentedSquareButtonStyle}" Margin="10,0" MinWidth="100" Command="{Binding CancelCommand}" />
294293
</StackPanel>

OATControl/DlgAxisCalibration.xaml.cs

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ enum CalibrationState
3333
WaitToStart = 1,
3434
WaitForStartAxisSolution = 2,
3535
WaitForEndAxisSolution = 3,
36-
ConfirmResults = 4,
37-
SlewBackToHome = 5
36+
ConfirmResults = 4
3837
}
3938
private MountVM _mountVM;
4039
private string _selectedAxis;
@@ -80,7 +79,7 @@ public DlgAxisCalibration(MountVM mountVM)
8079
_displayStatus = false;
8180

8281
_cancelCommand = new DelegateCommand(() => OnCancel(), () => true);
83-
_continueCommand = new DelegateCommand(async () => await OnContinue(), () => true);
82+
_continueCommand = new DelegateCommand(() => OnContinue(), () => true);
8483
_closeCommand = new DelegateCommand(() => OnClose(), () => true);
8584
_changeSlewingStateCommand = new DelegateCommand((arg) => OnChangeSlewingState((string)arg), () => true);
8685
_transferStepsToMountCommand = new DelegateCommand(async (arg) => await OnTransferStepsToMount((string)arg), () => true);
@@ -106,6 +105,7 @@ private void PlateSolveOccurred(object sender, PlatesolveEventArgs e)
106105
{
107106
InputCoordinateRA = curRA.ToUIString();
108107
InputCoordinateDEC = curDEC.ToUIString();
108+
Log.WriteLine($"AXISCALIB: Received Platesolve results. RA: {curRA.ToUIString()} DEC:{curDEC.ToUIString()}");
109109
}
110110
}, Application.Current.Dispatcher);
111111
}
@@ -127,9 +127,6 @@ private void OnPropertyChanged([CallerMemberName] string field = "")
127127

128128
public void OnCancel()
129129
{
130-
// Issue STOP command to mount
131-
_mountVM.StopSlewingCommand.Execute(null);
132-
_mountVM.HomeCommand.Execute(null);
133130
this.Close();
134131
}
135132

@@ -188,15 +185,19 @@ async Task OnTransferStepsToMount(string arg)
188185
switch (arg)
189186
{
190187
case "RA":
188+
Log.WriteLine($"AXISCALIB: Updating RA steps/deg to {CalculatedStepsPerDegree.ToString("F1")}");
191189
await _mountVM.SetSteps(CalculatedStepsPerDegree, _mountVM.DECStepsPerDegree);
192190
break;
193191
case "DEC":
192+
Log.WriteLine($"AXISCALIB: Updating DEC steps/deg to {CalculatedStepsPerDegree.ToString("F1")}");
194193
await _mountVM.SetSteps(_mountVM.RAStepsPerDegree, CalculatedStepsPerDegree);
195194
break;
196195
case "ALT":
196+
Log.WriteLine($"AXISCALIB: Updating ALT steps/deg to {CalculatedStepsPerDegree.ToString("F1")}");
197197
await _mountVM.SetSecondarySteps(_mountVM.AZStepsPerDegree, CalculatedStepsPerDegree);
198198
break;
199199
case "AZ":
200+
Log.WriteLine($"AXISCALIB: Updating AZ steps/deg to {CalculatedStepsPerDegree.ToString("F1")}");
200201
await _mountVM.SetSecondarySteps(CalculatedStepsPerDegree, _mountVM.AZStepsPerDegree);
201202
break;
202203
}
@@ -448,6 +449,10 @@ private void OnTimerTick(object sender, EventArgs e)
448449
{
449450
switch (_calibrationState)
450451
{
452+
case CalibrationState.WaitToStart:
453+
AxisStepsBefore = GetAxisPosition(_selectedAxis);
454+
break;
455+
451456
case CalibrationState.WaitForStartAxisSolution:
452457
CanContinue = MountVM.TryParseCoord(InputCoordinateRA, out _raSolvedStart);
453458
CanContinue &= MountVM.TryParseCoord(InputCoordinateDEC, out _decSolvedStart);
@@ -460,15 +465,6 @@ private void OnTimerTick(object sender, EventArgs e)
460465
CanContinue &= MountVM.TryParseCoord(InputCoordinateRA, out _raSolvedEnd);
461466
CanContinue &= MountVM.TryParseCoord(InputCoordinateDEC, out _decSolvedEnd);
462467
break;
463-
464-
case CalibrationState.SlewBackToHome:
465-
if (!_mountVM.IsSlewing(_axisChar))
466-
{
467-
Log.WriteLine("STEPCALIBRATION: Slewing ended.");
468-
Task.Run(() => OnContinue());
469-
_timer.Stop();
470-
}
471-
break;
472468
}
473469
}
474470

@@ -500,42 +496,49 @@ private void GenerateSuggestion(string axis, float movedDegrees, float stepsMove
500496
}
501497
}
502498

503-
public async Task OnContinue()
499+
public void OnContinue()
504500
{
505501
switch (_calibrationState)
506502
{
507503
case CalibrationState.WaitToStart:
508504
_calibrationState = CalibrationState.WaitForStartAxisSolution;
509505
OnPropertyChanged("Step");
510506
CanContinue = false;
507+
Log.WriteLine($"AXISCALIB: Starting {_selectedAxis} calibration. Initial position: {_axisStepsBefore.ToString("F0")}");
511508
_timer.Start();
512509
break;
513510

514511
case CalibrationState.WaitForStartAxisSolution:
515512
_calibrationState = CalibrationState.WaitForEndAxisSolution;
513+
Log.WriteLine($"AXISCALIB: First solution is RA:{InputCoordinateRA} and DEC:{InputCoordinateDEC}");
514+
InputCoordinateDEC = "";
515+
InputCoordinateRA = "";
516516
OnPropertyChanged("Step");
517517
CanContinue = false;
518518
break;
519519

520520
case CalibrationState.WaitForEndAxisSolution:
521521
var currentSteps = GetAxisPosition(_selectedAxis);
522522
float stepsMoved = currentSteps - _axisStepsBefore;
523+
MountVM.TryParseCoord(InputCoordinateRA, out _raSolvedEnd);
524+
MountVM.TryParseCoord(InputCoordinateDEC, out _decSolvedEnd);
525+
Log.WriteLine($"AXISCALIB: Second solution is RA:{InputCoordinateRA} ({_raSolvedEnd.ToString("F5")}) and DEC:{InputCoordinateDEC} ({_decSolvedEnd.ToString("F5")}). StepsMoved:{stepsMoved}");
523526
switch (SelectedAxis)
524527
{
525528
case "RA":
526529
{
527-
MountVM.TryParseCoord(InputCoordinateRA, out _raSolvedEnd);
528530
float movedDegrees = 15.0f * (_raSolvedStart - _raSolvedEnd);
529531
CalculatedStepsPerDegree = Math.Abs(stepsMoved / movedDegrees);
530532
MountStepsPerDegree = _mountVM.RAStepsPerDegree;
531533
ErrorRatio = 100.0f * CalculatedStepsPerDegree / MountStepsPerDegree;
532534
GenerateSuggestion("RA", movedDegrees, stepsMoved);
535+
Log.WriteLine($"AXISCALIB: RA calibration. MovedDegrees:{movedDegrees.ToString("F2")}. Calculated steps/deg:({CalculatedStepsPerDegree.ToString("F1")}). Mount steps/deg:{MountStepsPerDegree.ToString("F1")}");
536+
Log.WriteLine($"AXISCALIB: RA calibration error:{ErrorRatio.ToString("F1")}%");
533537
}
534538
break;
535539

536540
case "DEC":
537541
{
538-
MountVM.TryParseCoord(InputCoordinateDEC, out _decSolvedEnd);
539542
// The direction of the stepper deltas changes on either side of home.
540543
float movedDegrees = (_decSolvedStart - _decSolvedEnd) * Math.Sign(currentSteps);
541544
float movedRADegrees = Math.Abs(15.0f * (_raSolvedStart - _raSolvedEnd));
@@ -547,13 +550,17 @@ public async Task OnContinue()
547550
MountStepsPerDegree = _mountVM.DECStepsPerDegree;
548551
ErrorRatio = 100.0f * CalculatedStepsPerDegree / MountStepsPerDegree;
549552
GenerateSuggestion("DEC", movedDegrees, stepsMoved);
553+
Log.WriteLine($"AXISCALIB: DEC calibration. DecSolvedStart:{_decSolvedStart.ToString("F2")}. DecSolvedEnd:{_decSolvedEnd.ToString("F2")}. Currentsteps:{currentSteps}");
554+
Log.WriteLine($"AXISCALIB: DEC calibration. MovedRADegrees:{movedRADegrees.ToString("F2")}");
555+
Log.WriteLine($"AXISCALIB: DEC calibration. MovedDegrees:{movedDegrees.ToString("F2")}. Calculated steps/deg:({CalculatedStepsPerDegree.ToString("F1")}). Mount steps/deg:{MountStepsPerDegree.ToString("F1")}");
556+
Log.WriteLine($"AXISCALIB: DEC calibration error:{ErrorRatio.ToString("F1")}%");
550557
}
551558
break;
552559
case "ALT":
553560
case "AZ":
554561
{
555-
MountVM.TryParseCoord(InputCoordinateRA, out _raSolvedEnd);
556-
MountVM.TryParseCoord(InputCoordinateDEC, out _decSolvedEnd);
562+
Log.WriteLine($"AXISCALIB: ALT/AZ calibration. DecSolvedStart:{_decSolvedStart.ToString("F5")}. DecSolvedEnd:{_decSolvedEnd.ToString("F5")}");
563+
Log.WriteLine($"AXISCALIB: ALT/AZ calibration. RaSolvedStart:{_raSolvedStart.ToString("F5")}. RaSolvedEnd:{_raSolvedEnd.ToString("F5")}");
557564
AstroTools.RaDecToAzAlt(
558565
_raSolvedStart * 15.0,
559566
_decSolvedStart,
@@ -568,16 +575,39 @@ public async Task OnContinue()
568575
AppSettings.Instance.SiteLongitude,
569576
DateTime.UtcNow,
570577
out double azimuth, out double altitude);
571-
float movedDegrees = (SelectedAxis == "ALT") ? (float)Math.Abs(altitude - altitudeStart) : (float)Math.Abs(azimuth - azimuthStart);
578+
Log.WriteLine($"AXISCALIB: ALT/AZ calibration. ALT Start:{altitudeStart.ToString("F2")}. End:{altitude.ToString("F2")}");
579+
Log.WriteLine($"AXISCALIB: ALT/AZ calibration. AZ Start:{azimuthStart.ToString("F2")}. End:{azimuth.ToString("F2")}");
580+
// Assume ALT. ALT is unlikely to have a 0 crossing, but AS is very likely to cross 0/360 since we're supposed to be pointing North.
581+
float movedDegrees = (float)(altitude - altitudeStart);
582+
if (SelectedAxis == "AZ")
583+
{
584+
if (azimuth > 270)
585+
{
586+
azimuth -= 360;
587+
}
588+
if (azimuthStart > 270)
589+
{
590+
azimuthStart -= 360;
591+
}
592+
movedDegrees = (float)(azimuth - azimuthStart);
593+
Log.WriteLine($"AXISCALIB: ALT/AZ calibration. Corrected AZ Start:{azimuthStart.ToString("F2")}. End:{azimuth.ToString("F2")}. MovedDegrees now {movedDegrees.ToString("F3")}");
594+
}
595+
else
596+
{
597+
Log.WriteLine($"AXISCALIB: ALT/AZ calibration. ALT MovedDegrees {movedDegrees.ToString("F3")}");
598+
}
572599
CalculatedStepsPerDegree = Math.Abs(stepsMoved / movedDegrees);
573600
MountStepsPerDegree = SelectedAxis == "ALT" ? _mountVM.ALTStepsPerDegree : _mountVM.AZStepsPerDegree;
601+
Log.WriteLine($"AXISCALIB: ALT/AZ calibration. Calculated steps/deg {CalculatedStepsPerDegree.ToString("F1")}");
602+
Log.WriteLine($"AXISCALIB: ALT/AZ calibration. Mount steps/deg {MountStepsPerDegree.ToString("F1")}");
574603
if (MountStepsPerDegree == 0)
575604
{
576605
ErrorRatio = 0;
577606
}
578607
else
579608
{
580609
ErrorRatio = 100.0f * CalculatedStepsPerDegree / MountStepsPerDegree;
610+
Log.WriteLine($"AXISCALIB: ALT/AZ calibration. Error Ratio {ErrorRatio.ToString("F1")}%");
581611
}
582612
GenerateSuggestion(SelectedAxis, movedDegrees, stepsMoved);
583613
}
@@ -590,25 +620,9 @@ public async Task OnContinue()
590620
break;
591621

592622
case CalibrationState.ConfirmResults:
593-
// Slew back to home
594-
DisplayStatus = true;
595-
_calibrationState = CalibrationState.SlewBackToHome;
596-
OnPropertyChanged("Step");
597-
_mountVM.HomeCommand.Execute(null);
598-
await Task.Delay(500);
599-
_timer.Start();
600-
break;
601-
602-
case CalibrationState.SlewBackToHome:
603-
// If slew complete
604-
{
605-
DisplayStatus = false;
606-
WpfUtilities.RunOnUiThread(() => this.Close(), Application.Current.Dispatcher);
607-
}
623+
WpfUtilities.RunOnUiThread(() => this.Close(), Application.Current.Dispatcher);
608624
break;
609625
}
610-
611-
//CanContinue = !DisplayStatus;
612626
}
613627
}
614628
}

OATControl/OATControl Setup.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

44
#define MyAppName "OATControl"
5-
#define MyAppVersion "1.1.18.0"
5+
#define MyAppVersion "1.1.21.0"
66
#define MyAppPublisher "OpenAstroTech"
77
#define MyAppURL "https://wiki.openastrotech.com/"
88
#define MyAppExeName "OATControl.exe"

OATControl/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.1.20.0")]
55-
[assembly: AssemblyFileVersion("1.1.20.0")]
54+
[assembly: AssemblyVersion("1.1.21.0")]
55+
[assembly: AssemblyFileVersion("1.1.21.0")]

OATControl/Readme.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
Revision History
22
----------------
33

4+
OATControl V1.1.21.0 2 Aug 2025
5+
- Made the Axis Calibration dialog modeless and had it close the settings
6+
dialog, so that the screen is less cluttered and you xan use any
7+
controls.
8+
- Fixed a bug in ALT calibration that would incorrectly calculate the
9+
distance moved when it crossed the 0/360 degree boundary.
10+
- Stopped the calibration wizard from slewing the mount home when
11+
calibration is complete.
12+
- Cleared the inpout coordinates for Step 2.
13+
14+
OATControl V1.1.20.0 1 Aug 2025
15+
- Added axis calibration wizard to Mount Settings dialog (uses plate
16+
solving).
17+
418
OATControl V1.1.18.0 9 Jul 2025
519
- Added AZ/ALT motor status display to main screen.
620
- Fixed a bug related to window positioning when ensuring they always open

0 commit comments

Comments
 (0)