Shop OBEX P1 Docs P2 Docs Learn Events
need reliable code for bs2 wth daventech srf-10 or srf-04 — Parallax Forums

need reliable code for bs2 wth daventech srf-10 or srf-04

NauketecNauketec Posts: 51
edited 2007-08-01 14:43 in BASIC Stamp
I have been working with the SRF-04 and now find that the SRF-10 is a better solution but my data is still a bit jumpy.·

I need to ping a room (around ten to 20 feet) set this value as the room size. ·The size of the room should then have 3 feet removed (for the·first 3 feet from the·wall with the sensor), the rest of the room is·divided into 5 separate zones. So from the sensor if the sonar reports the distance of 1ft or under then goto MOD8.· If the distance is 3 to 2 feet then goto MOD6.· If the distance is 3 to 2 feet and remains there for x amount of time then goto MOD7.· If the distance is equal to the range of the first zone after 3ft then goto MOD6.· If the distance is equal to the range of the·second zone after 3ft then goto MOD5.· If the distance is equal to the range of the·third zone after 3ft then goto MOD4·If the distance is equal to the range of the·fourth zone after 3ft then goto MOD3···if the distance is equal to the range of the·fifth zone after 3ft then goto MOD2.··If·the distance equals the room distance·then goto MOD1·and repeat pinging.·

The only other concern is that if the distance is reported to be right between·two zones, it will choose one over the other so as not to keep jumping back and forth.·
·
Anyone out there familiar with this kind of application.· I would sure appreciate a hand I have been at this for about 3 months with no real results.
Thanks! Daniel·· confused.gif

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-08-01 12:53
    Nauketec -

    Double posting messages makes it more difficult and confusing for everyone trying to assist you.

    Although I don't quite understand what you're doing, here is one possible approach using the SELECT -- CASE command.

    I'm SURE it will require modifications to have it work as you want it to.

    'dist is in inches

    Select dist

    ·Case <= 12

    ·GOTO Mod8

    ·Case 24 to 36

    ·For n = 1 to Some_Determinite_Time

    ·· IF dist < 24 OR dist > 36 GOTO MOD6

    ·NEXT

    GOTO Mod7

    Case = First_Z_Range - 3

    ·GOTO Mod6

    Case = Second_Z_Range - 3

    ·GOTO Mod5

    Case = Third_Z_Range - 3

    ·GOTO Mod4

    Case = Fourth_Z_Range - 3

    ·GOTO Mod3

    Case = Fifth_Z_Range - 3

    ·GOTO Mod2

    Case = Room_Dist

    ·GOTO Mod1

    Case ELSE

    ·DEBUG "No Range Case Match"

    END SELECT

    That should give you the basic idea (no pun intended).

    Regards,

    Bruce Bates
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-08-01 14:43
    Duplicate post removed.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.