/****************************************************************************/
/* Copyright 1994 to 1996 MBARI                                             */
/****************************************************************************/
/* Summary  : PT10 Pan/Tilt Unit Definitins and Constants                   */
/* Filename : pt10.h                                                        */
/* Author   : Andrew Pearce                                                 */
/* Project  : Tiburon Pan & Tilt Controller For PT10                        */
/* Version  : 1.0                                                           */
/* Created  : 04/08/94                                                      */
/* Modified : 03/13/96                                                      */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/* $Header: /usr/tiburon/.cvsroot/micro/h/pt10.h,v 1.1.1.1 1997/05/02 17:15:40 pean Exp $
 * $Log: pt10.h,v $
 * Revision 1.1.1.1  1997/05/02 17:15:40  pean
 * Initial release of the microcontroller software after Tiburon
 * Moolpool Dive to test IView, Lapboxes, modified Power can
 * GF/5V using bus capacitance mode.
 *
 * Revision 1.2  95/11/10  14:42:22  14:42:22  pean (Andrew Pearce)
 * Added Software Position Limit Switches. Fixed Temeprature Sensor Range
 *
 * Revision 1.1  95/03/24  10:04:25  10:04:25  pean (Andrew Pearce)
 * Initial revision
 *
 */
/****************************************************************************/

#define POT_GEAR_RATIO           100L
#define POT_FULLSCALE          0xffff
#define POT_RANGE                 342

#define PT_10_GEAR_RATIO          88L
#define PT_25_GEAR_RATIO         160L

#define PT_STEPS_PER_REV         200L
#define PT_RANGE                 360L

#define PAN_AXIS_GUARD            130
#define TILT_AXIS_GUARD            75

#define PT_CAL_STEP_DEGS            5
#define PT_CAL_ANALOG_SAMPLES     100
#define PAN_AXIS_CAL_RANGE        330
#define TILT_AXIS_CAL_RANGE       180

#define PT_DEGS_TO_DAC_BITS(degs) \
 ((Byte) ((( ((Int32) ((degs / 100) + (POT_RANGE / 2))) * ((1 << PT_DAC_BITS) -1)) / POT_RANGE)))

/* For PT10 steps per degree =  200 * 88  / 360 = 48.88 */
/* For PT25 steps per degree =  200 * 160 / 360 = 88.88 */


#define PT_MOVE_TIMEOUT          1000   /* 10 sec timeout for moves         */
#define PT_ZERO_LOOP_TRYS          10   /* Try zeroing position 10 times    */
#define PT_INITIALIZE_TRYS         10   /* Initialization trys              */
#define PT_ZERO_OFFSET      (Int32) 1   /* Max Zero Calibration Offset      */
#define PT_XTRA_SETTLING_DELAY    100   /* Additional settling delay        */
#define PT_POSITION_DELTA         300   /* 3.0 degres error before alarm    */
#define PT_OFFSET_SAMPLES           5   /* Num analog feedback samples      */
#define PT_POS_MOVE_DELTA          50   /* 0.5 degs position difference for */
                                        /* stopped moving decision          */

                                        /* Pan/Tilt Command Strings         */
#define PT_ADDRESS_BASE           'A'
#define PT_SOFTWARE_RESET      "\003"
#define PT_CMD_ABORT           "\033"
#define PT_SOFT_RESET             "@"
#define PT_CLEAR_PARAMS           "C"
#define PT_DIVIDE_RES             "D"
#define PT_SETTLING_TIME          "E"
#define PT_PROGRAM_GO             "G"
#define PT_RESOLUTION             "H"
#define PT_INITIAL_VEL            "I"
#define PT_RAMP_SLOPE             "K"
#define PT_LIMIT_SWITCH           "l"
#define PT_MOVE                   "M"
#define PT_SET_ORIGIN             "O"
#define PT_PROGRAM_MODE           "P"
#define PT_STORE_PARAMS           "S"
#define PT_SLEW_VEL               "V"
#define PT_SET_CURRENT            "Y"
#define PT_READ_POSITION          "Z"
#define PT_READ_LIMITS            "]"
#define PT_READ_NVRAM             "["
#define PT_READ_POSITION_CHR      'Z'
#define PT_MOVE_CHR               'M'
#define PT_READ_LIMITS_CHR        ']'
#define PT_GET_ID                 " "

                                        /* Convert P/T Param to Integer     */
#define PT_PARAM_VALUE(high, low) ((Int16) (((Int32) 14700000) / ((((Nat32) 65536) - ((high << 8) + low)) * 12)))

                                        /* Addresses of various P/T         */
                                        /* Parameters in Stepper Controller */
#define RESOLUTION_MODE          1985
#define DIVIDE_FACTOR            1987
#define ACCEL_SLOPE              1990
#define DECEL_SLOPE              1991
#define HOLD_CURRENT             1996
#define RUN_CURRENT              1997
#define SETTLING_TIME            1998
#define INITIAL_VEL_LOW          2006
#define INITIAL_VEL_HIGH         2007
#define SLEW_VELOCITY_LOW        2011
#define SLEW_VELOCITY_HIGH       2012

