Go to Post Antimatter.. It will help us in the never ending quest to build the bot under the weight limit. - Elgin Clock [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-01-2014, 15:02
vigneshv vigneshv is offline
Registered User
FRC #2489
 
Join Date: Jan 2014
Location: United States
Posts: 53
vigneshv is on a distinguished road
Exclamation PIDController not manipulating jaguars

Hi,
I have a PIDController with the PIDSource as an encoder and the PIDOutput as a Jaguar. Even though the PIDController->GetError() returns a value of 100 (the encoder distance value - setpoint (this is correct)), the Jaguars do not run automatically to minimize the error. Why is this happening?
Reply With Quote
  #2   Spotlight this post!  
Unread 25-01-2014, 16:30
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: PIDController not manipulating jaguars

What values did you use for P, I, and D? Did you enable the PID Controller?
Reply With Quote
  #3   Spotlight this post!  
Unread 25-01-2014, 17:41
vigneshv vigneshv is offline
Registered User
FRC #2489
 
Join Date: Jan 2014
Location: United States
Posts: 53
vigneshv is on a distinguished road
Re: PIDController not manipulating jaguars

P = 13, I = 13, D = 13, PID was enabled.
Reply With Quote
  #4   Spotlight this post!  
Unread 25-01-2014, 17:59
NotInControl NotInControl is offline
Controls Engineer
AKA: Kevin
FRC #2168 (Aluminum Falcons)
Team Role: Engineer
 
Join Date: Oct 2011
Rookie Year: 2004
Location: Groton, CT
Posts: 261
NotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond repute
Re: PIDController not manipulating jaguars

Are there any flashing or solid lights on the Jaguar? is it a black jag or a grey one? Do you notice the same behavior using BDC-COM?
__________________
Controls Engineer, Team 2168 - The Aluminum Falcons
[2016 Season] - World Championship Controls Award, District Controls Award, 3rd BlueBanner
-World Championship- #45 seed in Quals, World Championship Innovation in Controls Award - Curie
-NE Championship- #26 seed in Quals, winner(195,125,2168)
[2015 Season] - NE Championship Controls Award, 2nd Blue Banner
-NE Championship- #26 seed in Quals, NE Championship Innovation in Controls Award
-MA District Event- #17 seed in Quals, Winner(2168,3718,3146)
[2014 Season] - NE Championship Controls Award & Semi-finalists, District Controls Award, Creativity Award, & Finalists
-NE Championship- #36 seed in Quals, SemiFinalist(228,2168,3525), NE Championship Innovation in Controls Award
-RI District Event- #7 seed in Quals, Finalist(1519,2168,5163), Innovation in Controls Award
-Groton District Event- #9 seed in Quals, QuarterFinalist(2168, 125, 5112), Creativity Award
[2013 Season] - WPI Regional Winner - 1st Blue Banner
Reply With Quote
  #5   Spotlight this post!  
Unread 25-01-2014, 18:52
vigneshv vigneshv is offline
Registered User
FRC #2489
 
Join Date: Jan 2014
Location: United States
Posts: 53
vigneshv is on a distinguished road
Re: PIDController not manipulating jaguars

The Jaguar is a grey Jaguar, and the Jaguar just has a solid orange light. I cannot use Set() to manipulate it either.
Reply With Quote
  #6   Spotlight this post!  
Unread 25-01-2014, 19:12
gpetilli gpetilli is offline
Registered User
FRC #1559
 
Join Date: Jan 2009
Location: Victor, NY
Posts: 285
gpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to allgpetilli is a name known to all
Re: PIDController not manipulating jaguars

Quote:
Originally Posted by vigneshv View Post
The Jaguar is a grey Jaguar, and the Jaguar just has a solid orange light. I cannot use Set() to manipulate it either.
Are you using CAN or PWM for the Jaguar. If CAN, the gray Jaguars do not have an RS232 to CAN interface and can not be the first Jaguar in a chain. You should check it by using PC with BDC-COM and a serial cable to a black Jaguar and daisy chain CAN to the gray one. You might as well flash the firmware while you have it hooked up.
Reply With Quote
  #7   Spotlight this post!  
Unread 25-01-2014, 19:40
NotInControl NotInControl is offline
Controls Engineer
AKA: Kevin
FRC #2168 (Aluminum Falcons)
Team Role: Engineer
 
Join Date: Oct 2011
Rookie Year: 2004
Location: Groton, CT
Posts: 261
NotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond repute
Re: PIDController not manipulating jaguars

Quote:
Originally Posted by vigneshv View Post
The Jaguar is a grey Jaguar, and the Jaguar just has a solid orange light. I cannot use Set() to manipulate it either.
Can you paste your code? Because the light is solid that means that the jaguar is correctly gettting power and receiving comms. It may be a programming problem, maybe the wrong motor controller is referenced.

Posting your code will help us better help you.
__________________
Controls Engineer, Team 2168 - The Aluminum Falcons
[2016 Season] - World Championship Controls Award, District Controls Award, 3rd BlueBanner
-World Championship- #45 seed in Quals, World Championship Innovation in Controls Award - Curie
-NE Championship- #26 seed in Quals, winner(195,125,2168)
[2015 Season] - NE Championship Controls Award, 2nd Blue Banner
-NE Championship- #26 seed in Quals, NE Championship Innovation in Controls Award
-MA District Event- #17 seed in Quals, Winner(2168,3718,3146)
[2014 Season] - NE Championship Controls Award & Semi-finalists, District Controls Award, Creativity Award, & Finalists
-NE Championship- #36 seed in Quals, SemiFinalist(228,2168,3525), NE Championship Innovation in Controls Award
-RI District Event- #7 seed in Quals, Finalist(1519,2168,5163), Innovation in Controls Award
-Groton District Event- #9 seed in Quals, QuarterFinalist(2168, 125, 5112), Creativity Award
[2013 Season] - WPI Regional Winner - 1st Blue Banner
Reply With Quote
  #8   Spotlight this post!  
Unread 25-01-2014, 19:59
vigneshv vigneshv is offline
Registered User
FRC #2489
 
Join Date: Jan 2014
Location: United States
Posts: 53
vigneshv is on a distinguished road
Re: PIDController not manipulating jaguars

We also get a PID output with a value between 1 and -1, but the Jaguar does not move. The Jaguar is connected to the PWM output port 1.
Code:
#include "WPILib.h"

class RobotDemo : public SimpleRobot
{
	RobotDrive myRobot; // robot drive system
	
	Joystick *stick; // only joystick
	DriverStationLCD *screen;
	Encoder *encoder1;
	
	Jaguar *motor1;
	
	PIDController *PIDmotor1;
	

public:
	RobotDemo():
		myRobot(1, 2)//,	// these must be initialized in the same order
		
	{
		stick = new Joystick(1);
		screen = DriverStationLCD::GetInstance();
		encoder1 = new Encoder(13,14);
		motor1 = new Jaguar(1);
		PIDmotor1 = new PIDController(0.5,0,0,encoder1,motor1);
		
		PIDmotor1->SetContinuous(true);
		PIDmotor1->SetOutputRange(-1,1);
		PIDmotor1->SetTolerance(3);
		
		myRobot.SetExpiration(0.1);
	}

	/**
	 * Drive left & right motors for 2 seconds then stop
	 */
	void Autonomous()
	{
		myRobot.SetSafetyEnabled(false);
		myRobot.Drive(-0.5, 0.0); 	// drive forwards half speed
		Wait(2.0); 				//    for 2 seconds
		myRobot.Drive(0.0, 0.0); 	// stop robot
	}


	void OperatorControl()
	{
		myRobot.SetSafetyEnabled(true);
		
		encoder1->Start();

		PIDmotor1->SetSetpoint(0);
		
		while (IsOperatorControl())
		{
			if(stick->GetRawButton(3))
			{
				PIDmotor1->SetSetpoint(100);
			}
			if(stick->GetRawButton(2))
			{
				PIDmotor1->SetSetpoint(-100);
			}
			if(stick->GetRawButton(4))
			{
				PIDmotor1->Enable();
			}
			


			

			screen->PrintfLine(DriverStationLCD::kUser_Line1, "Count = %d", encoder1->GetRaw());
			screen->PrintfLine(DriverStationLCD::kUser_Line2, "Error = %f", PIDmotor1->GetError());
			screen->PrintfLine(DriverStationLCD::kUser_Line3, "Setpoint = %f", PIDmotor1->GetSetpoint());
			screen->PrintfLine(DriverStationLCD::kUser_Line4, "Output = %f", PIDmotor1->Get());
			//myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
			screen->UpdateLCD();
			Wait(0.005);				// wait for a motor update time
		}
	}
	
	/**
	 * Runs during test mode
	 */
	void Test() {

	}
};

START_ROBOT_CLASS(RobotDemo);
Reply With Quote
  #9   Spotlight this post!  
Unread 25-01-2014, 20:09
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: PIDController not manipulating jaguars

Both the Jaguar and the RobotDrive are using PWM 1.
Reply With Quote
  #10   Spotlight this post!  
Unread 25-01-2014, 20:35
vigneshv vigneshv is offline
Registered User
FRC #2489
 
Join Date: Jan 2014
Location: United States
Posts: 53
vigneshv is on a distinguished road
Re: PIDController not manipulating jaguars

So if we remove the RobotDrive, it will work?
Reply With Quote
  #11   Spotlight this post!  
Unread 25-01-2014, 20:36
vigneshv vigneshv is offline
Registered User
FRC #2489
 
Join Date: Jan 2014
Location: United States
Posts: 53
vigneshv is on a distinguished road
Re: PIDController not manipulating jaguars

So if we remove the RobotDrive, it will work, because as I understand RobotDrive uses the Jag ports as well?
Reply With Quote
  #12   Spotlight this post!  
Unread 26-01-2014, 13:08
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: PIDController not manipulating jaguars

Put your PID-controlled Jaguar on a PWM port that isn't already being used by other code. It's a one-character change to your code, and a single connector to move from one set of pins to another.
Code:
motor1 = new Jaguar(3);
Reply With Quote
  #13   Spotlight this post!  
Unread 26-01-2014, 15:32
vigneshv vigneshv is offline
Registered User
FRC #2489
 
Join Date: Jan 2014
Location: United States
Posts: 53
vigneshv is on a distinguished road
Re: PIDController not manipulating jaguars

Isn't the RobotDrive supposed to use the jaguar ports, or should I remove that entirely and control the robot with motor1->Set()?
Reply With Quote
  #14   Spotlight this post!  
Unread 26-01-2014, 21:38
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: PIDController not manipulating jaguars

The questions you're asking seem to be assuming something that you haven't told us. Can you explain exactly what you're trying to get the robot to do? What sort of mechanism are you controlling, and where do you have the encoder mouted? I get the feeling that what you want is something you haven't quite made clear to us.
Reply With Quote
  #15   Spotlight this post!  
Unread 27-01-2014, 09:14
vigneshv vigneshv is offline
Registered User
FRC #2489
 
Join Date: Jan 2014
Location: United States
Posts: 53
vigneshv is on a distinguished road
Re: PIDController not manipulating jaguars

Hi,
I am trying to use the PID controller to keep the robot stationary while shooting.
Reply With Quote
Reply


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:45.

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