I have managed to augment my Microbric Viper with the Parallax PING ultrasonic sensor. It was an exciting addition, considering that it will allow my robot to locate objects in the environment without bumping them (sensing the object without physical contact) and on top of, it adds range finding abilities (determining the distance of the obstacle).
Parallax PING))) Sensor
In a nutshell, the Parallax PING))) Sensor is similar to how Bats navigate and locate objects in the thick of darkness, they make use of the concept called "Echo Location" or "Active SONAR", This is achieved by sending very high frequency sound pulses directed at a an object or obstacle, the location and distance of the object is then calculated based on the time it took for the sound pulse's echo (reflecting off an object) to return back to the sender, the sooner that the sound returns the closer the object, the later the sound returns the farther the object.
What I like about this sensor is it simplicity of design, unlike other ultrasonic range finder sensors out there, which makes use of analog signal, which in return needs an analog pin to interpret the output. The PING))) Sensor output signal is purely digital, which is very important since the Microbric Viper does not have an analog input/output pin, it's not that Atom Basic 28 Pin 16F876A PICMicro Microcontroller can't support it, but the Microbric Viper's mainboard did not enable those pins, this was to minimize the size the complexity of the mainboard. Ultimately, this sensor only requires one(1) pin both for input (triggering the sensor to send high frequency sounds) and output (reading the value of the distance). The sensor can accurately detect and determine the distance of objects within 3 centimeter to 3 meter range.
Start PING)))ing.
Time to get busy, I started with unpacking the Parallax PING))) Sensor.
As mentioned, the Parallax PING))) sensor has simple design, it only requires 1 digital pin, +5 volts and ground pin as seen below.
I then proceeded on assembling the servo mounting bracket then mounting the whole assembly the Parallax Servo.
Here is the completed sensor assembly with the Parallax servo, this will allow sensor to swivel l
eft to right and vice versa, this will be used for sensor scanning.
There you have it, the completed sensor assembly. On the next topic.. Interfacing.
Viper meet PING))), PING))) meet Viper
Now that the sensor is ready, it's time to interface with the Microbric Viper.
Connecting the sensor is done, by a make-shift jumper wire connected to Viper's mainboard pins (in the future I will find a way of cleanly terminating the pins to a breadboard or male/female headers). For rapid prototyping purposes, this will do for now.
Interfacing my Viper with the PING sensor was not straight forward as I have expected, though there were a lot of sample code to make it work, it was for the Parallax Basic using the Parallax Basic Stamp II microcontroller.
A whole lot of reading the PING sensor manual, googling and analyzing of code solved the problem.
Portions of the code was derived from Kurte, a fellow roboteer member from the Lynxmotion forums. I have modified the code to allow it to output the sensor reading via the Viper mainboard UART port and also set two LEDs to blink once the object is less the 15cm from the sensor.
ViPING))) version 0.1 - ATOM BASIC source code
DistanceInCM var word
DistanceInINCH var word
PING_Trigger con 5
PING_Echo var word
PING_Scale var long
PING con p1
L_LED con P5
R_LED con P7
main:
Low PING
Low L_LED
Low R_LED
pulsout PING, PING_Trigger
pulsin PING, 1, PING_Echo
PING_Scale.highword = 0
PING_Scale.lowword = 2251
DistanceInCM = (PING_Echo */Ping_Scale) / 2
'send output to UART interface
serout s_out,i9600,["Distance 1 = ", dec DistanceInCM," cm" ,13]
pause 5
if DistanceInCM <= 15 then
'if Distance of the object is less than 15 cm, Blin R/F LEDs
High L_LED
High R_LED
pause 50
'Toggle L_LED
'Toggle R_LED
endif
Low L_LED
Low R_LED
goto main
What's the frequency err distance Kenneth?
After hours of debugging and coding, it's time to see the above source code in action. Here is the video, showing the Microbric Viper and the Parallax PING))) detecting objects and reading object distance in centimeters.Enjoy!
Well, that wraps it all up. Keep posted for more, next topic will be building the robot with incorporating the sensor and the code to make it roam autonomously. DMFP
1 comment:
dapuk! that's too cool pre. syet, i only have this darn "ping" pong ball in my nose to play. :)
Post a Comment