Go to Post I thought it said Cheesecake Regional and that's why I'm here. - madhav [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 Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 25-11-2009, 09:29
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
FTC, I have returned.
AKA: @doctorfogarty @GarnetSq
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,555
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
Question [FTC]: Buttons RobotC

I am trying to assign buttons to control a Tetrix DC motor when ever i assign 2 functions to control the same motor say one button forward and one backward the motor coughs and jumps and vibrates moving spastically. I attached the code below, how could i solve this problem?




if(joy2Btn(2) )
{
motor[motorF] = 100;
}
else
{
motor[motorF] = 0;
}

if(joy2Btn(1) )
{
motor[motorF] = -100;
}
else
{
motor[motorF] = 0;
}
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
Reply With Quote
  #2   Spotlight this post!  
Unread 25-11-2009, 10:53
emmell's Avatar
emmell emmell is offline
Murphy was an Optimist!
AKA: Mannie Lowe
no team (Radbotics, RoboKnights, CircuitRunners, Oscar, and more...)
Team Role: Coach
 
Join Date: Dec 2005
Rookie Year: 2005
Location: Marietta, GA
Posts: 178
emmell is just really niceemmell is just really niceemmell is just really niceemmell is just really niceemmell is just really nice
Re: [FTC]: Buttons RobotC

Let's break this down step by step:

Quote:
Originally Posted by John_1102 View Post
if(joy2Btn(2) )
{
motor[motorF] = 100;
}
else
{
motor[motorF] = 0;
}
What the above "if" is saying is "If Button 2 on Joystick 2 is pushed, set power to motorF to 100%. Otherwise, set it to 0".

Quote:
Originally Posted by John_1102 View Post
if(joy2Btn(1) )
{
motor[motorF] = -100;
}
else
{
motor[motorF] = 0;
}
This one is saying "if Button 1 on Joystick 2 is pushed, set power to motorF to 100% in reverse. Otherwise, set it to 0".

The problem is not with the if (true) conditions, it's the else conditions that are conflicting with each other. If Button 1 is pressed, then button might or might be pressed, so motorF shouldn't go (the else conditions). Likewise for Button 2.

A better way to right the code is:
Code:
if (joy2Btn(1))
    {
    motor[motorF] = -100;
    }
else if (joy2Btn(2))
   {
    motor[motorF] = 100;
   }
else
    {
    motor[motorF] = 0;
    }
Since the target of the conditional test is the same resource (motorF), you'll have to keep the tests with the target in one condition.

Good luck!
__________________
Mannie Lowe
FIRST Program Manager - Center for Mathematics and Science Education - University of Mississippi
Mississippi FIRST Tech Challenge Affiliate Partner


Reply With Quote
  #3   Spotlight this post!  
Unread 25-11-2009, 19:13
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
FTC, I have returned.
AKA: @doctorfogarty @GarnetSq
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,555
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
Re: [FTC]: Buttons RobotC

Quote:
Originally Posted by emmell View Post
Let's break this down step by step:


What the above "if" is saying is "If Button 2 on Joystick 2 is pushed, set power to motorF to 100%. Otherwise, set it to 0".


This one is saying "if Button 1 on Joystick 2 is pushed, set power to motorF to 100% in reverse. Otherwise, set it to 0".

The problem is not with the if (true) conditions, it's the else conditions that are conflicting with each other. If Button 1 is pressed, then button might or might be pressed, so motorF shouldn't go (the else conditions). Likewise for Button 2.

A better way to right the code is:
Code:
if (joy2Btn(1))
    {
    motor[motorF] = -100;
    }
else if (joy2Btn(2))
   {
    motor[motorF] = 100;
   }
else
    {
    motor[motorF] = 0;
    }
Since the target of the conditional test is the same resource (motorF), you'll have to keep the tests with the target in one condition.

Good luck!
Thanks this worked perfectly
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
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]: Programming Clarification [RobotC] basicxman FIRST Tech Challenge 3 11-02-2009 20:21
[FTC]: RobotC and NXT-G (The two programming languages) craig_yates FIRST Tech Challenge 1 30-01-2009 21:47
[FTC]: [FTC]: RobotC Template Problem (causing an FMS issue) and Potential Servo Prob PackersFan FIRST Tech Challenge 11 26-01-2009 21:25
[FTC]: RobotC Template gdo FIRST Tech Challenge 14 10-11-2008 06:26


All times are GMT -5. The time now is 17:16.

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