ReviewEssays.com - Term Papers, Book Reports, Research Papers and College Essays
Search

Programming

Essay by   •  February 19, 2011  •  Study Guide  •  869 Words (4 Pages)  •  961 Views

Essay Preview: Programming

Report this essay
Page 1 of 4

Evaluation

Overall, the project was fairly straight forward and should have been easy to build. Unfortunately we had our problems but managed to overcome most ofthem. We achieved our aim in that we built a functional automated telescope mount, but we didn't achieve the accuracy that we really required. Our tracking function was also unfinished but this could be easily implemented through the development of the software given time. All in all it was a rewarding experience building a project and getting the desired results.

Appendices

Appendix: A Ð'- Telescope Mount Program (telescopeMount.c)

/* I/O Definitions */

int KEYPAD = 0x1F;/* mask for keypad */

int DIGITAL_INPUT = 0x7fff; /* Adress of digital inputs to be used */

/* Keypad Button Definitions */

int X_BUTTON = 0x19;

int Y_BUTTON = 0x1D;

int CALIBRATE_BUTTON = 0x20;

int ONE_BUTTON = 0x01;

int TWO_BUTTON = 0x11;

int THREE_BUTTON = 0x09;

int FOUR_BUTTON = 0x05;

int FIVE_BUTTON = 0x15;

int SIX_BUTTON = 0x0D;

int SEVEN_BUTTON = 0x03;

int EIGHT_BUTTON = 0x13;

int NINE_BUTTON = 0x0B;

int ZERO_BUTTON = 0x17;

int DECIMAL_BUTTON = 0x07;

int ENTER_BUTTON = 0x0F;

int START_BUTTON = 0x1B;

int STOP_BUTTON = 0x1F;

/* Reads Coordinate From Keypad */

float readCoordinate()

{

float coordinate = 0.0; /* value to return */

float numberFactor = 100.0;

float numberPressed = -1.0; /* stores value of number pressed on keypad */

while(!((KEYPAD & peek(DIGITAL_INPUT)) == ENTER_BUTTON)

&& (numberFactor > .001))

{

if((KEYPAD & (peek(DIGITAL_INPUT))) == ONE_BUTTON)

numberPressed = 1.0;

else if((KEYPAD & (peek(DIGITAL_INPUT))) == TWO_BUTTON)

numberPressed = 2.0;

else if((KEYPAD & (peek(DIGITAL_INPUT))) == THREE_BUTTON)

numberPressed = 3.0;

else if((KEYPAD & (peek(DIGITAL_INPUT))) == FOUR_BUTTON)

numberPressed = 4.0;

else if((KEYPAD & (peek(DIGITAL_INPUT))) == FIVE_BUTTON)

numberPressed = 5.0;

else if((KEYPAD & (peek(DIGITAL_INPUT))) == SIX_BUTTON)

numberPressed = 6.0;

else if((KEYPAD & (peek(DIGITAL_INPUT))) == SEVEN_BUTTON)

numberPressed = 7.0;

else if((KEYPAD & (peek(DIGITAL_INPUT))) == EIGHT_BUTTON)

numberPressed = 8.0;

else if((KEYPAD & (peek(DIGITAL_INPUT))) == NINE_BUTTON)

numberPressed = 9.0;

else if((KEYPAD & (peek(DIGITAL_INPUT))) == ZERO_BUTTON)

numberPressed = 0.0;

else if((KEYPAD & (peek(DIGITAL_INPUT))) == DECIMAL_BUTTON)

{

if(numberFactor == 10.0)

coordinate = coordinate / 100.0;

else if(numberFactor == 1.0)

coordinate = coordinate / 10.0;

numberFactor = .1;

printf("Enter coordinate:%fn", coordinate);

sleep(.25);

}

if(numberPressed != -1.0) /* User has pressed a number */

{

coordinate = coordinate + (numberPressed * numberFactor);

numberFactor = (numberFactor / 10.0); /* sets for next use */

numberPressed = -1.0; /* reset variable */

printf("Enter coordinate:%fn", coordinate);

sleep(.25);

}

}

/* if no leading zeros where entered by user */

if(numberFactor == 10.0)

coordinate = coordinate / 100.0;

else if(numberFactor == 1.0)

coordinate = coordinate / 10.0;

return(coordinate);

}

/* Function to drive stepper motor */

void runStepperMotor(int motorNumber, int dir, float distance)

{

/* arrays determine sequence for handyBoard motor ports */

int motorPort[] = {0,1,0,1};

int motorDirection[] = {0,1,1,0};

int stepNumber = 0;

while(((KEYPAD & peek(DIGITAL_INPUT)) != STOP_BUTTON) && (distance > 0.0))

...

...

Download as:   txt (6.7 Kb)   pdf (101.9 Kb)   docx (11.8 Kb)  
Continue for 3 more pages »
Only available on ReviewEssays.com