View unanswered posts | View active topics It is currently Mon Oct 20, 2014 10:34 pm






Reply to topic  [ 4 posts ] 
problem with my program 
Author Message
Rookie

Joined: Sat May 30, 2009 5:17 am
Posts: 1
Post 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
*/

task main ()
{
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
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3225
Location: Rotterdam, The Netherlands
Post 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
Profile WWW
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 405
Post 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
CMU Robotics Academy
ROBOTC Support


Tue Jun 02, 2009 5:06 pm
Profile
Rookie

Joined: Sat Aug 30, 2008 2:25 am
Posts: 25
Post 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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.