Go to Post note to self: MUST try harder to be funnier... - dlavery [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: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 06-02-2012, 20:11
Teamcodeorange's Avatar
Teamcodeorange Teamcodeorange is offline
Registered User
FRC #3476
 
Join Date: Jan 2011
Location: US
Posts: 236
Teamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant future
Exclamation Shooter PID loop

I know this has been asked many times before, but none of the answers I found are clear enough for me. How exactly do I program a PID loop to make sure our shooter is at the right rpm, compensating for variables such as battery voltage?

I know labview pretty well but PIDs look really complicated. We have a flywheel shooter with a US digital encoder. I would like to be able to input any rpm value I want (eg 1-8000 rpm) and have the motor automatically speed up or slow down to ~+/- 100 rpms of the requested speed.

Any help is greatly appreciated.
Reply With Quote
  #2   Spotlight this post!  
Unread 06-02-2012, 20:33
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,034
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: Shooter PID loop

Quote:
Originally Posted by Teamcodeorange View Post
...I know labview pretty well but PIDs look really complicated.... How exactly do I program a PID loop
You don't have to program it; that's already been done for you. There's a PID vi in LabVIEW.

Your desired speed goes to the setpoint input. The encoder signal goes to the process variable input. The output goes to the motor.

You will have to "tune" (adjust) the P I and D gains to make it work right.

Quote:
none of the answers I found are clear enough for me
Ask some specific targeted questions.

Reply With Quote
  #3   Spotlight this post!  
Unread 06-02-2012, 20:52
Teamcodeorange's Avatar
Teamcodeorange Teamcodeorange is offline
Registered User
FRC #3476
 
Join Date: Jan 2011
Location: US
Posts: 236
Teamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant future
Re: Shooter PID loop

Quote:
Originally Posted by Ether View Post

Ask some specific targeted questions.

So what do I do from here? I am kind of a noob in complex data management.
Attached Thumbnails
Click image for larger version

Name:	labview.PNG
Views:	143
Size:	10.2 KB
ID:	11777  
Reply With Quote
  #4   Spotlight this post!  
Unread 07-02-2012, 15:15
kuh-nig-its-EL's Avatar
kuh-nig-its-EL kuh-nig-its-EL is offline
Registered User
FRC #1939
 
Join Date: Jan 2011
Location: US
Posts: 26
kuh-nig-its-EL is on a distinguished road
Re: Shooter PID loop

It may be easier for you to use a CAN jaguar instead. CAN will do most of the PID work for you and there is an example already in labview for it. It's actually quite simple. For PID calculations try using Ziegler–Nichols method. Just keep adjusting P until you get a set oscillation and then the rest is easy.

-Ethan Lopez
Reply With Quote
  #5   Spotlight this post!  
Unread 07-02-2012, 15:48
j.cole j.cole is offline
Registered User
FRC #0379
 
Join Date: Jan 2010
Location: Girard
Posts: 159
j.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud of
Re: Shooter PID loop

@Ether You can't simply put the encoder into the PID process variable you have to find the speed of the motor using the encoder and put that into there. Correct? Unless I'm missing something.
__________________

It's not normally a good idea to give a programmer a drill but rules are made to be broken.
Reply With Quote
  #6   Spotlight this post!  
Unread 07-02-2012, 15:59
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,034
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: Shooter PID loop

Quote:
Originally Posted by j.cole View Post
@Ether You can't simply put the encoder into the PID process variable you have to find the speed of the motor using the encoder and put that into there. Correct? Unless I'm missing something.
You have to scale the process variable (the encoder signal) and/or the setpoint so they have the same range and offset.

Examples:

If your process variable (encoder signal) has been scaled to represent RPM, then you have to scale your setpoint so it also is in RPM (and not, say, -/+1).

Or you can do it the other way. If your setpoint has been scaled so that it has the value +1 when you want MaxRPM, and it has the value -1 when you want -MaxRPM, then you should scale your encoder signal so that it outputs +1 when the device it is measuring is spinning at MaxRPM, and it outputs -1 when the device it is measuring is spinning at -MaxRPM.


Last edited by Ether : 07-02-2012 at 16:07.
Reply With Quote
  #7   Spotlight this post!  
Unread 07-02-2012, 16:29
Tommy F.'s Avatar
Tommy F. Tommy F. is offline
Yeah! Collages!
AKA: 7h0m45
FRC #1985 (Robohawks)
Team Role: Alumni
 
Join Date: Mar 2011
Rookie Year: 2010
Location: St. Louis, MO
Posts: 188
Tommy F. is just really niceTommy F. is just really niceTommy F. is just really niceTommy F. is just really nice
Re: Shooter PID loop

Quote:
Originally Posted by Teamcodeorange View Post
So what do I do from here? I am kind of a noob in complex data management.
From there, I would go to "Help" > "Find Examples..." and in the NI Example Finder search for "PID" and look for the General PID Simulator.vi (or any other one you would like to use)

In the block diagram of the example, I would copy the PID gain cluster and the bundle + chart with the PV Setpoint Output label, so your code might look something like below.

Click image for larger version

Name:	pid.JPG
Views:	111
Size:	15.3 KB
ID:	11791

I like to include the graph so that the gains are easier to tune, as well as using the controls so you can adjust them while the code is running. (When you get the gains the way you want them, be sure to write them down and take out the controls and replace them with constants; they tend to reset themselves.)
__________________

FTC 289, 290 & 291 :: FRC 1985

2013 St. Louis Regional Semi-Finalist (with 3411 and 4330), Industrial Design Award
2013 Queen City Regional Winner (with 379 and 447)

Reply With Quote
  #8   Spotlight this post!  
Unread 07-02-2012, 20:02
Teamcodeorange's Avatar
Teamcodeorange Teamcodeorange is offline
Registered User
FRC #3476
 
Join Date: Jan 2011
Location: US
Posts: 236
Teamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant future
Re: Shooter PID loop

Thanks guys! I'll try to work off of that.
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:56.

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