|Page 1 of 1|
|Author:||asma [ Fri Mar 07, 2008 9:23 am ]|
|Post subject:||Encoder Position....|
I’m writing a program that:
• Turn motor A to right and measure the distance.
• Return motor A to its original position (which supposes to be zero).
• Turn motor A to left and measure the distance.
• Return motor A to its original position (which also supposes to be zero).
The problem is that: the encoder value doesn’t return to its original position and after a while the accumulated shift has increased which causes some problems.
Here is the code:
I tried to use nMotorEncoderTarget instead; however, I got the same result. So could please guide me how to do it more accurately?
|Author:||MK [ Sat Mar 08, 2008 8:37 pm ]|
|Post subject:||Re: Encoder Position....|
In order to avoid encoder drift, you want to remove the encoder reset from your return blocks. You wait until encoder value zero is reached and then stop the motor and reset the encoder to zero. If the commands execute fast enough, then the encoder value is still zero when you reset it. In this case the command is useless. If execution is not fast enough, then encoder value will drift with respect to physical position.
You could use the nMotorEncoderTarget variable in order to perform the task. However, be aware that the value is not understood as absolute target position but as a number of encoder increments to advance.
This has some drift implications as well. Consider the ROBOTC example NXT Position Control with the suggested "hand of a clock" robot design. You will find that you can create a permanent delay in the hand by blocking it for one or more loop iterations. For a clock, such relative, incremental position control is not really an ideal solution. Absolute control is better.
However, I do not know of a smart way to implement it. My solution consists of a PD control that forces the moter to go to a given absolute encoder value.
This code implements an absolute position control for motorA. The example sets the motor to a random angle every 500 ms.
You can go to any absolute target encoder value by setting t to that value. There will be no drift due to overshoot or external influences.
Best regards, Martin Kraska
|Page 1 of 1||All times are UTC - 5 hours [ DST ]|
|Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group