Go to Post Not everything has to be cashed in or has to have instant recognition. Sometimes being a part of a program of value and opportunity is enough. And, what you put into the program is what you get out of it. - JaneYoung [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 02-02-2016, 15:51
2386programming 2386programming is offline
Registered User
FRC #2386 (Trojans)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2011
Location: Burlington
Posts: 34
2386programming is an unknown quantity at this point
PID While Loop

I have put a PID into my code for autonomous. The PID is inside of a while loop, how would I stop the loop once the PID reaches it's set point? We are using labview for programming.

Last edited by 2386programming : 02-02-2016 at 15:57.
Reply With Quote
  #2   Spotlight this post!  
Unread 02-02-2016, 16:16
aeastet aeastet is offline
Programming Mentor
AKA: Tim Easterling
FRC #6043 (Allegan Tigers Robotics)
Team Role: Coach
 
Join Date: Jan 2015
Rookie Year: 2011
Location: Holland, MI
Posts: 116
aeastet is an unknown quantity at this point
Re: PID While Loop

Posting your code would make it easier to help or at least a picture of the area you are talking about.

Normally you do not stop a PID that is running the motor for RPM. That is the purpose of the PID to get the motor to the proper RPM and them maintain it.

Unless we know what you are doing in your code it would be difficult to tell you how to do what you are trying to accomplish.

Tim
Reply With Quote
  #3   Spotlight this post!  
Unread 02-02-2016, 16:29
2386programming 2386programming is offline
Registered User
FRC #2386 (Trojans)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2011
Location: Burlington
Posts: 34
2386programming is an unknown quantity at this point
Re: PID While Loop

Here ya go
Attached Thumbnails
Click image for larger version

Name:	cooode.png
Views:	62
Size:	99.2 KB
ID:	19942  
Reply With Quote
  #4   Spotlight this post!  
Unread 02-02-2016, 16:43
aeastet aeastet is offline
Programming Mentor
AKA: Tim Easterling
FRC #6043 (Allegan Tigers Robotics)
Team Role: Coach
 
Join Date: Jan 2015
Rookie Year: 2011
Location: Holland, MI
Posts: 116
aeastet is an unknown quantity at this point
Re: PID While Loop

Why do you have the PID in the other loop? From what I see you are using it to turn. If this is true once you get the PID to turn your robot it should go to close to zero on the output if you set it up correctly. If you put it in the same loop you could use an "In Range?" vi to make your robot quit turning if your PID has some residual output. If you put this in a second loop things get more difficult.

The other thing I see is that you are trying to feed values from one loop to the other with tunnels. That is not the way LabVIEW works. If you want to get a values into the bottom loop you will have to use a local variable or some pther method to do that. THe distance will not go to the bottom loop this way.

Last edited by aeastet : 02-02-2016 at 16:45.
Reply With Quote
  #5   Spotlight this post!  
Unread 02-02-2016, 16:51
2386programming 2386programming is offline
Registered User
FRC #2386 (Trojans)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2011
Location: Burlington
Posts: 34
2386programming is an unknown quantity at this point
Re: PID While Loop

I'll try putting the Pid in the other loop. What is being done is we have made an algorithm to find out how far back or forward we need to move to be in line with the lower goal. The PID is to have the robot move to the proper setpoint.
Reply With Quote
  #6   Spotlight this post!  
Unread 05-02-2016, 08:48
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
FRC #4901 (Garnet Squadron)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Columbia, SC
Posts: 1,126
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: PID While Loop

So a few problems here.

A while loop with no time constraint is asking for trouble. It'll eat up your CPU resources running as fast as possible while not maintaining a constant delta time between calls. That will make it untunable since the dT between calls is never the same. That's my biggest

If you want to terminate a separate running while loop, you can use Notifiers. Definitely look at some example code in the LabVIEW help. If you use Obtain Notifier in code that you call often, you need to call Release Notifier, or else it will eat up all your RAM over time. Ask me how I know...

But, as aeastet, you typically want to keep your PID running at all times. Perhaps put it in a while loop in Period Tasks that runs every 50ms? You can share the set-point using global variables or notifiers.
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

Previous mentor and student from Team Fusion, FRC 364
Reply With Quote
  #7   Spotlight this post!  
Unread 06-02-2016, 23:43
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 While Loop

It looks like you want to share data constantly between the two loops by running wires between them. That's not how LabVIEW works -- a loop doesn't produce an output until it has finished running. You need to put everything in the same loop, or you can share data using variables (local or global) or queues or some other mechanism.
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 08:06.

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