Go to Post Mind you... if your ball kicker has as much energy stored up as a trackball launcher, you ought to be able to kick balls up into the stands. - dtengineering [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 17-02-2010, 20:29
lsprague lsprague is offline
Registered User
FRC #3256 (WarriorBorgs)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2009
Location: San Jose, CA
Posts: 1
lsprague is an unknown quantity at this point
Programming Pots

We planned to set up joystick buttons to make the kicker move to a set position using potentiometers, but it keeps overshooting and getting stuck. Here's what we have:

Code:
if(rightstick->GetRawButton(HIGH_POT_BTN))
{
while(kickerValue != HIGH_POT)
{
GetWatchdog().Feed();
if(kickerValue>HIGH_POT)
winch->Set(Relay::kForward);
else 
winch->Set(Relay::kReverse);
}
else
winch->Set(Relay::kOff);
}
We tried using if instead of while because of watchdog problems, but that would only work by holding the button down. Now, the kicker pulls back too far and gets stuck. Does anyone know if it's a problem in the code or in the numbers we used for the pots?
  #2   Spotlight this post!  
Unread 17-02-2010, 21:11
miniman's Avatar
miniman miniman is offline
Registered User
FRC #0701
 
Join Date: Sep 2007
Rookie Year: 2007
Location: fairfield
Posts: 10
miniman is an unknown quantity at this point
Re: Programming Pots

be careful with your comparison of kickerValue to HIGH_POT. because the programs happens in loops, kickerValue is a snapshot of it's current position, a frame if you will. The moment that kickerValue is equal to High_POT may occur between frames. Use a >= or <=, to check if kickerValue is at or past the HIGH_POT value.

The idea is that with a single button press, the kicker will move to a position determined by a pot right?

Code:
if (button pressed)
    //set a bool to true to indicate that the kicker is in forward "mode"
if (in forward mode)
{
     if(kickerValue < HIGH_POT)
         //move kicker forward
     else
     {
          //stop kicker
          //set bool to false to indicate the kicker is done
     }
}
good idea to use a variable stopping point for the kicker.
__________________
--The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' (I found it!) but 'That's funny ...' -Issac Asimov

Last edited by miniman : 17-02-2010 at 21:20.
  #3   Spotlight this post!  
Unread 17-02-2010, 21:42
kevin.li.rit's Avatar
kevin.li.rit kevin.li.rit is offline
Imaginary Friend
AKA: Kevin Li
FRC #0596 (SciClones)
Team Role: Student
 
Join Date: Jan 2003
Rookie Year: 2001
Location: Hopkinton, Massachusetts
Posts: 936
kevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond reputekevin.li.rit has a reputation beyond repute
Send a message via Yahoo to kevin.li.rit
Re: Programming Pots

Am I correct in assuming that the motor turns full on when the pot value is less then the joystick and doesn't turn off until after it goes past?

You can set up a PID Loop to control the overshoot even if you are only bringing it to one position. A quick search of CD will give you a lot of information. Basically you are going to take the difference between the value of the joystick and the potentiometer to set the speed of the motor (needs to be on a speed controller of course).
__________________
Kevin Li

596 - Sciclones
1405 - Finney Falcons
2262 - Holliston Panthers
  #4   Spotlight this post!  
Unread 18-02-2010, 11:31
DCRich DCRich is offline
Mentor
FRC #2180 (Zero Gravity)
Team Role: Mentor
 
Join Date: Nov 2008
Rookie Year: 2006
Location: Steinert H.S., Hamilton NJ
Posts: 21
DCRich is an unknown quantity at this point
Re: Programming Pots

PID is the best way to approach a set point. But in this case, it may be over engineering. The problem is that "not equal" in your while loop. In pure math equal or not equal is well defined. In real world engineering there are always tolerances. The A/D will have a noise floor for every signal so when you look to find a specific voltage you may never actually see. Change the while loop to less than High_Pot and then it will stop once it reaches the value or just a tad beyond - unless you are running so fast that the CPU does not see the change (not very likely with the cRIO). Good rule of thumb is to never use = or != when dealing with sensors.
  #5   Spotlight this post!  
Unread 18-02-2010, 13:50
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: Programming Pots

The way I always do this sort of thing is the following:

Code:
...encoder stuff to set up theEncoder (or potentiometer) and shove its value into iEncVal...

int setPoint;

if(iButton1){
setPoint = 100;
}
if(iButton2){
setPoint = 1000;
}

if(abs(iEncVal - setPoint) > DEADBAND){
if(iEncVal < (setPoint - approachDistance)){
motor->Set(1);
}else{
motor->Set(formula to figure out an scaled value based on approachDistance);
}
if(iEncVal > (setpoint + approachDistance)){
//stuff goes here
}
}else{
motor->Set(0);
}
Basically, make the buttons change the setPoint, and the motor ALWAYS drives to the current set point, and scales its speed down on approach (I find 10 encoder ticks generally works).
Closed Thread


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
small joystick pots?? Bruceb Control System 1 18-02-2008 11:59
10 turn 100k pots rust710 Electrical 5 02-04-2003 15:10
Limit Switches/Pots Brett W Technical Discussion 3 28-01-2003 14:25
THIS IS AN OT POTS!!!!!1!!!! (EOM) archiver 2001 0 24-06-2002 03:17
3-turn pots archiver 2001 2 24-06-2002 01:24


All times are GMT -5. The time now is 10:07.

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