Go to Post Keep arrogant, belittling and misspelled bragging off these boards. - Mike [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 02-02-2008, 13:26
EHaskins EHaskins is offline
Needs to change his user title.
AKA: Eric Haskins
no team (CARD #6 (SCOE))
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Elkhorn, WI USA
Posts: 998
EHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond repute
Send a message via MSN to EHaskins
Problem with negitive numbers

I've been working on a velocity PID for motor control, but I'm having trouble.

When the PID calculation returns a positive value the code runs fine, but when it return a negitice value the motor output begins jumping appearently randomly from very high(5 digit) to very low(-5 digit) values.

Once this happens the PID reacts correctly, but due to the values that a far outside of normal it never recovers.

Here is the code I think contains the issue, but I can't find it. I added some comments to help explain the issue.
Code:
void MotorControl (unsigned char motor)
{
         
    //The printfs in CalculateSpeed() give correct data. 

	int speed = CalculateSpeed(motor);
	int output;
	//printf("speed on motor %d = %d\r\n", motor);
	//printf("Speed Goal = %d\r\n", speedGoal[motor]);

    // Last line in PID prints the PID output, and it always appears correctly. 

	output = PID(speed, speedGoal[motor], &pidInfo[motor]);
 	currentOutput[motor] += output;

	if (loopCount == 0)
	{
          //This is where the issue is obvious. It prints strange values within
          //the same loop as PID() returns a negitive value, and then until reset.

        
		printf("Output %d = %d\r\n\r\n\r\n", motor, (int)currentOutput[motor]);
	}
	switch (motor)
	{
		case 0:
			MOTOR_ONE = LimitInput(currentOutput[motor] + 127, 0, 255);
			//printf("Motor one set during %d\r\n", motor);
			break;
		case 1:
			MOTOR_TWO = LimitInput(currentOutput[motor] + 127, 0, 255);
			//printf("Motor one set during %d\r\n", motor);
			break;
	}
}
__________________
Eric Haskins KC9JVH

Last edited by EHaskins : 03-02-2008 at 12:58.
 


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
Problem with Lofting cooker52 Inventor 14 04-11-2007 15:00
Problem With Footsteps Popper99 3D Animation and Competition 1 04-11-2007 09:34
Problem with RoboEmu2? Calvin Programming 1 12-02-2005 11:27
Problem with communicating with STAMP through serial port Skabana159 Technical Discussion 2 06-02-2003 21:10
Problem with OI / RC Jay Lundy Technical Discussion 2 29-03-2002 23:07


All times are GMT -5. The time now is 23:51.

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