View unanswered posts | View active topics It is currently Mon May 30, 2016 8:50 pm

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
problem with my program
Author Message
Rookie

Joined: Sat May 30, 2009 5:17 am
Posts: 1
problem with my program
HI to all.

i am new to robotc and new to c programming.
i try to write a program that move my robot just with ch1+ch2 on the remote.
the only part of the program that work is (ch2-up + ch1 left)
anyone know what am i doing rong?

here is my code :

/* conguration:

left motor= port2
right motor= port3
*/

{
bMotorReflected[port2] = 1; // change motor 2 diraction because motore 2 is reverse side
bVexAutonomousMode = false; //Activates Remote Control Mode

while (1==1)
{
if (vexRT[Ch1] == 0 && vexRT[Ch2]>0) // if just channel 2 is active up > move forward
{
motor[port2]= vexRT[Ch2];
motor[port3]= vexRT[Ch2];
}
if (vexRT[Ch1] == 0 && vexRT[Ch2]<0 ) // if just channel 2 is active down > move backward
{
motor[port2]= vexRT[Ch2];
motor[port3]= vexRT[Ch2];
}
if (vexRT[Ch2]==0 && vexRT[Ch1] > 0 ) //if just channel 1 is active to right > move right in place
{
motor[port2]= vexRT[Ch1];
motor[port3]= - vexRT[Ch2];
}
if (vexRT[Ch2]==0 && vexRT[Ch1] < 0 ) // if just channel 1 is active to left > move left in place
{
motor[port2]= vexRT[Ch1];
motor[port3]= - vexRT[Ch2];
}
if (vexRT[Ch2]>0 && vexRT[Ch1] > 0 ) //if chanel 2 up and channel 1 right
{
motor[port2]= (vexRT[Ch2])-((vexRT[Ch2]* vexRT[Ch1])/127);
motor[port3]= vexRT[Ch2];
{
if (vexRT[Ch2]>0 && vexRT[Ch1] < 0 ) //if channel 2 up and channel 1 left
{
motor[port2]= vexRT[Ch2];
motor[port3]= (vexRT[Ch2])+((vexRT[Ch2]* vexRT[Ch1])/127);
}
if (vexRT[Ch2]<0 && vexRT[Ch1] > 0) //if channel 2 down and channel 1 right
{
motor[port2]= vexRT[Ch2];
motor[port3]= (vexRT[Ch2])-((vexRT[Ch2]* vexRT[Ch1])/127);
}
if (vexRT[Ch2]<0 && vexRT[Ch1] < 0) //if channel 2 down and channel 1 left
{
motor[port2]= (vexRT[Ch2])+((vexRT[Ch2]* vexRT[Ch1])/127);
motor[port3]= vexRT[Ch2];
}
else
{
motor[port2]= 0;
motor[port3]= 0;
}
}
}
}

Thanks for the help
asher
}

Sat May 30, 2009 5:24 am

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Re: problem with my program
Moved to correct forum.

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]

Sat May 30, 2009 8:11 am

Joined: Tue May 15, 2007 9:02 am
Posts: 409
Re: problem with my program
Try this code out, a slightly modified version from the "Single Joystick Control" Sample program:

 Code:task main(){   bMotorFlippedMode[port2] = 1;    //Port 2 Motor Direction Flipped   bVexAutonomousMode = false;         //Activates Remote Control Mode   while (true)   //Creates an infinite loop   {      motor[port2] = vexRT[Ch2]/2 - vexRT[Ch1]/2;      //y-axis value: forward/backward motion      motor[port3] = vexRT[Ch2]/2 + vexRT[Ch1]/2;      //x-axis value: left/right steering                                                                           //divided by 2 to prevent values over 127   }}

_________________
Jesse Flot
ROBOTC Support

Tue Jun 02, 2009 5:06 pm
Rookie

Joined: Sat Aug 30, 2008 2:25 am
Posts: 25
Re: problem with my program
And if you remove the "/2" you won't limit your top speed artificially. That is the code I

Thu Jun 04, 2009 8:17 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 4 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning