Encoders' measure
Page 1 of 1

Author:  Albert [ Wed May 28, 2008 12:54 pm ]
Post subject:  Encoders' measure


I'm making a program with RobotC which has to read the rotation position of a NXT motor. I use nMotorEncoder(motor) but this function gives me absolute position of the encoder. If I move the motor backward, my measure turns to 360 and goes down, and I want it as -1ª, -2ª... It's a problem for me too that my measure passes from 360º increasing to 1º, and not to 361º
Is there a simple solution to this?


PD: I promise you to upload my program when I finish, a self-balancing robot with a Gyroscope.

Author:  starwarslegokid [ Thu May 29, 2008 12:26 am ]
Post subject: 

Hi Albert

You can reset the encoder to whatever value you want anytime, here is the command to do this.

nMotorEncoder[motorA] = 0; // reset encoder to 0

Did this answer your question?

Good luck with your project B-)

Author:  elemes [ Fri May 30, 2008 5:15 am ]
Post subject:  Re: Encoders' measure

Hi Albert,

You will need a new variable or a conditional statement to reach the behavior you need.

Author:  mightor [ Fri May 30, 2008 5:57 am ]
Post subject: 

Out of curiousity, does resetting the encoders affect the motors' PID control at all?


Author:  Albert [ Sun Jun 01, 2008 12:22 pm ]
Post subject: 

mightor, this is the question i'm trying to solve, because if I design a control it will run properly only between 0 and 360 degrees, not mor than this or with negative rotation.

What I want to use is the rotation position without encoder reset to obtain, for example, 450º or -80º,-500º. I don't understand why there isn't a function to read rotation in this way, because in the window "NXT Device Control Display", in all "Tacho" columns this kind of result is given.

EDIT: I solved this problem. The problem is that when you put the function degreesToRadians it returns you a value between 0 and 2*PI radians. To solve this, I used a definition #define DEG_RAD 0.01745 and I multiply this with the encoder value.


Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group