Shop OBEX P1 Docs P2 Docs Learn Events
Garage sonic ranger parking assistant — Parallax Forums

Garage sonic ranger parking assistant

RTurleyRTurley Posts: 8
edited 2008-02-01 06:42 in Robotics
Garage Sonic Ranger Parking Assistant
·
Background
·
If your garage is like mine, there is little room for a walkway in front of the garage.· Stuff gets piled up and if a car is parked too far forward, there is little passage way left.· That means when you are lugging the groceries, travel bags, camping gear or whatever, you have to dance and wiggle through the remaining space carrying a load.
·
I would be nice if every car was parked such that the walkway was clear?· This project provides one solution to this problem.
·
The schematic for this project is easy.· The coding is a little (but not much) more challenging, depending on the desired behavior of the device.
·
General Description
·
The hardware consists of a Stamp BS-2, a Devantech SRF04 ultrasonic ranging device, three LEDs, resistors, four pushbutton switches, a calculator-sized project box and a wall adapter for power.
·
When a car enters the far detection range (GrnMax), the green LED is illuminated.· As the car proceeds forward, the car exits the green detection range and enters the yellow detection range (YelMax). At this point, the green LED is turned off and the yellow LED is turned on.·· Continuing forward, the car enters the red detection range (RedMax).· The yellow LED is turned off and the red LED is turned on.· The red detection range is a window of 8 inches.· Parking anywhere in this range is good.· If the car moves beyond the end of the red window closest to the sensor (RedMin), then the red LED begins blinking to indicate that the car is too close. The drawing in Attachment-1 will help clarify the green, yellow, red and red blink detection distances.
·
Code
·
Desired functionality
·
I wanted the device to be smart enough to turn the red LED off after a car was parked. I also wanted the device not to react to people walking through an empty garage, so I needed some way to ignore readings in the yellow and red ranges if the green range had not been traversed first. I also learned through experience that it is helpful to be able to adjust the red and green detection distances without having to download a new program.·
·
Note: Rather than converting timings to distance, the program uses the raw timing values received from the SRF04 for purposes of its measurements.
·
Description of the program
The program code is in Attachment-2.
·
Startup
·
The program initializes pins and reads stored timing values from EEPROM.· The only stored values are the red distance measurement (where you want the car to stop) and the beginning of the green detection range. It clears three switch values to false.· These switch values (one each for green, yellow and red) keep track of whether the car (or other object) has passed through green to get to yellow, through yellow to get to red and through red to get to red blink.·
·
It then checks to see if any pushbutton switches are pressed.·
·
If not, it drops into the main loop.
·
Main Loop
·
Here begins the slow pinging for an object.· As long as no object is detected, it remains in the slow pinging state, with all LEDs off.
·
Once an object is detected in the green detection range, the ping rate increases, the green LED is turned on and the green switch is set to true.· As each detection zone is entered, the corresponding LED is turned on, the previous LED is turned off and the switch value is set true for the corresponding detection zone.· These switch values are used to decide if yellow or red should be displayed.· Yellow will be displayed if the GrnWasOn switch is True.· Otherwise, it is ignored.· The same is true for red.
·
The main routine periodically pings and if an object is detected, tests the time returned to see if it is less than GrnMax and greater than YelMax.· If so, the green LED is turned on, the other LEDs are turned off and the GrnWasOn switch is set true.·
·
If the ping time is less than YelMax and greater than Red Max, then the yellow LED is turned on, the other LEDs are turned off and the YelWasOn switch is set true.
·
If the ping time is less than RedMax and greater than RedMin, then the red LED is turned on and the others are turned off.
·
If the ping time is less than RedMin, the red LED is turned on for 100 mSeconds and turned off.
·
A loop counter is used to count the number of times through the red zone loop.· Once this count is exceeded, the program reverts back to the slow ping state with all LEDs off and all switches set to false.
·
The distance measurements are stored in EEPROM. These are the red distance measurement (ideally where you want the car to stop) and the green detection distance. The program calculates the beginning of the yellow detection distance, the beginning of the red detection distance and the beginning of the red blink detection distance at start up, according to the following computations:
·
RedMin is the start of the red blink detection distance and is calculated by subtracting the red negative adjustment factor from the red measurement.
·
Red Max is the start of the red detection distance and is calculated by adding the red positive adjustment factor to the red measurement.· RedMin and Red Max define a widow where the nose of the car should stop.· Inside of RedMin is the red blink range and outside of RedMax is the yellow range.
·
GrnMax is the beginning of the green detection distance.· It initially defaults to about 12 feet, at or beyond the maximum range or the SRF04.
·
YelMax is the beginning of the yellow detection distance and is calculated by dividing the difference between GrnMax and RedMax by 2 and adding this number to RedMax. ((GrnMax-RedMax)/2) + RedMax.· This makes the Green and Yellow zones of equal size.
·
There two groups of routines that are subordinate to the main routine.· These are subroutines and terminal routines.·
·
Subroutines
·
GetSonar
·
The first subroutine was written by Jon Williams (thank you Jon) and obtains the echo timing from the SRF04. Please refer to Jon’s “Sonic Sight” program and accompanying documentation for information regarding use of this device.
·
ErrorLeds
·
The second subroutine is an error display that simply toggles each LED on and off in sequence from green to yellow to red.· It performs this sequence a few times, to signify that an error has occurred.
·
ShowGreenDistance
·
The third subroutine displays the current value of GrnMax.· Here, the timing value is converted to distance. ··The number of feet in GrnMax is displayed by flashing the green LED once for each foot of GrnMax.· If a half foot (or greater) exists, the yellow LED is flashed once to signify this.· So, if GrnMax is set to 9 1/2 feet, the green LED will flash 9 times and the yellow LED once.· If GrnMax is set to 9 feet, then the green LED will flash 9 times and the yellow LED will not flash
·
ShowRedDistance
·
The fourth subroutine displays the converted value of RedMax.· To display RedMax, the red LED will flash one time per foot and the yellow LED will flash for each 1-inch fraction of a foot.· For example, to display 3 feet 8 inches, the red LED will flash 3 times and the yellow LED will flash 8 times.
·
Terminal Routines
·
The terminal routines are used to obtain or modify the red measurement and the beginning of the green detection distance. They are executed once and terminate with an END instruction.
·
SetDistance
·
This routine is used to take the initial red measurement.· To take the initial measurement, park the car where you want it to stop.· Invoke the SetDistance routine by holding the Set pushbutton down and then press and release the Reset pushbutton.
·
SetDistance will obtain the time measurement for the distance from the front of the car to the sensor. This is RedMeas.· The RedPlusAdj amount is added to RedMeas to give RedMax.· The RedMinusAdj amount is subtracted from RedMeas to give RedMin.· This creates the window where the car should stop, when parked.
·
These values are edited to insure that RedMax is greater than RedMin.· If so, RedMeas and the default value of GrnMax is written to EEPROM and the two distance display subroutines are called to display the respective distances.· If not, then the ErrorLeds subroutine is called to show that the adjusted red distance measurement is bad.··
·
IncreaseRed
·
This routine adds 3 inches to RedMin, RedMax and RedMeas (pushing the red window away from the sensor).· Red max must be at least 2 feet less than GrnMax (so a workable yellow range can be created).· If not, the ErrorLeds routine is invoked.· If ok, the new value of RedMeas is saved in EEPROM and value of RedMax is displayed on the red/yellow LEDs. Invoke the IncreaseRed routine by pressing and holding the Set and Red pushbuttons and press and release the Reset pushbutton.
·
DecreaseRed
·
This routine subtracts 3 inches from RedMax, RedMin and RedMeas (pulling the red window closer to the sensor). Both RedMax and RedMin must be greater than zero. If not, the ErrorLeds routine is invoked.· If ok, the new value of RedMeas is saved in EEPROM and value of RedMax is displayed on the red/yellow LEDs. Invoke the DecreaseRed routine by pressing and holding the Red pushbutton and press and release the Reset pushbutton.
·
IncreaseGreen
·
This routine adds 6 inches to GrnMax (pushing the green detection distance away from the sensor). If GrnMax is greater than the maximum distance allowed, the ErrorLeds routine is invoked. If ok, the new value of GrnMax is saved in EEPROM and value of GrnMax is displayed on the green/yellow LEDs. Invoke the IncreaseGreen routine by pressing and holding the Set and Green pushbuttons and press and release the Reset pushbutton.
·
DecreaseGreen
·
This routine subtracts 6 inches from GrnMax (pulling the green detection distance closer to the sensor). Red max must be at least 2 feet less than GrnMax (so a workable yellow range can be created).· If not, the ErrorLeds routine is invoked.· If ok, the new value of GrnMax is saved in EEPROM and value of GrnMax is displayed on the green/yellow LEDs. Invoke the DecreaseGreen routine by pressing and holding the Green pushbutton and press and release the Reset pushbutton.
·
InvalidSetup
·
This routine is invoked if nothing has been saved in EEPROM (zeros read from EEPROM).· The ErrorLeds routine is invoked.
·
Final note
·
The reason for the Increase/Decrease Red distance is so you can nudge the red detection window towards or away from the sensor.· This is handy if your initial measurement leaves the car too close to the walkway or has the car so far back that it is too close to the garage door.
·
The reason for changing the green detection distance is different.· With two or more cars parked side-by-side, it is possible to get spurious echoes from adjacent cars in the garage or from “stuff” stacked along the side of the garage.· Buy shortening the green detection distance for one car stall, you can cause the device to ignore echoes from adjacent cars and other clutter in the garage, by putting them outside of the initial detection range.
·
Parts List
The Schematic is in Attachment-3.
·
Part Name····················· ········Vendor· ···Vendor Part No.··· Quan ·Price··
·
Stamp BS2····························· Parallax ··BS2-IC·· ···········1 ··$49.00
SRF04 Ultrasonic Range Finder········· Parallax·· 28015··· ···········1··· 36.00
10K Ohm Resistor 5%··················· Mouser···· 291-10K····· ·······3···· 0.24
300 Ohm Resistor 5%··················· Mouser···· 291-330··· ·········3···· 0.24
KingBrite green 8mm diffused LED······ Mouser···· 604-L793GD·· ·······1···· 0.30
KingBrite yellow 8mm diffused LED····· Mouser···· 604-L793ID·· ·······1···· 0.30
KingBrite red 8mm diffused LED········ Mouser···· 604-L793YD·· ·······1·· ··0.30
Phihong 5V switching ext power adapt·· Mouser···· 552-PSC-15A-050S··· 1··· 14.25
Mountain switch pushbutton switch····· Mouser···· 104-0013··········· 4···· 3.48
Amp right angle DB-9 pcb connector···· Mouser···· 571-7478444········ 1···· 1.36
.1uF capacitor························ Mouser···· 80-C320C104K5R····· 2···· 0.32
PacTec plastic enclosure 3.6x5.7x1.29· Mouser···· 616-60620-510-000·· 1···· 5.49
24-pin IC socket for Stamp············ Mouser···· 571-3902621········ 1···· 0.24
Eagle Plastics ¼ inch PCB post········ Mouser···· 561-DMSP250········ 2···· 0.34
Eagle Plastics threaded nylon spacer·· Mouser···· 561-MF440-37······· 4···· 1.28
Eagle Plastics 4-40 nylon screws······ Mouser···· 561-P440.25········ 4···· 0.76
Eagle Plastics 4-40 nylon nuts· ·······Mouser···· 561-H440··········· 4···· 0.68
········································································· ______
Total··································································· $115.28
·
·
Construction details
Photos of the finished device are in Attachments 4, 5 and 6.
·
Raise the bottom of the LEDs ½ inch above the circuit board prior to soldering, so the LEDs will extend through the cover of the enclosure.· The holes in the case for the SRF04 emitter and receiver should be lightly larger than the diameter of these devices, so that the emitter does not cause sympathetic vibration of the case. I used self-adhesive Velcro tabs to affix the device to the garage wall.· I used 5 pins of a SIP snap strip soldered to the circuit board and soldered wire-wrap pins through the connection holes in the SRF04 board. These pins insert into the SIP strip and allow removal of the SRF04 without de-soldering.
·
Even though the schematic shows a DB-9 serial connector for Stamp communications, I used a 4-pin Amp header on the actual circuit board.· This saves valuable space on the circuit board. I use a specially-made cable for communicating with the Stamp to/from my notebook computer.
·
That’s about it.· I’ve attached the schematic, photos of the actual device as mounted in our garage, the internals of the device and the source code file.
·
This was a fun and practical project and it beats having tennis balls hanging down from the ceiling. I built enough of these, so that each of the stalls in our garage has one.· We now can walk unimpeded from the farthest parked car to the entrance to the house without having to dodge car bumpers and those deformed license plate holders that snag your pant legs as you walk by.
·
Regards,
·
Rusty Turley
·
·
·
576 x 327 - 15K
2052 x 1234 - 185K
1280 x 960 - 286K
1280 x 960 - 281K

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-01-20 18:39
    Very cool. I was thinking about such a project the other day. I was considering a digital readout at eye-level, and the sonar sensor at license plate level.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • steve_bsteve_b Posts: 1,563
    edited 2005-01-20 20:40
    Something similar was in nuts and volts...no?

    Great idea nonetheless!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve
    http://members.rogers.com/steve.brady
    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • dandreaedandreae Posts: 1,375
    edited 2005-01-21 00:12
    This is so cool, the "Background" description describes
    my garage to the tee.· I can't tell you·how many times that my family and I have danced around the car hoping not to scratch it.· Two thumbs up for this project!

    Dave


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Tech Support
    dandreae@parallax.com
    www.parallax.com



    Post Edited (Dave Andreae (Parallax)) : 4/27/2005 2:58:18 PM GMT
  • villianvillian Posts: 3
    edited 2005-03-13 22:01
    jumpin.gif·You can save some money if you purchase one of Parallax's BS2 OEM kits for this project.
    They currently have them on sale for $30.00. ·I recently bought two of them for "stock".· It's hard
    to beat the price!
  • clayljclaylj Posts: 9
    edited 2005-03-26 17:15
    Great project.

    I have been looking for something like this to illistrate to my wife why I am doing this microcontroller thing! smilewinkgrin.gif
  • Kevin B SlaterKevin B Slater Posts: 49
    edited 2005-04-25 20:39
    That is a nice looking board where did you have that made.· I like the fact that it has the part printing on it.

    Kevin


    Post Edited (Kevin B Slater) : 4/28/2005 3:16:00 AM GMT
  • RTurleyRTurley Posts: 8
    edited 2005-04-27 03:04
    Hi Kevin.

    I made the board.· I use the technique described here

    http://www.pulsar.gs/1_PCB/a_Pages/1_Menu/Overview.html

    I use the direct etch method described on this site.· It's pretty reliable.· I've done boards up to 6x9, single and double sided.

    You have to have some type of layout tool/software to produce the artwork.· Then you need transfer paper to run thru a laser printer.· Then the image can be transferred to the copper-clad board·using a laminator.

    You can read the details on the web site.

    Hope this helps,

    RTurley
  • Wade SmithWade Smith Posts: 25
    edited 2005-04-27 15:17
    Very nice project. Just ordered an OEM BS2 and plan to make one using a PING I purchased already instead of the SRF04. If I use 4 AA instead of AC power any idea how long·they will last?·Getting to the nearest AC power would be more·of a problem for where I want to use it.
  • Kevin B SlaterKevin B Slater Posts: 49
    edited 2005-04-28 03:37
    RTurley,

    · Thanks, that is a great site!

    Kevin




    Post Edited (Kevin B Slater) : 4/29/2005 2:38:03 AM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-28 11:52
    The Ping (actaully, any sonic rangefinder) requires a bit of energy when it transmits, so you may want to use an additional trigger (perhaps light level) before you start pinging.· Even then, you'll want to have a bit of space (a second or two) between pings to converve battery power.· Then, when you detect the car is not moving any longer, you can shut down.·
    Wade Smith said...

    Very nice project. Just ordered an OEM BS2 and plan to make one using a PING I purchased already instead of the SRF04. If I use 4 AA instead of AC power any idea how long·they will last?·Getting to the nearest AC power would be more·of a problem for where I want to use it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2005-06-15 01:17
    ·"······hop.gif·····THESE GUYS HAVE GONE MAD "····················hop.gif
    ···················"·THEY NEED HELP BAD"
    ·····hop.gif·It has been moved to is garage open or closed
    ····jumpin.gif

    Post Edited (sam_sam_sam) : 6/16/2005 11:49:09 PM GMT
  • llomllllomll Posts: 4
    edited 2008-01-30 03:42
    This is a great project; however, I was wondering what would be the best mounting height for such a device? I have a car and a SUV which share same parking spot. If I place the sensor lower, it will not detect the SUV being present and vice versa.

    Thanks
  • Beau SchwabeBeau Schwabe Posts: 6,545
    edited 2008-01-30 05:43
    llomll,

    See this similar....Errr... Almost identical thread posted 2 years later.

    RTurley get's the credit for original design in the forum.

    http://forums.parallax.com/showthread.php?p=636791

    llomll,

    In answer to your question ... I have a 2002 Jeep Grand Cherokee ... My sensor is located about·30 inches from the ground.
    This places the sensor "looking" right into the center of the grill on the car.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 1/30/2008 5:49:46 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-01-30 15:23
    We’ve got ours aimed at the license plate, since it is the flattest section on the front of the car. The entire rest of the nose (2007 Hyundai Elantra) is all curves and doesn’t reflect well. And yes, credit should be given to RTurley for the first posted project doing this. In fact, if I didn’t give credit on my project page I will post that now.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Matthew BurmeisterMatthew Burmeister Posts: 49
    edited 2008-02-01 02:53
    broken link http://www.pulsar.gs/1_PCB/a_Pages/1_Menu/Overview.html

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the blue smoke comes out of a Basic Stamp... You know that you did something wrong... -- Matthew
  • Beau SchwabeBeau Schwabe Posts: 6,545
    edited 2008-02-01 06:42
    Matthew Burmeister,

    Try this... (A little URL hacking)smilewinkgrin.gif

    http://www.pulsarprofx.com/PCB/a_Pages/1_Menu/overview.html



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
Sign In or Register to comment.