|
Page 1 of 1
|
[ 2 posts ] |
|
What is the behavior of setting motor[] > 127
| Author |
Message |
|
cody
Rookie
Joined: Mon Feb 18, 2013 2:57 am Posts: 1
|
 What is the behavior of setting motor[] > 127
Hello ROBOTC,
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
|
| Mon Feb 18, 2013 3:06 am |
|
 |
|
JohnWatson
Site Admin
Joined: Thu May 24, 2012 12:15 pm Posts: 380
|
 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.
_________________Check out our Blog! And our Facebook page! Need help? Take a look at our Wiki and our Forums.I just met you, And this is crazy, But here's my code now, So fix it, maybe? ~ Carly Rae Jepsen parody
|
| Mon Feb 18, 2013 1:32 pm |
|
|
|
Page 1 of 1
|
[ 2 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 6 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
|
|