| Author |
Message |
|
Koldo
Rookie
Joined: Sun Aug 12, 2007 3:18 pm Posts: 38
|
 Problems with the motor encoder
Hi
I want to develop a program that moves the motor to diverse positions in forward and backward. I do not have problems when it is in forward but yes in backward. I am trying to correct the difference when the nEncodertarget is <0 , but I have some problems with the encoders.
In he program: when the nEncoderTarget is -200, the result is Tach User is -281 but nMotorEncoder [motor] read -200 (it isn’t the real position), so I can’t correct the diference.
Witch tach read nMotorEncoder [motor]?
Thanks
|
| Fri Jul 04, 2008 5:02 am |
|
 |
|
Abbeyjean
Rookie
Joined: Thu Jun 26, 2008 11:27 am Posts: 21 Location: Johannesburg, South Africa
|
Hi
If you change the line:
nMotorEncoderTarget[motor__]=-200;
to be
nMotorEncoderTarget[motor__]= 200; (no negative sign)
you will get a more accurate result. Setting the nMotorEncoderTarget to a negative value means the motor will coast or float rather than braking after it reaches the desired target.
|
| Sat Jul 05, 2008 4:42 am |
|
 |
|
elemes
Expert
Joined: Fri Nov 09, 2007 4:51 am Posts: 121 Location: Hungary, Europe
|
wow, how did you find it out?
is that a bug or a feature?
|
| Sat Jul 05, 2008 7:48 am |
|
 |
|
Abbeyjean
Rookie
Joined: Thu Jun 26, 2008 11:27 am Posts: 21 Location: Johannesburg, South Africa
|
It's a feature I guess as it is mentioned in the documentation.
|
| Sat Jul 05, 2008 1:23 pm |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
Actually, to my opinion, this "feature" is a big fat BUG ! 
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Sat Jul 05, 2008 1:44 pm |
|
 |
|
MK
Rookie
Joined: Mon Oct 29, 2007 4:25 pm Posts: 7 Location: Potsdam, Germany
|
I knew that bugs simply are undocumented features.
Now, documented features turn into bugs  ?
I stopped to judge the motor control by my expectation as how motor control should work. For my application, precise position control is required. Initially, I expected the nMotorEncoderTarget being of use for that. However, even after finding out that these values are not absolute targets (encoder positions that the PID tries to reach) but count from the current encoder position, there still is the drift due to overshoot.
Still, the nMotorEncoder value is my friend, based on which a simple PD position control can be implemented (works fine for me and has been posted if I remember correctly).
MK
|
| Sat Jul 05, 2008 5:03 pm |
|
 |
|
starwarslegokid
Moderator
Joined: Wed Jan 31, 2007 3:39 am Posts: 298 Location: San Diego, California. USA
|
where in the documentation is this stated?
_________________Mmmm Legos B-) My Robot Projects: http://www.freewebs.com/robotprojects/
|
| Fri Jul 11, 2008 12:05 am |
|
 |
|
Abbeyjean
Rookie
Joined: Thu Jun 26, 2008 11:27 am Posts: 21 Location: Johannesburg, South Africa
|
Hi
It is in the section 'Motors Overview' under 'Moving to a Specific Encoder Value'
|
| Fri Jul 11, 2008 3:47 am |
|
 |
|
Koldo
Rookie
Joined: Sun Aug 12, 2007 3:18 pm Posts: 38
|
My last solution:
With "bMotorReflected[motorA] = true" the encodertarget always is positive. It runs fine.
|
| Fri Jul 11, 2008 5:55 pm |
|
 |
|
Abbeyjean
Rookie
Joined: Thu Jun 26, 2008 11:27 am Posts: 21 Location: Johannesburg, South Africa
|
Hi
You could cut this code down to 3 lines if you wanted.
|
| Sat Jul 12, 2008 3:02 am |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
or forget about the nMotorEncoderTarget and runstates etc and do it this way, simple and stupid:
maybe you wish to make the motor a little slower if is it's getting close to the target, you can add to the while loop:
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Sat Jul 12, 2008 5:11 am |
|
 |
|
Koldo
Rookie
Joined: Sun Aug 12, 2007 3:18 pm Posts: 38
|
|
| Sat Jul 12, 2008 11:29 am |
|
|