View Single Post
  #25   Spotlight this post!  
Unread 14-01-2005, 11:29
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Kevin Watson's Kick-off Demo Code!

Quote:
Originally Posted by Squall
Sorry to hear about your home
Thanks.

Quote:
Originally Posted by Squall
And since we programers were just helping out with other stuff we decided to do a very simple GUI for your code, We'll be finishing it today and I'll post here.
I assume this is for the gyro code? If so, the conversions I gave you were in units of degrees, which is too course to use. Rich Petras wanted milliradians (pi radians = 180 degrees), so that's what the new gyro code will return. I've also built in the option of returning tenths of a degree by uncommenting some #defines in gyro.h:
Code:

/*******************************************************************************
*
* TITLE  gyro.h 
*
* VERSION: 0.2 (Beta)						   
*
* DATE:  12-Jan-2005
*
* AUTHOR:  R. Kevin Watson
*	kevinw@jpl.nasa.gov
*
* COMMENTS:
*
********************************************************************************
*
* CHANGE LOG:
*
* DATE		 REV  DESCRIPTION
* -----------  ---  ----------------------------------------------------------
* 21-Nov-2004  0.1  RKW - Original
* 12-Jan-2005  0.2  RKW - Altered Get_Gyro_Rate() and Get_Gyro_Angle() to use
*				   long integers for internal calculations, allowing larger
*				   numerators and denominators in the GYRO_RATE_SCALE_FACTOR
*				   and GYRO_ANGLE_SCALE_FACTOR #defines.
* 12-Jan-2005  0.2  RKW - GYRO_RATE_SCALE_FACTOR and GYRO_ANGLE_SCALE_FACTOR
*				   #defines added for Analog Devices' ADXRS401, ADXRS150 and
*				   ADXRS300 gyros.
*
*******************************************************************************/
 
#ifndef _gyro_h
#define _gyro_h
#define TRUE 1
#define FALSE 0
// MILLIRADIANS_PER_TENTH_DEGREE = 349/200
// ADC_BITS_PER_VOLT = 1024/5
// GYRO_RATE_SCALE_FACTOR = ANGULAR_RATE_PER_VOLT / ADC_BITS_PER_VOLT
// GYRO_ANGLE_SCALE_FACTOR = GYRO_RATE_SCALE_FACTOR / SAMPLE_RATE
// default parameters for Silicon Sensing Systems' CRS03
// sensitivity = 20mV/deg/sec
// #define GYRO_RATE_SCALE_FACTOR 625/256 // defaults to 625/256 for tenths of a degree/sec
// #define GYRO_ANGLE_SCALE_FACTOR 25/512 // defaults to 25/512 for tenths of a degree
// #define GYRO_RATE_SCALE_FACTOR 8725/2048 // defaults to 8725/2048 for milliradians/sec
// #define GYRO_ANGLE_SCALE_FACTOR 349/4096 // defaults to 349/4096 for milliradians
// default parameters for Analog Devices' ADXRS401
// sensitivity = 15mV/deg/sec
// #define GYRO_RATE_SCALE_FACTOR 1665/512 // defaults to 1665/512 for tenths of a degree/sec
// #define GYRO_ANGLE_SCALE_FACTOR 333/5120 // defaults to 333/5120 for tenths of a degree
// #define GYRO_RATE_SCALE_FACTOR 5811/1024 // defaults to 5811/1024 for milliradians/sec
// #define GYRO_ANGLE_SCALE_FACTOR 581/5120 // defaults to 581/5120 for milliradians
// default parameters for Analog Devices' ADXRS150
// sensitivity = 12.5mV/deg/sec
// #define GYRO_RATE_SCALE_FACTOR 125/32 // defaults to 125/32 for tenths of a degree/sec
// #define GYRO_ANGLE_SCALE_FACTOR 5/64  // defaults to 5/64 for tenths of a degree
#define GYRO_RATE_SCALE_FACTOR 1745/256  // defaults to 1745/256 for milliradians/sec
#define GYRO_ANGLE_SCALE_FACTOR 349/2560 // defaults to 349/2560 for milliradians
// default parameters for Analog Devices' ADXRS300
// sensitivity = 5.0mV/deg/sec
// #define GYRO_RATE_SCALE_FACTOR 625/64 // defaults to 625/64 for tenths of a degree/sec
// #define GYRO_ANGLE_SCALE_FACTOR 25/128 // defaults to 25/128 for tenths of a degree
// #define GYRO_RATE_SCALE_FACTOR 8725/512 // defaults to 8725/512 for milliradians/sec
// #define GYRO_ANGLE_SCALE_FACTOR 349/1024 // defaults to 349/1024 for milliradians

void Initialize_Gyro(void);  // initializes and starts the gyro software
int Get_Gyro_Rate(void);  // returns the current heading angular rate of change
int Get_Gyro_Angle(void);  // returns the current heading angle
void Calc_Gyro_Bias(void);  // calculates the current gyro bias
int Get_Gyro_Bias(void);  // returns the current calculated gyro bias
void Set_Gyro_Bias(int);  // manually sets the gyro bias
void Reset_Gyro_Angle(void); // resets the heading angle to zero
void Disable_Gyro(void);  // disables the gyro
void Initialize_Timer_2(void); // initializes and starts timer2
void Timer_2_Int_Handler(void); // interrupt service routine for timer2
#endif

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org