|Page 1 of 1|
|Author:||quirkey [ Sat Oct 06, 2007 7:21 am ]|
|Post subject:||Measuring Rotation|
I've been looking for a way to work out how many rotations the motor has done in say a 1 second period. But all I can find is things about motor encoders? If someone could provide a basic program, I would be most grateful.
Thanks in advance,
|Author:||starwarslegokid [ Sun Oct 07, 2007 8:06 pm ]|
Motor encoders are rotation sensors that are built right into each NXT motor. These sensors return the distance the motor has moved since you last reset the encoder.
When you turn the motor, it will register 1 full rotation as 360 encoder ticks.
Heres a program I made for you, it shows you how you can read where the encoder is at, reset the encoder and do different things when the motor gets to a specific encoder spot.
Hope this helps
nMotorEncoder[motorA] = 0;
nMotorEncoder[motorB] = 0;
//reset the encoders to 0//
motor[motorA] = 50;
motor[motorB] = 50;
nxtDisplayTextLine(2,"Enc A=%d", nMotorEncoder[motorA]);
nxtDisplayTextLine(3,"Enc B=%d", nMotorEncoder[motorB]);
//read and display the encoder values on screen as motors turn//
nMotorEncoder[motorA] = 0; //reset the encoder to 0 when it gets to 360, one full rotation//
motor[motorB] = 0; //stop when encoder ticks is greater than 500//
|Author:||Dick Swan [ Sat Oct 13, 2007 1:39 am ]|
To do what you want.
Read and save in a variable the motor encoder count.
Wait for the duration you desire
Using the saved encoder count find the difference between the end and start counts from before and after the time period.
|Author:||quirkey [ Sat Oct 13, 2007 4:25 am ]|
Thank you both for your suggestions - they have been used!
|Page 1 of 1||All times are UTC - 5 hours [ DST ]|
|Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group