### Author Topic: Good ways to measure distance(2"-24")?  (Read 4332 times)

0 Members and 1 Guest are viewing this topic.

#### zachstevedave

• Beginner
• Posts: 1
##### Good ways to measure distance(2"-24")?
« on: January 03, 2007, 03:39:52 PM »
I am in the process of building a table that changes height by about 20 inches.  I am going to use an air cylinder to lift it up to its new height, but I can't find a good sensor for measuring height.  I need a really small sensor that can accurately measure height between 2" and 24".
I thought about using the sensor from either an optical mouse or the old ones with the ball, but if I do either of the mouse options how can I have it remember it's position so It doesn't have to go to its lowest point and then its highest point?
The other thought was that little sharp IR sensor, but is that accurate enough over the 2"-24" range?
My last thought was a small ultrasonic sensor, but I haven't found any small ones that are accurate down to 2"?
The sensor needs to be small so I can hide it inside of the table leg either hugging the air cylinders shaft or right next to it.
Any Ideas?

#### Militoy

• Expert Roboticist
• Full Member
• Posts: 111
##### Re: Good ways to measure distance(2"-24")?
« Reply #1 on: January 03, 2007, 06:09:07 PM »
Do you need to measure actual distance to another object, or just how far your cylinders extend? If you just need a measure of extension, you could use a resistive linear encoder in parallel with each cylinder. A reference voltage fed into the encoder will be fed back as a voltage analog of the cylinder extension, and that can easily be converted using an A/D converter to a digital value corresponding to table height.

#### dunk

• Expert Roboticist
• Supreme Robot
• Posts: 1,086
##### Re: Good ways to measure distance(2"-24")?
« Reply #2 on: January 03, 2007, 06:21:13 PM »
hey zachstevedave,
you could mount an ultrasound transmitter on the table and a receiver on the base and compare the difference in time between a sound pulse and an electric one. you might have problems with the sound passing through the table as well as through the air but it sounds feasible.

there's definitely a sharp IR sensor that works at this sort of range too. it would be easier to implement than ultrasound i think.

so it's essentially the same problem as a printer carrage except you don't want it to go to it's home position when you power on right?
a lot of printers use a linear encoder. basically a series of black marks on a white background. the printer counts how many marks it has gone past to determine it's position.
this wouldn't work for you without a little modification as you want to know where you are at power up without going to the start (or bottom) position.

one method of making this work would be to use a microcontroller with some eprom memory so it remembers it's position from last time.
i'm presuming you are using some sort of microcontroller to track the tables position?

a simpler method would be to use multiple linear encoders.
the first would be divided into 2 sections, half light and half dark.
the next would be divided into 4 sections, 2 light, 2 dark.
etc.
you would need 5 of these strips to get accuracy of 1".
with 8 you would get accuracy of 0.1"
if you made the linear encoders out of a transparent material and just mask out the dark sections you would be able to use small U shaped photoelectric sensors like these: http://pewa.panasonic.com/acsd/sunx/products/pm.php one for each encoder to read the position.
i think you could build something less than 2" wide and the same length as your air cylinder that would give you reliable results.
that's how i'd do it anyway.

let us know how you get on!

dunk.

• Supreme Robot
• Posts: 11,632
##### Re: Good ways to measure distance(2"-24")?
« Reply #3 on: January 03, 2007, 07:01:41 PM »
before i go into the other stuff . . . does it just need to go to a height of 20", or do you need to also control any height in between too? because if you just need it to go to a maximum height, using a limit switch, microswitch, or some other switch that turns off the actuators at a set extension would be easiest.

otherwise . . .

what would you consider acceptable error? if it is off by .4 inches, is that ok? or maybe .04 inches? there will always be some error, and higher acceptable error is easier and cheaper to do.

the sharp IR would be reasonably accurate within a half inch - depends on which type you get.
http://www.societyofrobots.com/sensors_sharpirrange.shtml

for highest accuracy, a linear encoder would be best. your accuracy is the distance between each slot.
an example is the 3rd pic at the top right of this page:
http://www.societyofrobots.com/sensors_encoder.shtml
the U shaped sensor that dunk metioned is also often called a slot encoder sensor, or slot IR sensor, etc.

now to keep the table level . . .
for a 4 leg table, you will need one encoder strip per leg. if you use a sharp IR, you will need 3 to triangulate the height. if all sensors read the same value, then the table is level.

as for sonar, you have the issue of a low sample rate, and interference from things like the table legs. you will need 3 sonar, meaning only one can be used at a time, further hurting sample rate. probably the most accurate, tho.

in terms of what is easiest, i would say the sharp IR. you should buy one for like ~\$15 and see if it is accurate enough for you.
http://www.acroname.com/robotics/parts/c_Sensors.html

#### JesseWelling

• Expert Roboticist
• Supreme Robot
• Posts: 707
• Only You Can Build A Robot!
##### Re: Good ways to measure distance(2"-24")?
« Reply #4 on: January 04, 2007, 01:54:35 AM »
Sonar isn't to much slower than the sharp IR.
The Sharps I have update every 32miliseconds.
The Max EZ-1 Sonar updates every 50 miliseconds but is only acturate to from 6 to 255 inches.
But the Max EZ-1 is tricky to use (if you want serial)
so I'd go with this one for sonar (it's even reasonalby easy to do 3 sonars at one time)
http://www.robot-electronics.co.uk/htm/srf02tech.htm

#### Militoy

• Expert Roboticist
• Full Member
• Posts: 111
##### Re: Good ways to measure distance(2"-24")?
« Reply #5 on: January 04, 2007, 02:07:07 PM »
Quote
for highest accuracy, a linear encoder would be best. your accuracy is the distance between each slot.

The types with slots are known as Incremental Linear Encoders. Actually, the type I use that I was referring to have infinite resolution - they're Linear Potentiometer Sensors - kind of like a potentiometer built right into a skinny shock absorber. They're used on race cars, and in heavy machinery, etc. for hydraulic and pneumatic actuator feedback. There are even some types that can be built right into the actuator itself.

• Supreme Robot
• Posts: 11,632
##### Re: Good ways to measure distance(2"-24")?
« Reply #6 on: January 04, 2007, 02:38:17 PM »
Quote
the type I use that I was referring to have infinite resolution - they're Linear Potentiometer Sensors
ok even better. i never had a use for these though cause I always required a infinite number of rotations/travel. i was blind!

zachstevedave, what is your total required travel distance of the table? not sure how long the linear pots in the market can get . . .

#### Militoy

• Expert Roboticist
• Full Member
• Posts: 111
##### Re: Good ways to measure distance(2"-24")?
« Reply #7 on: January 04, 2007, 06:19:54 PM »
Quote
not sure how long the linear pots in the market can get . . .

Several companies make them up to at least a meter long, and they probably go longer. The ones I use average 1-2 feet travel, and the really rugged ones aren't exactly cheap. The super-long ones might be kind of pricey. The advantage of the continuously-variable pot shows up when it's used in a feedback system, where the position is constantly being corrected. In reality, even though the analog voltage read off the encoder is infinitely variable, the feedback isn't - as it depends on your A/D converter resolution. An 8-bit converter will give you 255 steps of resolution, no matter what the length of the encoder. To get better accuracy, a converter with better resolution (like 10 or 12 bits) can be used.

#### HDL_CinC_Dragon

• Supreme Robot
• Posts: 1,261
##### Re: Good ways to measure distance(2"-24")?
« Reply #8 on: November 16, 2007, 11:34:36 PM »
use a 10k ohm radial potentiometer, stick a rack on the bottom surface of the table-top, sit a pinion gear on the pots little knobby thing, gear it so that the total travel distance on the pot is a maximum of 25"(for equipment safety's sake) or so. And there you go. All you gotta do is send that analog signal to the MCU and your golden...
United States Marine Corps
Infantry
Returns to society: 2014JAN11