|
Page 1 of 1
|
[ 5 posts ] |
|
| Author |
Message |
|
Albert
Rookie
Joined: Wed May 28, 2008 12:47 pm Posts: 2
|
 Encoders' measure
Hello!
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?
Regards,
Albert
PD: I promise you to upload my program when I finish, a self-balancing robot with a Gyroscope.
|
| Wed May 28, 2008 12:54 pm |
|
 |
|
starwarslegokid
Moderator
Joined: Wed Jan 31, 2007 3:39 am Posts: 298 Location: San Diego, California. USA
|
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-)
Scott
_________________Mmmm Legos B-) My Robot Projects: http://www.freewebs.com/robotprojects/
|
| Thu May 29, 2008 12:26 am |
|
 |
|
elemes
Expert
Joined: Fri Nov 09, 2007 4:51 am Posts: 121 Location: Hungary, Europe
|
 Re: Encoders' measure
Hi Albert,
You will need a new variable or a conditional statement to reach the behavior you need.
|
| Fri May 30, 2008 5:15 am |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2864 Location: Rotterdam, The Netherlands
|
Out of curiousity, does resetting the encoders affect the motors' PID control at all?
Regards,
Xander
|
| Fri May 30, 2008 5:57 am |
|
 |
|
Albert
Rookie
Joined: Wed May 28, 2008 12:47 pm Posts: 2
|
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.
PROBLEM SOLVED!!!
|
| Sun Jun 01, 2008 12:22 pm |
|
|
|
Page 1 of 1
|
[ 5 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 7 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
|
|