View unanswered posts | View active topics It is currently Wed Apr 25, 2018 12:40 pm

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
rotation Encoder not accurate?
Author Message
Rookie

Joined: Sat Feb 02, 2008 10:24 pm
Posts: 1
rotation Encoder not accurate?
I am needing to make accurate turns. I have looked at the forum and read on resetting the motor encoders to 0.

It appears that the motor is over-rotating. 360 encoder ticks is WAY too many. 300 is close but still too much...it is visually evident by watching a tire attached to the motor that it is over-rotating.

360 encoder turns on slaved motors with a -100 turn index gives me more than 180 degree turn (about 210 degrees).

What am I doing wrong? I have braking on (in preferences and declared in the program). I have tried the slave motors and individually powered motors with opposite signs (+50, -50)...but the fact that you can just pick a spot on the motor and SEE that it rotates too far is getting me.

Any help would be appreciated.

_________________
Thanks,

Doug

Sat Feb 02, 2008 10:37 pm
Expert

Joined: Fri Nov 09, 2007 4:51 am
Posts: 121
Location: Hungary, Europe
nmotorencodertarget
Hi,

I was trying the nmotorencodertarget function to instruct the motors to turn to an accurate position. however, I have failed, for the same reason you've told.

Since I was working on a plotter that requires quite accurate positioning I have created my own task to control the motors to reach a specific encoder value.
 Code:task motor_movement(){  byte i;  long d;   do {      i = 0;      mtr[ i ] =   nMotorEncoder[ i ];      d = target[ i ] + mtr[ i ];      if( d >  CLOSE ) motor[ i ] = -MFAST;      else if( d >      0 ) motor[ i ] = -MSLOW;      else if( d < -CLOSE ) motor[ i ] =  MFAST;      else if( d <      0 ) motor[ i ] =  MSLOW;      else                  motor[ i ] = 0;      for( i = 1; i < 3; i++ ) {         mtr[ i ] =   nMotorEncoder[ i ];         d = target[ i ] - mtr[ i ];         if( d >  CLOSE ) motor[ i ] =  MFAST;         else if( d >      0 ) motor[ i ] =  MSLOW;         else if( d < -CLOSE ) motor[ i ] = -MFAST;         else if( d <      0 ) motor[ i ] = -MSLOW;         else                  motor[ i ] = 0;         }      wait1Msec( 1 );   } while( 1 );}

This task is executed a few hundred times a second (execution may take 1 msec or so and then it waits one more msec). The main task simply sets the target[i] variable like the pen up function here:
 Code:void pu(){   target[ 2 ] -= 30;   do wait10Msec( 1 );   while( nMotorRunState[ 2 ] != runStateIdle );}

It is of course possible to set targets for two motors at the same time. Since in my case speed was not an important factor the constants MFAST was set to 20 and MSLOW was set to 10. In such slow speed the motors were capable to reach their target quite well therefore the constant CLOSE (which is actually the tolerance) is zero.

Realize that this task is more autonomous than RobotC's built in nmotorencodertarget. Using the built in function you first set the target then start the motors. My implementation strarts the motor every time the position does not match the target -- even if an external torque turns the motor axle. Applying a constant torque on the motor axle (e.g. in a poorly designed crane) my solution might start to "oscillate".

Sun Feb 03, 2008 3:41 pm
Expert

Joined: Fri Nov 09, 2007 4:51 am
Posts: 121
Location: Hungary, Europe
mistake
Eh, I can see this (latest) version lacks the tolerance I have mistakenly referred the parameter CLOSE as if it were tolerance. No it is not, it is the distance when the task reduces speed to MSLOW.

Tolerance here is hardwired to zero but it can be a parameter easily.

Correct operation of this automated motor control requires initialization:
 Code:   target[ 0 ] = 0; nMotorEncoder[ 0 ] = 0;   target[ 1 ] = 0; nMotorEncoder[ 1 ] = 0;   target[ 2 ] = 0; nMotorEncoder[ 2 ] = 0;   StartTask( motor_movement );

Sun Feb 03, 2008 3:46 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 3 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