Need help with Project
Ganni17
Posts: 11
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
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 Savage
Parallax Engineering
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.
[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.
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]
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.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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.
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.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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.
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
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.
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.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PG
' {$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?
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.
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.
' {$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?
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