#ifndef _TAILCONE_H
#define _TAILCONE._H

/****************************************************************************/
/* Copyright (c) 2000 MBARI.                                                */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  : Tailcone Controller                                           */
/* Filename : tailcone.h                                                    */
/* Author   : Andrew Pearce                                                 */
/* Project  : Dorado AUV Tailcone                                           */
/* Version  : 1.0                                                           */
/* Created  : 01/19/00                                                      */
/* Modified : 01/19/00                                                      */
/* Archived :                                                               */
/****************************************************************************/

/*************** Tailcone Device Serial Channel assignments *****************/

#define RUDDER_SER_CHAN         0
#define ELEVATOR_SER_CHAN       1
#define PROP_MOTOR_SER_CHAN     2

/************ Tailcone Low Power Switch Board Channel assignments **********/

#define RUDDER_LPS_CHAN         0
#define ELEVATOR_LPS_CHAN       1
#define PROP_MOTOR_LPS_CHAN     2

/****************************** Tailcone Commands from MVC *****************/

#define SET_MOTOR_TORQUE        0x31
#define SET_ELEVATOR_POS        0x32
#define SET_RUDDER_POS          0x33
#define SET_CONTROL_VALUES      0x34
#define INITIALIZE_TAILCONE     0x35
#define SET_DEADMAN_TIMEOUT     0x36
#define SAVE_CONFIG_TO_NVRAM    0x37

#define GET_MOTOR_RPM           0x38
#define GET_ACUATOR_POS         0x39
#define GET_CONTROL_STATUS      0x3A
#define GET_HEALTH_STATUS       0x3B
#define GET_ENG_TELEMETRY       0x3C
#define GET_TEMPERATURE         0x3D
#define GET_CURRENT_READINGS    0x3E
#define GET_GND_FAULT_CURRENT   0x3F
#define GET_CONFIURATION        0x40


/****************************** Internal Constants *************************/

#define CTRL_SURFACE_CTRL_PERIOD 2      /* 50Hz control rate               */

#define LIN_ACT_POT_TURNS_PER_INCH  12  /* Linear actuator pot turns/inch  */
#define LIN_ACT_STEPS_PER_TURN     200  /* Linear actuator steps/turn      */

#define LIN_ACT_STEPS_PER_INCH  \
    (LIN_ACT_STEPS_PER_TURN * LIN_ACT_POT_TURNS_PER_INCH)

                                        /* 25.4 mm per inch                */
#define LIN_ACT_STEPS_PER_MM ((LIN_ACT_STEPS_PER_INCH * 254) / 10)

     /* 8 bit A/D. 2 inches of travel = 5v = 4800 (ie 12 * 200 * 2) steps  */
#define LIN_ACT_BITS_TO_STEPS  ((Int16) ((((Int32) bits) * 4800L) / 256))

#define LIN_ACT_BITS_TO_MM     \
    (LIN_ACT_BITS_TO_STEPS(bits) * LIN_ACT_STEPS_PER_MM)

#endif
