Commands to the PIC based controllers
Right now there are 4 controllers: Elevation and Azimuth position control, and Elevation and Azimuth absolute encoder accumulators. Commands are addressed each over the RS-485 interface. The elevation position controller is addressed with the identifier "E". The azimuth position controller is addressed with the identifier "A". The elevation encoder accumulator will be addressed with the identifier "F". The azimuth encoder accumulator will be addressed with the identifier "B". Controllers will not transmit anything on its half duplex RS-485 serial interface unless it receives a request from the PC. The PC is the master of the RS-485 interface.
Safety considerations
The elevation position controller assumes an incremental encoder count of 0x00a is zero degrees, and 0x0787 is 90 degrees. This is used in the elevation limit check. If the encoder indicates the dish is at 90.5 degrees or -.5 degrees, the motor stops. A similar scheme will be used on Azimuth when I get a chance.
Each controller has an internal watchdog timer that resets itself if the timer is not reset every 7ms. This protects against faults internal to the controller. Two other timers are used in the position controllers to detect command activity from the PC. When the PC watchdog timer is turned on, it will stop the motor if there is no valid command from the PC after 5 seconds. The elevation controller will stow the dish if there is no PC activity within 2 minutes and the current encoder position is known (through the initialize encoder command).
A soft reset command is provided to reset any controller from the PC. Program memory has parity checking. If a program parity error occurs, the controller is reset.
Translating encoder values to degrees
There are two sets of encoders for each axis: Elevation has a 128 position incremental encoders on the 5 degrees/revolution shaft and a 4096 position absolute encoder on the 360 degrees/revolution shaft. Azimuth has a 128 position incremental encoder on the 5 degrees/revolution shaft and a 4096 position absolute encoder on a 540 degrees/revolution shaft (1.5:1 gear ratio). The position controllers use the incremental encoders for their closed loop positioning. The absolute encoders are used by Vectortrak to provide absolute position information. This absolute position information (after 16x oversampling) is used by Vectortrak and is also passed by Vectortrak (after scaling) to the position controllers for initialization.
The incremental encoders provide 21.3 encoder counts per degree. This means about 2.816 minutes per count. Zero degrees elevation is assumed to be an encoder count of 0x000A. 90 degrees elevation is assumed to be a count of 0x0787. Azimuth has the same resolution. Zero degrees azimuth is assumed to be an encoder count of 0x3C38. +720 degrees is 0x7870. –720 degrees is 0x0000.
The absolute encoders have 12 bit outputs. A 16x oversampling scheme implemented in the encoder accumulators increases the resolution to 16 bits. This corresponds to about .3296 minutes per count on elevation since there is no gear reduction. Zero degrees elevation is represented by a 16 bit value of 0x005B. A 16 bit value of 0x0000 corresponds to –0.5 degrees. Ninety degrees elevation is represented by 0x405B. This offset is done to prevent rollover problems in elevation. Azimuth is a bit more complicated. A gear reduction is used such that one rotation of the encoder shaft corresponds to 1.5 turns of the dish. The 16 bit value of 0x0000 azimuth is East. The numbers increase as the dish moves counterclockwise from East to North to West to South. At South the 16 bit value is 0x7fff. The numbers continue to increase as it moves counterclockwise past East and North for a second time, ending at West where the count is 0xFFFF. Note that the range from East to North to West can be represented by two values because of the gear reduction. Counter rollover can be avoided by keeping azimuth within the count of 0x0000 and 0xFFFF. Note that because of the gear reduction, the azimuth resolution is about 0.494 minutes per count.
Command Definitions
All commands have the following format:
^A[Axis][command][arguments]CR
- ^A is a control A, or ASCII SOH (start of header) character.
- Axis is one of four values: E for elevation position controller, A for azimuth position controller, F for elevation encoder accumulator or B for azimuth encoder accumulator.
- Command is a request for action or a request for a response from either the position controllers or encoder accumulators.
- Arguments are values that may be needed with the command like encoder values for the initialize command. Note that all hex value letters are lower case (a-f).
- CR is a carriage return
The controller responds with "CR, LF (line feed) > " after a command and any possible return value. For example a read encoder command could respond with:
012f
>
The 012f is the returned value (the encoder value).If a command is bad in some way, for instance a bad argument or an illegal command, the response is:
!
>
The "!" indicates a bad command.The commands and arguments for the position controllers are as follows:
- Stop.
This stops movement to the addressed axis: Command is "s". There are no arguments- Up for elevation axis, clockwise for azimuth axis:
Command is "u". There are no arguments.- Down for elevation, counterclockwise for azimuth:
Command is "d". There are no arguments.- Reset.
Soft reset for addressed axis: Command is "h". There are no arguments.- Initialize encoder.
Initializes encoder value for addressed axis: Command is "i". The argument is 4 hex digits that are the desired initial encoder value. For example, to initialize the elevation encoder to the value 100 (decimal), the command would be: ^AEi0064CR since 100 decimal is 0064 in hex.- Read encoder.
Returns a 4 digit hex value that is the current encoder value. The command is "r". There are no arguments.- Move dish.
This moves the addressed axis to the desired encoder value and maintains it there (closed loop): The command is "m". The argument is the 4 hex digit encoder value. For example, to move Azimuth to encoder value 14, the command is ^AAm000eCR since 14 decimal is 000e hex.- Speed.
This sets a speed on the addressed axis from 0 (stopped) to 255 (full speed). This command must be used in conjunction with the up or down command to make the dish move. This command sets the speed voltage to the motor drive: The command is "v". The argument is a 2 digit hex value representing the speed. For example, to set the elevation speed to half the maximum, the command would be ^AEv7fCR. The argument 7f hex is 127 decimal.- Status.
This command returns a 4 digit hex value representing the status of the addressed controller: The command is "c". There are no arguments. The bits are as follows:
- Bit 7: autostowing due to PC watchdog timer timeout
- Bit 12: Unsafe
- Bit 13: Azimuth position known
- Bit 14: Elevation position known
- Start/Stop PC watchdog timer.
When the PC watchdog timer is enabled, the PC must send a valid command to each controller every 5 seconds. If there is no command activity to a controller after 5 seconds, that controller stops its motor. If the elevation controller sees no PC activity after 2 minutes, the elevation axis will move to the stowed position if the current encoder position is known. The command is "t". The argument to turn the timers on is "1". The argument to turn timers off is "0".Commands for the encoder accumulators are as follows:
Position Controller Introduction
- Read Encoder.
Returns a 4 digit hex value that is the absolute position. The command is "r". There are no arguments.- Reset.
Soft reset for addressed axis: Command is "h". There are no arguments- Write calibration EEPROM.
Command is "w". The argument is 4 hex digits that are the error offset value for the encoder. For example, if zero degrees elevation produces a 16 bit count value of 0x006B (should be 0x005B), then the offset should be 0x0010. The command would be: ^AFw0010CR . Negative values should be in two’s complement form.- WARNING!
Be sure to set calibration to 0000 before determining error. In other words, set calibration ("W" command) to 0000, set dish to 0 degrees, read encoder value, then set encoder calibration with offset command.
Controller Schematics:
Peter Goldman, 12/20/04- Controller Block Diagram
- Azimuth Controller
- Azimuth Speed Isolation Amplifier
- Elevation Controller
- Elevation Speed Isolation Amplifier
- Speed Signal Amplifiers
- Relays