View Single Post
  #3   Spotlight this post!  
Unread 29-02-2008, 20:31
gnormhurst's Avatar
gnormhurst gnormhurst is offline
Norm Hurst
AKA: gnorm
#0381 (The Tornadoes)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Trenton, NJ
Posts: 138
gnormhurst will become famous soon enoughgnormhurst will become famous soon enough
Re: Get_Gyro_Angle() overflows beyond about -20000 deci-decgrees?

Okay, I'll check out Kevin's newer code....

BTW, for my current code I dereferenced the macros and got

Code:
long Get_Gyro_Angle(void)
{
	// Return the calculated gyro angle to the caller.
	return(((gyro_angle * GYRO_SENSITIVITY * 5L) / (ADC_RANGE * ADC_UPDATE_RATE)) * GYRO_CAL_FACTOR);
        // translates to:
	//return(((gyro_angle * 800L * 5L) / (1024L * ADC_SAMPLE_RATE/(ADC_SAMPLES_PER_UPDATE * NUM_ADC_CHANNELS))) * 958/1000);
        // which translates to ...
	//return(((gyro_angle * 800L * 5L) / (1024L * 200/(4 * 1))) * 958/1000);

	
}
I guess I could make my own Get_Gyro_Angle_Low_Resolution() that doesn't use such a large value for GYRO_SENSITIVITY.
__________________
Trenton Tornadoes 381
2004 Philadelphia Regional Winners
2006 Xerox Creativity Award
---
My corner of the USPTO.
My favorite error message from gcc: main is usually a function
My favorite error message from Windows: There is not enough disk space available to delete this file.