Shop OBEX P1 Docs P2 Docs Learn Events
Need help with Project — Parallax Forums

Need help with Project

Ganni17Ganni17 Posts: 11
edited 2009-04-21 05:32 in Accessories
I am building a model of a retractable speed bump, depending on speed of upcoming car, the bump goes up for going over speed limit and down for under. I am looking to use the parallax, ping ultrasonic sensor and a microcontroller to pick up and determine speed of upcoming car. I also want my microcontroller to tell my bump to go up or down. I was planning on using a airbag system to raise and lower bump. I have no experience with any of this, so am I heading in the right direction? Is this idea possible with these products? Do I have the right products or should I be using something else? Any help would be greatly appreciated.

Comments

  • Jessica UelmenJessica Uelmen Posts: 490
    edited 2009-03-10 20:40
    Hello,

    Your duplicate posts in the Stamps in Class and Robotics forums have been removed. Please refrain from duplicate posting.

    Thank you!

    Jessica

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jessica Uelmen
    Education Department
    Parallax, Inc.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-03-10 20:46
    Additional duplicate message removed from BASIC Stamps forum.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • SRLMSRLM Posts: 5,045
    edited 2009-03-11 00:36
    The ping probably wouldn't work well, since it requires head on (perpendicular) surfaces to reflect the signal back, and ultrasonic is fairly slow and limited in range. Take a look here for a better speed idea:

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

    Deploying the airbag is almost certainly a bad idea. I'm guessing here, but the airbags probably aren't intended to have a semi-truck roll over them while inflated, and aren't designed for repeated inflation and deflation in a harsh environment. You'll have to make a mechanical system of some kind to raise and lower the speed bump. I'd recommend a design with a screw and thrust bearing to take the force of the hit.

    A microcontroller will be able to do what you need, though.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-03-11 01:40
    I agree with SRLM that using something pneumatic is not a good idea. One possibility, however, is to use something hydraulic. Either an inflatable hose type of gizmo or use hydraulics to lift up a smooth barrier. Something to look into is the patterning of smaller bumps that can create a resonance that will make driving too fast unpleasant. A single bump maybe isn't as good as a series of smaller ones that are spaced out in a particular way. If you've ever driven off road in a desert and hit a "wash board", you know what I'm talking about.
  • kwinnkwinn Posts: 8,697
    edited 2009-03-11 02:57
    Don't encourage anyone producing more speed bumps. They are the biggest reason I am replacing shocks more frequently than ever before. I do not speed and I drive slowly and carefully in parking lots.
  • Ganni17Ganni17 Posts: 11
    edited 2009-03-15 03:19
    So, how about two lasers set up, a number of feet before the bump. A 555 timer to determine the time between, from the tire hitting laser one to hitting laser two. A microcontroller to determine the mph, and to send a signal to the bump, whether to raise or not. Am I on the right track?
  • SRLMSRLM Posts: 5,045
    edited 2009-03-15 03:36
    That might work. The link that I posted has some nice schematics to make a nice pulse that a BS2 can read.
  • Ganni17Ganni17 Posts: 11
    edited 2009-03-16 17:22
    Slowly but surely I am moving ahead, as I read more and learning more about the equipment I need and will be using. So, I got the set up of two lasers to determine the time between, from the tire hitting laser one to hitting laser two. I know I will use a 555 timer to read the time. And Im thinking of using the TSL230R as my laser detector. What lasers should I use, they have to be able to withstand the elements, and work in rain and sunshine? What kind of basic stamps will I be needing? Do I need a stamp at each laser, at each detector and another for the 555 timer and finally another one to send signal to my bump?
  • SRLMSRLM Posts: 5,045
    edited 2009-03-16 21:33
    After more reading, it mentions in the link from the thread I linked that the 555 timer would be a poor choice for areas where temperature varies (outdoors). It will give you a speed, but that will be a variable of the temperature. PJ's schematic is better (and simpler)

    start_stop_speed.jpg
    [noparse][[/noparse]Copied]

    You can use any laser, and you can mount all your electronics in an enclosure with a small, clear lens (for the laser). Obviously, this lens should be kept clean, and that can be helped by choosing slick surfaces and shielding it from rain and splatter (including road splatter and dust). A fan might help with that if you can afford the power.

    As erco mentioned (in the link), you'll want to have light shields for your detectors so that all it sees is the laser light.

    With this setup, you need only a single microcontroller to measure the pulse and take action.
  • SRLMSRLM Posts: 5,045
    edited 2009-03-17 02:53
    This item popped up in another thread: http://www.acam-usa.com/Content/English/gp2/gp2_1.html

    It's probably overkill for your project and it's certainly rather advanced, but if you get it working then you'll have a firm understanding of microelectronics. [noparse]:)[/noparse]
  • mctriviamctrivia Posts: 3,772
    edited 2009-03-17 03:19
    my question is why? speed bumps can be designed for any speed by altering there hight and width. You can make a speed bump that is perfectly fine at 50km/h.

    The problem with speed bumps is people drive rapidly up to them then slow down at the bump only. People slow down often much slower then is really necisary. Speed bumps work more by being visible then actually duing anything to the car itself.

    I.E. if you see a speed bump coming you will slow down.

    Your bump won't be there so it won't cause people to slow down but it will hurt there car because it will be there only when they hit it.




    What may work better as a speed deterrent is a sign saying automatic spike strip for drivers over xxkm/h just please don't actually put a spike strip in.



    On a more serious note how about putting in audible pain field system if driving over a specific speed. Causes no ill effects to the car and hurts a lot to drivers going to fast.

    How to make pain field:
    1) Very loud speeker 120db in 15-20kHz range
    2) Create rapidly changing very load sounds in the 15-20kHz range

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Need to make your prop design easier or secure? Get a PropMod has crystal, eeprom, and programing header in a 40 pin dip 0.7" pitch module with uSD reader, and RTC options.
  • mctriviamctrivia Posts: 3,772
    edited 2009-03-17 03:21
    oh by the way you can use inductive sensers cut into the asshphault to measure speed. That is how the stop lights detect cars. Basically a wire loop that's inductance changes when large metal body is near by.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Need to make your prop design easier or secure? Get a PropMod has crystal, eeprom, and programing header in a 40 pin dip 0.7" pitch module with uSD reader, and RTC options.
  • Ganni17Ganni17 Posts: 11
    edited 2009-03-17 04:20
    Why a speed bump, because its a school project which majority ruled the topic in our group and now we are too far along in the semester to change the idea. So I have to figure out away to make this thing functionable with knowing very little.
  • mctriviamctrivia Posts: 3,772
    edited 2009-03-17 04:58
    well school projects don't always make practical sense so that is a good enough reason for me. Do you have the ability to install inductive sensers in the road way? (requires saw cutting the road. easily patched up afterwords but saw cutting equipment may be hard for school to get a hold of.)

    Lazer eyes work but are suseptible to dirt from mud. Inductive is the way to go.


    If you can not actually install inductive sensers the proper way for testing purpose you could lay the coils on the asphalt and place plywood over it to protect it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Need to make your prop design easier or secure? Get a PropMod has crystal, eeprom, and programing header in a 40 pin dip 0.7" pitch module with uSD reader, and RTC options.
  • mctriviamctrivia Posts: 3,772
    edited 2009-03-17 05:06
    http://auto.howstuffworks.com/question234.htm

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Need to make your prop design easier or secure? Get a PropMod has crystal, eeprom, and programing header in a 40 pin dip 0.7" pitch module with uSD reader, and RTC options.
  • Ganni17Ganni17 Posts: 11
    edited 2009-03-17 15:57
    mctrivia, Thank you for help but I do believe my setup is the two lasers before the bump and taking the time between them with to figure out the velocity
  • Ganni17Ganni17 Posts: 11
    edited 2009-04-13 22:31
    Could you guys check my schematic? I think it should work. Also, I could use help on writing the program. I saw the other post had this, I just neeed to change a few things with the mph conversion because my lasers are 4 inches apart so I need inchpersec

    Here is the basic program.

    ' {$STAMP BS2}
    ' {$PBASIC 2.0}

    t VAR Word
    mph VAR Word

    SPEED_TRAP:

    Trigger:
    IF IN1 = 0 THEN Main
    GOTO Trigger

    Main :
    PULSIN 0, 1, t

    IF t = 0 THEN Trigger

    mph = (34090 / t * 10) + (34090 // t * 10 + (t/2) / t) * 2
    DEBUG CR, DEC mph/10, ".", DEC1 mph, " MPH" ' units of 0.2 mph

    GOTO Trigger
  • SRLMSRLM Posts: 5,045
    edited 2009-04-14 20:28
    What exactly is your question? If you have a definate issue, go ahead and post it. Otherwise, try it out. Experiment. See what happens.

    Anyway, good code should have some comments...

    What exactly is the line that starts with 'mph =' doing?

    'Here is my version

    t = t*2 'convert t to uS

    'use equation rate * time = distance
    'rate = distance / time
    'rate = (1/3) foot / t uS * (1,000,000 uS/ 1 s) * (60 s / 1 min) * (60 min / 1 hr) * (1 mi / 5280 feet)
    'rate = 1,000,000 * 60 * 60 / (3 * t * 5280) ' in mph
    'rate = 227273 / t
    rate = 4*(56818 / t) 'split out the four so that the numbers fit in a 16 bit word

    'Note: as t gets larger, the precision of the result is gets smaller.
  • Ganni17Ganni17 Posts: 11
    edited 2009-04-15 12:02
    Coud you run me though the code I wrote in post just before yours. Explain exactly what each line does so I can get a little better understanding. I have taken one class in c++, so not to much experience. As of now I have my two phototransistors hooked up to P0 and P1. I need to know when each laser is broken so it can configure the speed of vehicle. Than I have two LEDs, one in P2 and one in P3 which are supposed to light up depending on speed of vehicle above, or below speed limit.
  • SRLMSRLM Posts: 5,045
    edited 2009-04-16 15:41
    The first two lines are pre compiler directives (or the equivilent of C++'s #).
    The next two lines declare two variables called t and mph. The author choose a word size (16 bits)
    The next line is a label, and is not needed.
    The block starting with Trigger: has another label, an if statement that tests for a low on pin 1, and a GOTO. This section basically waits for pin 1 to be high.
    The next line after main measures an input pulse.
    The next line I'm not sure what it's there for. Perhaps a timeout sensor?
    The next line (with mph = ) is the big long equation I discussed in my last post.
    The next line with DEBUG outputs mph to the screen.
    Finally the last line makes the program go back to waiting for a trigger.

    To test to see if the speed limit has been broken you'll need to insert your own IF statement somewhere close but before the last line.

    Be sure to take a look at "What's a Microcontroller" and other stamps in class books. You can download them on the main parallax website.
  • P!-RoP!-Ro Posts: 1,189
    edited 2009-04-18 23:21
    One more possibility is making a speed hole rather than speed bump. If you have a speed bump, you will have to create a pneumatic or hydraulic system capable of lifting a couple tons, or it will either break when a car hits it, or just lower rather than give the car a jolt. If you make a speed hole, you can just dig a pit in the road, then use a motor to slide a piece of metal over it. When a car comes by that is going too fast, it will pull the cover off the pit causing the car to dip down when it hits it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PG
  • Ganni17Ganni17 Posts: 11
    edited 2009-04-20 20:11
    This is what I have so far:

    ' {$STAMP BS2}
    ' {$PBASIC 2.0}

    I need to set P0 and P1 to inputs and P2 & P3 to outputs Is this the correct way to go about setting I/O?
    in0 PIN 0 ' pin-type symbol representing I/O 0

    INPUT 0 'set P0 to input

    in1 PIN 1 'pin-type symbol representing I/O 1

    INPUT 1 'set P1 to input

    out0 PIN 2 'pin-type symbol representing I/O 2

    OUTPUT 2 ' Set Signal pin to output

    out0=0 ' reset LED to off

    out1

    OUTPUT 3 ' Set Signal pin to output

    out3=0 'reset led to off


    t VAR Word
    These lines setup the program to recognize these variables "t" and "mph"
    mph VAR Word

    SPEED_TRAP: name of program module

    Trigger:
    IF IN1 = 0 THEN Main if P0 =0 than go to main subroutine below. If =1 than loop back to trigger(called do loop). This program also looks like only one I/O pin is used. Also was there any info on the designation of PULSIN ?. Its not in the manual ?
    GOTO Trigger

    Main :
    PULSIN 0, 1, t

    IF t = 0 THEN Trigger if t=0 than no car has triggered the sensor so loop back to trigger. If t=anything than proceed. t=will be the time in uSec or mSec.

    mph = 4*(56818 / t)
    DEBUG CR,".", DEC1 mph, " MPH" ' units of 0.2 mph

    GOTO Trigger loop back to trigger to begin process again


    Once I get the result I need to compare it to a raise or lower the speed bump limit than turn on the correct led by addressing either P2 or P3

    Does this look correct?
    Can you help me finish?
  • SRLMSRLM Posts: 5,045
    edited 2009-04-20 20:32
    According to the formula I stepped through, the units are in 1 mph, not .2 mph. You'll have to make some adjustments if you want that.

    In general, help on the forums is for those who help themselves. Nobody wants to write your program for you, but we are willing to help you trouble shoot. Why don't you go ahead and experiment some, build the setup, write all your code, and see what happens. From there, try to get it working. After a while, if it doesn't work, then ask. You'll learn much more that way, and feel better about your project.

    As a side note, one of the most effective ways of writing a program is to write the algorithm first, then fill in with the code. Something like this to start:

    'Get car speed
    'Determine if car is going to fast
    'If the car is going too fast, raise the bump
    'Return to get car speed

    The more detailed, the better. The programming language is just a tool to put that algorithm into practice. If you know exactly what you want to do, chances are that you won't have many problems programming.
  • Ganni17Ganni17 Posts: 11
    edited 2009-04-20 20:47
    Do I have the Inputs and Outputs correct? Is that the correct way to write it in this language?
  • SRLMSRLM Posts: 5,045
    edited 2009-04-20 22:29
    Take a look at the Basic Stamp Syntax and Reference Manual, page 83. Again, also take a look at What's a Microcontroller.

    I'm not familiar with PBASIC 2.0, you may want to move to 2.5

    And no, the way that you are using INs and OUTs is not correct. You'd know that if you tried tokenizing (compiling) the code in the editor. I suggest that you poke around the Parallax site, and look at some of the sample code. See how they do things, and you can learn quite a bit about the correct syntax. Expect to spend at least ten hours before you're comfortable with the language enough to catch mistakes like these.
  • Ganni17Ganni17 Posts: 11
    edited 2009-04-20 22:51
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}


    sensor1 PIN 1 ' pin-type symbol representing I/O 1

    INPUT sensor1 'set sensor1 to input

    sensor2 PIN 2 ' pin-type symbol representing I/O 2

    INPUT sensor2 ' set sensor2 to imput

    led1 PIN 3 ' pin-type symbol representing I/O 3

    OUTPUT led1 ' Set Signal pin to output

    led1=0 ' reset LED to off

    led2 PIN 4 ' pin-type symbol representing I/O 4

    OUTPUT led2 ' Set Signal pin to output

    led2=0 'reset led to off


    Hows that look for Input/Outputs?
  • Ganni17Ganni17 Posts: 11
    edited 2009-04-21 05:26
    Is there a reason why we cannot use in0, in1, etc? We try and use those names and it gives us errors. Other than that, the main issue is that Pin 1 never becomes high. If pin 1 became high, the rest of the program should work, but it won't be high.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-04-21 05:32
    Read the Stamp Reference Manual pages 81-102.

    Also, you've set pin 1 to input mode. It will never be high in input mode unless some external circuit sets it that way. An input pin is a high impedance input of indeterminant state.

    Post Edited (Mike Green) : 4/21/2009 5:37:31 AM GMT
Sign In or Register to comment.