Skip to content

Commit e89c53a

Browse files
committed
Completed Software Interface Documentation
1 parent a83d695 commit e89c53a

File tree

1 file changed

+57
-3
lines changed

1 file changed

+57
-3
lines changed

rot2proG.py

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import serial
2-
import time
3-
41
'''
52
File: rot2proG.py
63
Author: Jaiden Ferraccioli
@@ -11,11 +8,33 @@
118
and a moving target.
129
'''
1310

11+
import serial
12+
import time
13+
14+
'''
15+
This class defines the control interface for the SPID Elektronik rot2proG antenna rotor controller.
16+
17+
Note: The controller will not change azimuth or elevation values unless the rotor is connected.
18+
19+
Setup: The controller must be set to use the "SPID" protocol. To do this, press the 'S' button on the
20+
controller until it says 'PS' along with the current azimuth and elevation. Then the left or
21+
right buttons on the controller to change between protocols. Select the protocol saying 'SP' in
22+
the 'Horizontal' field of the controller. Once the controller is set to use the SPID protocol,
23+
we must put it into automated mode. To do this, press the 'F' button until the controller reads
24+
'A' along with the current azimuth and elevation. You are now ready to communicate with the
25+
rotor controller.
26+
'''
1427
class Rot2proG:
1528

1629
pulse = 0
1730
debug = False
1831

32+
'''
33+
This sets up the serial connection and pulse value.
34+
When set to true, the debugging parameter allows for information such as
35+
asimuth, elevation and pulse to be printed out when functions are called.
36+
Debugging defualts to False.
37+
'''
1938
def __init__(self, debugging=False):
2039
self.ser = serial.Serial(port='/dev/ttyUSB0',baudrate=600, bytesize=8, parity='N', stopbits=1, timeout=None)
2140
self.status()
@@ -24,9 +43,19 @@ def __init__(self, debugging=False):
2443
print(self.ser.name)
2544
print("Pulse: " + str(self.pulse) + "\n")
2645

46+
'''
47+
This makes sure that the serial connection is closed when the class is deleted
48+
or the program terminates
49+
'''
2750
def __del__(self):
2851
self.ser.close()
2952

53+
'''
54+
Send a STATUS command to the controller, which requests the current azimuth
55+
and elevation of the rotor. The azimuth, elevation and pulse are then computed,
56+
the pulse is set and the azimuth, elevation and pulse are returned as a list (first
57+
element being azimuth, the second being elevation, and the third being pulse).
58+
'''
3059
def status(self):
3160
cmd = ['\x57','\x00','\x00','\x00','\x00','\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x1f', '\x20']
3261
packet = "".join(cmd)
@@ -41,6 +70,8 @@ def status(self):
4170
ph = ord(rec_packet[5])
4271
pv = ord(rec_packet[10])
4372

73+
ret = [az, el, ph]
74+
4475
assert(ph == pv)
4576
self.pulse = ph
4677

@@ -51,6 +82,15 @@ def status(self):
5182
print("PH: " + str(ph))
5283
print("PV: " + str(pv) + "\n")
5384

85+
return ret
86+
87+
'''
88+
Send a STOP command to the controller, which causes the rotor to stop moving and
89+
return the current azimuth, elevation and pulse of the rotor where it stopped. The
90+
azimuth, elevation and pulse are then computed, the pulse is set and the azimuth,
91+
elevation and pulse are returned as a list (first element being azimuth, sencond
92+
being elevation and the third being pulse).
93+
'''
5494
def stop(self):
5595
cmd = ['\x57','\x00','\x00','\x00','\x00','\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x0f', '\x20']
5696
packet = "".join(cmd)
@@ -65,6 +105,8 @@ def stop(self):
65105
ph = ord(rec_packet[5])
66106
pv = ord(rec_packet[10])
67107

108+
ret = [az, el, ph]
109+
68110
assert(ph == pv)
69111
self.pulse = ph
70112

@@ -75,6 +117,14 @@ def stop(self):
75117
print("PH: " + str(ph))
76118
print("PV: " + str(pv) + "\n")
77119

120+
return ret
121+
122+
'''
123+
send a SET command to the controller, which causes the rotor to adjust its position
124+
to the azimuth and elevation specified by the azi and eli parameters respecitvely.
125+
The azi and eli parameters are floating point values that specify the desired position.
126+
There is no response to the SET command, thus nothing to return.
127+
'''
78128
def set(self, azi, eli):
79129
az = "0" + str((self.pulse * (azi + 360)))
80130
el = "0" + str((self.pulse * (eli + 360)))
@@ -94,6 +144,10 @@ def set(self, azi, eli):
94144

95145
time.sleep(1)
96146

147+
'''
148+
Calls the STATUS, STOP and SET functions multiple times
149+
in order to test the rot2proG class functionality
150+
'''
97151
def test(self):
98152
rot = Rot2proG(True)
99153
rot.status()

0 commit comments

Comments
 (0)