Go to Post It's kind of magical how I went from legos to replacing most of the iron in my blood with aluminum, and all thanks to my elementary school science teacher. - Astrokid248 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #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.
  #2   Spotlight this post!  
Unread 06-11-2006, 11:15
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
Re: Only one side moves!?!?

What kind of variables are temp_currentX and temp_currentY? If they're char or int, that multiply by 0.59 is going to round down to 0, which can cause unexpected results.
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
  #3   Spotlight this post!  
Unread 07-11-2006, 02:07
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
Re: Only one side moves!?!?

They are just normal int's. I tried sticking 0.59 as a floating point value by putting an F at the end, but that still didn’t work. I'll give it a try tomorrow afternoon. Thanks Matt!
  #4   Spotlight this post!  
Unread 07-11-2006, 12:32
psquared89's Avatar
psquared89 psquared89 is offline
Registered User
AKA: Pat Pannuto
FRC #0245 (Adambots)
Team Role: Driver
 
Join Date: Mar 2005
Rookie Year: 2004
Location: Rochester Hills, MI
Posts: 73
psquared89 is a jewel in the roughpsquared89 is a jewel in the roughpsquared89 is a jewel in the roughpsquared89 is a jewel in the rough
Re: Only one side moves!?!?

Floating point calculations on the MCC18 are always a little sketchy. Also, true PID calculations take more processing power than it has. If you really want to implement PID I'd suggest looking at a co-processor. If you're interested, our team used one last year, and we're in the process of writing a guide for how other teams can create their own.

Check out the beginnings of our guide on our website. We're in the process of writing the guide right now, by the end of the month it should be complete so check back often.
__________________
At the end of the game, the King and the Pawn both go back into the same box.
~ Italian Proverb
---------------------------------
adambots.com
  #5   Spotlight this post!  
Unread 07-11-2006, 13:25
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
Re: Only one side moves!?!?

Quote:
Originally Posted by kiettyyyy
They are just normal int's. I tried sticking 0.59 as a floating point value by putting an F at the end, but that still didn’t work. I'll give it a try tomorrow afternoon. Thanks Matt!

Even so, integers could still make for flaky numbers. My recommendation is multiply it by 59, then divide by 100, fundamentally it's still the same, but that operation is much faster, and more supported by the processor, with minimal (and predictable) data loss in the form of rounding error.
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
  #6   Spotlight this post!  
Unread 11-11-2006, 14:51
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
Re: Only one side moves!?!?

Ahh... So that was the problem! Since the temp_currentX and temp_currentY were defined as "int", the system only had temp_currentX with the correction going on one side. That seemed to fix it. Thanks everyone!
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Only one side moving Idaman323 Programming 11 21-02-2005 00:00
2 human players on one side? Sscamatt Rules/Strategy 11 22-02-2004 23:34
Navigate.c Current Sense code=only one polarity Dale(294engr] General Forum 1 05-02-2004 16:25
I guess there can only be one . . . archiver 1999 0 23-06-2002 22:46
In The End, There can be only one..... archiver 1999 6 23-06-2002 22:02


All times are GMT -5. The time now is 09:58.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi