ROBOTC.net forums
http://robotc.net/forums/

How to check the current value of the motor encoder?
http://robotc.net/forums/viewtopic.php?f=52&t=1061
Page 1 of 1

Author:  arkarind [ Fri Dec 26, 2008 3:46 pm ]
Post subject:  How to check the current value of the motor encoder?

How do I check the current value of a DC motor encoder, and then save it into a variable?

I have like no idea how to do this.. :?

Author:  Sunny1261 [ Sat Dec 27, 2008 1:33 pm ]
Post subject:  Re: How to check the current value of the motor encoder?

Well, first, be sure that the encoders are calculated in clicks, and the number of clicks is that essentially gets you the "position".

But there is a function for getting the number of clicks the encoder is on.

for a motor named MotorD, the function would be nMotorEncoder[MotorD];
so if you are doing it like a variable, it would be.

int x = nMotorEncoder[MotorD]; // where x is the variable.

For a full list of functions and other things, use the following link: http://www.education.rec.ri.cmu.edu/con ... _Guide.pdf

Author:  arkarind [ Sat Dec 27, 2008 3:14 pm ]
Post subject:  Re: How to check the current value of the motor encoder?

How do i do this for a servomotor?

Author:  Sunny1261 [ Sat Dec 27, 2008 8:48 pm ]
Post subject:  Re: How to check the current value of the motor encoder?

:D, by you asking that question told me that you did not look at the link I presented. Please go to the link: http://www.education.rec.ri.cmu.edu/con ... _Guide.pdf . It has a lot of valuable information.

None the less I will still answer your question. For a servo name ServoD and a variable x. The line of code would be

int x = ServoValue[ServoD];

The ServoValue[ServoD] is the function you use to check the number of clicks for a servo encoder.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/