/***************************************************************************

StepperMotor.h

Team Firefox

ME 218A 11/20/09

This software module

  1) Reads input from grapple dial to control the stepper motor

  2) Controls the stepper motor

  3) Keeps track of the number of steps which determines Tom Cruise's position

 

Input:

A0 - Grapple Dial

 

Output:

A1 - stepCMD

A2 - direction

****************************************************************************/

 

/*---------------------------- Include Files ------------------------------*/

#ifndef StepperMotor_h

#define StepperMotor_h

 

#include <string.h>

#include <timers12.h>

#include <stdio.h>

#include <ME218_C32.h>

#include "ADS12.h"

 

/*---------------------------- Module Defines ------------------------------*/

typedef enum {       MOTOR_NOT_IN_RANGE_STATUS,

                     MOTOR_IN_RANGE_STATUS,

                     MOTOR_HIT_FLOOR_STATUS,

                     MOTOR_RESETTING_STATUS

       } MOTOR_STATUS_t;

 

/*---------------------------- Public Function Prototypes ------------------------------*/

void initStepMotor(int);                        //To be called before each game to reset position

 

MOTOR_STATUS_t checkStepMotorStatus(void);      //will run stepper motor using dial input

//Will return one of the following:

//     MOTOR_HIT_FLOOR_STATUS – if Tom Cruise has hit the floor

//     MOTOR_IN_RANGE_STATUS – if Tom Cruise is in range of the computer to download the file

//     MOTOR_NOT_IN_RANGE_STATUS - otherwise   

 

MOTOR_STATUS_t slowVictoryReset(void);          //will return stepper motor to zero position at a

                                                //calibrated victory speed; to be called after the //user wins the game

//Will return one of the following:

//     MOTOR_NOT_IN_RANGE_STATUS – if stepper motor is at the zero position

//     MOTOR_RESETTING_STATUS - otherwise 

 

MOTOR_STATUS_t resetStepMotorStatus(void);      //will slowly return stepper motor to zero position

//Will return one of the following:

//     MOTOR_NOT_IN_RANGE_STATUS – if stepper motor is at the zero position

//     MOTOR_RESETTING_STATUS - otherwise

 

 

//test functions

void calibrateDial(void);         //Will print to screen the conditioned analog input of the dial

void showMotorPos(void);          //Will print to screen the current position of the stepper motor

#endif