Package: rot2prog
ROT2ProgThis is a python interface to theAlfa ROT2Prog Controller. The ROT2Prog is an electronic controller used for turning rotators. The Controller may be connected to one Azimuth and Elevation rotator and operates with direct current motors. The ROT2Prog is designed to work with either an Alfa RAS or BIGRAS or a combination of one azimuth rotator RAU, RAK and a REAL rotator.This package is responsible for implementing the serialprotocolto interact with the ROT2Prog controller. There is also asimulation modelof the ROT2Prog controller included in the package, which can be used for testing when hardware is not available.ContentsGetting StartedInstallationUsageAPISimulationProtocolCommand PacketResponse PacketDegrees Per PulseStop CommandExampleStatus CommandExampleSet CommandExampleGetting StartedIf you intend to use this package with hardware:Press setup keySuntilPSis displayed on the far left screen of the controller.Use the<>keys to set the value (to the right ofPS) toSP.Press the function keyFuntilAis displayed on the far left screen of the controller.Congratulations! Your ROT2Prog will now respond to SPID commands.NOTE: The hardware is not required for testing, seeSimulation.InstallationTherot2progpackage is published on PyPi and can be installed in the terminal.pip install rot2progThis package was developed using Python3.10.2, and has not yet been tested with earlier releases of Python. If using an earlier version of Python, it is recommended to proceed with caution, running thesimulationandstandalone scripttogether to exercise all commands.UsageImportingimportrot2progrot=rot2prog.ROT2Prog('COM1')NOTE: For more information, reference theAPIin/docs/rot2prog.Standalonepython -m rot2prog.utils.runNOTE: The standalone mode offers direct access to thestop,status, andsetcommands, allowing the hardware to be controlled directly from the terminal.SimulationBegin by establishing a connection between the two desired ports:Use a tool such asFree Virtual Serial Portsto connect two virtual ports of the same host.Use a male-male USB cable connected to two physical ports of the same host.Use a male-male USB cable connected to two physical ports on different hosts. In this case, each host must run its own software to communicate.python -m rot2prog.utils.simNOTE: The simulator's serial connection should be established first.NOTE: The simulator does not perfectly match real-world behavior in regard to executing commands. The real system cannot move to a new position instantaneously, whereas the simulator currently does.ProtocolThe SPID protocol supports 3 commands:STOP: Stops the rotator in its current position.STATUS: Returns the current position of the rotator.SET: Tells the rotator to rotate to a given position.The rotator controller communicates with the host using a serial port. The serial communication parameters are:600 bps8 bitsno parity1 stop bitAll commands are issued as 13 byte packets.All responses are received as 12 byte packets.Command PacketByte0123456789101112FieldSTARTH1H2H3H4PHV1V2V3V4PVKENDValue0x570x3?0x3?0x3?0x3?0x0?0x3?0x3?0x3?0x3?0x0?0x?F0x20START- Start byte (always 0x57)H1 - H4- Azimuth as ASCII characters 0-9PH- Azimuth resolution in pulses per degree (ignored in command packet)V1 - V4- Elevation as ASCII characters 0-9PV- Elevation resolution in pulses per degree (ignored in command packet)K- Command0x0F = STOP0x1F = STATUS0x2F = SETEND- End byte (always 0x20)Response PacketByte01234567891011FieldSTARTH1H2H3H4PHV1V2V3V4PVENDValue0x570x0?0x0?0x0?0x0?0x0?0x0?0x0?0x0?0x0?0x0?0x20START- Start byte (always 0x57)H1 - H4- Azimuth as byte valuesPH- Azimuth resolution in pulses per degreeV1 - V4- Elevation as byte valuesPV- Elevation resolution in pulses per degreeEND- End byte (always 0x20)Positions from the response packet are decoded using the following formulas:az=(H1*100)+(H2*10)+H3+(H4/10)-360el=(V1*100)+(V2*10)+V3+(V4/10)-360Degrees Per PulseThe PH and PV values in the response packet reflect the settings of the rotator controller. The ROT2Prog supports the following resolutions (the value is always the same for azimuth and elevation):Degrees per pulsePHPV10x010x010.50x020x020.250x040x04Stop CommandThe stop command stops the rotator immediately in the current position and returns the current position.Command PacketByte0123456789101112FieldSTARTH1H2H3H4PHV1V2V3V4PVKENDValue0x570x000x000x000x000x000x000x000x000x000x000x0F0x20NOTE: The H1-H4, PH, V1-V4 and PV fields are ignored, so only the S, K and END fields are used.Stop Command ExampleExample Response PacketByte01234567891011FieldSTARTH1H2H3H4PHV1V2V3V4PVENDValue0x570x030x070x020x050x020x030x090x040x000x020x20Decoding Example Response Packetaz=(3*100)+(7*10)+2+(5/10)-360=12.5el=(3*100)+(9*10)+4+(0/10)-360=34.0PH=PV=0x02Status CommandThe status command returns the current position of the antenna.NOTE: Status commands can be issued while the rotator is moving and will always return the current position.Command PacketByte0123456789101112FieldSTARTH1H2H3H4PHV1V2V3V4PVKENDValue0x570x000x000x000x000x000x000x000x000x000x000x1F0x20NOTE: The H1-H4, PH, V1-V4 and PV fields are ignored, so only the S, K and END fields are used.Status Command ExampleExample Response PacketByte01234567891011FieldSTARTH1H2H3H4PHV1V2V3V4PVENDValue0x570x030x070x020x050x020x030x090x040x000x020x20Decoding Example Response Packetaz=(3*100)+(7*10)+2+(5/10)-360=12.5el=(3*100)+(9*10)+4+(0/10)-360=34.0PH=PV=0x02Set CommandThe set command tells the rotator to turn to a specific position. The controller does not send a response to this command.Encoding Command PacketH=PH*(az+360)V=PV*(el+360)NOTE: H1-H4 and V1-V4 are H and V converted to ASCII (0x30-0x39, i.e., '0'-'9').Set Command ExampleEncoding Example Command Packetaz = 123.5
el = 77.0
PH = PV = 0x2H=2*(123.5+360)=967V=2*(77.0+360)=874Example Command PacketH = 0967
V = 0874
PH = PV = 0x2Byte0123456789101112FieldSTARTH1H2H3H4PHV1V2V3V4PVKENDValue0x570x300x390x360x370x020x300x380x370x340x020x2F0x20NOTE: The PH and PV values are ignored. The values used by the rotator control unit are set by choosing resolution in the setup menu directly on the controller. These values can be read using the status command if they are unknown.