|
Re: Issues with our code
Here is the code so far:
Our file, ConstantsandControl.h:
#ifndef Constants_Control
#define Constants_Control
//Constants
#define AUTO_FIELD 1
#define INFINITE 1
//Ports
#define GYRO_PORT 1
//Controls
#endif
The run file, main.c:
//Define robot type(FRC vs. VEX) (Done only once)
#ifndef _FRC_BOARD
#define _FRC_BOARD
#endif
//Include features
#include "BuiltIns.h"
#include "Constants_Control.h"
//Setup competition mode, called first
void IO_Initialization(void)
{
//Set to automatic competition mode handling
SetCompetitionMode(AUTO_FIELD);
}
//Initialize: run at robot startup regradless of mode
void Initialize(void)
{
//Initailize Sensors
SetGyroType(1,80);
InitGyro(GYRO_PORT);
}
//Note: will switch between auto and operator automatically,
//even if the code is currently in an infinite loop
//Autonomous: run at field control enable
void Autonomous(void)
{
int heading;
StartGyro(GYRO_PORT);
while(INFINITE)
{
heading = GetGyroAngle(GYRO_PORT);
//Print
printf("Gyro Angle: %d\r",heading);
}
}
//OperatorControl: Teleoperated period
void OperatorControl(void)
{
int heading;
StartGyro(GYRO_PORT);
while(INFINITE)
{
heading = GetGyroAngle(GYRO_PORT);
//Print
printf("Gyro Angle: %d\r",heading);
if(heading < 0)
{
heading = heading * -1;
}
SetPWM(1,heading);
}
}
//Main: Satifies call requiremen only, unused
void main(void)
{
}
Thats the code.
The only warning we get on compile are qualifier mismatch in assignment, and we get two of them on the line that assigns GetGyroAngle to heading.
EDIT: That Setpwm thing was our way of testing if the printf was the problem. We just hooked a servo up to it ans tested to see if it moved t all when we moved the gyro.
__________________
CRUD Name: Windows
Rookie Year: 2005
Alumni to Team: 350
Last edited by Ryan O : 26-01-2008 at 12:19.
Reason: Additional information
|