What is the behavior of setting motor[] > 127
Page 1 of 1

Author:  cody [ Mon Feb 18, 2013 3:06 am ]
Post subject:  What is the behavior of setting motor[] > 127


The motor[] array where the user program may set values intended to drive the motors on a robot is of type int (16 bits with a range of −32,768 to 32,767).

We know that motors can only be assigned a value between -128 and 127.

As such a conversion from type int to a one byte value is happening between the point where we enter our desired value into the motor[] array and when that value is sent off to the motor controllers.

What I want to know is HOW this conversion takes place?

Is it a direct cast, and thus can possibly "roll over" or are these values being checked, and as such getting clamped to -128 to 127 before being converted?

Thanks, -Cody

Author:  JohnWatson [ Mon Feb 18, 2013 1:32 pm ]
Post subject:  Re: What is the behavior of setting motor[] > 127

The motor value is passed to the ROBOTC firmware on the NXT and the number is then set to the min/max value (-127 or +127). You can pass higher values to the NXT brick but they will be capped at the maximum values via the firmware.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group