capeMirror ASCOM driver

Introduction

In this post I’ve included the most significant files from the capeMirror ASCOM driver. The full set can be downloaded here.

The image on the right shows them within Visual Basic 2008 Express. The easiest way to approach them is like this:
1. Set-up the global variables.
2. View the main driver.

Module CM_Globals
    '------------------------------------------------------------------
    '   ===============
    '    CMGlobals.VB
    '   ===============
    '
    ' capeMirror global properties and variables module
    '
    ' Introduction: This module declares all variables used in driver.
    ' Many of these variables are required by the Telescope Class,     
    ' others are necessary for the operation of the mount itself.      
    '
    ' Much of the structure of this document taken from the excellent 
    ' ScopeSim which was written by Jon Brewster.
    '
    ' Written:          01-Jan-09   
    ' By:               ben at cape ealing
    '------------------------------------------------------------------

    '---------------------------------------------
    ' ASCOM variables for functions and libraries
    '---------------------------------------------
    '
    Public CM_Util = New Helper.Util
    Public CM_Serial = New Helper.Serial
    Public CM_Profile = New Helper.Profile

    '----------------------------------------------
    ' capeMirror driver variables for form and subs
    '----------------------------------------------
    '
    Public CMSetup = New SetupDialogForm     'Setup Dialog Form
    Public CMC As CMController     'Create HandController Form
    Private WithEvents m_Timer As Helper.Timer     'HandController form timer 
    Public CM_Ticks As Double = 1000 ' ticks every second

    '---------------------------------------------
    ' capeMirror driver properties
    '---------------------------------------------
    '
    Public CM_Description As String = "capeMirror ASCOM Driver"
    Public CM_DriverInfo As String = "This driver controls capeMirror using the ASCOM interface. Designed by Ben."
    Public CM_DriverVersion As String = "v 1.0"
    'Telescope class interface version 2
    Public CM_InterfaceVersion As Short = 2
    Public CM_Name As String = "capeMirror"
    Public CM_ID As String = "ASCOM.capeMirror.Telescope"

    '---------------------------------------------
    ' capeMirror properties (persistent)
    '---------------------------------------------
    '
    ' No finding home
    Public CM_CanFindHome As Boolean = False
    ' No parking
    Public CM_CanPark As Boolean = False
    ' No pulse guiding
    Public CM_CanPulseGuide As Boolean = False
    ' DeclinationRate cannot be changed for offset tracking
    Public CM_CanSetDeclinationRate As Boolean = False
    ' Guide rate properties used for PulseGuide() cannot be adjusted
    Public CM_CanSetGuideRates As Boolean = False
    ' No programmed setting of park position (ie SetPark() method)
    Public CM_CanSetPark As Boolean = False
    ' Not an EQ mount
    Public CM_CanSetPierSide As Boolean = False
    '   No offset tracking
    Public CM_CanSetRightAscensionRate As Boolean = False
    ' Can track
    Public CM_CanSetTracking As Boolean = True
    ' Can slew
    Public CM_CanSlew As Boolean = True
    ' Cannot slew on alt az coords
    Public CM_CanSlewAltAz As Boolean = False
    ' Cannot slew on alt az coords
    Public CM_CanSlewAltAzAsync As Boolean = False
    ' Any slew must finish before further instructions follow
    Public CM_CanSlewAsync As Boolean = False
    ' Can sync
    Public CM_CanSync As Boolean = True
    ' Can sync on Alt Az coords
    Public CM_CanSyncAltAz As Boolean = True
    ' No parking
    Public CM_CanUnpark As Boolean = False
    ' AltAz mount
    Public CM_AlignmentMode = AlignmentModes.algAltAz
    ' Includes refraction in its calculations
    Public CM_DoesRefraction As Boolean = True
    ' local topocentric coords
    Public CM_EquatorialSystem As String = EquatorialCoordinateType.equLocalTopocentric
    ' If CanSetRightAscensionRate is False, this must return 0. 
    Public CM_RightAscensionRate As Double = 0

    ' ------------------------------------------
    ' capeMirror State Variables (persistent)
    ' ------------------------------------------
    '
    ' capeMirror optics
    '
    ' sqm aperture area 
    Public CM_ApertureArea As Double = 0.003848451
    ' 70mm diameter lenses (in metres)
    Public CM_ApertureDiameter As Double = 0.07
    ' 130mm focal length
    Public CM_FocalLength As Double = 0.13

    ' capeMirror geography
    '
    ' Site latitude, default to cape ealing
    Public CM_SiteLatitude As Double = 51.522396087646484
    ' Site longitude, default to cape ealing
    Public CM_SiteLongitude As Double = -0.312625
    ' Site elevation, default to cape ealing
    Public CM_SiteElevation As Double = 5

    ' capeMirror position
    '
    ' Does not do 'home'.  Could implement to be pole star.
    Public CM_AtHome As Boolean = False
    ' Does not do 'park'.  This is the 'turned off' position.
    Public CM_AtPark As Boolean = False

    ' capeMirror weather conditions
    '
    ' pressure
    Public CM_Pressure As Double = 1013
    ' temperature
    Public CM_Temperature As Double = 5

    ' Serial communication
    '
    ' COM port
    Public CM_ComPort As Double = 7
    ' Baud rate
    Public CM_BaudRate As Double = 9600

    ' -------------------------------------------
    ' capeMirror variables (not persistent)
    ' -------------------------------------------
    '
    ' time
    '
    ' UTC date time
    Public CM_UTCDate As DateTime
    ' Sidereal time
    Public CM_SiderealTime As Double

    ' mount co-ords at start-up
    '
    ' Polaris RA
    Public CM_RightAscension As Double = CM_Util.HMSToHours("02:40:12.07")
    ' Polaris Dec
    Public CM_Declination As Double = CM_Util.DMSToDegrees("89:18:22.8")
    ' Altitude
    Public CM_Altitude As Double
    ' Azimuth
    Public CM_Azimuth As Double

    ' Target RA
    Public CM_TargetRA As Double
    ' Target Dec
    Public CM_TargetDec As Double
    ' Target Alt
    Public CM_TargetAlt As Double
    ' Target Az
    Public CM_TargetAz As Double
    ' Hour Angle
    Public CM_HourAngle As Double

    ' mount state
    '
    ' Not connected at startup
    Public CM_Connected As Boolean = False
    ' Not slewing at startup
    Public CM_SlewingTracking As Boolean = False
    ' Not tracking at startup
    Public CM_Tracking As Boolean = False

    ' mount values
    '
    ' resolution of Alt stepper motor in degrees
    Public CM_AltResolution As Double = 0.09
    ' resolution of Az stepper motor in degrees
    Public CM_AzResolution As Double = 0.045
    ' capeMirror in simulator mode
    Public CM_Simulator As Boolean = True


    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'THIS NEEDS TO BE TIDIED UP
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Variables that should be unused now just for buttons - which not yet working right
    'Need to 'stop' the click events when slewing - sure it's conflict that crashes it cos the
    'less frequent the ticks the less likely slewing will crash it.

    Public CM_Busy As Boolean
    Public M_Altitude As Double
    Public M_Azimuth As Double

    'These are the values 'frozen' when PC loses control
    Public M_FrozenAlt As Double
    Public M_FrozenAz As Double
    Public M_OnBoardAltSteps As Double
    Public M_OnBoardAzSteps As Double


    'CM_AltResolution is the value (in degrees) of 1 step of stepper motor
    Public M_RightAscension As Double
    Public M_Declination As Double
    Public CM_AltSteps As Double
    Public CM_AzSteps As Double

    '    Public M_Time As Date

    'These are values which define value of button click on form
    Public Alt_Value As Double = 1 * CM_AltResolution
    Public Az_Value As Double = 1 * CM_AzResolution

    'Variables for maths calculations
    Private TA As Long

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Variables for testing.  To be removed.
    'Just for testing
    Public T As Long
    Public B_HourAngle2 As String


End Module

this is the main driver

post a comment...

you must be logged in to post a comment.