Shop OBEX P1 Docs P2 Docs Learn Events
BOE-Bot Line Maze Program; How to run Program A or Program B — Parallax Forums

BOE-Bot Line Maze Program; How to run Program A or Program B

RoboticsProfessorRoboticsProfessor Posts: 54
edited 2008-11-09 17:36 in BASIC Stamp
A line maze robot takes two runs through the maze. One to take all the turns and find the end while "deleting" or correcting all bad turns. On the second run the robot now knows the shortest path, so can use the stored path to complete the maze most efficiently.

Several issues:
1. I tried putting both programs together.
-Load 0 in EEPROM location 0 on download of a small "set EEPROM, byte 0 to zero" program.
-Robot starts by reading EEPROM. Zero means this is first path, any positive integer means this is pass 2.
-When robot completes the maze on pass 1, store the best-path in EEPROM, with location 0 containing the number of turns in the final path.
- Second time through, the stored path is used unstead of a left-hand rule.

I'm annoyed that every time I load the program, it starts running. Sometimes the LEDs even hit the "end of maze" combination before I can place it in the maze.

I have room on the protoboard for two switches.
Can't I just wire the two switches to two ports (say 5 & 6) and do this?
start:
...if pin5 = 1 then goto programA
...if pin6 = 1 then goto programB
goto start

programA:
'code to traverse the maze the first time.
end

programB
'Code to read the best path from EEPROM
end

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Richard Vannoy

Programming and Electronics Instructor
www.PICRobots.com
www.SailingStrategy.info
www.TeachingTechnicalTraders.com
·

Comments

  • SRLMSRLM Posts: 5,045
    edited 2008-11-04 00:06
    Yes. The easiest thing to do is to have three programs: one to decide what to do, and your two maze programs.
  • $WMc%$WMc% Posts: 1,884
    edited 2008-11-04 01:24
    Mr. Professor

    Are You useing editor vers.2.2 or vers.2.4 ??????



    _____________________________________________$WMc%__________________________????__
  • RoboticsProfessorRoboticsProfessor Posts: 54
    edited 2008-11-04 02:38
    To SRLM: Aren't the three snippets I posted above (start:, programA, programB) three programs, or do I misunderstand you.

    To: $WMc%: I'm using 2.4.

    By the way...
    The full working source is at:
    http://picrobots.com/my-line-maze.php

    With a video of it working here:
    http://www.youtube.com/watch?v=raEQlDq_EwI

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Richard Vannoy

    Programming and Electronics Instructor
    www.PICRobots.com
    www.SailingStrategy.info
    www.TeachingTechnicalTraders.com
    ·
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-11-04 02:46
    Seems you should only need·1 switch, RoboProf.

    A_or_B:                           [color=green]' subroutine select[/color]
     
     IF Switch_X = 1 THEN Program_B
     GOTO Program_A                   [color=green]' Switch_X = 0[/color]
    
    
  • FranklinFranklin Posts: 4,747
    edited 2008-11-04 04:43
    PJ, what if you want the bot on but not running the maze until you press a button?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • SRLMSRLM Posts: 5,045
    edited 2008-11-04 05:29
    The code that you posted above is for three subroutines, not different programs. If you are using a BS2e or above, you have eight slots to put stuff in. The subroutine method works fine, if you have the space. However, on a big maze you may run out of EEPROM.

    So, I guess I missunderstood. What are you asking? The switching that you show would work fine. If you want to drop it down to one pin, you can have the switch be pressed down for a short time or a long time.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-11-04 12:29
    Franklin, et al.,
    I dunno -- "what if"?·
    If a robot is on but not running the maze, idle...·then·it's smoking batteries on company time and should be fired.· I figured it was a decision for·A or B.· If a "Go"·switch is required, then groove on.· A/B_switch, Go/Nogo_switch; 6 of these, a half-dozen of those.
    ·
  • ercoerco Posts: 20,256
    edited 2008-11-04 17:44
    Or have it branch to umpteen subroutines using an IR remote. You need just one i/o with a $3 IR receiver on it. Universal remotes are cheap and add lots of flexibility to your project. Plenty of Parallax info on how to use them, just cut & paste their IR routine into your program. When your program starts, have it wait for a legit IR code before doing anything.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • RoboticsProfessorRoboticsProfessor Posts: 54
    edited 2008-11-09 17:16
    I was asking about an "idle" mode because my program responds to the floor sensors. If the program starts as soon as I load it, then the changes the sensors detect while I'm moving the robot from near the computer to on the maze playing field actually mess me up. So I need a way that the program is not "active" with the sensors until directed.
    My options seemed to be:
    (Simplest) Button A begins the "search maze for the first time" subroutine.
    Button B begins the "Go read the stored "best path" for the maze from EEPROM and follow that.

    (Or...)Only one button. If EEPROM location zero has a zero, then search first time. If EEPROM location zero is any positive integer, then a path has been stored so go to "best path".

    I thought of running the USB from a laptop and put the laptop on/next to the start of the maze, but then the robot takes off before I can get the USB cable unplugged.

    So, although it is only for a few seconds, I don't see how else to have the program wait until started by a button.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Richard Vannoy

    Programming and Electronics Instructor
    www.PICRobots.com
    www.SailingStrategy.info
    www.TeachingTechnicalTraders.com
    ·
  • RoboticsProfessorRoboticsProfessor Posts: 54
    edited 2008-11-09 17:18
    Exactly what I want.
    Franklin said...
    PJ, what if you want the bot on but not running the maze until you press a button?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Richard Vannoy

    Programming and Electronics Instructor
    www.PICRobots.com
    www.SailingStrategy.info
    www.TeachingTechnicalTraders.com
    ·
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-11-09 17:36
    Idle:······················ ·'looks at a pushbutton
    · IF Go_NoGo = 0 THEN Idle·· 'pushbutton

    A_or_B:····················· 'looks at AorB sel.
    · PAUSE 2000·················'change if you need more·setup time
    · IF AorB = 1 THEN Program_B

    Program_A:
    ·(subroutine)
    ·should "end" with END or GOTO Idle

    Program_B:
    ·(subroutine)
    ·should "end" with END or GOTO Idle
Sign In or Register to comment.