Go to Post We excel at making our robots nice and colorful. - AlecMataloni [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 20-03-2016, 10:15
btcshields6 btcshields6 is offline
Registered User
FRC #4206
 
Join Date: Aug 2014
Location: Texas
Posts: 107
btcshields6 is an unknown quantity at this point
Setting Mechanism Position with Button

Hey guys, I've got a question about triggering some PID loops.

So I built a small VI with a PID control in it that reads the value of a potentiometer and attempts to change it by actuating a motor (the reference voltages for various positions are inputted). I want to trigger moving to a different position using a button.

My plan is to put the VI in periodic tasks inside a case structure, and control it using a boolean that is tied to a joystick button. But I don't want to hold it down continuously while the loop executes. How could I program it to execute on the button press and continue executing (as true, so the code stays active in the loop) until it achieves the desired position (or a position very close to it; when it's in range). I want it to run until its close and then stop.

Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 20-03-2016, 14:45
btcshields6 btcshields6 is offline
Registered User
FRC #4206
 
Join Date: Aug 2014
Location: Texas
Posts: 107
btcshields6 is an unknown quantity at this point
Re: Setting Mechanism Position with Button

I'm thinking about trying to put it together as a button start of a timed action, similar to the Team 358 example shown here. Maybe have the PID loop execute for 3 sec?

Any thoughts on that?
Reply With Quote
  #3   Spotlight this post!  
Unread 20-03-2016, 16:03
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 325
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
Re: Setting Mechanism Position with Button

Can you provide more details on the mechanism that you are trying to control? Is it a requirement that the PID loop runs then quits?

An arm on a motor for example should probably keep the PID loop running. Position control on a drive train probably shouldn't, or if you must change to 'manual' (open loop) control.

In the case you describe, how do you decide when your PID loop is 'done'. Is a timer like in FRC358's example sufficient?
__________________
Programming in LabVIEW? Try VI Snippets!

FIRST LEGO League 2004 - 2005
FRC Team 870 Student 2006 - 2009
FRC Team 3005 Mentor 2013 -
Reply With Quote
  #4   Spotlight this post!  
Unread 20-03-2016, 17:04
rich2202 rich2202 is offline
Registered User
FRC #2202 (BEAST Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Wisconsin
Posts: 1,229
rich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond repute
Re: Setting Mechanism Position with Button

You need 2 functions.

Function 1: Looks at the Button, and sets a Variable when it is pressed. Make sure you "debounce" the button (all presses within n milliseconds is considered the same press).

Function 2: Looks at the Variable, and does whatever (move to different position) when it sees the variable set. When it is done, it resets the variable.
Reply With Quote
  #5   Spotlight this post!  
Unread 20-03-2016, 17:09
btcshields6 btcshields6 is offline
Registered User
FRC #4206
 
Join Date: Aug 2014
Location: Texas
Posts: 107
btcshields6 is an unknown quantity at this point
Re: Setting Mechanism Position with Button

It's an arm moving from an angle of about 15 degrees to about 75 degrees. I suspect a timed termination would be mostly sufficient, unless there was a mechanical conflict that prevented the actuation happening in the normal amount of time. However, I'd prefer it to terminate when it has confirmation that it's achieved the specified position, or something very near that, like with a deadband on a joystick control.

I know I could just leave the loops running constantly, and switch between them to get to different positions. The PID would 0 out, and presumably no movement would occur. But I just figured it'd be better to terminate after. The arm is worm gear, so it will not backdrive (so far it hasn't), so I just don't see a reason to keep it running.

Do I face any issues leaving it running? If not, I could have each loop in a separate case of a single case structure within periodic tasks, and switch between the cases to go to various positions, avoiding termination entirely.
Reply With Quote
  #6   Spotlight this post!  
Unread 20-03-2016, 18:46
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 325
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
Re: Setting Mechanism Position with Button

Instead of switching between multiple loops in different cases, what I am suggesting is having a single loop with the PID controller in it.

You could implement this with a simple global variable as your set point. When you press the button to change the arm angle, just write your desired position to the global variable.

So in periodic tasks you have a single loop for the PID controller. The loop constantly reads from the global variable which is set to the target arm position. When the arm is near the target the PID output will be close to 0. This is also where you can implement a deadband to force the output to 0.

Now in auton/teleop all you need to do to set the arm angle is write to the global variable.
__________________
Programming in LabVIEW? Try VI Snippets!

FIRST LEGO League 2004 - 2005
FRC Team 870 Student 2006 - 2009
FRC Team 3005 Mentor 2013 -
Reply With Quote
  #7   Spotlight this post!  
Unread 20-03-2016, 19:31
btcshields6 btcshields6 is offline
Registered User
FRC #4206
 
Join Date: Aug 2014
Location: Texas
Posts: 107
btcshields6 is an unknown quantity at this point
Re: Setting Mechanism Position with Button

That sounds like a good plan! Thanks!

I think I know how to implement nearly all of that. I'll post back if I have questions or run into issues.

Thank you,

Benjamin
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 20:25.

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