Source code of the PISCO telescope driving functions (Visual Basic)

' ====================================
' Writing on the serial port
' DTR = Pin 4 (bit 0 from register 4)
' ====================================
Sub WriteBit0(valeur As Integer)
Dim r As Integer

If valeur = 0 Then
   r = outport(ComAdress + 4, inport(ComAdress + 4) And &HFE)
   r = outport(ComAdress + 4, inport(ComAdress + 4) And &HFE)
   r = outport(ComAdress + 4, inport(ComAdress + 4) And &HFE)
Else
   r = outport(ComAdress + 4, inport(ComAdress + 4) Or 1)
   r = outport(ComAdress + 4, inport(ComAdress + 4) Or 1)
   r = outport(ComAdress + 4, inport(ComAdress + 4) Or 1)
End If

End Sub

' ====================================
' Writing on the serial port
' RTS = Pin 7 (bit 1 from register 4)
' ====================================
Sub WriteBit1(valeur As Integer)
Dim r As Integer

If valeur = 0 Then
   r = outport(ComAdress + 4, inport(ComAdress + 4) And &HFD)
   r = outport(ComAdress + 4, inport(ComAdress + 4) And &HFD)
   r = outport(ComAdress + 4, inport(ComAdress + 4) And &HFD)
Else
   r = outport(ComAdress + 4, inport(ComAdress + 4) Or 2)
   r = outport(ComAdress + 4, inport(ComAdress + 4) Or 2)
   r = outport(ComAdress + 4, inport(ComAdress + 4) Or 2)
End If

End Sub

' ====================================
' Writing on the serial port
' TxD = Pin 3 (bit 6 from register 3)
' ====================================
Sub WriteBit2(valeur As Integer)
Dim r As Integer

If valeur = 0 Then
   r = outport(ComAdress + 3, inport(ComAdress + 3) And 191)
   r = outport(ComAdress + 3, inport(ComAdress + 3) And 191)
   r = outport(ComAdress + 3, inport(ComAdress + 3) And 191)
Else
   r = outport(ComAdress + 3, inport(ComAdress + 3) Or 64)
   r = outport(ComAdress + 3, inport(ComAdress + 3) Or 64)
   r = outport(ComAdress + 3, inport(ComAdress + 3) Or 64)
End If

End Sub

' ====================================
' Serial Port initialization
' Pulse on bit 3 from register 4
' ====================================
Sub InitCom()
Dim r As Integer
Dim i As Integer

r = outport(ComAdress + 4, 0)
r = outport(ComAdress + 4, 0)
r = outport(ComAdress + 4, 0)

r = outport(ComAdress + 4, 8)
r = outport(ComAdress + 4, 8)
r = outport(ComAdress + 4, 8)

r = outport(ComAdress + 4, 0)
r = outport(ComAdress + 4, 0)
r = outport(ComAdress + 4, 0)

' Empty the Shift Register
WriteBit2 0 ' Latch set to 0

For i = 1 To 8
   WriteBit0 0  ' Write 0
   WriteBit1 0  ' 8 clock pulses
   WriteBit1 1
Next

WriteBit1 0

WriteBit2 1 ' Latch set to 1

End Sub

' ===============================================
' Set to 0 all the bits from the Shift Register
' ===============================================
Sub RazCom()
Dim r As Integer
Dim i As Integer

' Empty the Shift Register
WriteBit2 0 ' Latch set to 0
For i = 1 To 8
   WriteBit0 0  ' Write 0
   WriteBit1 0  ' 8 pulses on the Clock
   WriteBit1 1
Next
WriteBit1 0

WriteBit2 1 ' Latch set to 1

End Sub

' ===============================================
' Set to 0 all the bits from the Shift Register
' except bit 4 (slow or fast speed)
' ===============================================
Sub RazComFast()
Dim i As Integer

WriteBit2 0 ' Latch set to 0
For i = 1 To 8
   WriteBit0 0  ' Write 0
   WriteBit1 0  ' 8 pulses on the Clock
   WriteBit1 1
Next
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock decreasing edge
'WriteBit0 1

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit2 1 ' Latch set to 1

End Sub

' =====================
' Right Ascension +
' (Bit 0)
' =====================
Sub AdPlus()
Dim i As Integer

WriteBit2 0 ' Latch set to 1
For i = 1 To 8
   WriteBit0 0  ' Set to 0
   WriteBit1 0  ' 8 clock pulses
   WriteBit1 1
Next
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge
 
WriteBit2 1 ' Latch set to 1

End Sub

' ======================
' Right Ascension -
' (Bit 1)
' ======================
Sub AdMoins()
Dim i As Integer

WriteBit2 0 ' Latch set to 1
For i = 1 To 8
   WriteBit0 0  ' Set to 0
   WriteBit1 0  ' 8 clock pulses
   WriteBit1 1
Next
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge
 
WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit2 1 ' Latch set to 1

End Sub

' =================
' Declination plus
' (Bit 2)
' =================
Sub DecPlus()
Dim i As Integer

WriteBit2 0 ' Latch set to 1
For i = 1 To 8
   WriteBit0 0  ' Set to 0
   WriteBit1 0  ' 8 clock pulses
   WriteBit1 1
Next
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge
 
WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit2 1 ' Latch set to 1

End Sub

' ==================
' Declination  minus
' (Bit 3)
' ==================
Sub DecMoins()
Dim i As Integer

WriteBit2 0 ' Latch set to 1
For i = 1 To 8
   WriteBit0 0  ' Set to 0
   WriteBit1 0  ' 8 clock pulses
   WriteBit1 1
Next
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge
 
WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit2 1 ' Latch set to 1

End Sub

' =======================================
' Right Ascension plus and fast speed
' (Bit 0 + 4)
' =======================================
Sub AdPlusFast()
Dim i As Integer

WriteBit2 0 ' Latch set to 1
For i = 1 To 8
   WriteBit0 0  ' Set to 0
   WriteBit1 0  ' 8 clock pulses
   WriteBit1 1
Next
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge
 
WriteBit2 1 ' Latch set to 1

End Sub

' =======================================
' Right Ascension minus and fast speed
' (Bit 1 + 4)
' =======================================
Sub AdMoinsFast()
Dim i As Integer

WriteBit2 0 ' Latch set to 1
For i = 1 To 8
   WriteBit0 0  ' Set to 0
   WriteBit1 0  ' 8 clock pulses
   WriteBit1 1
Next
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge 

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge
 
WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit2 1 ' Latch set to 1

End Sub

' ==================================
' Declination plus and fast speed
' (Bit 2 + 4)
' ==================================
Sub DecPlusFast()
Dim i As Integer

WriteBit2 0 ' Latch set to 1
For i = 1 To 8
   WriteBit0 0  ' Set to 0
   WriteBit1 0  ' 8 clock pulses
   WriteBit1 1
Next
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge
 
WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit2 1 ' Latch set to 1

End Sub

' ==================================
' Declination mois and fast speed
' (Bit 3 + 4)
' ==================================
Sub DecMoinsFast()
Dim i As Integer

WriteBit2 0 ' Latch set to 1
For i = 1 To 8
   WriteBit0 0  ' Set to 0
   WriteBit1 0  ' 8 clock pulses
   WriteBit1 1
Next
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge 

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit2 1 ' Latch set to 1

End Sub

' =====================
' Positive Focus
' (Bit 5)
' =====================
Sub FocusPlus()
Dim i As Integer

WriteBit2 0 ' Latch set to 1
For i = 1 To 8
   WriteBit0 0  ' Set to 0
   WriteBit1 0  ' 8 clock pulses
   WriteBit1 1
Next
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge
 
WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit2 1 ' Latch set to 1

End Sub

' =====================
' Negative Focus
' (Bit 6)
' =====================
Sub FocusMoins()
Dim i As Integer

WriteBit2 0 ' Latch set to 1
For i = 1 To 8
   WriteBit0 0  ' Set to 0
   WriteBit1 0  ' 8 clock pulses
   WriteBit1 1
Next
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit2 1 ' Latch set to 1

End Sub

' =======================================
' Positive Focus and fast speed
' (Bit 4 et 5)
' =======================================
Sub FocusPlusFast()
Dim i As Integer

WriteBit2 0 ' Latch set to 1
For i = 1 To 8
   WriteBit0 0  ' Set to 0
   WriteBit1 0  ' 8 clock pulses
   WriteBit1 1
Next
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge
 
WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit2 1 ' Latch set to 1

End Sub

' ====================================
' Negative focus and fast speed
' (Bit 4 et 6)
' ====================================
Sub FocusMoinsFast()
Dim i As Integer

WriteBit2 0 ' Latch set to 1
For i = 1 To 8
   WriteBit0 0  ' Set to 0
   WriteBit1 0  ' 8 clock pulses
   WriteBit1 1
Next
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge
 
WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 1 ' Input line set to 1
WriteBit1 1 ' Clock raising edge
WriteBit1 0 ' Clock falling edge

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit0 0 ' Shift one position
WriteBit1 1
WriteBit1 0

WriteBit2 1 ' Latch set to 1

End Sub
 

Back