Go to Post I'm about to brain myself on a wall in frustration! - pfreivald [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 04-02-2017, 18:09
Arod192's Avatar
Arod192 Arod192 is offline
Registered User
AKA: Andrew Rodriguez | Koala
FRC #1972 (Searing Engineering)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Imperial California
Posts: 4
Arod192 is an unknown quantity at this point
We are trying to set up PID

This is the first year where we are
actually trying to do some of the more "complex" stuff. We are having a lot
of trouble with PID loops, attached are some pictures of our teleop and begin code.

Reply With Quote
  #2   Spotlight this post!  
Unread 04-02-2017, 18:24
flemdogmillion's Avatar
flemdogmillion flemdogmillion is offline
Programmer, Builder, Driver...
FRC #3007
 
Join Date: Nov 2016
Rookie Year: 2015
Location: Minnesota
Posts: 149
flemdogmillion will become famous soon enoughflemdogmillion will become famous soon enough
Re: We are trying to set up PID

P is proportional gain. That gain pushes back based on how far off you are. I is integral gain. It pushes back based on how long you've been how far away. Finally, D is derivative gain. It pushes back based on how fast you're going away.

In LabVIEW, it works a little weird, as you'll notice you have proportional gain, integral "time" and derivative "time." The way this works is that when you increase the P gain, all three gains are actually being increased, and the "time" values are multiplied by the P values to get their respective gain values (in a very weird way, there are extra multipliers in there, so don't go trying to figure out what your gains are, just roll with it)

You have to tune PID loops no matter what, it takes time, it's slightly dangerous (integral gain can run away from you fast, so have your hand on the E-stop), and honestly it's far from easy.

Good luck!
__________________
Team 4506: 2015-2016
Team 3007: 2017

Jack of all trades except C++ & Java
Reply With Quote
  #3   Spotlight this post!  
Unread 04-02-2017, 18:54
Owen Makin Owen Makin is offline
Registered User
FRC #1972
 
Join Date: Jan 2013
Location: CUHS El Centro
Posts: 52
Owen Makin is an unknown quantity at this point
Re: We are trying to set up PID

I am also part of this team. We understand the theory of the PID loop, but are having a hard time understanding if our application is correct. We have a PID loop to rotate the robot with a gyro to a set point and the PID works fine it that situation. At least with a tolerance of about 5 degrees. But getting the encoders to rotate at a constant speed is the issue. We are wondering, if there is an issue with how we are getting our rate. If our rate is outputting a value that makes sense. Why our PID loop does not reach our setpoint.
Reply With Quote
  #4   Spotlight this post!  
Unread 04-02-2017, 20:12
flemdogmillion's Avatar
flemdogmillion flemdogmillion is offline
Programmer, Builder, Driver...
FRC #3007
 
Join Date: Nov 2016
Rookie Year: 2015
Location: Minnesota
Posts: 149
flemdogmillion will become famous soon enoughflemdogmillion will become famous soon enough
Re: We are trying to set up PID

If your robot doesn't complete the movement, try raising your integral gain.
__________________
Team 4506: 2015-2016
Team 3007: 2017

Jack of all trades except C++ & Java
Reply With Quote
  #5   Spotlight this post!  
Unread 04-02-2017, 20:59
Owen Makin Owen Makin is offline
Registered User
FRC #1972
 
Join Date: Jan 2013
Location: CUHS El Centro
Posts: 52
Owen Makin is an unknown quantity at this point
Re: We are trying to set up PID

Quote:
Originally Posted by flemdogmillion View Post
If your robot doesn't complete the movement, try raising your integral gain.
The robot is not completing the ramp up to speed. This solution you have proposed is, if I understand correctly, helpful only if the motor does not have enough power to get up to speed. This is not the case as the robot is off the floor and the wheels are free spinning. As i increase the P value it climbs, but then begins to behave erraticly and the motor values jump quickly between 1 and -1.
Leave the P value at a value thay does produce erractic behavior, such as the value above, and increasing the I anywhere from 1000 to 1 will also produce erractic rate changes and sometimes stop producing a motor output.
Reply With Quote
  #6   Spotlight this post!  
Unread 05-02-2017, 11:47
flemdogmillion's Avatar
flemdogmillion flemdogmillion is offline
Programmer, Builder, Driver...
FRC #3007
 
Join Date: Nov 2016
Rookie Year: 2015
Location: Minnesota
Posts: 149
flemdogmillion will become famous soon enoughflemdogmillion will become famous soon enough
Re: We are trying to set up PID

Quote:
Originally Posted by Owen Makin View Post
The robot is not completing the ramp up to speed. This solution you have proposed is, if I understand correctly, helpful only if the motor does not have enough power to get up to speed. This is not the case as the robot is off the floor and the wheels are free spinning. As i increase the P value it climbs, but then begins to behave erraticly and the motor values jump quickly between 1 and -1.
Leave the P value at a value thay does produce erractic behavior, such as the value above, and increasing the I anywhere from 1000 to 1 will also produce erractic rate changes and sometimes stop producing a motor output.
1000 to 1? We're talking FRC robots in Labview here. The units on the I and D values are in minutes. It's really weird, I know.

Also, if the motor overshoots an oscillates, increase derivative gain.
__________________
Team 4506: 2015-2016
Team 3007: 2017

Jack of all trades except C++ & Java
Reply With Quote
  #7   Spotlight this post!  
Unread 05-02-2017, 13:31
sraque's Avatar
sraque sraque is offline
Registered User
AKA: Steve Raque
FRC #2614 (MARS)
Team Role: Mentor
 
Join Date: Jun 2012
Rookie Year: 2009
Location: Morgantown, WV
Posts: 93
sraque is on a distinguished road
Re: We are trying to set up PID

As stated, the Labview PIDs are weird and, for us, have always defied tuning in a way that we understand.

Though you may not wish such a change, I have attached our PID VI. It has inputs consistent with common PID control practice (i.e. not coupled). It is a re-entrant VI so you can use it multiple times, and there are comment statements in it to explain its use, but feel free to PM me.
Attached Files
File Type: zip CustomPID_v2.1.zip (29.1 KB, 9 views)
Reply With Quote
  #8   Spotlight this post!  
Unread 05-02-2017, 18:38
BitTwiddler's Avatar
BitTwiddler BitTwiddler is online now
electronics/programming mentor
AKA: Mr Tanguay
FRC #1726 (N.E.R.D.S.)
Team Role: Mentor
 
Join Date: Oct 2008
Rookie Year: 2006
Location: Sierra Vista, AZ
Posts: 254
BitTwiddler is on a distinguished road
Re: We are trying to set up PID

We too are using PID this year and are having some luck with it for a change.
I've attached a couple of images of some helper VIs we created. The drive VI uses the NI LabView PID. We didn't have much luck controlling turns with it so we created our own PID using Proportional only. Seems to work pretty well too.
For driving we only use the encoders to tell us when to stop, the gyro works with PID to keep us going straight.
Attached Thumbnails
Click image for larger version

Name:	1726 PID.JPG
Views:	18
Size:	76.0 KB
ID:	21717  

Last edited by BitTwiddler : 05-02-2017 at 18:44. Reason: More info.
Reply With Quote
  #9   Spotlight this post!  
Unread 05-02-2017, 18:57
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,945
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: We are trying to set up PID

Looks nice.
Do you realize that the In Range and Coerce function has it's upper limit disabled (by default)? That's why it's a clear box, rather than a filled box like the lower limit has.
Right-click on the function and choose Include upper limit
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 05-02-2017 at 19:03.
Reply With Quote
  #10   Spotlight this post!  
Unread 05-02-2017, 19:37
BitTwiddler's Avatar
BitTwiddler BitTwiddler is online now
electronics/programming mentor
AKA: Mr Tanguay
FRC #1726 (N.E.R.D.S.)
Team Role: Mentor
 
Join Date: Oct 2008
Rookie Year: 2006
Location: Sierra Vista, AZ
Posts: 254
BitTwiddler is on a distinguished road
Re: We are trying to set up PID

Quote:
Originally Posted by Mark McLeod View Post
Looks nice.
Do you realize that the In Range and Coerce function has it's upper limit disabled (by default)? That's why it's a clear box, rather than a filled box like the lower limit has.
Right-click on the function and choose Include upper limit
Wow! As many times as I've used it I never noticed that. Something new every day.
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 19:50.

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