View unanswered posts | View active topics It is currently Wed Dec 17, 2014 9:26 pm






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

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

Joined: Thu May 24, 2012 12:15 pm
Posts: 619
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 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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: CARBOT and 1 guest


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.