Repost i know but i'm desperate I'm looking for a distance sensor sub $100 that will range out more than 20 feet. The situation is there is a fixed sensor with a crate moving towards it. the sensor reporting the distance of the crate up to 20 feet away where it will register either no crate or further than 20 feet. ultrasonic seems limited with being able to avoid objects around the "crate" ideally the sensor range would be limited to a 4' diameter circle extending outward from the sensor. any help would be great. Thanks
Can the sensor be elsewhere? If so, you can use a laser pointer, a couple of front reflective mirrors, and a photodiode (plus opamp to amplify it).
This arrangement won't work for circles, but it'll work for a line.
Get a 5V power supply, and buy some laser pointer cartridges off of ebay. You can get front side mirrors from allelectronics.com. Arrange the mirrors so that the outgoing laser pointer points at one mirror, which reflects the light to the other mirror across the line, and then back to your power supply.
If you are having a hard time making the laser pointer hit the photodiode, you can use a flashlight mirror to focus the beam onto it by setting it up like a reflecting telescope, i.e., the sensor faces away from the incoming beam, and the flashlight mirror faces the beam, and focuses it onto the sensor.
Use a standard photodiode or phototransistor sensor arrangement (search the web) so that you get a clean signal when something blocks the laser path. This will give you a good indication of something crossing the line at a particular distance.
Another way to do this would be to use a video camera which is sensitive to IR, and an IR laser. The WII uses this arrangement, in which there is an IR camera and a set of IR diodes, allowing it to orient itself. You would need to be good at software to do something like this, but it would be possible to either split a beam, or spin it, directing it towards the floor, and then analyze the path (on the floor) of the beam with the camera and software on a PC. If the path deviates from the normal line or arc, you have detected an object. There are cheapo IR cameras available, and continuous 5mW IR lasers can be had for $30 or so. I've heard you can split a laser into a line using a polished glass semi-circular rod. You could also use a motor to spin the laser, but it might be hard to align properly. With this solution, the software is the problem, of course. You would need to write software to detect the object using the video input.
My final suggestion is to get some hefty ultrasonic transducers, and chirp at it. Use a PLL chip to detect the reflection, and time the reflections using software. The temperature will affect this reading, as will possible reflections off of other nearby objects, ambient sounds, etc.
The easiest one is the first one, but it assumes some things about the space that you might not want to assume.