View Single Post
  #1   Spotlight this post!  
Unread 06-11-2006, 01:15
kiettyyyy's Avatar
kiettyyyy kiettyyyy is offline
Registered User
FRC #1538 (The Holy Cows)
Team Role: Engineer
 
Join Date: Mar 2006
Rookie Year: 2005
Location: San Diego, CA
Posts: 181
kiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond repute
Send a message via AIM to kiettyyyy
Only one side moves!?!?

Hey all,

I've been having trouble with this PID code. I made some change to the code in the past but I haven’t noticed that only one side does the correction since a few days ago.

I've tried to debug and all of that good stuff, but I haven’t been able to get my finger on the cause of the problem. Here’s the code!

Code:
	if (currentX == 127)
	{
		// printf("CurrentX: %d Gyro Angle: %d\r\n", currentX, cur_heading);
		temp_currentY = (currentY - 127 + error);
		printf("temp_currentY 1: %d\r\n", temp_currentY);
		temp_currentY = ((temp_currentY * 0.59) );
		printf("temp_currentY 2: %d\r\n", temp_currentY);
		temp_currentY = (127L + temp_currentY);
		printf("temp_currentY 3: %d\r\n\r\n", temp_currentY);
		temp_currentY =	Limit_Mix(2000 + temp_currentY);
	
		temp_currentX = (currentX - 127 - error);
		printf("temp_currentY 1: %d\r\n", temp_currentX);
		temp_currentX = ((temp_currentX * 0.59) );
		printf("temp_currentY 2: %d\r\n", temp_currentX);
		temp_currentX = (127 + temp_currentX);
		printf("temp_currentX 3: %d\r\n\r\n", temp_currentX);
		temp_currentX = (254L - temp_currentX);
		temp_currentX =	Limit_Mix(2000 + temp_currentX);
	
			pwm_rightDrive_cim = pwm_rightDrive_fp = Limit_Mix(2000 + temp_currentX + temp_currentY - 127);
			pwm_leftDrive_cim = pwm_leftDrive_fp = Limit_Mix(2000 + temp_currentX - temp_currentY + 127);
	
		if(currentY == 127)
		{
			pwm_rightDrive_cim = pwm_rightDrive_fp = Limit_Mix(2000 + currentX + currentY - 127);
			pwm_leftDrive_cim = pwm_leftDrive_fp = Limit_Mix(2000 + currentX - currentY + 127);
			Reset_Gyro_Angle();
		}
		else
		{

			pwm_rightDrive_cim = pwm_rightDrive_fp = Limit_Mix(2000 + temp_currentX + temp_currentY - 127);
			pwm_leftDrive_cim = pwm_leftDrive_fp = Limit_Mix(2000 + temp_currentX - temp_currentY + 127);

		}
	}
	else if((ratechange < 10 && ratechange > -10) && (currentX == 127))
	{	 
	
	
		 pwm_rightDrive_cim = pwm_rightDrive_fp = Limit_Mix(2000 + currentX + currentY - 127);
		 pwm_leftDrive_cim = pwm_leftDrive_fp = Limit_Mix(2000 + currentX - currentY + 127);
	
		Reset_Gyro_Angle();
	}
	else
	{	 
		 pwm_rightDrive_cim = pwm_rightDrive_fp = Limit_Mix(2000 + currentX + currentY - 127);
		 pwm_leftDrive_cim = pwm_leftDrive_fp = Limit_Mix(2000 + currentX - currentY + 127);
	
		Reset_Gyro_Angle();
	}
Any suggestions? Thanks!

Last edited by kiettyyyy : 06-11-2006 at 01:25.