Escolar Documentos
Profissional Documentos
Cultura Documentos
Module
Motion.c
Revision
1.0
Description
This is Motion module. Functions to perform different motions.
Notes
Different error <-> different calibration speed?
History
When
Who
What/Why
----------------------02/12/2015
11:22 Sky
Added Shoot
02/11/2015 09:50 Sky
Added CalibrateForward
02/10/2015 10:56
Sky
Initial version
****************************************************************************/
//#define testMotor
#include "ES_Configure.h"
#include "ES_Framework.h"
#include "ES_DeferRecall.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
"inc/hw_memmap.h"
"inc/hw_types.h"
"inc/hw_gpio.h"
"inc/hw_sysctl.h"
"driverlib/sysctl.h"
"driverlib/pin_map.h" // Define PART_TM4C123GH6PM in project
"driverlib/gpio.h"
"inc/hw_ssi.h"
"inc/hw_nvic.h"
"PWM4Wheel.h"
"Motion.h"
"WheelRPMControl.h"
"PWM4ShootMotor.h"
#define LEFTWHEEL 1
#define RIGHTWHEEL 2
#define LEFT
0
#define RIGHT 1
#define
#define
#define
#define
SPEEDLV1 0
SPEEDLV2 1
SPEEDLV3 2
SPEEDLVCLIMB 2
#define FORWARD 0
#define BACKWARD 1
/*****************************Constants**************************************/
static const uint16_t InnerWheelRPM4Turn[3] = {20, 20, 15};
static const uint16_t OuterWheelRPM4Turn[3] = {75, 80, 30};
static const uint16_t LeftWheelRPM4Move[3] = {30, 85, 60};
static const uint16_t RightWheelRPM4Move[3] = {30, 85, 60};
static const uint16_t RotateRPM = 20;
/*************************Module Variables***********************************/
/*******************************Public Functions*****************************/
/********************************************************************
FUNCTION TurnRight
ARGUMENTS: a integer represent the speed level
RETURN: no return
DESCRIPTION: set the motor speed and direction to turn right
********************************************************************/
void TurnRight(uint8_t SpeedLv)
{
//set direction for motors first
SetDirection(FORWARD, LEFTWHEEL);
SetDirection(FORWARD, RIGHTWHEEL);
SetTargetRPMLeft(OuterWheelRPM4Turn[SpeedLv]);
SetTargetRPMRight(InnerWheelRPM4Turn[SpeedLv]);
}
/********************************************************************
FUNCTION TurnLeft
ARGUMENTS: a integer represent the speed level
RETURN: no return
DESCRIPTION: set the motor speed and direction to turn left
********************************************************************/
void TurnLeft(uint8_t SpeedLv)
{
//set direction for motors first
SetDirection(FORWARD, LEFTWHEEL);
SetDirection(FORWARD, RIGHTWHEEL);
SetTargetRPMLeft(InnerWheelRPM4Turn[SpeedLv]);
SetTargetRPMRight(OuterWheelRPM4Turn[SpeedLv]);
}
/********************************************************************
FUNCTION MoveForward
ARGUMENTS: a integer represent the speed level
RETURN: no return
DESCRIPTION: set the motor speed and direction to move forward
********************************************************************/
void MoveForward(uint8_t SpeedLv)
{
//set direction for motors first
printf("Forward!\n\r");
SetDirection(FORWARD, LEFTWHEEL);
SetDirection(FORWARD, RIGHTWHEEL);
SetTargetRPMLeft(LeftWheelRPM4Move[SpeedLv]);
SetTargetRPMRight(RightWheelRPM4Move[SpeedLv]);
}
/********************************************************************
FUNCTION MoveBackward
#ifdef testMotor
#define clrScrn()
#define goHome()
#define clrLine()
printf("\x1b[2J")
printf("\x1b[1,1H")
printf("\x1b[K")
#define LEFTWHEEL 1
#define RIGHTWHEEL 2
int main(void)
{
// Set the clock to run at 40MhZ using the PLL and 16MHz external crysta
l