ROBOTC.net forums
http://www.robotc.net/forums/

Robot moving forward uncontrolably
http://www.robotc.net/forums/viewtopic.php?f=11&t=10450
Page 1 of 1

Author:  copecrow [ Tue Feb 03, 2015 12:10 pm ]
Post subject:  Robot moving forward uncontrolably

In my robotics class our cortexes seem to ignore all attempts to install code. The file manager shows the code as the only one, however the robot does not follow it, instead it rolls forwards endlessly whenever it is turned on. I am sure code is not the issue and my teacher has no idea what he is doing so any help would be awsome.

Author:  CARBOT [ Tue Feb 03, 2015 12:24 pm ]
Post subject:  Re: Robot moving forward uncontrolably

It is best to post the version of RobotC being used and your code.
Have you tried commenting out all motor commands to see if it rolls forward endlessly?

Author:  JohnWatson [ Tue Feb 03, 2015 12:27 pm ]
Post subject:  Re: Robot moving forward uncontrolably

There are a couple of things that could be causing this particular issue. To help debug this issue, we will need to see the code that is being used and causing this issue (the smallest program possible to replicate this issue); you can post this to the forums using the [code] tags.

Also, please check the wiring of the motors and ensure that they are plugged into the correct ports, are orientated correctly, and that you are using Motor Controller 29's for motors plugged into ports 2-9. If the motors are plugged in backwards (the 3-prong connectors on the Motor Controller 29 and the 2-prong connectors on the motors are keyed to help prevent this) or if the 2-wire motor prongs are plugged directly into the 3-wire motor ports, you may experience the issues you have described.

Thanks in advance!

Author:  copecrow [ Tue Feb 03, 2015 12:32 pm ]
Post subject:  Re: Robot moving forward uncontrolably

Here is my code and the version is 4.27
We are using 2 pronged motor wires and when plugged in key side they do nothing and respond to no code, while in the outer 2 ports they move as described, thank you for your quick responses


#pragma config(Motor, port2, BL, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port3, FR, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port4, BR, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port5, BR, tmotorVex393_MC29, openLoop, driveLeft)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main
{
motor[port5] = 127
motor[port2] = 127
motor[port3] = 127
motor[port4] = 127
wait1Msec(1000)
motor[port5] = -127
motor[port2] = -127
motor[port3] = -127
motor[port4] = -127
}

Author:  JohnWatson [ Tue Feb 03, 2015 12:50 pm ]
Post subject:  Re: Robot moving forward uncontrolably

To confirm; are you using a Motor Controller 29 between each motor and the Cortex itself? If you are plugging the two wire motors directly into ports 2, 3, 4 or 5, they will not work properly.

From the coding standpoint; you have told the motors to move forward at power level 127 for 1000 ms (1 second), but when you turn the motors on backwards with a power level of -127, you do not tell them how long to keep going backwards for. You will need to add another wait1Msec command after the backwards motor assignments to resolve this issue:

Code:
task main
{
motor[port5] = 127;
motor[port2] = 127;
motor[port3] = 127;
motor[port4] = 127;
wait1Msec(1000);

motor[port5] = -127;
motor[port2] = -127;
motor[port3] = -127;
motor[port4] = -127;
wait1MSec(1000);
}


Also note that the commands need to end with a semicolon ; in order to compile properly. ROBOTC will recognize this and insert the semicolons 'behind the scenes' for you, but other C compilers will not and will stop the program from compiling (and will probably generate a long list of error messages).

Edit: Here is a nice blog post we've made explaining how to connect the Motor Controller 29's to a Cortex and motor properly: http://www.robotc.net/blog/2011/01/07/u ... roller-29/

Author:  copecrow [ Wed Feb 04, 2015 12:18 pm ]
Post subject:  Re: Robot moving forward uncontrolably

Thank you so much for your help, the building manual did not specify that we needed motor controllers. As for the code I knew it wasn't complete i just needed something simple to confirm everything was working, thanks again :)

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/