06.07.2013 Views

Final Report - Claymore - Grand Valley State University

Final Report - Claymore - Grand Valley State University

Final Report - Claymore - Grand Valley State University

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Offensive Robot Controller Program<br />

// AUTHOR: TEAM 6<br />

// COURSE: EGR345 PROJECT<br />

// DATE: 11-12-06<br />

// FILENAME: OFFENSE_V1.C<br />

// DESCRIPTION: THIS PROGRAM IMPLEMENTS A MOSTLY-AUTONOMOUS MOTION CONTROLLER FOR<br />

// THE DEFENSIVE ROBOT.<br />

#include <br />

#include <br />

#include <br />

#include <br />

#define C_MAX 255 // Maximum PWM output<br />

#define C_MIN 255 // Minimum PWM output<br />

#define CLK_ms 10 // update every 10 ms<br />

#define US_OFF 1<br />

#define THEM_OFF 3<br />

#define THEM_DEF 4<br />

#define OPEN 1<br />

#define CLOSED 0<br />

#define BALL 1<br />

#define NO_BALL 0<br />

#define PLAY_GAME 1<br />

#define END_GAME 0<br />

int accel = 16,<br />

direction = 0,<br />

moving = 0, // Motor starts from rest<br />

pwm_out = 0, // PWM output<br />

SNEG = 0x80, // PWM output that overcomes static friction, negative direction<br />

SPOS = 0x80, // PWM output that overcomes static friction, positive direction<br />

KNEG = 0x80, // Lowest PWM output that keeps motor moving, negative direction<br />

KPOS = 0x80, // Lowest PWM output that keeps motor moving, positive direction<br />

rpos[5],<br />

START = 0,<br />

Goal[] = {0, 0, 0, 0},<br />

gmin[] = {0, 21, 106, 191},<br />

gmax[] = {0, 63, 149, 234};<br />

unsigned int CNT_timer0; // The delay time<br />

// FUNCTION PROTOTYPES<br />

void AD_setup(void);<br />

int db(int c_target);<br />

void PWM_init();<br />

void PWM_update(int value);<br />

int v_out(int v_adj);<br />

void IO_setup();<br />

void IO_update();<br />

void CLK_setup(void);<br />

int Reload(void);<br />

int AttackGoal(int goal);<br />

void FireCannon(void);<br />

void Delay(int ticks);<br />

// FUNCTION DECLARATIONS<br />

void Delay(int ticks)<br />

{<br />

// ticks are approximately 1ms<br />

volatile int i, j;<br />

for(i = 0; i < ticks; i++)<br />

{<br />

for(j = 0; j < 1000; j++){}<br />

}<br />

}<br />

50

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!