/****************************************************************************/
/* Copyright 1991 to 1993 MBARI                                             */
/****************************************************************************/
/* Summary  : Moog Motor Micro - Serial Interface Commands                  */
/* Filename : moogcmd.h                                                     */
/* Author   : Andrew Pearce                                                 */
/* Project  : Tiburon ROV                                                   */
/* Version  : Version 1.0                                                   */
/* Created  : 05/16/91                                                      */
/* Modified : 06/18/93                                                      */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/* $Header: /usr/tiburon/.cvsroot/micro/h/moogcmd.h,v 1.1.1.1 1997/05/02 17:15:39 pean Exp $
 * $Log: moogcmd.h,v $
 * Revision 1.1.1.1  1997/05/02 17:15:39  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 2.3  94/08/26  16:30:09  16:30:09  pean (Andrew Pearce)
 * Master/Slave version of serial protocol.
 * Added warning and alarm levels for temperature alarm
 * Water alarm threshold now externally settable in K Ohms
 *  Alarm added for NV RAM Initialization
 *
 * Revision 2.2  94/02/01  10:41:30  10:41:30  pean (Andrew Pearce)
 * Added commands to set Frame Acknowledge Timeout, get Retransmission
 * statistics, and to enable automatic motor disable on serial link failure.
 * Added MOTOR_DISABLE_SRQ alarm reporting if motor auto disables
 *
 * Revision 2.1  93/11/12  11:02:48  11:02:48  pean (Andrew Pearce)
 * Clean up in preparation for archiving
 *
 * Revision 2.0  93/06/18  16:43:51  16:43:51  pean (Andrew Pearce)
 * Added Keep Alive Serial Packets
 * Updated default Controller Gains & Constants after Thruster Characterization
 *
 * Revision 1.4  93/05/20  13:39:56  13:39:56  pean (Andrew Pearce)
 * Controller algorithms tested with vxWorks software on dyno.
 * Data acquisition mode added for motor characterization
 * IIR Filter added to velocity filter
 *
 * Revision 1.3  92/11/11  15:18:25  15:18:25  pean (Andrew Pearce)
 * Final version for prototype after testing regeneration limit mode
 *
 * Revision 1.3  92/09/01  12:05:39  12:05:39  pean (Andrew Pearce)
 * *** empty log message ***
 *
 * Revision 1.1  92/06/29  10:08:08  10:08:08  pean (Andrew Pearce 408-647-3746)
 * Initial revision
 *
 * Revision 1.2  92/06/12  17:11:37  17:11:37  pean (Andrew Pearce 408-647-3746)
 * Fixed checkTemperature, inverted sense of motor status & foldback signals
 * Added getMotorTorqueCmd serial command to return commanded torque
 * Modified microResetCmd to send CMD_OK and wait 50 msec before hard reset
 * Added board & motor serial number, Software revision read functions
 *
 * Revision 1.1  92/05/13  17:40:09  17:40:09  pean (Andrew Pearce 408-647-3746)
 * Initial revision
 * Added getMotorTorqueCmd serial command to return commanded torque
 *
*/
/****************************************************************************/

                                        /* Motor Fault Status Codes         */
#define STATUS_UNKNOWN          0x00    /* Motor status unknown             */
#define MOTOR_NO_FAULT          0x01    /* No fault detected                */
#define MOTOR_CONTROLLER_VOLTS  0x02    /* Motor controller under-voltage   */
#define MOTOR_CONTROLLER_TEMP   0x03    /* Motor controller temperature     */
#define MOTOR_STALL             0x04    /* Motor has stalled                */
#define MOTOR_RESOLVER          0x05    /* Motor Resolver Failure           */
#define MOTOR_OVERCURRENT       0x06    /* Motor overcurrent                */
#define MOTOR_FAULT             0x07    /* Other motor fault condition      */

                                        /* Motor Application Serial Commands*/
#define SET_MOTOR_CMD_TORQUE    0x01    /* Set Motor Commanded Torque       */
#define GET_MOTOR_VELOCITY      0x02    /* Get Motor Velocity Command       */
#define SET_TORQUE_OFFSET       0x03    /* Set Motor Torque Offset Command  */
#define GET_TORQUE_OFFSET       0x04    /* Get Motor Torque Offset Command  */
#define SET_MOTOR_CTRL_MODE     0x05    /* Set Motor Control Mode           */
#define GET_MOTOR_CTRL_MODE     0x06    /* Get Motor Control Mode           */
#define GET_MOTOR_STATUS        0x07    /* Get Motor Status Command         */
#define GET_MOTOR_FOLDBACK      0x08    /* Get Motor Foldback Status Cmd    */
#define MOTOR_ENABLE            0x09    /* Enable Motor Command             */
#define MOTOR_DISABLE           0x0a    /* Disable Motor Command            */

#define WRITE_NV_RAM            0x0b    /* Write Motor Non-volatile RAM Cmd */
#define GET_NV_CYCLES           0x0c    /* Get number of NV RAM Cycles Cmd  */
#define GET_NV_DATE_TIME        0x0d    /* Get NV RAM Date and Time Command */
#define GET_TEMPERATURE         0x0e    /* Get Temperature Sensor Value     */
#define GET_TEMP_ALARM_STATUS   0x0f    /* Get Temperature Alarm Status     */
#define GET_MOTOR_CMD_TORQUE    0x10    /* Get Motor Commanded Torque       */
#define GET_MOTOR_SER_NO        0x11    /* Get Motor Serial Number String   */
#define SET_MOTOR_SER_NO        0x12    /* Set Motor Serial Number String   */
#define GET_TEMP_ALARM_THRESH   0x13    /* Get temperature alarm threshold  */
#define SET_TEMP_ALARM_THRESH   0x14    /* Set temperature alarm threshold  */

#define SET_MOTOR_CMD_THRUST    0x15    /* Set Motor Commanded Thrust       */
#define SET_MOTOR_CMD_VELOCITY  0x16    /* Set Motor Commanded Velocity     */
#define SET_MOTOR_CMD_POWER     0x17    /* Set Motor Commanded Power        */

#define SET_CURRENT_MODE_GAIN   0x18    /* Set current control mode gain    */
#define GET_CURRENT_MODE_GAIN   0x19    /* Get current control mode gain    */
#define SET_TORQUE_MODE_GAIN    0x1a    /* Set torque control mode gain     */
#define GET_TORQUE_MODE_GAIN    0x1b    /* Get torque control mode gain     */
#define SET_VEL_MODE_GAINS      0x1c    /* Set velocity control mode gains  */
#define GET_VEL_MODE_GAINS      0x1d    /* Get velocity control mode gains  */
#define SET_LINEAR_MODE_GAINS   0x1e    /* Set linearized control mode gains*/
#define GET_LINEAR_MODE_GAINS   0x1f    /* Get linearized control mode gains*/

#define SET_DYNAMIC_MODEL_K4    0x20    /* Set thruster dynamic model param */
#define GET_DYNAMIC_MODEL_K4    0x21    /* Get thruster dymanic model param */

#define CALC_VELOCITY_OFFSET    0x22    /* Measure analog velocity offset   */
#define GET_MOTOR_TACH          0x23    /* Get motor tachometer velocity    */

#define MOTOR_REGEN_LIMIT_ON    0x24    /* Enable motor regen limit mode    */
#define MOTOR_REGEN_LIMIT_OFF   0x25    /* Disable motor regen limit mode   */
#define SET_REGEN_TORQUE_LIMIT  0x26    /* Set motor regen torque limit     */
#define GET_REGEN_TORQUE_LIMIT  0x27    /* Get motor regen torque limit     */

#define GET_WATER_ALARM_THRESH  0x28    /* Get water alarm threshold        */
#define SET_WATER_ALARM_THRESH  0x29    /* Set water alarm threshold        */
#define GET_WATER_ALARM         0x2A    /* Get water alarm status word      */

#define ENABLE_DAS_MODE         0x2B    /* Enable DAS measurement mode      */
#define GET_DAS_MODE_DATA       0x2C    /* Read DAS mode measurements       */

#define ENABLE_AUTO_DISABLE     0x2D    /* Motor Stop on serial link failure*/
#define MOTOR_STOP              0x2E    /* Immediate Motor Stop             */

                                        /* Motor Application SRQ's          */
#define MOTOR_FB_ON_SRQ      APPLIC_SRQ_BASE | 0x01 /* Foldback Detected    */
#define MOTOR_FB_OFF_SRQ     APPLIC_SRQ_BASE | 0x02 /* Foldback Undetect    */
#define MOTOR_CTRL_VOLTS_SRQ APPLIC_SRQ_BASE | 0x03 /* Controller Voltage   */
#define MOTOR_CTRL_TEMP_SRQ  APPLIC_SRQ_BASE | 0x04 /* Controller Temperatur*/
#define MOTOR_STALL_SRQ      APPLIC_SRQ_BASE | 0x05 /* Motor Stall          */
#define MOTOR_RESOLVER_SRQ   APPLIC_SRQ_BASE | 0x06 /* Motor Resolver Fault */
#define MOTOR_CURRENT_SRQ    APPLIC_SRQ_BASE | 0x07 /* Over Current Fault   */
#define MOTOR_STATUS_SRQ     APPLIC_SRQ_BASE | 0x08 /* Motor Status Unknown */
#define MOTOR_FAULT_SRQ      APPLIC_SRQ_BASE | 0x09 /* Other Motor Fault    */
#define MOTOR_NO_FAULT_SRQ   APPLIC_SRQ_BASE | 0x0A /* No Motor Fault       */
#define MOTOR_DISABLE_SRQ    APPLIC_SRQ_BASE | 0x0B /* Motor Disable        */
#define MOTOR_NVRAM_INIT_SRQ APPLIC_SRQ_BASE | 0x0C /* NV RAM Initialized   */

