View unanswered posts | View active topics It is currently Thu Oct 02, 2014 6:31 am






Reply to topic  [ 5 posts ] 
Encoders' measure 
Author Message
Rookie

Joined: Wed May 28, 2008 12:47 pm
Posts: 2
Post 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
Profile
Moderator
Moderator
User avatar

Joined: Wed Jan 31, 2007 3:39 am
Posts: 299
Location: San Diego, California. USA
Post 
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
Profile WWW
Expert
User avatar

Joined: Fri Nov 09, 2007 4:51 am
Posts: 121
Location: Hungary, Europe
Post 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
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3223
Location: Rotterdam, The Netherlands
Post 
Out of curiousity, does resetting the encoders affect the motors' PID control at all?

Regards,
Xander


Fri May 30, 2008 5:57 am
Profile WWW
Rookie

Joined: Wed May 28, 2008 12:47 pm
Posts: 2
Post 
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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.