View unanswered posts | View active topics It is currently Sun Dec 16, 2018 9:10 am

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Measuring Rotation
Author Message
Rookie

Joined: Mon Oct 01, 2007 11:56 am
Posts: 7
Location: England
Measuring Rotation
Hi again,

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.

Oliver Q

Sat Oct 06, 2007 7:21 am
Moderator

Joined: Wed Jan 31, 2007 3:39 am
Posts: 299
Location: San Diego, California. USA

Hi Oliver

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
Scott B-)

{

nMotorEncoder[motorA] = 0;
nMotorEncoder[motorB] = 0;
//reset the encoders to 0//
motor[motorA] = 50;
motor[motorB] = 50;

while (true)
{
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//

if (nMotorEncoder[motorA]==360)
{
PlayTone(2000,1);
nMotorEncoder[motorA] = 0; //reset the encoder to 0 when it gets to 360, one full rotation//
}

if (nMotorEncoder[motorB]>500)
{
PlayTone(1500,1);
motor[motorB] = 0; //stop when encoder ticks is greater than 500//
}

}
}

_________________
Mmmm Legos B-)

My Robot Projects:
http://www.freewebs.com/robotprojects/

Last edited by starwarslegokid on Sat Oct 13, 2007 3:23 pm, edited 1 time in total.

Sun Oct 07, 2007 8:06 pm
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 616

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.

Sat Oct 13, 2007 1:39 am
Rookie

Joined: Mon Oct 01, 2007 11:56 am
Posts: 7
Location: England

Thank you both for your suggestions - they have been used!

Sat Oct 13, 2007 4:25 am
Display posts from previous:  Sort by
 Page 1 of 1 [ 4 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning