Do I Need a Rotary Encoder?

This forum is dedicated to those Hobbyists Interested in CNC machining & 3D Printing in their home shops. (Digital Read Outs are also topical, as is CAD/CAM as it relates to CNC)

Moderator: Harold_V

User avatar
SteveHGraham
Posts: 7788
Joined: Sat Jan 17, 2009 7:55 pm
Location: Florida

Do I Need a Rotary Encoder?

Post by SteveHGraham »

I have a choice.

1. I can fix my lathe so it gives off two signals per spindle revolution, allowing the controller to make it do threading.

1. I can install a rotary encoder which--I think--will supply a signal every few degrees, presumably giving the controller a better idea where the spindle is at any given instant.

Adding two optical sensors is not hard. Adding a rotary encoder will be a pain in the butt. It has to turn at the same rate as the spindle, but obviously, you can't mount it on the same axis as the spindle, so you have to set it up so it's off below the spindle, turning at the same speed. I can do this by mounting it on a shaft below the spindle which holds a gear of appropriate size.

Is there any reason to prefer a rotary encoder? Will the lathe be able to do anything it can't do with two beeps per revolution?
Every hard-fried egg began life sunny-side up.
User avatar
ctwo
Posts: 2996
Joined: Tue Mar 27, 2012 12:37 pm
Location: Silly Cone Valley

Re: Do I Need a Rotary Encoder?

Post by ctwo »

I'd go with option 1. You'll have lots of fun.

btw, you just need one optical sensor (photo interrupter) and one or two slots. I'm not sure if Mach could read encoder pulses quick enough (I've read it needs 1 ppr), but not sure what your motion controller can handle.

https://www.youtube.com/watch?v=eCZo9f5JKRg



I'd go with an encoder if I could because I've also read that light duty spindle motors can bog down under load and you'd get inaccurate threading.
Standards are so important that everyone must have their own...
To measure is to know - Lord Kelvin
Disclaimer: I'm just a guy with a few machines...
User avatar
Dave_C
Posts: 960
Joined: Mon Apr 21, 2008 10:34 am
Location: Springfield. MO.

Re: Do I Need a Rotary Encoder?

Post by Dave_C »

CTWO is correct. Mach 3 can only read one pulse per rev! The manual talks about having four slots but one slot needs to be 25% wider than the other three so it knows which one is TDC. I think they never got this to work as intended!

One lsot is all it needs to do threading. Unless you have vector control over the spindle having encoders that can read in degrees is no help.

Basically one pulse (one slot in the wheel) is enough to set Top Dead Center so to speak. The software will sync to this spot and start the thread routine with this timing.

It works very well! (at least mine does)

Dave C.
I learn something new every day! Problem is I forget two.
User avatar
SteveHGraham
Posts: 7788
Joined: Sat Jan 17, 2009 7:55 pm
Location: Florida

Re: Do I Need a Rotary Encoder?

Post by SteveHGraham »

The problem is that the controller insists on more than one input. Mach3 isn't hassling me.
Every hard-fried egg began life sunny-side up.
User avatar
Dave_C
Posts: 960
Joined: Mon Apr 21, 2008 10:34 am
Location: Springfield. MO.

Re: Do I Need a Rotary Encoder?

Post by Dave_C »

Steve,

Ok, the "more than one input" is confusing me. On most break out boards (AKA BOB's) there is an input for a "pulse" from what ever you are using to index the spindle. Most I have seen want a Binary signal meaning a pulse that goes on/off in some way. So I used a optical sensor and a slotted disk fastened to the end of the spindle. One slot = one rev and one pulse locates the spindle to start the X axis moving. Time delays are not an issue here as the time delay will be the same on each threading pass. The pulse is basically a trigger that says "Start now".

So if you need more than one input, what is your controller asking these inputs to see or do?

Dave C.
I learn something new every day! Problem is I forget two.
User avatar
SteveHGraham
Posts: 7788
Joined: Sat Jan 17, 2009 7:55 pm
Location: Florida

Re: Do I Need a Rotary Encoder?

Post by SteveHGraham »

The controller I have is a KFlop. The guy who makes it says you can't get by with one pulse per revolution. The controller, not Mach3, wants more than that. You can either have two sensors 90 degrees apart on the spindle, or you can use a rotary encoder.

I asked if I could get away with a single pulse per revolution, and I was told it won't work.

That's all I know at the moment.
Every hard-fried egg began life sunny-side up.
User avatar
Dave_C
Posts: 960
Joined: Mon Apr 21, 2008 10:34 am
Location: Springfield. MO.

Re: Do I Need a Rotary Encoder?

Post by Dave_C »

Steve,

I'm not familiar with KFlop but it sounds like your input board then has two inputs for spindle position. I'll look it up and see what I can find.

Ok, I'm back. (That did not take long) Your KFlop controller is not setup for a pulse (on/off) input like my BOB is. Your board wants the A and B phase of a encoder.

Now you just passed my pay grade so I can't help any more, LOL

Dave C.
I learn something new every day! Problem is I forget two.
User avatar
SteveHGraham
Posts: 7788
Joined: Sat Jan 17, 2009 7:55 pm
Location: Florida

Re: Do I Need a Rotary Encoder?

Post by SteveHGraham »

Welcome to my world. Thanks, though.
Every hard-fried egg began life sunny-side up.
User avatar
ctwo
Posts: 2996
Joined: Tue Mar 27, 2012 12:37 pm
Location: Silly Cone Valley

Re: Do I Need a Rotary Encoder?

Post by ctwo »

Yes, it wants quadrature input. The question is what does it feed to mach (I think this is it: MySpindleDefs.h)?

You should be able to simulate this input. I've had several old PC ball mouses apart and used the encoders (there are usually three quadrature encoders in a ball mouse, one for the x,y and one for the wheel if it has one) to feed a microcontroller. I think you could simuilate it with two momentary switches going 1,2,,1,2,,1,2, and watch the led blinky feedback in mach (the diagnostic menu shown in the video up there).

So, Steve, your question is already answered. You need a quadrature encoder and then learn how to adjust the program I referenced up there so mach gets the right pulse rate.
Do I need to be a C Programmer to use your Controller?
Yes. Certain operations such as Controller initialization and Homing involve User C Programs that Execute in KFLOP. So some modification of C Programs is required. We do this because it is the most powerful and flexible approach. It isn't necessary to be a C expert, but basic programming knowledge is helpful. Download the software and go to the C Programs Screen to get an idea the level of difficulty.
Here you go, like reading the Sunday paper:
MySpindleDefs.h
#define SPINDLEAXIS 6 // Axis Channel to Jog to rotate Spindle
#define FACTOR (1000/60.0) // to convert RPM to counts/sec (counts/rev / 60.0sec)
#define SPINDLECW_BIT 154 // bit to activate to cause CW rotation
#define SPINDLECCW_BIT 155 // bit to activate to cause CCW rotation
#define SPEEDVAR 99 // global persistant variable to store latest speed
#define STATEVAR 98 // global persistant variable to store latest state (-1=CCW,0=off,1=CW)
#define KMVAR PC_COMM_CSS_S // variable KMotionCNC will pass speed parameter (113)
#define USE_POS_NEG_VOLTAGE 0 // 0 = output Magnitude, 1 = output positive and negative speed
Here is another piece I found:
Single ended [encoders] are sometimes referred to as TTL. Single ended have only two signals A and B (plus power and ground and possibly an Index pulse). The A and B signals are referenced to GND (more than 2.8V is high and less than 0.4V is low).

Differential signals have 4 signals called A+ A- B+ B-. This method is much better because there is basically no reference to any ground and so any noise or differences between grounds have no effect. When the A+ signal is at a more positive voltage relative to the A- signal the value is considered high, when the A+ signal is at a more negative voltage relative to the A- signal the value is considered low. The Difference only needs to be ~ 0.2V to be interpreted correctly but the + and - signals are usually driven by a Line Driver device that provides 2~4V of difference. If "twisted pair" cables are used then noise immunity is even better because any noise picked up in the cable is likely to be picked up exactly the same in both the + and - signals and so will not change their relative difference.

KFLOP by itself only accepts single ended signals. Our Kanalog and SnapAmp boards have differential encoder inputs. 3rd party modules are available to convert between single ended and differential.
Disclaimer: I could be wrong...
Last edited by ctwo on Mon Jul 25, 2016 11:13 pm, edited 2 times in total.
Standards are so important that everyone must have their own...
To measure is to know - Lord Kelvin
Disclaimer: I'm just a guy with a few machines...
User avatar
ctwo
Posts: 2996
Joined: Tue Mar 27, 2012 12:37 pm
Location: Silly Cone Valley

Re: Do I Need a Rotary Encoder?

Post by ctwo »

BTW, I don't recall why you went with kflop? I've been using a simple parallel BoB with my Bridgeport and it runs superb, for an open loop machine. I'm not dogging your choice, just trying to understand what I might be missing...
Standards are so important that everyone must have their own...
To measure is to know - Lord Kelvin
Disclaimer: I'm just a guy with a few machines...
User avatar
SteveHGraham
Posts: 7788
Joined: Sat Jan 17, 2009 7:55 pm
Location: Florida

Re: Do I Need a Rotary Encoder?

Post by SteveHGraham »

Thanks for all that effort. I already knew I needed something beyond a simple disk with one sensor, which is what other people manage to use with Mach3.

What I wanted to know was this: is there any reason to prefer a rotary encoder, with dozens of slots or whatever, to a simple disk with one slot and two sensors at 90 degrees to each other?

A real rotary encoder should be able to provide much better resolution, but is better resolution good for anything?

As for why I went with a KFlop, your guess is as good as mine. It was two years ago. I don't remember why I chose it, but I did a pile of research beforehand.
Every hard-fried egg began life sunny-side up.
User avatar
Dave_C
Posts: 960
Joined: Mon Apr 21, 2008 10:34 am
Location: Springfield. MO.

Re: Do I Need a Rotary Encoder?

Post by Dave_C »

Steve,

Done't feel bad for choosing KFlop because when we first get into CNC most of us don't know what parts to buy or what some of the terms actually mean. On the other hand, I cheated! I came across a person who had converted the exact model of lathe that I had and he was very happy with how it was working. I watched several of his videos and then sent him an email asking him if he would send me his parts list. He did and was very helpful when I got stumped on what turned out to be simple stuff.

Mine uses Win XP and Mach 3 but I have no complaints with how it cuts. Threads, curves and all that are perfect! You just have to know what your limitations are with each setup you build.

You'll get it going sooner or later,

Dave C.
I learn something new every day! Problem is I forget two.
Post Reply