|
Page 1 of 1
|
[ 7 posts ] |
|
| Author |
Message |
|
brianchen11
Rookie
Joined: Tue Jul 03, 2012 5:16 am Posts: 43
|
 nMotorEncoderTarget
Hi, I'm experiencing issues when nMotorEncoderTarget is set to 0, the motor simply continues in one direction when it is obvious that it has gone past the limit. NOTE: I do not want to reset the motors anywhere in the program.
|
| Fri Sep 21, 2012 7:37 pm |
|
 |
|
Spiked3
Expert
Joined: Tue Feb 28, 2012 3:10 pm Posts: 195
|
 Re: nMotorEncoderTarget
from the help file; "A target value of 0 (zero) means run forever."
so you can not use 0 as a target and if it comes up mathematically you have to deal with it.
_________________Mike aka Spiked3 http://www.spiked3.com
|
| Fri Sep 21, 2012 10:08 pm |
|
 |
|
brianchen11
Rookie
Joined: Tue Jul 03, 2012 5:16 am Posts: 43
|
 Re: nMotorEncoderTarget
I will need the encoders to be accurate as possible. I tried resetting them but then it makes it very unaccurate especially when it is resetted many times in a short period of time. What other methods can I use?
|
| Sat Sep 22, 2012 2:46 am |
|
 |
|
Spiked3
Expert
Joined: Tue Feb 28, 2012 3:10 pm Posts: 195
|
 Re: nMotorEncoderTarget
That is by definition, "as accurate as possible".
If you are looking for 100% accuracy, LEGO is probably not an appropriate platform. Even if 0 worked as you hoped, you will find that a) the final position is +/- a couple of degrees (encoder ticks) and b) the gear slop is +/- a couple of degrees.
In robotics, uncertainty is always the case and should be dealt with to some extent. There are entire college courses on the subject. The most expensive robots made, have uncertainty.
At the beginner level, I have never encountered a LEGO situation where a small bit of inaccuracy was a fail / no fail proposition. For example, when moving a distance of exactly 100mm, if it comes up at 102mm, the next time I simply move 2mm less. Very easy, works every time. Remember that you can also mechanically improve some by gear reduction, so the 2 degree inaccuracy becomes a 1/2 degree inaccuracy (or some gear multiple).
_________________Mike aka Spiked3 http://www.spiked3.com
|
| Sat Sep 22, 2012 8:39 am |
|
 |
|
brianchen11
Rookie
Joined: Tue Jul 03, 2012 5:16 am Posts: 43
|
 Re: nMotorEncoderTarget
The thing is, I have to use nMotorEncoderTarget in a loop and after hundreds of loops, +-1 degree results in quite a large difference. I am working on a printing device with an arm and the angles have to be precise. I have already geared the motors quite high, but I guess I'll have to gear it higher. Thanks.
If there is a way to use nMotorEncoderTarget without resetting it, please reply. At the moment, without resetting the motors, when the target is 0, it will simply go forever.
|
| Sun Sep 23, 2012 3:31 am |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: nMotorEncoderTarget
Actually, I am not sure I understand what you want but just answering the face question you have. In theory, there is no reason to reset the encoder targets. You can keep the encoders running. Let's say the encoders are cleared to begin with. Then you set the encoder targets to some distance ahead. When the motors get there, they will stop (with some small amount of error). Then if you want to set another target some distance ahead again, you can read the current encoder value, add the delta distance to it and set it as your new encoder target. Since you did not clear the encoders, the previous error will be accounted for when setting your next target. Am I answering your question, or am I way off?
|
| Sun Sep 23, 2012 4:25 am |
|
 |
|
brianchen11
Rookie
Joined: Tue Jul 03, 2012 5:16 am Posts: 43
|
 Re: nMotorEncoderTarget
That would work so I'll put that into the program. I had that idea a long time ago, but I was afraid of the target being 0. I guess I'll just put an if else statement if the target is 0: if(target==0){ //don't set target and don't run motor } Don't worry about this anymore. It's just a tiny issue.
|
| Sun Sep 23, 2012 8:05 pm |
|
|
|
Page 1 of 1
|
[ 7 posts ] |
|
Who is online |
Users browsing this forum: nikefreeway and 5 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
|
|