View unanswered posts | View active topics It is currently Tue Oct 22, 2019 9:34 am






Reply to topic  [ 5 posts ] 
bug in motor[] (robotc2.01 for the NXT) 
Author Message
Expert
User avatar

Joined: Mon Oct 06, 2008 6:30 pm
Posts: 176
Location: Netherlands
Post bug in motor[] (robotc2.01 for the NXT)
Hi,

Here is a small bug I found. The motor[] variable does not return 0 when the motor is stopped, instead it returns the last non zero value set by the user program. All non zero motor speeds are returned as expected.


Aswin

Code:
#pragma config(Motor,  motorA,          Mright,        tmotorNormal, PIDControl, reversed, encoder)

task main()
{
  motor[motorA]=20;
  wait1Msec(1000);
  nxtDisplayString(0,"%3d",motor[motorA]);

  motor[motorA]=40;
  wait1Msec(1000);
  nxtDisplayString(1,"%3d",motor[motorA]);

  motor[motorA]=0;
  wait1Msec(1000);
  nxtDisplayString(2,"%3d",motor[motorA]);

  motor[motorA]=20;
  wait1Msec(1000);
  nxtDisplayString(3,"%3d",motor[motorA]);

  motor[motorA]=0;
  while (true){};
}
 

_________________
My most recent blog: A grain of sugar


Tue Jan 05, 2010 6:22 pm
Profile WWW
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: bug in motor[] (robotc2.01 for the NXT)
Aswin,

If you are using the motor[] speed to check if a motor is running or not, you're better off using the nMotorRunState[] variable instead. It returns any one of these:
  • runStateIdle
  • runStateRampUp
  • runStateRunning
  • runStateRampDown
  • runStateHoldPosition

If that is not the case then disregard this message :)

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]


Tue Jan 05, 2010 6:33 pm
Profile WWW
Expert
User avatar

Joined: Mon Oct 06, 2008 6:30 pm
Posts: 176
Location: Netherlands
Post Re: bug in motor[] (robotc2.01 for the NXT)
Xander,

I'm not. This bug, and the one before that, all come from a function library I use to create a nice looking dashboard on the nxt screen. Amongst others it displays motor speed. But I can use your suggestion in a workaround.

Here is an image made during the 1.47 days.

Attachment:
dahborad.jpg
dahborad.jpg [ 18.08 KiB | Viewed 4028 times ]

_________________
My most recent blog: A grain of sugar


Last edited by Aswin on Wed Jan 06, 2010 12:15 pm, edited 1 time in total.



Tue Jan 05, 2010 7:09 pm
Profile WWW
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: bug in motor[] (robotc2.01 for the NXT)
Oh that is cool looking :) Very slick!

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]


Tue Jan 05, 2010 7:17 pm
Profile WWW
Rookie

Joined: Wed Oct 07, 2009 9:39 am
Posts: 16
Post Re: bug in motor[] (robotc2.01 for the NXT)
I thought that it might have been from design so I didn't bother reporting it. I got around it by making a variable for each motor and writing an updateMotors() function that has a lot of statements that say
motor[<whatever>] = <2 letter abreivation for <whatever>>;
hope this helps.
Also could you send me that library I think that it would be nice to have a dash board to glance at for debugging on my teams robot.
Oliver Graff


Fri Jan 15, 2010 12:38 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.