Go to Post The greatest lesson we can teach our kids is how to win. - AdamHeard [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
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 03-02-2009, 17:14
nate15810's Avatar
nate15810 nate15810 is offline
World's Most Clueless Programmer
FTC #0154 (154 Renegade)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Rhode Island
Posts: 22
nate15810 is an unknown quantity at this point
[FTC]: Toggle controls

Is it possible to toggle the controls?
i have a couple of servos that need it
Reply With Quote
  #2   Spotlight this post!  
Unread 03-02-2009, 19:44
Michael Coleman's Avatar
Michael Coleman Michael Coleman is offline
Registered User
no team
 
Join Date: Nov 2006
Rookie Year: 2001
Location: Orlando, Florida
Posts: 82
Michael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of light
Re: [FTC]: Toggle controls

Can you provide additional details about what is meant by "toggle the controls?"

Thanks,

Michael
Reply With Quote
  #3   Spotlight this post!  
Unread 05-02-2009, 15:33
nate15810's Avatar
nate15810 nate15810 is offline
World's Most Clueless Programmer
FTC #0154 (154 Renegade)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Rhode Island
Posts: 22
nate15810 is an unknown quantity at this point
Re: [FTC]: Toggle controls

Push a button...the servo goes there
release the button and it says there
push again and it goes to the starting position
release and it stays there
ex)


animation made by me
Reply With Quote
  #4   Spotlight this post!  
Unread 05-02-2009, 16:22
Michael Coleman's Avatar
Michael Coleman Michael Coleman is offline
Registered User
no team
 
Join Date: Nov 2006
Rookie Year: 2001
Location: Orlando, Florida
Posts: 82
Michael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of light
Re: [FTC]: Toggle controls

Great animation! Thanks.

Which programming language are you using?

Michael
Reply With Quote
  #5   Spotlight this post!  
Unread 05-02-2009, 16:42
nate15810's Avatar
nate15810 nate15810 is offline
World's Most Clueless Programmer
FTC #0154 (154 Renegade)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Rhode Island
Posts: 22
nate15810 is an unknown quantity at this point
Re: [FTC]: Toggle controls

Robot C
Reply With Quote
  #6   Spotlight this post!  
Unread 05-02-2009, 18:05
ttldomination's Avatar
ttldomination ttldomination is offline
Sunny
no team
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2007
Location: Roanoke, TX
Posts: 2,066
ttldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond repute
Re: [FTC]: Toggle controls

OK. So what you want is that when u press a button, let's assume button 1, then the servo moves to one position. if you press another button, the servo moves to an original position.

So, the code has is a tad bit more complex.

int sum = 2;

if(joy2Btn(1)) // if button one is pressed
{
sum = sum +1;
}

int calcremainder = sum % 2; // This line calculates the remainder of sum/2.

if (calcremainder = 0)
{
servo[Servo1] = 100;
}
else
{
servo[Servo1] = 0;
}

So the code above basically does this. Each time you hit the button, the program counts it. I know there's an official counter in the program, but i'm ghetto like this.

Then, it takes the number of times the button has been hit, and it divides by 2. So, then the value can either be 0 or 1. So each time you hit the button, the value switches between 0 and 1, so when the value is 0, you have a position, when it is 1 you have a position.

That's the logic.
There might be a better way, but this is one possibly option.
__________________
1261: 2007-2012
1648: 2013-2014
5283: 2015
Reply With Quote
  #7   Spotlight this post!  
Unread 05-02-2009, 18:39
nate15810's Avatar
nate15810 nate15810 is offline
World's Most Clueless Programmer
FTC #0154 (154 Renegade)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Rhode Island
Posts: 22
nate15810 is an unknown quantity at this point
Re: [FTC]: Toggle controls

it just makes the arm reverse itself
Reply With Quote
  #8   Spotlight this post!  
Unread 05-02-2009, 19:41
ttldomination's Avatar
ttldomination ttldomination is offline
Sunny
no team
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2007
Location: Roanoke, TX
Posts: 2,066
ttldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond repute
Re: [FTC]: Toggle controls

That code above should do what the animation does. But you will have to put in the correct servo values.
__________________
1261: 2007-2012
1648: 2013-2014
5283: 2015
Reply With Quote
  #9   Spotlight this post!  
Unread 06-02-2009, 16:14
nate15810's Avatar
nate15810 nate15810 is offline
World's Most Clueless Programmer
FTC #0154 (154 Renegade)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Rhode Island
Posts: 22
nate15810 is an unknown quantity at this point
Re: [FTC]: Toggle controls

yeah, i put that in and reset the servo values, but it just reversed the servo...
here's my code
Code:
int sum = 2;

if(joy2Btn(2)) // if button 2 is pressed
{
sum = sum +1;
}

int calcremainder = sum % 2; // This line calculates the remainder of sum/2.

if (calcremainder == 0) <this was an error in your lines...it needed a double=
{
servo[ServoB] = 100;
}
else
{
servo[ServoB] = 0;
}
Reply With Quote
  #10   Spotlight this post!  
Unread 06-02-2009, 16:54
Ethan Spitz Ethan Spitz is offline
President
FRC #3637 (The Daleks)
Team Role: Leadership
 
Join Date: Feb 2009
Rookie Year: 2011
Location: New Jersey
Posts: 133
Ethan Spitz is an unknown quantity at this point
Re: [FTC]: Toggle controls

What do you mean it makes the servos reverse themselves?

Also, I don't see how that works if the counter resets itself each time, it wouldn't stay I don't believe

Code:
int touch = 1;
//put variable before while loop

if(joy2Btn(1)) {
   if(touch == 1){
     touch = 0;
   }else{
     touch = 1;
   }
}

//you may want a really short wait here so when you press the button it does not switch back to original really quick

if(touch == 1){
  servo[ServoB] = 100;
}else{
  servo[ServoB] = 0;
}
Reply With Quote
  #11   Spotlight this post!  
Unread 06-02-2009, 19:09
ttldomination's Avatar
ttldomination ttldomination is offline
Sunny
no team
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2007
Location: Roanoke, TX
Posts: 2,066
ttldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond reputettldomination has a reputation beyond repute
Re: [FTC]: Toggle controls

ah yes. The counter would have to be outside the while loop.

That is a basic code.

Now there is an official counter which might be better than actually going in and creating another variable. It probably won't make a huge difference, but whateva you want.
__________________
1261: 2007-2012
1648: 2013-2014
5283: 2015
Reply With Quote
  #12   Spotlight this post!  
Unread 10-02-2009, 14:47
nate15810's Avatar
nate15810 nate15810 is offline
World's Most Clueless Programmer
FTC #0154 (154 Renegade)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Rhode Island
Posts: 22
nate15810 is an unknown quantity at this point
Re: [FTC]: Toggle controls

still doesn't do anything
...thanks anaways guys
if you could figure it out, thanks for putting up with me
Reply With Quote
  #13   Spotlight this post!  
Unread 10-02-2009, 16:53
nate15810's Avatar
nate15810 nate15810 is offline
World's Most Clueless Programmer
FTC #0154 (154 Renegade)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Rhode Island
Posts: 22
nate15810 is an unknown quantity at this point
Re: [FTC]: Toggle controls

found this online, but i tried converting it and with my small ammount of programming knowledge, i didn't get very far

Code:
#include <stdio.h>
 
int main() {
     int x;
     for (x = 0; x < 10; x++) {
          if(x == 1 || x == 4 ) {
               continue;
          }
          else if(x == 8) {
               break;
          }
          else {
               printf("x = %d", x);
          }
     }
 
     return (1);
}
Reply With Quote
  #14   Spotlight this post!  
Unread 10-02-2009, 17:21
ptan ptan is offline
Paul C. Tan., P.Eng.
AKA: Paul Tan
no team (Bolt Action)
Team Role: Mentor
 
Join Date: Dec 2005
Rookie Year: 2000
Location: Toronto
Posts: 61
ptan is a splendid one to beholdptan is a splendid one to beholdptan is a splendid one to beholdptan is a splendid one to beholdptan is a splendid one to beholdptan is a splendid one to behold
Re: [FTC]: Toggle controls

The modulo ("%") function code will do what you want, but you really should look into state machines. The code should look more like:

int state=0;

while (true) {
... (add your getjoystick function here)
... (and any other code you have)

switch (state) {
case 0:
if(joy2Btn(1)) // if button one is pressed
{
// Move your server to the first position (aka state)
servo[Servo1] = 100;
state = 1;
}
break;
case 1:
if (joy2Btn(1) == 0) {
// if the button was released then we can wait for another
// button push
state = 2;
}
break;
case 2:
if(joy2Btn(1)) // if button one is pressed
{
// now move your servo to the other position (aka state)
servo[Servo1] = 0;
state = 3;
}
break;
case 3:
if (joy2Btn(1) == 0) {
// again, wait for the button to be released
// before we look for another push
state = 0;
}
break;
default:
state = 0;
break;
}

}


Hope this helps.

Paul Tan.
__________________
Paul C. Tan., P.Eng.
Coach - FTC Team 27 (now retired)
Coach - VRC Team 2027 (now retired)
Past Mentor - FRC Teams 188, 610, 1009, 2634
Reply With Quote
  #15   Spotlight this post!  
Unread 11-02-2009, 20:19
nate15810's Avatar
nate15810 nate15810 is offline
World's Most Clueless Programmer
FTC #0154 (154 Renegade)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Rhode Island
Posts: 22
nate15810 is an unknown quantity at this point
Re: [FTC]: Toggle controls

thanks...will try it tomorrow...that's when we meet....


i get this when i try it...

Last edited by nate15810 : 12-02-2009 at 14:53.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[FTC]: FTC]: FTC Champ Tournament - Ontario (Scoring Breakdown) Mr. Lim FIRST Tech Challenge 2 03-03-2008 11:54
[FTC]: [FTC]: Ontario Provincial FTC Start/End Times cbhl FIRST Tech Challenge 8 16-12-2007 13:37
toggle switch Windward Programming 31 27-01-2006 22:38
Code: Toggle on Tap Dave Scheck Programming 0 11-02-2005 18:07
Toggle? f22flyboy Programming 5 03-11-2002 08:03


All times are GMT -5. The time now is 12:35.

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