|
Page 1 of 1
|
[ 6 posts ] |
|
RobotC braking problem with NXT motors
Author |
Message |
vizino
Rookie
Joined: Sun Apr 19, 2009 7:44 am Posts: 8
|
 RobotC braking problem with NXT motors
I'm teaching RobotC to a group of FTC students and encountered what seems like a bug in RobotC. I want my robot to drive forward 1804 degrees (nothing special about this number), stop with braking, and then wait 2 seconds: I am using RobotC 3.08 w/ firmware v. 9.12. Using the 56mm (5.6cm) knobby tires with no gearing the robot should travel: 1804 deg * (5.6cm * PI / 360 deg) = 88cmHowever, when run, the robot blows right past this distance to something like 120cm. There is a bit of a hesitation in the motors as it crosses the 88cm mark but the motors appear to coast on and not brake. If I take out the wait1Msec() function, the robot travels the expected distance so assume there is automatic braking at program end. Using NXC (with Bricx Command Center 3.3 and v. 1.31 extended firmware) the robot works perfectly, exactly as I would expect (travels 88cm): Why are the motors not braking under RobotC when using "bFloatDuringInactiveMotorPWM = false;" and setting the motors to 0 power? Any assistance would be appreciated!
|
Fri Mar 23, 2012 12:58 am |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: RobotC braking problem with NXT motors
Try this code and see if it works. Change the motors if necessary - Xander  |  |  |  | Code: #pragma config(Motor, motorA, LEFT, tmotorNormal, PIDControl, encoder) #pragma config(Motor, motorB, RIGHT, tmotorNormal, PIDControl, encoder) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main () { // setup B to be the slave of A. nSyncedMotors = synchAB;
// this is the ratio at which B turns in relationship to A // In this case, they both run at the same speed. nSyncedTurnRatio = 100;
// because A is the master, you don't need to set B nMotorEncoderTarget[motorA] = 1804;
// same applies to the speed motor[motorA] = 90; // not setting it to 100 gives the controller a // little more wiggle room to modify the speeds. while (nMotorRunState[motorA] != runStateIdle) { wait1Msec(10); } // motors will stop automagically. PlaySound(soundBeepBeep); while (bSoundActive) { wait1Msec(10); } } |  |  |  |  |
_________________| 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]
|
Fri Mar 23, 2012 2:14 am |
|
 |
vizino
Rookie
Joined: Sun Apr 19, 2009 7:44 am Posts: 8
|
 Re: RobotC braking problem with NXT motors
First of all, thank you for your quick reply. I am confident that it will work and will test it out at our next team meeting.
I understand exactly what you added but it doesn't explain the problem with my specific code and the robot not stopping. What you provided just worked around it. *Why* didn't the motors stop in the RobotC code I provided? We have some rookie team members and would like to try to keep things very simple for them as they learn the basics of motor control in RobotC. The problem encountered was in one of the student's codes and would like to explain it to him.
Again, thanks!
|
Fri Mar 23, 2012 8:19 am |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: RobotC braking problem with NXT motors
I am not sure why it wouldn't work. What I do know is that using the nMotorEncoderTarget is the preferred method for moving a motor to specific target.
You may find that putting a 5 ms wait inside your while loop will give much better results for most things. There is no need to have a loop as tight as you make it and it will give the firmware more time to deal with other tasks (such as polling the motors, etc) while the main one sleeps.
- Xander
_________________| 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]
|
Fri Mar 23, 2012 3:57 pm |
|
 |
steelside
Rookie
Joined: Thu May 03, 2012 3:33 pm Posts: 1
|
 Re: RobotC braking problem with NXT motors
We've got this issue too. It's very annoying. Have you tested this to see if you get the same behaviour, mightor? Our motors continue running, or they do some kind of skip at the very end when they suddenly increase speed again before they power down. Turning of the breaking and allowing them to float seemed to ease the sudden speed increase somewhat, but it's not ideal. Also, the synch command is not functioning for us at all, it tries to keep the motors at a constant 45(+-3ish) degree difference, so it won't go straight at all. Different speeds affect this slightly, but only like max 5 degrees. Writing our own code to keep them synchronized works, as long as we use nMotorEncoderTarget for moving, else it skips when stopping the motors.
|
Thu May 03, 2012 3:43 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: RobotC braking problem with NXT motors
I would suggest you write some short bits of code that demonstrate this issue and send a bug report to support@robotc.net. Make sure you also mention which version of ROBOTC you're using and anything else you think might help them track down the issue. - Xander
_________________| 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]
|
Thu May 03, 2012 6:13 pm |
|
|
|
Page 1 of 1
|
[ 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
|
|