View unanswered posts | View active topics It is currently Sun Feb 17, 2019 8:34 pm

Reply to topic  [ 2 posts ] 
What is the behavior of setting motor[] > 127 
Author Message

Joined: Mon Feb 18, 2013 2:57 am
Posts: 1
Post 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

Mon Feb 18, 2013 3:06 am
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post 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 updated help documentation and the ROBOTC Forums.

Mon Feb 18, 2013 1:32 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.