Using the SONAR rangefinder on other platforms (Namedly, a VEX microcontroller
Does anyone have any advice on how to code an interface for this sensor (the Parallax Ping ultrasonic distance sensor) for the VEX microcontroller using a C based language (Robot C)? EVen some pseudocode would be very helpful. As far as I know, the VEX has 4 internal timers, and maybe one of those could be used to measure the pulses. So far, every bit of code I have come across in BASIC Stamp or Javelin Stamp has had pulsin or pulsout commands, but I don't think those are commands·built into·the robot C platform. does anyone know what these routines actually do?
I'm new to this, and have started this as a part time hobby, so foprgive my noobiness. Any help or advice would be very helpful.
Thanks,
-M
I'm new to this, and have started this as a part time hobby, so foprgive my noobiness. Any help or advice would be very helpful.
Thanks,
-M
Comments
The PING))) uses a single I/O pin to both trigger the sensor and to provide the range information. The microcontroller has to produce a short +5V (or +3.3V) output pulse, at least 2us in width, then change it's I/O pin from output mode to input mode and wait for the leading edge of a pulse (0V to +5V) to begin (about 750us). Once it sees that leading edge, it has to time the width of the pulse (115us to 18.5ms). The sample code in the PING))) documentation gives the conversion factors from microseconds to distance in inches or cm. Again, the details of how to do the multiplication and retain as much precision as possible will vary from microcontroller to microcontroller and programming language to programming language.
PULSOUT <pin> , <duration>
This sets the specified I/O pin to output mode and toggles it (from whatever state it was in when it was last an output), waits the specified time, then toggles the output pin again. This produces an output pulse of the specified width. The units for the pulse width vary from Stamp model to Stamp model. For the BS2, it's 10us.
PULSIN <pin> , <state> , <variable>
This sets the specified I/O pin to input mode and waits for the pin to go from the opposite of the specified state (1 or 0) to the specified state (0 or 1). It times the width of the pulse and stores the result in the variable. The units vary from Stamp model to Stamp model and is 10us for the BS2. The maximum time it will wait is 655ms for the BS2.
Post Edited (Mike Green) : 11/16/2008 6:33:03 PM GMT
This sensor question is being moved to the Sandbox forum. Sorry for any inconvenience this has cause. The sensors forum is being removed. Please see announcements for further details. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering