View Full Version : DIY encoder for digitizing
duluthboat 09-14-2004, 07:28 PM Question, how many CPR are on the smallest diameter of an everyday CD?
Question, can this cheap technology be used to build a high resolution encoder?
Gary
ToyMaker 09-14-2004, 08:04 PM Interesting idea.
Raw data comes off a CD at something like 44kHz. The drive motor is in a servo loop such that the disc passes under the head at a constant rate, a process called constant linear velocity (CLV). When the read head is near the inside edge the disc spins fast (>300 rpm?), and when near the outside edge it is slow (~100 rpm?). Because there is only one track on a CD (similar to a phonograph record) there would have to be a way to step the head out each revolution.
If you could record a (very) constant tone so that there were a known number of wavelengths per revolution, couple the shaft to your cnc machine, and count wavelengths, the whole thing just might work.
I think the index step each revolution might be the big gotcha.
robotic regards,
Tom
= = = = =
"Some politicians like to move their lips, and apparently, some lips like to move politicians."
- - Shan Jones
pminmo 09-14-2004, 09:16 PM How high of resolution do you want? Something I've wondered about is using the gear sets out of RC servos to increase resolution. I'm not sure what the ratio is but it could easily be greater than 32:1. It would be fairly easy to make a disk with say 32 quadrature cycles on it, at a ratio of 32:1 that would be 1/1024 or .0009. I'm sure there is some downfall to this idea, just don't know what it is. Nylon gearsets are available for less than $4.
Phil
duluthboat 09-14-2004, 10:47 PM I would like 100,000 pluses per revolution, 200,000 would be better. That makes the standard optical disk unrealistically large; under 2” would be OK for a diameter. :eek:
I looked at using gears and at first they look like a good option but even the ones that say they are zero backlash, have only 1.5 arc min. accuracy.
There are very small high resolution encoders, but I can not afford them. With all the inventive people on this forum we should be able figure something out.
Gary
Graham S 09-15-2004, 05:37 AM The fact that the dots on the CD form a spiral means it is a no-no as far as I can see. Although CD players are cheap they are modern marvels of control technology in the way they track etc.
Harmonic drives are one way to get true zero backlash gearing but looking at Faro patents it does seem that they use just small and expensive encoders.
One thought I had was to run a cord from the base of one arm portion to the tip of the next and wrap this multiple times around the shaft of an encoder that was springloaded, the extension and retraction of the cord would create multiple revolutions of the encoder, however this would be messy and possibly difficult to calibrate.
Graham
ToyMaker 09-15-2004, 07:50 AM The best trade-off for resolution v. price I can think of is an optical mouse. At <USD10 and 400 ticks/inch it's not too shabby (are there higher res OM out there?).
A 3.1416 inch diameter disk produces 4,000 counts/revolution at the perimeter. That's 11.11 counts/degree or about 5.4 arc-min/count (if my arithmetic is any good).
Even though that's only 1/25 of the goal of 100k counts/rev the price is attractive.
robotic regards,
Tom
= = = = =
"We have civil engineers; too bad we can't engineer civility."
- - Dennis R. Ridley
Cliff_J 09-15-2004, 08:37 AM A quick idea - has anyone found out more of the method of detection used by the higher resolution encoders? They don't use a simple slot system but rather a special pattern and multiple detectors to sense each movement. Is there a term for this science as some sort of geometric or physics to research?
How about some sort of 2D barcode scanner that could read a disc printed with a special pattern? If we could truly print at 1200dpi or 2400dpi on a laser printer on clear stock this sounds like a true budget dream, one person could print multiple wheels on a sheet for a few bucks and easy to mail. When I subscribed to Forbes magazine they sent out a barcode scanner, some sort of mouse device. You were supposed to be able to scan a barcode in ads and get web info from the advertiser. It was a flop and the units were sold as surplus later on (from what I can tell) but some high schools and colleges used the things to teach kids about bar codes and it was opensource. Another $10 idea but this one might be feasible to get real precise....
Cliff
Al_The_Man 09-15-2004, 10:09 AM I am not sure if you mean incremental encoders above around 100p/turn, below around 100p/turn the light/photo source can differentiate between the individual slots, above that a light/photo source does not work due to the very narrow slot, high resolution encoders still use a slot grating chrome plated or photo etched into the glass This applies to both rotary and linear types.
Above a certain resolution a phenomena known as the moire effect is used. ( I dont profess to know the physics behind the moire effect).
But you may have observed this when light shines through a fine mesh or sheer drapes etc, you can observe a swirling pattern effect ( no I wasn't smoking anything)!.
In a fine graticule encoder e.g. 1000 p/rev, a small piece of grating material is carried by the moving photo head assy and is slightly skewed in relation to the main grating. The effect is, that due to the moire effect, the photo reciever now *sees* an alternating light-dark band, the width of each band is around half the verticle height of the grating, the alternating bands move like a shutter, perpendicular to the direction of motion, i.e. on a linear scale, if the head is moving in a horizontal direction the 'shutter' appear to be rotating up or down,depending on the direction of movement.
This is obviously much wider than the space between the grating, the band will change from light to dark for one increment of the scale.
I hope I have put this in some meaningfull way, but it is one of those
things that is easier with pictures.
Al
KissSys 09-15-2004, 01:56 PM Well I've been reading this thread from day one and have enjoyed it greatly, I guess its time I put in my 2 bits worth to keep this going.
If some computer guru could burn the same 2bit grey code onto a pocket CD we could mount two laser diodes to read the bits just as in a typical optical encoder. The CD rom itself would not be used and the disc would move just like an optical encoder but hopefully with more steps.
Even better would be to burn a 16 bit grey code radially and have an absolute encoder.
Steve
ESjaavik 09-15-2004, 03:15 PM Al, I think the moiré effect is also used by having a graticule with a slightly different spacing than the disk. If you have 2 disks, one with 1000 lines/rev, and one with 1001 lines. When viewing through both one side will be completely dark 0% light, the other side 50% dark. In between you will have 0-50% dark. Here is an example of a linear scale:
http://www.sjaavik.com/CNC/images/moire_effect.gif
(Why doesn't IMG tags work here?)
The upper row of lines are spaced 4.08mm, the lower one 4.00mm and the lines are 2mm wide. There are the same number of lines in each row. Now if you scan over the lines left to right, within 25 lines there is complete darkness and going further 25 lines you're back to 50% darkness. (There is no brighter than 50% because the lines and the spacings are equal.
Do you know why people wearing striped suits or ties make the TV production crew cry? It's because they know the moiré effect will make it look awful with lots of strange color artifacts.
ESjaavik 09-15-2004, 03:28 PM You want high resolution? Well then take the signal from the phototransistor in the encoder and don't shape it to a logic Hi/Low, but buffer it and run it to an analog input of a microcontroller (or PC). Now you will be able to distinguish not only bright (line 0-12 in my example) or dark (line 13-25). You can also find how dark it is. The position resolution could in theory approach number-of-lines times bits-of-DAC-resolution.
So with an AVR ATtiny15 chip costing $3-4 you multiply the encoder resolution with 1024. This is assuming a lot of things not being there in real life, but let's say you can multiply it by 200, even that is not bad. You would probably have to make a lookup table as the output from the phototransistor during constant speed motion will be more like a sinewave than a triangular wave.
Al_The_Man 09-15-2004, 03:47 PM Al, I think the moiré effect is also used by having a graticule with a slightly different spacing than the disk. If you have 2 disks, one with 1000 lines/rev, and one with 1001 lines. When viewing through both one side will be completely dark 0% light, the other side 50% dark. In between you will have 0-50% dark.
Evidentally it will also work with gratings of the same spacing as shown in this technical paper, where you can copy two exact gratings for demonstration purposes. http://claymore.engineer.gvsu.edu/~jackh/books/plcs/chapters/cont_sens.pdf
Also the shutter effect can be seen if a 'dead' encoder with the disc exposed but the head still present is held up to reflective light and the shaft is turned.
I still remember working on old linear scales by Ferranti that had a 15watt incandescant lamp in them and every time you changed a lamp the sine/cosine relationship between the heads had to be adjusted using a 'scope.
Al
duluthboat 09-15-2004, 05:30 PM 1” diameter disks are available with 1250 counts per rev for US $14. Even at times 100, this is getting interesting.
duluthboat 09-15-2004, 05:35 PM http://www.usdigital.com/products/disk/
Link to disks.
ESjaavik 09-15-2004, 05:37 PM Here's how to make really cheap encoder wheels and graticules:
You need a "master" encoder wheel to do this.
Go find your old camera, the one that used a film and not a memory card. If you're not as old as me or Al (The referrence to Ferranti tells me you're not just out of school), you should ask your father to borrow his. The camera must be able to take close up shots (macro), and should be a TTL camera.
Go to a good photo store and ask for a fine grained (slow) black and white film. Load it into your camera. If your camera does not do macro, but have detacheable lens, ask for a set of extension rings that fits your camera to fix that.
Lay the existing encoder wheel on a piece of glass between 2 tables or chairs. Place a sheet of white paper on the floor below and illuminate that with a lamp. Take pictures of the encoder wheel with as good sharpness and little shake as you can. A camera mount is good to avoid shake. You may as well shoot the whole film while you're at it. The encoder wheel should fill the frame as much as possible.
Go back to the photo shop and ask them to develop the film, but no prints please.
Come back later and get a strip of 24 or 36 encoder wheels. All you need do is cut them out and mount on a boss. The rather "floppy" film will be straight as long as you use a boss with a diameter not too small.
Cut up some of them as graticules and mount on a metal plate between the photo transistor and LED. You kill a mouse to find both of these inside.
Graham S 09-15-2004, 07:47 PM I think the general procedure is to make a large version of the encoder and then use photgraphic techniques to make a minature version. Photographing a high resolution encoder is unlikely to get decent results purely based on the low numerical aperture of the lenses and probable aberation. It is possibly to have things like this made at reasonable cost as they do such things to make masks for photo lithography etc.
The moire effect using an angled grating is interesting but I am not sure exactly how doable it is for the amateur.
Going the analogue route brings all kinds of noise issues up and calibration problems.
Of course all of these things are possible but is anyone prepared to spend the time developing something that may be rather difficult? Given that in this case it needs to work perfectly or it is pointless.
I guess I am just thinking a backlash free 5:1 gear ratio and a 2500CPR encoder is the most likely way of making the system work if a gear mechanism that it 100.000% backlash free can be found.
Graham
KissSys 09-15-2004, 10:10 PM I came to the same conclusion, I ordered a 2500cpr encoder which I will gear with a O-ring and pulleys. The encoder as bearings and should provide no load on the gearing so it should be backlash free. I hooked a 200cpr unit I had to a LS7084 and a Pic microprosser. My tests seemed to indicate I could count the pulses and send the data to another computer without loosing pulses when in the sending mode if the encoder moved while transmitting which is guaranteed to happen. I wrote the code in CCS C and it took about 3.5 microseconds to do the addition to a 32 bit number. Probably do it in a third of that if I write my own code.
I plan on having a couple dollar pic chip at each encoder keeping track of position. I'll hook them all to a common Pic chip in the base that will request the data from each encoder, do the math required and send it to the PC.
Sounds easy but I'm not sure if the encoder hooked up to a Pic interupt will
disturb the transmission to the main PC. We'll see in week or so when I get time to hook the encoder micorprocessor to the main microprosser probably via SPI and move the encoder while requesting position and at a high rate to see if it loses position.
I'm sure this is alot of jibberish to some but from what I can tell from what I've see posted in the past there are plenty who could comment on what I'm doing and if they think it's going in the right direction.
I'd appreciate any comments. This is all just testing as I don't even now the final data format that I'll use but I'd like it to spit out Microscribe syntax.
Steve
ESjaavik 09-16-2004, 02:13 AM Steve,
If you get problems with the PIC sending to PC, there are a couple of thing you could do.
- Implement a ready signal to the encoder processors. When the base processor is in the send routine, signal busy to the encoders and let them buffer the counts until it's free to listen again. It would also make it easier when all the encoder processors wantsend at once if it give each a time slot when it is allowed to send.
- Or use a processor with UART. I don't know the PIC, but AVR have these also on low priced units.
KissSys 09-16-2004, 07:43 AM I plan on daisy chaining the micros, when one gets a pin pulled low it will puts its data on the bus, it will then tell the next one in chain to send its data until we get to the last one which will send its data plus a that's all folks. The order of the data would be known and you could keep adding encoders if you want.
I hope to make them only send data and not receive on the SPI bus so I don't have to worry about receiving screwing up the count. They will look for a bit set to get thlings going. Basically when they aren't sending they are only counting pulses and looking to see if I want data. I can bit bang the SPI code so that I can deal with small interupts that occur when the LS7084 sends a pulse. I don't want the micro to have any interupts active other than looking at the encoder.
Not sure what to do about a reset other than power on which would take care of itself. I might add another wire to do reset to zero or just hold the data request bit down for a longer time. Should only need to run 5 wires between each micro.
Steve
jfong 09-16-2004, 10:07 AM One way is to use a LS7083 chip instead. Hook it up to two pic counter input pins set up to count external pulses. Run a routine every so often to calculate the encoder position before counter overflow. No chance of missing any counts due to interrupts during serial/SPI sending of data.
There is a microchip servo app note with C code that does something similiar but uses a couple of flip flops instead of a LS7083 to do the up/down pulse generation.
The LS7083 is much nicer since it can do 4x decoding in hardware.
Jim
KissSys 09-16-2004, 10:20 AM I get 4x decoding with the LS7084 but I would have to use two interupts instead of one with the LS7083.
Steve
jfong 09-16-2004, 01:54 PM I actually meant to write that ls7083/84 is nice since it does 4x decoding. I know that both chips support it. The microchip app note was only 1x decoding.
If using the 7083 chip, you actually don't need to use any external interrupts at all and let the PIC 8 or 16bit hardware counters increment the count automatically. Just have to keep track of the counter overflow but that is easy to do.
Jim
ESjaavik 09-16-2004, 03:43 PM Why not just let the microcontroller do the counting all by itself? Are you counting so fast that a change of state interrupt cannot do it? Then 1x 2x or 4x decoding is up to the software. We're not looking at many instructions for a simple state machine.
Graham S 09-16-2004, 08:37 PM You are going off topic start a new thread
Andreas wrote code upto 8 encoders and send via the serial port if you want to try it out.
I think I have come up with a decent ZERO backlash system but I am not sure if to do a patent search before telling you lot ;)
Graham
KissSys 09-17-2004, 12:01 PM I'd like to try the code, I write code only to fill my needs I don't enjoy doing it.
File the patent quick so we can get on with this, I'm not looking to make any money just get a working device as soon a I can.
Steve
duluthboat 09-17-2004, 12:57 PM I keep looking at it from the point of the arm I’m working on. For this small arm gears or pulleys seem clunky. But if I was using 2” diameter tube on an arm that could reach of 6’, the added mechanics would not be so noticeable. With a smooth belt, (O-ring) I think the backlash would be hard to measure. For the DIY’er this would be the simplest approach. But like Graham, Steve and others I have spent a lot of time thinking about speed multipliers, with affordability a major factor.
Gary :D
Graham S 09-18-2004, 08:14 PM I was only joking about the patent, really just needed time for the diagram.
The concept is effectively a belt drive however rather than use a timing belt a plastic coated stainless steel wire is used, these are sometimes seen in printers and plotters etc. The drive does not rely on friction but rather the ends of the wire are securely attached to the large pulley. They are also attached to the smaller pulley but to allow a full rotation of the large pulley the wire is wrapped around the smaller one several times but attached only in the middle. The wire passes through two fixed guides, as the large pulley is turned it pulls wire from the small one which in turn pulls wire off the large one, the unwrapping of the wire from the small pulley makes it want to move axially so it is allowed to do so along with the support bearings and the encoder on a movable plate. This keeps the wire parallel on the large drum and prevents non linearity as would be seen without the guides and slide.
The whole thing is under tension, there should be almost no stretch from a stainless wire and there is no friction required and hence no deformation. There are also no gears to mesh and so it should be a totally backlash free system that could produce a gear ratio of 5:1 with ease. The amount of sliding motion will depend on the gear ratio, 5:1 only really needs 5 turns. The small roller can be a screw to ensure the wire does not overlap although it is not essential. If it is a screw then it can be passed through nuts for a sort of auto traverse but this is probably not such a good idea and would still require the encoder to be on a slide or the use of a preloaded spline connection.
Not ideal I realize but I think it will work.
Graham
Graham S 09-18-2004, 08:19 PM Gary,
I think when a normal belt is used (non toothed) the required tension will load the bearings enough that the belt will tend to stretch a little under the load and you loose accuracy.
Perhaps a balanced pulley system could be made that keeps radial bearing load to a minium and hence friction, despite good belt tension.
Graham
KissSys 09-18-2004, 09:44 PM Pretty slick idea, what is the minimum radius that this wire can wrap around since that will predicate the size of the big wheel.
I think I'm gonna try my timing belts I got in the junk box first. Might hook it up to a stepper motor so I can cycle it hundreds of times and see what errors prop up.
Steve
Graham S 09-19-2004, 05:56 AM The wire is very thin and flexible, I'll try a few rods out to get an idea. Kevlar is the other option or a high tech fishing brade.
You won't be able to tell much from that test, remember that we were going to use a 10000 ppr encoder anyway geared 5:1 or so, a stepper is giving you 400ppr so it is just in a different ball park, cumlative error should be very little.
Graham
p.s. Got your email, reply soon
KissSys 09-19-2004, 11:05 AM I'll cycle it many times and then manually move the wheel to an index to read it, the stepper is accurate enough to get back to a point that should place it within the window to re index it and then see if the small pulley slipped. I'd like to be able to cycle it a thousand times and then take a reading and I don't want to do that by had. I also would like to cycle it in an unbalanced way, more CW than CCW and see if it generates an error. Just back and forth might average out to zero error when its not.
I knew I would get that response after I posted it but it was too late. We aren't taking readings when the wheel is in motion so tension will be equal and should be ballanced an accurate. I think Graham might be right about the plain belt because tension greater on one side than the other may cause the belt to walk on the wheel when the tension equalizes. This would probably only happen if the arm is moved very rapidly spinning the encoder
but it could happen.
I've got timing belts on several machines that I've built and if the device is not under load the timing belt is pretty much backlash free even with
very little tension on the belt.
Steve
Graham S 09-19-2004, 11:56 AM The belt does not need to walk, there will be a certain amount of stretch before the smaller pulley begins to turn, this is the problem. There is also deformation of the pulley material in general, remember we are talking 0.0072 degrees resolution if the 50000 PPR is aimed for.
Graham
jfirey 09-20-2004, 02:54 PM If you decide to explore the cable system described earlier in this thread, I have a bunch of cable winding drums for steppers, from system like Graham shows. 1" and 2: diameter, about three inches long. I'd be happy to donate some just to hear how it works out.
Graham S 09-20-2004, 06:29 PM Do you have a picture? Sound a bit big possibly.
Graham S 09-23-2004, 01:48 PM The wire I have is 0.33mm in diameter and will comfortably wrap around the 8mm shaft of my pencil. So at least is can be quite compact.
This stuff was actually from a small chart recorder.
Graham
Graham S 09-24-2004, 05:30 PM I mentioned my idea to a good friend and definate mechanical genious John Mack and a week later he sent me back this sketch and I think he is quite correct after much brain hurting.
Basically you can make my backlash free reducer without the slide you just lay the wire on the large drum at the helix angle of the smaller one. Easy!
Actually I am not sure how to set this up in practice yet but it is much simpler and well worth a try.
Graham
Cliff_J 09-24-2004, 11:21 PM Graham, like a simple groove on the large drum to match the angle could be machined to keep the wire in perfect alignment? Or is it even simplier and the shortest distance (and automatic path of the wire) between the two drums would force the wire to follow the path automatically. Seems the latter would be true, but trying to think if a lateral tracking error on the wire could cause issues. Seems not but more eyeballs can't hurt...
Cliff
cbcnc 09-25-2004, 12:16 AM Alright, I'm finding this thread awfully interesting. I don't know if I am interested in building a digitizing arm but I do have some thoughts.
You are talking about getting the resolution down to 50000 ppr or 0.0072°/step. Then you are talking about winding cable around a pully to move the encoder.
If I assume a 1/2" dia. pully then a movement of .0000314" will be one count. (.5 * pi / 50000 = .0000314" ) Or if I assume a 1" dia pully then one count = .0000628"
That is an awful lot to ask of any material let alone vinyl coated SS cable. I think that the vinyl coating will compress and decompress many times that amount. Plain SS cable would be a little better but then you are are also talking about thermal effects on the cable too.
I like the idea of cable wrapping around a pully. I'm not sure it is the best solution though. But, if you get several wraps around it then it will form it's own natural helix. As long as the static point that holds the free cable is behind the wrap point it should just fall into place against the previous wraps.
I don't mean to rain on your parade but a mechanical solution like this needs to be in some tightly constrained conditions to get that kind of resolution.
Chris
Graham S 09-25-2004, 04:20 AM Cliff, it doesn't have to have a groove although it could, the important part is that the end point on the large pulley is positioned correctly. The whole point of laying the wire on the drum at an angle is that it automatically tracks the helix as it moves.
Chris, you are quite right this kind of accuracy is not going to be easy to get. The stainless cable is not vinyl coated but more impregnated. You can hardly tell it is there, better than the likely surface roughness of any pulley I make, but that's another story. The fact is that a precise ratio is not required just a ratio, the important thing is the lack of backlash and linear response, backlash will come from stetch in the cable (hopefully non, eek). Many of the other effects will be balanced on each side and should not cause a problem assuming a preload of tension. The balance nature of the design is probably the best thing it has going for it.
My mega clever mate also suggested the problem of dust on the roller, yep this could be getting tricky.
As I have said it isn't ideal and might not work but I don't see an alternative, a homebrew high res encoder is not going to happen because no one will sit down and do it and to be honest I don't think they would suceed if they did. (just MHO, please prove me wrong).
Graham
p.s. My intention has always been to build an arm small enough to use the 10000ppr encoders, this is for the mad Faro arm copiers ;)
lerman 12-12-2004, 09:29 AM 100,000 lines is only .2 minutes of arc (12 seconds). http://easyweb.easynet.co.uk/~chrish/worms.htm describes how to make a worm gear with a periodic error of around 5 seconds of arc, so that's in the right ballpark. If you drove the worm with a servo so as to keep a mark aligned with the arm, you should be able to use an encoder on the worm as a readout.
Ken
MaxLogan 01-28-2006, 09:45 PM Guys...
Digital Absolute 16bit......(65,536 ppr)
Tagaotse 02-20-2006, 09:25 PM How about this.
Get 8 of these tilt sensors (http://www.spectronsensors.com/datasheets/SDS-117-1104.pdf) and place them in a circle facing outward at 45 degrees to each other. Tie into them with a PIC and keep track of current angle through software(firmware?).
0.02 arc degrees = 18,000 cpr
0.005 arc degrees = 72,000 cpr
Is this possible?
|
|