Go to Post I tried, but our freshmen lost enthusiasm about filing the blocks of aluminum I gave them into Andymark Performance Wheels after only a few hours! - Greg Woelki [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 24-01-2013, 20:15
KGU KGU is offline
Registered User
FRC #3284
 
Join Date: Jan 2013
Location: Missouri
Posts: 1
KGU is an unknown quantity at this point
Call to PIDController::GetError() and ::OnTarget() locks program.

We have been working with the PID controller and have a simple set up with a motor and potentiometer. The motor tries to control to set point as it should, but only if the we are not using the GetError or OnTarget methods. If either of these methods are called, the program locks up and does not continue on to the rest of the code. Here is a snippet of our code (we initialize everything in a separate header not shown):

Code:
CRobotMain::CRobotMain() : SimpleRobot()
{
	// Create our object pointers.
	m_pPot		= new AnalogChannel(1, 2);
	m_pMotor	= new Talon(1, 8);
	m_pPID		= new PIDController(0.1, 0.001, 0.0, m_pPot, m_pMotor);
}

void CRobotMain::OperatorControl()
{
	float	fError;
	bool	bOnTarget;
	
	m_pPID->SetOutputRange(-0.25, 0.25);
	m_pPID->SetInputRange(0, 1023);
	m_pPID->SetAbsoluteTolerance(50);
	m_pPID->SetContinuous(true);
	m_pPID->Enable();
	
	// Continuously run loop while in teleop mode.
	while (IsOperatorControl())
	{
		m_pPID->SetSetpoint(250);

///		fError = m_pPID->GetError();
///		bOnTarget = m_pPID->OnTarget();
		
		Wait(0.050);
	}
}

If either of the "m_pPID->GetError();" or "bOnTarget = m_pPID->OnTarget();" lines are uncommented, the code no longer functions.
Reply With Quote
 


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


All times are GMT -5. The time now is 12:55.

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