View unanswered posts | View active topics It is currently Fri Nov 21, 2014 9:57 pm






Reply to topic  [ 4 posts ] 
Can't set motor encoder value 
Author Message
Rookie

Joined: Sat Jun 02, 2007 8:54 pm
Posts: 17
Post Can't set motor encoder value
The docs seem to indicate that you can read and write to the motor encoder array.. but I have not found this to be true;

nMotorEncoder[motorA] = 300;

this statement does not set the encoder value to 300 as I expected..

is this not permitted? is the only write allowed, used only to reset the value to zero?

dave


Thu Nov 01, 2007 8:58 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 615
Post 
Yes. Any write action resets the encoder to zero.

The "legacy" behind this is that ROBOTC uses the LEGO-developed motor functionality which only provided the capability to reset but not change to an arbitrary value.


Thu Nov 01, 2007 4:10 pm
Profile
Rookie

Joined: Sat Jun 02, 2007 8:54 pm
Posts: 17
Post 
Thank's for a confirmation..

.. something for the next edit of the encoder description because it is natural to think you could set it to a value..

a 'resetEncoder() function might be a little more intuitive with any write attempt flagged as an error.. but I realize this has more than one platform and has other contexts..

dave


Thu Nov 01, 2007 5:20 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 615
Post 
Improved documentation -- will do.

This concept of any write to a register resetting a register is actually fairly common in many micro-controller CPUs. But I realize that this is also an obscure fact to the majority of NXT users.

Thanks for reporting the problem.


Thu Nov 01, 2007 5:25 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.