Hmm. That took a long time. A seriously long time. Anyway, I’ve now completed the ASCOM driver – the software which sits on the PC (within a planetarium programme) and communicates with the mount.
The final driver (sitting within SkyMap Pro) looks like this:
(I should add that the “hand controller” seen in the picture is not necessary to run the ASCOM driver – the ASCOM people get very upset at ‘bells and whistles’ forms being used to implement the driver. Instead, it is entirely optional and only calls standard ‘ASCOM commands’ like ‘slew’ or ‘move’ etc.)
The driver was written in visual basic and comprises two main modules:
1. The “AC class” which is based on the ASCOM driver template. It has all the necessary properties and methods for an ASCOM driver. Lots of those properties or methods are either not implemented (for example, Park and Unpark), or simply need to report back to queries from the client software (‘can this driver slew?’ ‘yes’ etc). As a result, this class just reports back to the client software or calls the other module (the CM Class) to actually execute a command which is implemented (eg ‘slew to these coords’).
2. The “CM Class” which actually implements the CapeMirror ASCOM driver.
The distinction is easiest to demonstrate on the acual modules, as follows.
First up, the ASCOM class:
' -------------------------------------------------------------------- ' CapeMirror Assembly: ASCOM Classes ' -------------------------------------------------------------------- [...] Imports ASCOM.Interface Public Class Telescope Implements ITelescope 'Early-bind interface implemented by an ASCOM driver [...] Private Shared ac_CanSetPark As Boolean = False ' Does not set Park position Private Shared ac_CanSlew As Boolean = True ' ' Can slew [...] Public Sub New() 'Create a reference to this instance of the driver AC = Me 'Create a reference to this instance of the underlying CM_Class CM = New ASCOM.CapeMirror.CM_Class [...] End Sub [...] Public ReadOnly Property CanSetPark() As Boolean Implements ITelescope.CanSetPark 'True if this telescope is capable of programmed setting of its park position (SetPark() method) Get Return ac_CanSetPark End Get End Property [...] Public Sub SlewToCoordinates(ByVal RightAscension As Double, ByVal Declination As Double) Implements ITelescope.SlewToCoordinates CM.SlewToCoordinates(RightAscension, Declination) End Sub
Now, the underlying CM class:
' -------------------------------------------------------------------- ' CapeMirror Assembly: CapeMirror Class ' -------------------------------------------------------------------- Imports System.Timers Public Class CM_Class ' The ASCOM helper Public AS_Util As New Helper.Util ' The CapeMirror controller Private Cntrl As CM_Controller ' The ASCOM set-up form Private cm_Setup As New SetupDialogForm ' Setup the timer (1 click per sec) Private cm_Timer As System.Timers.Timer ' The serial connection Private cm_Conn As IO.Ports.SerialPort [...] Public Sub SlewToCoordinates(ByVal coord_RA As Double, ByVal coord_DEC As Double) 'Move the telescope to the given equatorial coordinates, 'return when slew is complete 'This Method must be implemented if CanSlew returns True. 'Raises an error if the slew fails. 'The slew may fail if the target coordinates are beyond 'limits imposed within the driver component. 'Such limits include mechanical constraints imposed by the mount 'or attached instruments, 'building or dome enclosure restrictions, etc. 'The target coordinates are copied to Telescope.TargetRightAscension 'and Telescope.TargetDeclination whether or not the slew succeeds. 'Raises an error if AtPark is True, or if Tracking is False. If Me.Tracking = False Then MessageCentre("Error: Mount not tracking.") Throw New DriverException("CapeMirror error: Mount is not tracking.", vbObjectError + &H405) Exit Sub End If 'Mount throws an exception if already moving/slewing/tracking If Me.Slewing = True Then MessageCentre("Error: Mount is slewing.") Throw New DriverException("Slew to Coords error: already slewing.", vbObjectError + &H405) Exit Sub End If 'Amend the variables Me.Busy = True Me.Slewing = True cm_Timer.Enabled = False Me.AtHome = False 'Copy target coords to TargetRightAscension and TargetDeclination Me.TargetRightAscension = coord_RA Me.TargetDeclination = coord_DEC 'Find the alt and az of the slew target and store them in TargetAltArcSecs Call RADEC_TO_ALTAZ_ARCSECS(Me.TargetRightAscension, Me.TargetDeclination, Me.TargetAltArcSecs, Me.TargetAzArcSecs) 'Check Alt value If TargetAltArcSecs < cm_AltMinArcSecs Or TargetAltArcSecs > cm_AltMaxArcSecs Then MessageCentre("Error: coords out of range") Me.Busy = False Me.Slewing = False Me.cm_Timer.Enabled = True Exit Sub End If 'Work out how many steps to take Dim AzStepsToTake As Long, AltStepsToTake As Long Call CalcStepsToTake(Me.AzimuthArcSecs, Me.AltitudeArcSecs, Me.TargetAzArcSecs, Me.TargetAltArcSecs, AzStepsToTake, AltStepsToTake) 'Check there are steps to take If AzStepsToTake = 0 And AltStepsToTake = 0 Then Me.Slewing = False Me.Busy = False Me.cm_Timer.Enabled = True Exit Sub End If 'Report MessageCentre("Slewing to Az: " & Math.Round((Me.TargetAzArcSecs / 3600)) & "° Alt: " & Math.Round((Me.TargetAltArcSecs / 3600)) & "°") 'Send instruction SerialInstruction(AzStepsToTake, AltStepsToTake, cmdSlew) End Sub
The Full Driver
The full AC Class file can be viewed by clicking here.
The full CM Class file can be viewed by clicking here.
post a comment...
you must be logged in to post a comment.