|
Page 1 of 1
|
[ 4 posts ] |
|
| Author |
Message |
|
indica3d
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 */
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 |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2864 Location: Rotterdam, The Netherlands
|
 Re: problem with my program
Moved to correct forum.
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Sat May 30, 2009 8:11 am |
|
 |
|
jbflot
Site Admin
Joined: Tue May 15, 2007 9:02 am Posts: 383
|
 Re: problem with my program
Try this code out, a slightly modified version from the "Single Joystick Control" Sample program:
|
| Tue Jun 02, 2009 5:06 pm |
|
 |
|
fryfrog
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 |
|
|
|
Page 1 of 1
|
[ 4 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 3 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
|
|