View Single Post
  #7   Spotlight this post!  
Unread 13-02-2004, 21:22
Meandmyself's Avatar
Meandmyself Meandmyself is offline
Registered Magic Programming User
AKA: Gordon
#1123 (AIM robotics Crimson Lightning)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: springfield, VA
Posts: 26
Meandmyself will become famous soon enough
Re: printf isn't printf-ing. Help!

All those are great suggestions, but I think the problem is deeper than that. I noticed today that the program state light stays yellow when I download. I tried changing around a few things, such as the last function I added. I ditched the if counter>40 thing, and just printfing every time doesn't even work.
Basically, this is the last function I added since it stopped working:
Code:
void findcurrentpos(void)	/*basically takes input from yaw rate sensor and integrates to find how much the direction has changed*/

{
current.theta += ((gyroin + gyroprev - 1023) * CGYRO * deltat) + 2000;		/* finds our current direction  cgyro converts to degrees/100, find average and multiply by time, dt converted to seconds by dt/1000*/

	deltat = 0;     /*modified in user_routines_fast with the internal timer*/

//	if (current.theta < 2000) {current.theta += 36000;}
//	current.theta -= 2000;
//	if (current.theta > 360) {current.theta -= 36000;}
//	gyroprev = gyroin;

}/*end findcurrentpos()*/
(CGYRO = 0.08)

And this gives me either an overflow error, or the Program State LED on the Edubot blinks red. In the Edubot reference guide a blinking red light means an infinite loop.

However, a funny thing happens when I comment out all the code in findcurrentpos(), It works! no blinking red light, no overflow error. I wonder if there is a limit for how large a math operation can be. I know on my calculator, if you multiply two very large values, you can get an overflow error. I also had another problem with a sin approximation giving an overflow error. I just replaced it with a lookup table. If there is such a limit, what is it?
__________________
They call me the Idea man.
Not because my ideas work,
But because I have ideas...


I'm not a programmer. I'm an electrical guy who can program. If only I understood C!

www.aim-robotics.org //team website
www.tjhsst.edu/~gburgett //cool stuff for school