Project solved at the Department of Experimental Physics of FMFI UK
The mount is connected to the computer via a serial line (RS232). Since modern laptops and PCs no longer have a serial port, a standard USB-> RS232 converter must be used, which creates a serial port when connected to a computer. For compatibility reasons and based on the mount manufacturer's recommendations, we have decided for converter with FTDI chipset. The serial port settings of the mount are:
The complete instruction set is quite comprehensive, as the mount is primarily intended for shooting panoramas with cameras. For our purposes, we only need a few commands to direct the mount and determine the status of the mount:
We used the pyserial library to control mount in Python.
So that the user does not have to find out on which serial port the mount is connected, we use special function in the "pyserial" library to find out the list of ports. Then we open each of the ports with parameters as required by iPANO (with a timeout of 1 s) and ask the device with the command ": 01INF #" for identification. If it answers ": 10INF3600 #", the mount is connected to the given port. Otherwise the communication will end on timeout and we will try another serial port:
myportdevice='' ports = serial.tools.list_ports.comports(include_links=False) iPANOfound=False for port in ports : print('Checking '+port.device) ser = serial.Serial(port.device,115200, timeout=1) # open serial port ser.write(b':01INF#') s=ser.read(11) if s==b':10INF3600#': print('iPANO mount found on '+port.device) myportdevice=port.device iPANOfound=True break ser.close() if iPANOfound==False: print('iPANO mount not found') quit() |
We use the command GOTO (": 01SSLnTTTTTZZZZZ #") to direct the mount and the command ": 01GAS #" to find out if the mount is still in motion. The fact that the mount is in motion is indicated by the number 1 in the 18th place in the text of the answer. After the GOTO command, we have to wait a while until the mount starts, otherwise we could get the answer that the mount is not moving yet. The direction in which the mount is to be rotated is stored in the variables "azimuth" and "height":
command=':01SSL+%s%s#' % (str((int)(100*azimut)).zfill(5),str((int)(100*vyska)).zfill(5)) command=command.encode() #conversion to the sequence of 8-bit characters ser.write(command) #move to the next position ser.read(19) #ignore the answer time.sleep(0.1) #wait for the movement is started ser.write(b':01GAS#') #read the position and the state of the mount s=ser.read(19) while s[17]== ord('1'): #ASCII code of 1 = is moving ser.write(b':01GAS#') #read the position and the state of the mount s=ser.read(19) |
When measuring in the field, it can easily happen that the connection between the notebook and the mount fails (for example, if the USB connection cables are handled carelessly). As some types of measurements can take up to two hours, it is crucial to ensure that the measurement does not end with such an error, but that it is possible to continue it after the error has been rectified. Our concept of exception handling is as follows:
Program Exception Handling Concept:
... try: commands for the communication with port; except (serial.serialutil.SerialException,IndexError): print('\a') print("Connection to the iPANO mount is lost. Reconnect and press any key...") input('') repeat commands for the communication with port; ... |
The test program reads the sequence of measuring points (declination, azimuth) from the prepared file, gradually directs the mount in individual directions, waits one second (measurement simulation) and saves the current direction to the output file. Since we are counting on building the program into the GUI, we use functions "filedialog.askopenfilename ()" and "filedialog.asksaveasfilename ()" from the "tkinter" library to open the file and choose the name of the output file.
Full test program: ipano.py