Professional Documents
Culture Documents
Motor
Motor
Module
Motor.c
Revision
1.0.1
Description
This modules contain all helper functions for servo motors (including PopUp Motors
and Teraforming Motors). Helper functions for Rocket Motor(DC Motor) are inside
the
RocketMotorService
Notes
History
When Who
-------------- ---
****************************************************************************/
/*----------------------------- Include Files -----------------------------*/
/* include header files for this state machine as well as any machines at the
next lower level in the hierarchy that are sub-machines to this machine
*/
#include "ES_Configure.h"
#include "ES_Framework.h"
#include "ES_Port.h"
#include "ES_DeferRecall.h"
#include "ES_Timers.h"
#include "termio.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "inc/hw_sysctl.h"
#include "driverlib/sysctl.h"
#include "driverlib/pin_map.h" // Define PART_TM4C123GH6PM in project
#include "driverlib/gpio.h"
#include "PWM16Tiva.h"
#include "ADMulti.h"
#include "Motor.h"
#include "Knob.h"
#include "PopUpButton.h"
#include "Lever.h"
/****************************************************************************
Function
SetTeraMotor
Parameters: a float variable indicating KnobValue
Returns: none
Description: this member function set the TeraMotor according to the knob value
****************************************************************************/
void SetTeraMotor(float KnobValue){
//calculate the pulse width in terms of ticks, the clock is 0.8 uS clock
float TeraPulseWidthf = (2.4 - (2.4-0.6)*KnobValue)*1250.0;
uint16_t TeraPulseWidth = TeraPulseWidthf;
//set TeraMotor positon using PWM_TIVA_SetPulseWidth
PWM_TIVA_SetPulseWidth(TeraPulseWidth, TeraMotor);
}
/****************************************************************************
Function
SetPopUpMotorX, ResetPopUpMotorX
Parameters: None
Returns: None
Description: this member function set the PopUpMotors
****************************************************************************/
void SetPopUpMotor1(void){
//calculate proper pulse width for popup motor1, the range for pulse width is
0.6*1250~2.6*1250
float PulseWidthf = (.6+ (2.6-0.6)*0.25)*1250.0;
uint16_t PulseWidth = PulseWidthf;
//set pulse width for popup motor1 using PWM_TIVA_SetPulseWidth
PWM_TIVA_SetPulseWidth(PulseWidth, PopUpMotor1);
}
void ResetPopUpMotor1(void){
//reset popup motor1 to initial position using PWM_TIVA_SetDuty
PWM_TIVA_SetDuty(3, PopUpMotor1);
}
void SetPopUpMotor2(void){
//calculate proper pulse width for popup motor2
float PulseWidthf = 0.52*1250.0;
uint16_t PulseWidth = PulseWidthf;
//set pulse width for popup motor2 using PWM_TIVA_SetPulseWidth
PWM_TIVA_SetPulseWidth(PulseWidth, PopUpMotor2);
}
void ResetPopUpMotor2(void){
//reset popup motor2 to initial position using PWM_TIVA_SetDuty
PWM_TIVA_SetDuty(8, PopUpMotor2);
void SetPopUpMotor3(void){
//calculate proper pulse width for popup motor3
float PulseWidthf = (0.6+ (2.6-0.6)*0.05)*1250.0;
uint16_t PulseWidth = PulseWidthf;
//set pulse width for popup motor3 using PWM_TIVA_SetPulseWidth
PWM_TIVA_SetPulseWidth(PulseWidth, PopUpMotor3);
}
void ResetPopUpMotor3(void){
//reset popup motor3 to initial position using PWM_TIVA_SetDuty
PWM_TIVA_SetDuty(8, PopUpMotor3);
}
/*------------------------------- Footnotes -------------------------------*/
/*------------------------------ End of file ------------------------------*/