View unanswered posts | View active topics It is currently Sun Aug 25, 2019 3:02 pm






Reply to topic  [ 6 posts ] 
Robot moving forward uncontrolably 
Author Message
Rookie

Joined: Fri Jan 30, 2015 12:48 pm
Posts: 3
Post 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.


Tue Feb 03, 2015 12:10 pm
Profile
Expert

Joined: Thu Dec 01, 2011 12:07 am
Posts: 151
Post 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?


Tue Feb 03, 2015 12:24 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post 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!

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.


Tue Feb 03, 2015 12:27 pm
Profile
Rookie

Joined: Fri Jan 30, 2015 12:48 pm
Posts: 3
Post 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
}


Tue Feb 03, 2015 12:32 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post 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/

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.


Tue Feb 03, 2015 12:50 pm
Profile
Rookie

Joined: Fri Jan 30, 2015 12:48 pm
Posts: 3
Post 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 :)


Wed Feb 04, 2015 12:18 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 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:  
cron



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