Go to Post Two students with no clue but enough dedication to work on something is always better than one expert who doesn't care enough not to leaveit until the last day. - Matt Krass [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 11-25-2015, 01:20 PM
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,539
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Off Season Programming Question: Switch Statements

Quote:
Originally Posted by tomy View Post
When I ran that code it went into the first case statement got to the target then stopped. It doesn't seem to want to go into the second case statement.
Did you put this in the IsAutonomous && IsEnabled loop?
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #2   Spotlight this post!  
Unread 11-25-2015, 01:24 PM
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 490
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Off Season Programming Question: Switch Statements

Quote:
Originally Posted by GeeTwo View Post
Did you put this in the IsAutonomous && IsEnabled loop?


Yes. I figured out the problem and I'm trying to think of a way to fix it.

Code:
case 2:
     if(pid.OnTarget()){
          step++;
     }
     break;
That section of code is not change the value of step. I put "step" on the smart dash board and once it gets to case 2 it doesn't move on to case 3. I also checked the value of the encoder with the smart dashboard and it is getting to get set point.


EDIT: I just put the pid.OnTarget(); on the smart dashboard; it never changes to true. I cant figure out why.

Last edited by tomy : 11-25-2015 at 01:32 PM.
Reply With Quote
  #3   Spotlight this post!  
Unread 11-25-2015, 01:56 PM
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,539
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Off Season Programming Question: Switch Statements

Quote:
Originally Posted by tomy View Post
I just put the pid.OnTarget(); on the smart dashboard; it never changes to true. I cant figure out why.
Have you checked what value is being returned from the sensor? Perhaps it's close enough to the actual value that the applied drive speed is within the deadband of the controller, but the sensor value is not within 0.5.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #4   Spotlight this post!  
Unread 11-25-2015, 02:04 PM
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 490
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Off Season Programming Question: Switch Statements

Quote:
Originally Posted by GeeTwo View Post
Have you checked what value is being returned from the sensor? Perhaps it's close enough to the actual value that the applied drive speed is within the deadband of the controller, but the sensor value is not within 0.5.
The sensor value being returned is between 495-497. What do you mean the sensor value is not within 0.5? I thought the tolerance of the setpoint was set by pid.SetTolerance(); and that pid.SetOutPutRange(); was the maximum and minimum speed that you wanted the motor to move.
Reply With Quote
  #5   Spotlight this post!  
Unread 11-25-2015, 03:39 PM
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,539
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Off Season Programming Question: Switch Statements

Quote:
Originally Posted by tomy View Post
The sensor value being returned is between 495-497. What do you mean the sensor value is not within 0.5? I thought the tolerance of the setpoint was set by pid.SetTolerance(); and that pid.SetOutPutRange(); was the maximum and minimum speed that you wanted the motor to move.
IIRC, SetTolerance defines the allowable "plus-or-minus" for onTarget to return true. If your sensor is returning a value smaller than (or perhaps <=) 496.9, onTarget will continue to report false. Expand your tolerance to 2.0 or a bit higher, and this should let you move on.

Edit, I see that Tolerance is a percentage, so your answer must be above 496.5031 to have onTarget return true.

Re-edit: the percentage is a fraction of the range defined in SetInputRange(), which you have never called, so it defaults to zero. I suggest using SetAbsoluteTolerance() with a value of 2.0 or greater.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.

Last edited by GeeTwo : 11-25-2015 at 03:47 PM.
Reply With Quote
  #6   Spotlight this post!  
Unread 11-25-2015, 04:02 PM
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 490
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Off Season Programming Question: Switch Statements

That fixed it! Thanks for the help one last question. Shouldn't the input to .SetAbsoluteTolerance() be something like .4 instead of 4? I thought in the code it converted it to a percentage.
Reply With Quote
  #7   Spotlight this post!  
Unread 11-25-2015, 04:12 PM
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,539
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Off Season Programming Question: Switch Statements

SetAbsoluteTolerance() bypasses the percentage calculation, so that you specify the tolerance directly in terms of sensor output. SetTolerance() and SetPercentTolerance() are functionally equivalent and set the tolerance to a percentage of the range specified in the latest call to SetOutputRange(). Since you never called SetOutputRange, my reading of the source code makes me believe that these default to zero, so SetTolerance() will always produce a zero tolerance if SetOutputRange() has not been called.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
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 10:50 AM.

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