Go to Post The world isn't made out of Nerf, you will get scrapes and bruses, but you will get back up and continue on. If you watch out you can avoid the sharp edges. - Joe Matt [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 Rating: Thread Rating: 6 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 15-02-2013, 12:37
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 495
tomy has a spectacular aura abouttomy has a spectacular aura about
PID + Battery Voltage + Talon=??????

So my team needs a PID Controller code for our shooter. All the example code shows this:

Code:
	Joystick turretStick(1);
	Jaguar turretMotor(1);
	AnalogChannel turretPot(1);
	PIDController turretControl(0.1, 0.001, 0.0, &turretPot, &turretMotor);
	
	turretControl.Enable();  // start calculating PIDOutput values

	while(IsOperator())
   {
		turretControl.SetSetpoint((turretStick.GetX() + 1.0) * 2.5);
		Wait(.02);		// wait for new joystick values
	}
I cant find anything on using the battery voltage in that code or a talon. Also I read that the speed controllers have a trype of built in PID Loop. One more thing to the the battery volts we are using:

Code:
float volt
.
.
. 
volt = DriverStation::GetInstance()->GetBatteryVoltage();
Reply With Quote
  #2   Spotlight this post!  
Unread 15-02-2013, 12:59
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,113
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: PID + Battery Voltage + Talon=??????

I think that example shows how to set a motor's position based on the feedback from a potentiometer connected to a mechanism that turns with the motor (perhaps with some gear or sprocket reduction in the mix).

If you instead want to do velocity control, you'll need some sort of counter or encoder connected to the motor shaft so you can read its speed.

Why do you care about battery voltage?
Reply With Quote
  #3   Spotlight this post!  
Unread 15-02-2013, 13:07
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 495
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: PID + Battery Voltage + Talon=??????

My teams problem is that when we fire our shooter its accurate but when the compressor activates and the voltage drop so does the speed of the shooter. That is why we wanted to create a PID Loop with the battery voltage if possible
Reply With Quote
  #4   Spotlight this post!  
Unread 15-02-2013, 13:18
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,090
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: PID + Battery Voltage + Talon=??????

Quote:
Originally Posted by tomy View Post
My teams problem is that when we fire our shooter its accurate but when the compressor activates and the voltage drop so does the speed of the shooter. That is why we wanted to create a PID Loop with the battery voltage if possible
You have at least 2 choices:

1) Measure the battery voltage and compensate for that by adjusting your motor command. This does not require PID. Adjusting the motor command based on voltage will help, but may not be as accurate as the 2nd solution:

2) Put a speed sensor on your shooter wheel, and use that as the process variable in a feedback controller. You can use PID control for this, or you can use bang-bang.



Last edited by Ether : 15-02-2013 at 13:22.
Reply With Quote
  #5   Spotlight this post!  
Unread 15-02-2013, 13:20
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 495
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: PID + Battery Voltage + Talon=??????

Quote:
Originally Posted by Ether View Post
You have at least 2 choices:

1) Measure the battery voltage and compensate for that by adjusting your motor command. This does not require PID

2) Put a speed sensor on your shooter wheel, and use that as the process variable in a feedback controller. You can use a PID loop for this, or you can use bang-bang.


So we would have to do a type of if statement that looks at the battery voltage and if the level drops to a certain range change the speed to compensate?
Reply With Quote
  #6   Spotlight this post!  
Unread 15-02-2013, 13:28
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,090
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: PID + Battery Voltage + Talon=??????

Quote:
Originally Posted by tomy View Post
So we would have to do a type of if statement that looks at the battery voltage and if the level drops to a certain range change the speed to compensate?
Multiply your motor command by 12.5/V, where V is the measured voltage. As V goes down, this compensates by increasing your motor command.

This only works, of course, if you have some headroom in your motor command, i.e. you are not already commanding 100%.


Reply With Quote
  #7   Spotlight this post!  
Unread 15-02-2013, 13:56
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 495
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: PID + Battery Voltage + Talon=??????

but that is assuming your battery starts at 12.5 V what if you get a batter that starts at 12.8V or is that something we would have to test
Reply With Quote
  #8   Spotlight this post!  
Unread 15-02-2013, 14:58
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,090
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: PID + Battery Voltage + Talon=??????

Quote:
Originally Posted by tomy View Post
but that is assuming your battery starts at 12.5 V what if you get a batter that starts at 12.8V or is that something we would have to test
The voltage compensation method is not exact. 12.5 is close. If you want, you can measure the actual battery voltage when you have a fresh battery and the shooter is running at the desired speed and the compressor is not running, and use that value instead of 12.5

If you need accurate control of shooter speed, I suggest you use speed feedback, as most teams who want accurate speed control are doing.



Reply With Quote
  #9   Spotlight this post!  
Unread 15-02-2013, 15:29
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 495
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: PID + Battery Voltage + Talon=??????

speed feedback?
Reply With Quote
  #10   Spotlight this post!  
Unread 15-02-2013, 15:43
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,722
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: PID + Battery Voltage + Talon=??????

Attach an encoder to the wheel and read the rate out of it. It's what the example you posted does.
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 15:31.

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