| Detecting Wheel Motion |
Last Modified: 2006-11-10
This page describes how to use a Sharp GP2D12 infrared ranger to detect velocity on a robot that uses an omni-directional wheel as a caster. Such a caster system is described in the omni-wheel caster idea page.
The sensor stares at the fixed caster wheel. The surface of the omni-directional wheel is quite bumpy. The Sharp GP2D12 is sensitive enough to detect these bumps so the output of the ranger will vary as the wheel rolls. By checking the sensor at regular intervals and doing some additional processing, a robot can tell if it is rolling. If the robot detects that it has no velocity (it is not rolling) when it thinks it should be rolling, it can be reasonably sure that it hit an obstacle. Then the robot can perform an evasive maneuver.
At first glance, using a Sharp GP2D12 for this purpose may seem like overkill. But there are some advantages to this approach. It requires no modification to the wheel. Using a photoreflector to detect wheel motion may require the addition of an encoder pattern to the wheel. The GP2D12 sensor may be placed 3/4 inch to 1-1/2 inches from the wheel and has very convenient mounting holes. This makes it easier to retrofit a GP2D12 to an existing robot with an omni-directional wheel caster. A photoreflector must be placed very close to the wheel to get the best results. A photoreflector circuit also requires some additional electronics and assembly. The GP2D12 is ready to go.
In typical operation, the GP2D12 measures objects 4 inches to 32 inches away. Objects closer than 4 inches will make the sensor output "flip". Normally, this would be bad since a robot may think an object 3 inches away is actually 8 inches away. This makes for a very confused robot. For this application, the "flip" is actually quite useful. The GP2D12 has very good resolution in the 1-4 inch range. This makes it easy to detect the bumps on the wheel. If possible, try to place the sensor so it gets the greatest possible output variation as the wheel turns. You may need to move the sensor in-and-out and side-to-side to get the best results. The following pictures show the typical caster and wheel arrangement.
Build caster wheel and mount.
Diagram of recommended placement for sensor and caster wheel.
Filtering Sensor Data
With the sensor in place, the next step is processing the output to detect velocity. The basic approach is to run the analog output through a Schmitt Trigger in order to digitize it and then count pulses. A regular stream of pulses means the robot is rolling. No pulses mean the robot is stopped. A Schmitt Trigger is a special type of comparator circuit that exhibits "hysteresis", or some memory of what has occurred in the past. When an input exceeds a maximum threshold, the output goes high. The output does not go low again until the input drops below a minimum threshold. When the input again exceeds the maximum, the output goes high once more, and so on. This prevents a rapid series of pulses when a noisy signal fluctuates about a threshold. A chart with typical input and output signals appears below.
Input and Output of sensor data with a Schmitt Trigger.
It is possible to build a velocity detection circuit out of chips and other components. Schmitt Trigger chips, such as the 74HC14 are common and inexpensive. Radio Shack sells a book that tells how to configure a 555 timer as a missing-pulse detector. However, additional details of such a project are beyond the scope of this document. It is also possible to implement the whole thing in software with a processor that has a built-in ADC. The following program shows how to do this with an OOpic microcontroller.
The program sits in an infinite loop. The counter object wClock increments the counter variable vt at a rate of 60Hz. Each call to the vcheck routine checks the wheel for motion. The two comparisons combined with a flag bit simulate the Schmitt Trigger behavior described above. If the wheel is moving, the vcheck routine will continually reset the counter variable vt . If the wheel is not moving, the counter variable will increment and eventually exceed a threshold. Once the count exceeds the threshold, the robot can assume that it is not moving. If the vlight output is connected to an LED, it will stay lit while the wheel is turning and blink while the wheel is stopped. The proper constants and thresholds depend on the particular robot and wheel-sensor configuration.
This code uses BASIC syntax. It runs with version 3.0.4 of the OOPic compiler and version A.1.7 of the OOPic chip.
' filename: omni_vel.osc ' Velocity Detection Code ' const velA=73 ' velocity detection constants const velB=66 const velthr=30 dim vlight as new oDio1 dim vt as new oWord ' missing-pulse timer variables dim wclock as new oCounter dim gp12v as new oA2D ' velocity sensor dim vflag as new oBit ' velocity flag sub main() call init do call vcheck vlight=1 loop end sub sub init() vlight.ioline=17 vlight.direction=cvOutput gp12v.ioline=3 gp12v.operate=cvtrue vflag=0 wclock.mode=cvCount wclock.direction=cvPositive wclock.tick=0 wclock.clockin1.link(oopic.hz60) wclock.output.link(vt.value) wclock.operate=cvTrue vt=0 end sub sub vcheck() ' Software Schmitt Trigger ' min and max comparators with bit flag if ((gp12v > velA) and (vflag=0)) then vflag=1 vt=0 end if if ((gp12v < velB) and (vflag=1)) then vflag=0 vt=0 end if ' large vt means no velocity achieved ' so take appropriate action ' and reset missing-pulse timer if (vt>velthr) then vlight=0 oopic.delay=50 vt=0 end if end sub
| voice: 720-564-0373, email: email@example.com, address: 4822 Sterling Dr., Boulder CO, 80301-2350, privacy |
© Copyright 1994-2012 Acroname, Inc., Boulder, Colorado. All rights reserved.