Senior Design Project - RC car object detection
As the title says my team mates and I have bought a stamp2 microcontroller along with the super carrier board to program it. From the topics I've read so far I'm concerned that we won't be able to use PMW modulation and controlling the duty cycle as a means of motor speed control. The RC car we are using has 2 DC motors one for the front to control the left and right steering of the car and a second that control the forward and backward motion of the car. Since we aren't dealing with servos, will we need to be using HWPM to give us a cleaner duty cycle? We are using two parallax proximity sensors on the front and back as a means of collision detection, and the final goal of the project is to make the car autonomous and parallel park itself. I'm brand new to basic stamp programming and currently working on a sample program which moves the car forward and brings it to a complete stop when it senses an object a foot in front of it. Any references as far as motor control is concerned or any other info would be greatly appreciated.
Comments
http://www.parallax.com/Store/Accessories/MotorServoControllers/tabid/160/CategoryID/35/List/0/Level/a/ProductID/67/Default.aspx?SortField=ProductName,ProductName
Also I'm attempting to modify the sample code provided on the parallax site for the prox sensors using two at once. I keep receiving an error message when I try and check the syntax. It's giving me an Error: 174 - Label is missing ":" where it is highlighting the word Ping in the subroutine Get_Sonar. I'm not certain why I'm getting the error as the subroutine is identical to the sample code which Tokenizes Successfully when checked for syntax. Thanks again for any help.
'
[noparse][[/noparse] I/O Definitions ]
Ping1 PIN 15
Ping2 PIN 14
'
[noparse][[/noparse] Constants ]
#SELECT $STAMP
#CASE BS2, BS2E
Trigger CON 5 ' trigger pulse = 10 uS
Scale CON $200 ' raw x 2.00 = uS
#CASE BS2SX, BS2P, BS2PX
Trigger CON 13
Scale CON $0CD ' raw x 0.80 = uS
#CASE BS2PE
Trigger CON 5
Scale CON $1E1 ' raw x 1.88 = uS
#ENDSELECT
RawToIn CON 889 ' 1 / 73.746 (with **)
IsHigh CON 1 ' for PULSOUT
IsLow CON 0
'
[noparse][[/noparse] Variables ]
rawDist VAR Word ' raw measurement
inches VAR Word
'
[noparse][[/noparse] Initialization ]
Reset:
DEBUG CLS, ' setup report screen
"Parallax Ping Sonar ", CR,
"=====================", CR,
CR,
"Time (uS)..... ", CR,
"Inches........ ", CR
'
[noparse][[/noparse] Program Code ]
Main:
DO
GOSUB Get_Sonar ' get sensor value
inches = rawDist ** RawToIn ' convert to inches
DEBUG CRSRXY, 1, 3, ' update report screen
DEC rawDist, CLREOL,
CRSRXY, 1, 4,
DEC inches, CLREOL,
CRSRXY, 2, 3, ' update report screen
DEC rawDist, CLREOL,
CRSRXY, 2, 4,
DEC inches, CLREOL
PAUSE 100
LOOP
END
'
[noparse][[/noparse] Subroutines ]
' This subroutine triggers the Ping sonar sensor and measures
' the echo pulse. The raw value from the sensor is converted to
' microseconds based on the Stamp module in use. This value is
' divided by two to remove the return trip -- the result value is
' the distance from the sensor to the target in microseconds.
Get_Sonar:
Ping = IsLow ' make trigger 0-1-0
PULSOUT Ping, Trigger ' activate sensor
PULSIN Ping, IsHigh, rawDist ' measure echo pulse
rawDist = rawDist */ Scale ' convert to uS
rawDist = rawDist / 2 ' remove return trip
RETURN
You've got two definitions for I/O pins, "Ping1" and "Ping2". Neither one is "Ping".
Post Edited (d(-_-)b) : 11/16/2009 2:13:51 AM GMT