Counting servo pulses, and back tracking them (can it be done?).
SciTech02
Posts: 154
I know that you can count servo pulses, but can you back track them?· For example; If my robot goes forward for 24 pulses, and 1 left pulse.· Then if I make it turn around, can I make it back track them?· For example; can I make it do·1 right pulse, and go forward 24 pulses?· It sounds like you can do it, can I?······ -SciTech02.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
· So, each servo actuation is a step (an address in memory) and each step records a direction code (e.g. 01 = FWD, 02 = LT, 03 = RT, 04 = REV.)· Then, when you want to backtrack, you'll READ that address and deal accordingly.
· Does that make sense?
Here's what I'm working on, it's part of it.··What it does is it goes until the two ir sensers detect somthing, and it back tracks what it did.· What I'm asking is; Is there a type of "LOG" command or any command that's does the same thing?· Then, how would I program it to do it?· I·really want this program to work, so if you can help, I would be very happy.· NOTE.· In my program, I put it so when it makes a right turn, it logs it as a left.· I did that because when it turns around, it will turn the right direction.· And I had problems with the ENTER Key.
IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
GOSUB Back_Track
ELSEIF (irDetectLeft = 0) THEN
· LOG(?)·leftPulse
· PULSOUT 13, 850
· PULSOUT 12, 650
· PAUSE 20
ELSEIF (irDetectRight = 0) THEN
· LOG(?) rightPulse
· PULSOUT 13, 850·
· PULSOUT 12, 650
· PAUSE 20
ELSE
· LOG(?) forwardPulse
· PULSOUT 13, 850
· PULSOUT 12, 650
· PAUSE 20
ENDIF
Back_Track:
· FOR counter = 1 TO 40
··· PULSOUT 13, 650
··· PULSOUT 12, 650
··· PAUSE 20
· NEXT
· ???·
Post Edited (SciTech02) : 3/27/2006 5:23:34 AM GMT
First there is no "LOG" command as you proposed, and second, why do you feel there is a need, or requirement to back-track? If it's your feeling that this is the only way a robot can remove itself from a situation where it has gotten "stuck" (boxed in), let me assure you, it's not.
I'm not suggesting one couldn't do what you're asking, I just don't see the merit or purpose to doing it. Perhaps I'm missing something.
When you go into a store, you go in front first. When you come out, you come out front first. You don't back out the opposite way you came in (rear first). Why should the robot be required to do so, and to what end?
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Post Edited (Bruce Bates) : 3/27/2006 6:20:02 AM GMT
So this is NOT the same as a stepper motor, which really does move a certain distance per 'step'. Thus the sheer number of pulses sent does not really equal distance traveled. The encoder is really the only reliable way to determine how far your wheel has turned.
On the other hand, how far your robot has moved IS a factor of how long you've been sending pulses. Not a very exact factor, but there's clearly some relationship there. And the number of pulses you've sent is ALSO related to "how long you've been sending pulses". So perhaps you COULD use this number as a rough 'time' indication to reverse the path of your robot.
This assumes your robot is not 'blocked' by running in to anything, of course...
Oh, and you can 'log' up to 65,536 pulses merely by using two 'word' variables...
LeftCount VAR Word
RightCount VAR Word
GoStraight:
· PULSOUT LeftMotor, 850
· PULSOUT RightMotor, 650
· LeftCount·= LeftCount + 1
· RightCount = RightCount + 1
· RETURN
Now, if you want to 'log' a 'path' of these counts, you could write them into an external eeprom.· I wouldn't use the on-BS2 eeprom for this, as you'll be writing LOTS of data in short periods of time, which could wear out the eeprom.· An external eeprom is much more easily replaced.
Post Edited (allanlane5) : 3/27/2006 8:41:54 PM GMT
IF (irDetectLeft = 1) OR (irDetectRight = 1) THEN
· GOSUB GoStrait
ELSEIF (irDetectLeft = 0) OR (irDetectRight = 0) THEN
· GOSUB Back_Track
ELSE
· GOSUB Back_Track
ENDIF
Now I don't know how to make it count turning pulses, and how to make it back track them.····
Post Edited (SciTech02) : 3/27/2006 10:19:46 PM GMT
But I don't know how to count turning pulses and back track thoses in order.· Could·I still make it back track when it makes turns, and go back in order?
Post Edited (SciTech02) : 3/28/2006 4:05:33 AM GMT
I would show you the file, but I could not find it on my computer (?).· But if you want to make it, just follow the guidlines I just discussed.· Thank you guys for your help.····· -SciTech02.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Rule your Destiny-
--Be Good. Be Bad. Be Provas--