Go to Post oooh tight leather bumpers...sexy! - Nuttyman54 [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 8 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 29-01-2015, 05:09
rclothier rclothier is offline
Coach, Team 1723
AKA: Russell Clothier
FRC #1723 (The FIRST Bots of Independence, "The FBI")
Team Role: Coach
 
Join Date: Jan 2011
Rookie Year: 2006
Location: Independence, MO
Posts: 42
rclothier is on a distinguished road
PID Issue

We are trying to use PID on LabVIEW for the first time, and are having difficulties getting it to work. I've read the tutorials and threads, so I understand how it's supposed to function. We have encoders on the left and right wheels of a tank drive practice bot. We convert the rotation rate of each wheel into a linear speed in inches/sec. We feed that into a PID as the Process Variable. On the Front Panel of Teleop, we have a control to enter the desired speed for each wheel as the Setpoint. We set the maximum output to +/- 1, and feed that into a Tank Drive. A screen shot of the code is attached.

We put both Setpoints to 25 in/s, which is about one rotation per sec. When we set all 3 gains to 0, the wheels don't turn (of course). When the P gain increases above 0.003 the wheels begin to turn slowly, but not at the Setpoint. When the gain gets above 0.007, the wheels ramp up directly to full speed (+/- 1); the encoder velocity (process variable) goes to about 250 in/s. Its basically all or nothing. Adjusting the Setpoint higher or lower has no effect. If the P gain goes above 0.2, the wheels switch rapidly between +1 and -1, flipping back and forth. Adding gain to I or D only makes matters worse.

Clearly there is too much gain if we're maxxing out at P=0.007. The robot is on blocks, so there's no real load on the wheels; shouldn't it work anyway? (We don't want to put it on the ground when it's acting crazy.) Do we leave the dt(s) input empty? Is there something else we are missing?

Any advice would be appreciated. Thanks.
Attached Thumbnails
Click image for larger version

Name:	PID Code 1.png
Views:	65
Size:	197.5 KB
ID:	18041  
Reply With Quote
  #2   Spotlight this post!  
Unread 29-01-2015, 07:29
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: PID Issue

Quote:
Originally Posted by rclothier View Post
The robot is on blocks, so there's no real load on the wheels; shouldn't it work anyway? (We don't want to put it on the ground when it's acting crazy.)
Placing the robot on the floor might surprise you with how well-behaved it becomes. You're trying to tune a velocity PID when the system is essentially unloaded. As you have discovered, such a system is very unstable. There is not enough damping to keep it from immediately overshooting the set point and oscillating wildly.

If you put some load on the wheels, you will get much better results. You could also try to introduce some artificial inertia into the system by limiting the rate of change of the motor commands.
Reply With Quote
  #3   Spotlight this post!  
Unread 29-01-2015, 08:02
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: PID Issue

Quote:
Originally Posted by rclothier View Post
When the gain gets above 0.007, the wheels ramp up directly to full speed (+/- 1); the encoder velocity (process variable) goes to about 250 in/s. Its basically all or nothing.
This makes me think you may have a sign issue in the math. Do not set it on the floor until you check for this or else you might damage something or someone.

Run the test you described above again and compare your axis value and your rate value. Do they have the same sign (i.e. are both positive or both negative?). If they have different signs, your controller will become unstable (i.e. the speed will quickly ramp up to full speed). In this case, you will need to negate the encoder rates, then try again. The controller should become well behaved after that.

One other thing: are you scaling the axis values from -1 to 1 to a value in in/sec?
__________________
-
An ounce of perception is worth a pound of obscure.
Reply With Quote
  #4   Spotlight this post!  
Unread 29-01-2015, 14:41
rclothier rclothier is offline
Coach, Team 1723
AKA: Russell Clothier
FRC #1723 (The FIRST Bots of Independence, "The FBI")
Team Role: Coach
 
Join Date: Jan 2011
Rookie Year: 2006
Location: Independence, MO
Posts: 42
rclothier is on a distinguished road
Re: PID Issue

Thank you both for your reply. I will check the +/- sign on the controller first, and if that doesn't fix it, I'll put it on the floor and see if it tracks better. I can't do it until Saturday, but I'll let you know how it turns out.

We currently aren't using the joystick with the PID, only target numbers entered from a control on the front panel. If/when we do add the joystick, we will do a conversion, as you suggest.
Reply With Quote
  #5   Spotlight this post!  
Unread 29-01-2015, 15:15
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: PID Issue

I didn't look closely enough at your code before, but now I see that you might have a fundamental problem. Think about what happens when the wheel speed matches the rate you're commanding. What's the output of the PID function going to be?

Zero.

That's not what you want to tell the motors. I think the simplest fix would be to "integrate" the output of the PID in order to make things work right. Instead of feeding it to the Tank Drive directly, use the PID output to add to or subtract from the motor speed command. That way, when the feedback and setpoint are the same, the motor will continue at its current speed.

Another way to do it is possible, but it isn't as simple to implement when using the "Academic PID" that LabVIEW provides.
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 03:52.

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