View unanswered posts | View active topics It is currently Sat Aug 30, 2014 3:01 am






Reply to topic  [ 3 posts ] 
rotation Encoder not accurate? 
Author Message
Rookie

Joined: Sat Feb 02, 2008 10:24 pm
Posts: 1
Post 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
Profile
Expert
User avatar

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

Joined: Fri Nov 09, 2007 4:51 am
Posts: 121
Location: Hungary, Europe
Post 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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: KeesSmit 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.