David's Astronomy Pages
Code Notes

 
Bullet CCDApp2 (Observatory Control Program
 
Bullet CCDApp2_AllSky
   
Bullet CCDApp3_AllSky
 
Bullet WeatherStationRepeater (Weather Server)
 
Bullet SQLForm2 (Observing Database Tool)
 
Bullet ObservatoryOverSeer
 
 

CCDApp2  (Observatory Control Program)


General

Back to Top


Sky Flats (2018-09-04)

- Button 'Take Dusk Flats'  (Take Dawn Flats will be added at a later date)
- File defining the filter/bin sets to be acquired by sky flats routine is hard coded as AutoSkyFlats.txt (this will be changeable at a later date) . The order of rows in the file defines the order in which flats are to be acquired if taken at dusk. (The order will be automatically reversed for Dawn Flats). 

- No. of frames for each filter/bin set is hard-coded as 15 (this will be changeable at a later date)

- Entry routine objconsole.RunTakeDuskFlats
- This calls the routine TakeAutoSkyFlatsNew(1, 0)    ' where 1 (Dusk), 0 (Not Auto)
- After reading the AutoSkyFlats.txt  a Loop calls  TakeAutoSkyFlatsSetNew routine for each filter/bin set
- CalcFlatSpot calculates Flat Spot Az/Alt based on current  Sun Location
- SlewToFlatSpot slews the scope to current Flat Spot

Back to Top


Telecomms Service (2018-08-23)

"TeleComms Service" refers to Telescope Communication Service between Main Computer and AllSky Computer for the purposes of

a) display status of telescope and dome shutter on the Observatory Scorecard & on the Night Summary Plot
b) display of telescope/current target position and upcoming target positions on Annotated AllSky Images
c) inform the Main Computer of the cloud cover prevailing at the current telescope/target position and at the upcoming target positions

(Current telescope /current target position and upcoming target positions are updated throughout execution of a job queue on Main Observatory Computer.  AllSky Images, Night Summary Plot  and Scorecard are produced on AllSky Computer every 30s)

When the service is running on the Main Computer the following data is sent to the AllSky Computer every 5s
 1) Date-Time
 2) Status  as string
 3) Shutter Status as string
 4) Scope Target Name
 5) Scope Ra
 6) Scope Dec

  7) Next Target1 Name
 8) Next Target1 RA
 9) Next Target1 Dec

10) Next Target2 Name
11) Next Target2 RA
12) Next Target2 Dec

13) Next Target3 Name
14) Next Target3 RA
15) Next Target3 Dec

- Data is taken from the TP object (TP.ShutterState, TP.Scope and TP.NextTarget() )
- ShutterState is populated from objDome object (POTH.Dome) by the Observatory Monitor every 2s.

- TP.Scope is populated via calls to TP.ShowScope subroutine (which might call TP.SetScopeCoords depending on whether Ra/Dec are provided or not) . 

Calls to TP.ShowScope (with RA,Dec) is made by ImageTargetT, ImageTargetT_QSO, ImageMosaicT,  ImageMosaicT_QSO
after slewing to a target.

, whilst calls to TP.Scope (without RA,Dec) is made by several routines, including RunMeasureFocusProfile, RunMappingRun1, TakeManualObject

- Scope is set hidden by a call to TP.HideScope. Calls to HideScope are made as a Post-Job task for RunTakeFrameJobs & RunTakeFrameJobsQSO

- TP.NextTarget() array is populated by calls to UpdateTpnNextTargets() that are made from within the LoadShootList and  DisplayShootListQSO routines (i.e. each time that  listTargetImaging  and listTargetImagingQSO  are updated respectively) .  NextTargets are set hidden by a call to TP.HideNextTargets

Data is sent over Port :   xxxx

If no new data is received by the AllSky Computer for 3.5 minutes, the last received data is treated as being Invalid, except for ShutterState which is treated as Invalid after 6 minutes.

The following data is sent back to the Main Computer every 2s
 1) Date-Time
 2) Scope Target Name
 3) Scope Cloud Value
 4) Scope Cloud ADU rate

  5) Next Target1 Name
 6) Next Target1 Cloud Value
 7) Next Target1 ADU rate

  8) Next Target2 Name
 9) Next Target2 Cloud Value
10) Next Target2 ADU rate

11) Next Target3 Name
12) Next Target3 Cloud Value
13) Next Target3 ADU rate

(Note data, except for DataTime, will only change with each new AllSky Images ,

Data is taken from IV record. IV record is populated with Cloud Information after processing each new AllSky Image ( i.e. every 30s or so)

 

Back to Top


 Autoguiding Control (2018-08-23)


Code connected with PHD2 Autoguiding is held in a VB.Module  'Phd2.vb'

Guiding Activation

PHD2 Autoguiding is activated by call to Phd2.StartPHD2Guiding()

After checking PHD2 connection the following steps are undertaken
a) a 'get_exposure' request is sent to get current exposure setting
b) a 'loop' request is sent in order to begin looping frame
c) a 'guide' request is sent to initiate guiding (following parameters are sent  "pixels": 1.5, "time": 5, "timeout": 20 )
d) responses from PHD2 are monitored, looking initially for a 'StartGuiding' event to see that guiding has starting and waiting ideally for a 'SettleDone' event to to know that PHD2 guiding has settled and that main imaging can commence.

 

The guide' method should do whatever it needs to start guiding and to report when guiding is settled and stable. It is understood to include auto-selected a guide star if one is not already selected. Sending a loop request is not absolutely necessary as the 'guide' method will start capturing of camera isn't looping already.

Given that Guide request generally doesn't result in PHD2 locking on to a suitable guidestar, the options would seem to be

i) add a delay between sending loop request and the guide request to ensure that guide will start by looking at a fresh image from the new target rather an image from the last target.

ii) find a way to de-select the current (last) guide star, if one exists, before sending the 'guide' request

ii) send a 'find_star' request, after 'loop' and before 'guide'. This method  will return the lock position of the selected star, otherwise it returns an error object

Guiding Monitoring

 

Guiding Suspension

PHD2 Autoguiding is stopped by a call 'Phd2.StopPHD2Guiding'
a) a 'stop_capture' request is set to stop looping/guiding
 ('get_appstate' is used to confirm that looping/guiding has stopped

 

More on PHD2 Event Monitoring (https://github.com/OpenPHDGuiding/phd2/wiki/EventMonitoring)

Back to Top


Job Queue (QSO)

QSO Job Queue is run using the subroutine
    RunTakeFramesJobQSO which in turn calls TakeFrameJobsQSO to execute the Job queue.

Regular targets (including those needing precise target centering with N/W offsets) are directed to the
ImageTargetT_QSO subroutine (Mosaic targets are directed to the ImageMosaicT_QSO subroutine instead)

Regular targets are slewed to the target by calling the subroutine
    SlewToRaDecQSO (ByRef T As classT, ByRef bError As Boolean)

Target results are reported back to Queue Executor using "T" variables

T.Status  (string that describes the result for listing in "listTargetImagingQSO")
T.ObservationStatu
s   (integer / enum  ObservationState.xxxxxx )
T.FailureMode   ( integer / enum FailureState.xxxxxx)

 T.Complete ( boolean)



 

Back to Top


Target Centering (2018-08-14)

QSO Job Queue is run using the subroutine
    RunTakeFramesJobQSO which in turn calls TakeFrameJobsQSO to execute the Job queue.

Regular targets (including those needing precise target centering with N/W offsets) are directed to the
ImageTargetT_QSO subroutine (Mosaic targets are directed to the ImageMosaicT_QSO subroutine instead)

Regular targets are slewed to the target by calling the subroutine
    SlewToRaDecQSO (ByRef T As classT, ByRef bError As Boolean)

This slews to the Target Object's RA/Dec Coordinates excluding the N/W Offset (if any) .
This would see to be a flaw as the Telescope should be slewed to coordinates that including any required N/W Offset, as per the original routine 
    SlewToObjectT (ByVal T As classT, ByVal EmployJogs As Boolean, ByRef bError As Boolean) with EmplogJogs=true

However, whilst it is a flaw that needs to be corrected it doesn't account for the specific centering issue seen in the recent session (2018-08-14 S618).

Centering is performed by routine
    ImageTargetT_CentreTarget (ByRef T As classT, ByRef ReturnStatus As String, ByRef bExitSub As Boolean)
in which Pointing Error is calculated by the routine
    CalculatePointingErrorNewSub (T.JogN, T.JogW, PointingError_mins, dErrorN, dErrorW, dJogNcorrection, dJogWcorrection)
 
 (ByVal dJogN As Double, ByVal dJogW As Double, ByRef PointingError_mins As Double, ByRef dErrorN As Double, ByRef dErrorW As Double, ByRef dJogNcorrection As Double, ByRef dJogWcorrection As Double)

Code Modifications (2018-08-16)

SlewToRaDecQSO modified to slew to Target Object including N/W Offset

ImageTargetT_CentreTarget modified to call new routine CalculatePointingErrorQSO

CalculatePointingErrorQSO
(T, PointingError_mins, dErrorN, dErrorW, dJogNcorrection, dJogWcorrection)
New routine based on original routine CalculatePointingErrorNewSub but takes object RA/Dec from T

 

Back to Top


Autofocussing (2018-09-04)

  Entry routine for performing autofocus is "PerformAutoFocusRun"
  RunAutoPickFocusStar takes a full frame image and automatically select a star   )
  objConsole.ShowFocusGraph shows the Focus Graph
  objConsole.MeasureFocusProfile measures the focus profile and
   objConsole.DrawGraphTab draws the Focus Graph

Graph produced by ShowFocusGraph
Image 

 

New subroutines:

ModifyImageBoxPosition :  Modifies the next  Image Box  position based on the position of the star in the current image box.  It order to keep star centered  (reducing the risk that the star will drift out of view), and optimise image box star (making it smaller and achieve faster download &  processing time)
CalculateHFD : function that returns the half-flux diameter in arc secs.

 

Back to Top


CCDApp2_AllSky  (AllSky Program, Old)

 

Change at 2018-09-23

globals. SetAllSkyMargins modified to set "AllSkyTopMargin" and "AllSkyBotMargin" based on AllSkyCam.Xc in order to ensure David Plesko's 180 images plost are shifted to a centre position

Small Plots:
globals.AllSkyProcessFolder

 frmImage.DrawAllSkyImage_MAIN()

IV.ImageScaleFactor = ScaleFactor

' Calculate Display Width
' -----------------------
IV.ImageDisplayWidth = IV.nX * IV.ImageScaleFactor
IV.ImageDisplayHeight = IV.nY * IV.ImageScaleFactor

bImageViewerOn = True


' Create bitmap for LOCAL image
' ----------------------------
bm_Image.Dispose()
bm_Image = New Bitmap(IV.ImageDisplayWidth, IV.ImageDisplayHeight + AllSkyTopMargin + AllSkyBotMargin)

 Dim g2 As Graphics = Graphics.FromImage(bm_Image)

g2.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic

If AllSkyViewing Then
g2.DrawImage(bm_ImageFull, New Rectangle(0, AllSkyTopMargin, IV.ImageDisplayWidth, IV.ImageDisplayHeight), _
0, 0, bm_ImageFull.Width, bm_ImageFull.Height, GraphicsUnit.Pixel)
Else
g2.DrawImage(bm_ImageFull, New Rectangle(0, 0, IV.ImageDisplayWidth, IV.ImageDisplayHeight), _
New Rectangle(0, 0, bm_ImageFull.Width, bm_ImageFull.Height), GraphicsUnit.Pixel)
End If
 

 frmImage.DrawAllSkyImage_SMALL_ALT()

 AllSkyTopMarginSm = AllSkyTopMargin
AllSkyBotMarginSm = AllSkyBotMargin

 IVImageScaleFactorSm = 0.5
WidthSm = IV.nX * IVImageScaleFactorSm
HeightSm = IV.nY * IVImageScaleFactorSm

' Create Bitmap for the Image
' ----------------------------
bm_ImageSm.Dispose()
bm_ImageSm = New Bitmap(WidthSm, HeightSm + AllSkyTopMarginSm + AllSkyBotMarginSm) ' new rescale code

 

 

 frmImage.ShowAllSkyImage


 frmImage.UpdateViewerDimensions()

 FormSize.Height = ClientSize.Height + frmImage.StatusBar1.Height + frmImage.StatusBar2.Height + MenuStrip1.Height + SystemInformation.CaptionHeight + 10 + 8 '

 


CCDApp3_AllSky  (AllSky Program, New)


Take Image Series (All Sky, Night/Day Monitoring)

Entry routine is RunAllSkyTakeFrames

Main work is down in the AllSkyTakeFrames routine, whose main sections are:

INITIALISATION
MAIN CYCLE LOOP, 
WAIT FOR SUNSET,
DAYTIME LOOP,
PROCEED TO NIGHTTIME IMAGING,

IMAGING CYCLE


   
 

Back to Top


Daytime Loop

Entry routine is RunAllSkyTakeFrames

Main work is down in the AllSkyTakeFrames routine, whose main sections are:

INITIALISATION
MAIN CYCLE LOOP, 
WAIT FOR SUNSET,
DAYTIME LOOP,
PROCEED TO NIGHTTIME IMAGING,

IMAGING CYCLE


   
 

Back to Top


WeatherStationRepeater  (Weather Server & Graphs)


SQLForm2  (Observing Database Tool)


ObservatoryOverSeer  (Observing Overseer)