Gear Ratios Please Help! - Page 1
Forum section: electronics / projects

author: Brendle12321
author_rank: Newbie
timestamp: June 26, 2015, 03:31:22 pm
content: Howdy,First time poster here.I am working on a stepper motor / rotary encoder setup.These are the two devices I have already purchased:Stepper motor:http://www.digikey.ca/product-detail/en/0/1528-1062-NDRotary Encoder:http://www.digikey.ca/product-detail/en/0/EAW0J-B24-BE0128L-NDBecause I'm a fool (obviously) who didn't consider gear ratios before I ordered these products, I find myself in a bit of a pickle.I want to gear these two devices together so that one full rotation of the stepper motor can be encoded as one full rotation of the rotary encoder. Specifically, I want to make sure that the absolute positioning of the stepper motor is held by the rotary encoder without any sort of non-volatile memory in my microcontroller. (so when I power on, based on the position of the rotary encoder, I want to be able to step the motor back to it's starting position using only the binary readout of the rotary encoder).This obviously poses a problem, because these two devices need a funny gear ratio.I think I've figured it out but I was hoping that I could have some confirmation before I go ordering expensive gears.Here is what I have so far:Stepper Motor: 200 steps/revolutionRotary Encoder: 128 counts(let's call them "steps")/ revolutionIf I put a gear with 64 teeth on the stepper motor, and 100 teeth on the rotary encoder I think this solves it.Math:Stepper motor: (200 steps/revolution)*64 teeth = 12,800 teeth*steps/revolutionEncoder: (128 steps/revolution)*100 teeth= 12,800 teeth*steps/revolutionObviously I'm no gear technician, but does this math work out, or am I about to order 50$ worth of useless gears?Thanks very much for your help!-Brendle

author: mikerj
author_rank: Super Contributor
timestamp: June 26, 2015, 04:17:59 pm
content: I may be misunderstanding your requirements, but there is no amount of gearing that will give you 200 discrete codes out of a 128 position encoder.Gearing up the encoder by a factor of 200/128 will give the same angular resolution as the stepper, but the problem is that the encoder will have spat out all of it's 128 codes when the stepper has turned only 360*(128/200) = 230.4 degrees. Past that the codes will be repeated, so you no longer have an absolute position sensor unless you add another sensor to the system to effectively add another bit to the encoder.

author: Brendle12321
author_rank: Newbie
timestamp: June 26, 2015, 04:22:15 pm
content: Hey, thank you for your reply.I don't necessarily need 200 codes out of my 128 code rotary encoder. I just need the gear ratio between these two devices such that when one makes a complete revolution, the other also makes a complete revolution. At least that way I can step the motor back to the 0 position with confidence.

author: albert22
author_rank: Regular Contributor
timestamp: June 26, 2015, 04:57:34 pm
content: Quote from: Brendle12321 on June 26, 2015, 04:22:15 pmYou pointed yourself to the solution. A 1:1 is needed. You will get the absolute position of the stepper but your readout is not going to be 1/200 it will be 1/128 instead. If you cannot afford to loose resolution I think that you will need to get another encoder N x 200 codes per rev.

author: IanB
author_rank: Super Contributor
timestamp: June 26, 2015, 05:07:49 pm
content: Confirmed. 1:1 gearing is what you need. If you set up the system so that "zero" on the rotary encoder corresponds to "zero" on the stepper motor, then whenever you want to return to zero you just step the motor until the rotary encoder reads zero again.As long as they start out at zero-zero and there is no slip in the system, then they will always return to zero-zero by stepping the motor enough times. The algorithm is "step motor until rotary encoder reads zero".

author: robrenz
author_rank: Super Contributor
timestamp: June 26, 2015, 05:49:40 pm
content: That encoder is mechanical and will not survive long connected to a stepper motor. And it is not meant to restrain the side loading that gearing would impose on it. Quit while you are ahead and get a proper encoder.

author: Brendle12321
author_rank: Newbie
timestamp: June 26, 2015, 05:53:34 pm
content: Hey everybody, thanks for the replies!Can anyone confirm my math for me that the gear ratio I calculated will provide a 1:1 turn ratio between the two devices?Also I appreciate the advice that the device is mechanical and won't last long, can someone point me to a "proper" encoder then please?Thanks,Brendle

author: georges80
author_rank: Frequent Contributor
timestamp: June 26, 2015, 06:08:22 pm
content: Quote from: Brendle12321 on June 26, 2015, 05:53:34 pm1:1 ratio implies 1:1 gearing.How about you actually explained EXACTLY what you are trying to achieve and what your 'system' is... Then more useful responses might be possible versus firing the shotgun randomly at an undefined target or targets.cheers,george.

author: Brendle12321
author_rank: Newbie
timestamp: June 26, 2015, 06:34:57 pm
content: Howdy,What I am trying to achieve is to have some way of telling where my stepper motor is after I power my circuit off without having some sort of non volatile memory.I figured that having an absolute rotary encoder attached to my stepper motor would allow me to at least step my motor back to the 0 position and go from there.My issue is that the stepper motor and the rotary encoder that I bought have a different number of steps per revolution.If gear them together in a 1:1 ratio, I think that this will make one rotation of the stepper motor equal more than one rotation of the rotary encoder.As I type this, it occurs to me that if I gear them together in a 1:1 ratio, one rotation of the stepper motor equals one rotation of the rotary encoder... So I think that I don't actually have a problem after all.Damnit.

author: georges80
author_rank: Frequent Contributor
timestamp: June 26, 2015, 06:40:52 pm
content: ... and you still haven't explained your system.Anyhow, I presume your stepper never goes beyond one full revolution?If so, you still won't know where your system zero is since the encoder will wrap around on each full revolution.Limit switches are often used to get a system back to zero. But again, you still haven't actually explained what you are trying to do - as in the BIG PICTUREcheers,george.

author: IanB
author_rank: Super Contributor
timestamp: June 26, 2015, 06:44:43 pm
content: Quote from: Brendle12321 on June 26, 2015, 05:53:34 pmNo, because it won't.If you put 64 teeth on the drive gear and 100 teeth on the driven gear, then when the drive gear makes one full turn the driven gear will make 64/100 (= 16/25) of a turn. A ratio of 16:25 is not the same as a ratio of 1:1.

author: Brendle12321
author_rank: Newbie
timestamp: June 26, 2015, 07:06:01 pm
content: Hey Georges80,I guess the reason I'm having trouble explaining my system is that there is no system...I just bought these two parts to have a little fun and figure out how to interface the two things.I see your point though if the stepper motor ever goes over one full revolution, I've lost my starting location.Can you explain what a limit switch is for me please?I suppose that my other option is to implement some sort of non-volatile memory to keep track of my positioning.I appreciate the help, you have all been very patient!

author: georges80
author_rank: Frequent Contributor
timestamp: June 26, 2015, 07:12:26 pm
content: google limit switch and read & learncheers,george.

author: IanB
author_rank: Super Contributor
timestamp: June 26, 2015, 08:37:44 pm
content: Quote from: georges80 on June 26, 2015, 06:40:52 pmThis depends on whether the system has any physical limits. If the system is free running it won't matter if the motor goes beyond one full revolution, you can always get it back to zero. An example of a free running system is a clock face...it doesn't matter how many times the hands have gone round, you can always get back to 12 o'clock.

author: georges80
author_rank: Frequent Contributor
timestamp: June 26, 2015, 08:44:48 pm
content: Yes, which is why I originally asked WHAT the OP's system actually was. Which finally turns out to be nothing other than a stepper and an encoder sitting on a bench...So, limit switches, rotary encoders, steppers, pixie dust etc don't seem to matter much in this caseThe OP is just experimenting and learning without an clear application at this stage.cheers,george.

author: dadler
author_rank: Unknown
timestamp: June 26, 2015, 08:53:33 pm
content: Or...http://www.ebay.com/itm/Rotary-optical-encoder-/261939109999?pt=LH_DefaultDomain_0&hash=item3cfcc9a06f

author: lincoln
author_rank: Regular Contributor
timestamp: June 26, 2015, 09:12:51 pm
content: Quote from: Brendle12321 on June 26, 2015, 07:06:01 pmSteppers are usually driven by something, a micro controller, set of counters ect. Why steppers have descret steps (Duh!) so that the provided the motor doesn't stall, the application knows the position by integrating the steps given to the motor. Most stepper driven equipment is run in an "open loop" fashion. the controller doesn't know if the commands given to the motor actually moved anything. (unlike a ac or DC servo that has an encoder to tell the controller actual distance or speed)you say: Well thats useless how do you know where you start from? what if you hit some thing?Ok, well usually a stepper is used to position something. Limit switches are placed at the end of travel in an arrangement that they will open just before the mechanical system begin driven will "crash" or come to a mechanical hard stop. For small motors this may not be so bad, for big systems this can be disastrous.A " home " switch is a switch that is triggered when the mechanical system crosses a single point. That fires an interrupt and sets the controller position to 0. On large CNC machines (think spindle motors rated in 10s and 100's of horse power) it is a common power down procedure to "park" the machine. that is send all axis to the home position. On power up, a cold start procedure is to home the axis, basically the controller will move the axis slowly back and for to find the home switch then trip the switch in one direction and reset the axis counter.A limit switch can also double as home switch, depending on the mechanics of what you are moving.It is up to the engineer to use a motor and drive that is suitably oversize so that the motor will not stall under load. The trade off is that the controls avoid potential problems with closed loop setup.Now back to your project. The encoders you have are mechanical and will eventually wear out, and have significant contact bounce, not the best for positioning but for some thing to screw around with, have fun.

author: John Coloccia
author_rank: Super Contributor
timestamp: June 26, 2015, 10:08:28 pm
content: I've done an awful lot of robotics and motion control. I can't think of even one system where I've ever used an absolute encoder. I'm sure I must have at some point, but it's not coming to mind. You invariably home the system before use. Trying to remember where you were is more trouble than it's worth in the vast majority of cases. What if the system moves when it's powered off? With servos, that's almost a certainty, and with steppers it's still probable.If you want to play, you should completely forget about encoders for the time being, and just get the stepper moving. That will give you enough trouble to get it moving with proper motion profiles. It's not trivial, though it's not all that difficult either if you do your homework.Then start playing with some limit switches and home routines. For example, with capacitive limit switches, and the home routine I wrote, I was able to home my CNC machine to better than .001" repeatability. No encoders anywhere...just a simple capacitive switch and an intelligent home routine. LOTS of systems run with steppers and no encoders.THEN, if you want to add encoders, understand that their primary purpose is not to tell you where you are, though you want to know that too. You're looking for rate data so you can close the loop on your motion profile. This is especially important for servos, but they're also sometimes used on steppers so that intelligent controllers can make adjustments, or at a minimum halt motion if you start loosing steps. This is where you start getting into big boy territory because it is NOT trivial at all to close the loop on this sort of motion. Most hobbyist/small CNC guys stick with open loop steppers to avoid all of the headaches involved with tuning closed loop systems. If you don't need to do it, most opt to simply avoid it for simplicity's sake. But this is also where you can really start extracting amazing performance from your system. Good servos, good encoders, good controllers and good software can team up to make a very accurate and precise system that runs very fast and smooth as glass.

author: B.B.Bubby
author_rank: Regular Contributor
timestamp: June 26, 2015, 10:27:14 pm
content: I don't understand where the problem is. Just mount the encoder after the gearbox. why does the ratio even matter??

author: CatalinaWOW
author_rank: Super Contributor
timestamp: June 27, 2015, 05:34:01 pm
content: Sometimes conceptual points are hard to get. Just to make what others are saying explicit, you need a 1:1 gear ratio, which means the same number of teeth on the encoder gear and the stepper motor gear. The encoder will make one turn when the stepper makes one turn. This is totally independent of the step size of the motor and the resolution of the encoder.While there are many reasons why you might choose not to use an absolute encoder to accomplish your goal of recovery of the "zero" position there is nothing conceptually wrong with it. Since your encoder has a different number of steps per turn than the motor you will have some fun in implementing it. If you read the encoder and use that to compute the number of motor steps to zero you might end up a step or two away. Why? Because there are multiple places around the revolution where full motor step won't cause an increment of the encoder. The last motor step just barely triggered the next encoder step, and the current step doesn't quite get to the next one. These issues are compounded by issues like gear backlash and so on. Cost and size are two of the common reasons people opt out of the encoder solution in many cases.A simple method of recovering zero that is related to limit switches is to use a simple optical interrupter at your zero point. Think of an led shining on a disk on your motor that has hole in it at the zero position. A detector on the other side of the disk triggers when the led shines through the hole. These interrupters are available as a package containing the led and detector with a gap between them. They are cheap and easy to interface.

author: Brendle12321
author_rank: Newbie
timestamp: June 27, 2015, 06:58:27 pm
content: Hey everyone,I want to say thank you all very much, I'm blown away by the support and the knowledge you all have provided for me.I think that I have alot to think about, and probably alot more parts to order to tinker around with!I feel like such a tool for being confused about this whole gear ratio thing in the first place, and now I realize that although I could theoretically hook the rotary encoder and the stepper motor together, it really isn't the right way to go. Thank you all for helping me save like 60$ on gears and stuff.I'm going to look into limit switches and optical interrupters I think, and then work on having my motor zero itself out on power up.Thanks again for the support, I know where to come next time I need help with this stuff!

author: John Coloccia
author_rank: Super Contributor
timestamp: June 27, 2015, 07:48:23 pm
content: One fairly traditional way of "zeroing" a stepper, even though you may end up off by a small number of steps, is to simply drive the stepper into a hardstop. There will be some uncertainty on exactly what position you're in, but if you can be off by a few steps, that's pretty effective. The reason you end up off is that you stall the stepper, but you have know way of knowing which phase you're on when it stalls. This works extremely well when you don't need absolute position but merely need to start at some reasonable location. An example might be if you need to execute a search algorithm where your actual position isn't critical...you're closing the loop on some external stimuli.Real encoders designed for motion control often have an "index" pulse (sometimes called a synch pulse). It goes off once per revolution. The idea is to remove any uncertainty/hysteresis in detecting the limit switch. You drive until you hit a limit switch. Then you slowly move forward until you hit the index pulse. That makes for a very precise home position...as accurate as the encoder itself.Lots of ideas to fiddle with just to turn a stupid motor!

author: CatalinaWOW
author_rank: Super Contributor
timestamp: June 27, 2015, 11:02:44 pm
content: One reason so many people were asking what you are doing is that there are literally thousands of ways to put a system together, and the "best" way to do it will depend on the final result desired.For example, a stepper motor is convenient to drive with a digital source, and has the advantage of a known number of steps per revolution. This lets you do many positioning tasks merely by sending an appropriate number of steps to the motor. But even with microstepping you are limited to about 1024 steps per revolution (about since given a strong enough desire almost anything is possible). But with an appropriate belt or gear drive this can become thousands of steps per revolution at the output shaft, with substantial increase in torque. Or with a brushless motor, gears and belts the resolution at the output can become nearly infinite.If you really want to do a lot of electro-mechanical engineering it will pay you to learn as many options as you can, their benefits and drawbacks. The bigger your toolbox the better your solutions to a given problem will be. There are always trades between speed, cost, power, volume, precision, reliability and other factors.