Page 1 of 2

Adding an encoder to my spindle motor

PostPosted: Sun Aug 09, 2020 11:17 pm
by MattTheNoob
I was all geared up to install one of these cool ENI-1024 magnetic encoders onto the back of my spindle motor, and then started reading that I actually want something down in the 100ppr range rather than the 1024ppr. Is there a low-resolution version of this same style of encoder? I really don't want to spend real money on an encoder if I don't have to.

It is a belt drive spindle with a power draw bar and there is no good place to add the encoder on the spindle itself, so adding it to the back of the TEFC motor is the best I can come up with. I was planning to epoxy the magnet to the back end of the shaft since the shaft doesn't extend beyond the cooling fan. Pic below showing the back of my motor.

Re: Adding an encoder to my spindle motor

PostPosted: Mon Aug 10, 2020 3:54 pm
by Robertspark
you can use a frequency divider circuit (counter)

search CD4017 (very very simple circuit)

https://www.eleccircuit.com/ic-4017-datasheet/

NOTE: You will need 2 x CD4017's..... one for the A and 1 for the B channels

Re: Adding an encoder to my spindle motor

PostPosted: Sun Aug 23, 2020 2:22 pm
by MattTheNoob
Thanks Robert.
After reading that material, I understand the frequency dividing part, but how do you get the A and B phased for the quadrature? It almost seems like you'd need to have B reset when A gets to 5 (assuming dividing by 10). Then for spinning the other way you'd have to reverse it.

I do some electronics, but I'm no wizard with it.

Re: Adding an encoder to my spindle motor

PostPosted: Sat Aug 29, 2020 4:40 am
by MattTheNoob
Well, I've opted to go to an AMT33 encoder (CUI) because I can configure that down to 100 (or even as low as 48) ppr. I'm sure the pulse divider would have worked, but it was going to be more electronics than I want to get into right now.

I'm in the process of extending the shaft beyond the fan shroud so I can mount the encoder. The mag encoder would have been a pretty cool option... I'm sure I'll use it somewhere.

I'll post some pics when it is done.

Re: Adding an encoder to my spindle motor

PostPosted: Wed Sep 02, 2020 1:16 am
by MattTheNoob
It's mostly working!
I extended the shaft on the back side of the motor. Made an alignment jig and epoxied it on. (Pics attached)

Here's the weirdness maybe you guys can help me with. My encoder is configured for 48 ppr. The pulley ratio between the motor and spindle is 1.3, giving me about 37ppr at the spindle. But... to get the UCCNC displayed speed to match the actual speed, I need to set the ppr to 110ppr... which is about 3x. Shouldn't this be 4x because of the way the quadrature is decoded? Using the 3x number is spot on through the whole range of 1000-7000 rpm.
What am I missing that's making this work at 3x rather than 4x?

Re: Adding an encoder to my spindle motor

PostPosted: Wed Sep 02, 2020 7:45 pm
by Robertspark
MattTheNoob wrote:Thanks Robert.
After reading that material, I understand the frequency dividing part, but how do you get the A and B phased for the quadrature? It almost seems like you'd need to have B reset when A gets to 5 (assuming dividing by 10). Then for spinning the other way you'd have to reverse it.

I do some electronics, but I'm no wizard with it.


I missed this....

quadrature incremental encoder (90 out of phase ... not absolute encoder with offset A&B encoder signals

https://www.cuidevices.com/blog/when-is ... l-encoders

most rotary encoders I've seen have been of the incremental type.... absolute I have seen with linear positioning systems, pneumatics and steering angle sensors

divide the A and. B channels by 10 each with their own divider chip. leave z as the index as pulse per revolution

Re: Adding an encoder to my spindle motor

PostPosted: Wed Sep 02, 2020 7:50 pm
by Robertspark
MattTheNoob wrote:It's mostly working!
I extended the shaft on the back side of the motor. Made an alignment jig and epoxied it on. (Pics attached)

Here's the weirdness maybe you guys can help me with. My encoder is configured for 48 ppr. The pulley ratio between the motor and spindle is 1.3, giving me about 37ppr at the spindle. But... to get the UCCNC displayed speed to match the actual speed, I need to set the ppr to 110ppr... which is about 3x. Shouldn't this be 4x because of the way the quadrature is decoded? Using the 3x number is spot on through the whole range of 1000-7000 rpm.
What am I missing that's making this work at 3x rather than 4x?


you have confused my simple brain but I'm keen to learn.... 1:3 ratio or 1.3 ratio....

Re: Adding an encoder to my spindle motor

PostPosted: Wed Sep 02, 2020 9:22 pm
by MattTheNoob
The pulley pair is a 1 : 1.3 ratio for the high speed. 1 rev of the motor gives me 1.3 revs of the spindle.
The encoder is on the motor, and is 48ppr. This gives me (48 / 1.3 =) 37 pulses per rev of the spindle.

Since Uccnc interprets rise and fall of channels A and B, it would seem that UC would like a setting of 4 times my ppr, but for whatever reason I'm having to adjust it to 3 times the ppr, or around 110ppr to get the UC speed to match actual speed, as measured by a laser tach.

(I'll play with it on the low speed pulley ratio tonight and see if the pattern holds... or maybe reveals the error in my math.)

Re: Adding an encoder to my spindle motor

PostPosted: Wed Sep 02, 2020 11:42 pm
by MattTheNoob
I don't know what it means yet, but here's another piece of the puzzle.
Low speed pulley pair has a ratio of 1: 0.56, so every rev of the motor gives me 0.56 revs of the spindle.
Again, the encoder on the motor is 48ppr. This gives me (48 / 0.56 =) 85.7 pulses per rev of the spindle.

Again, I'd expect UC to like a setting of 4x 85.7 or 342 ppr, but I had to go to a whopping 607ppr in UC to get the speeds to match. And with that they were spot-on through the whole range of 0-3000 rpm.

I think we're on to something here. With the high pulley ratio I needed a lower-than-expected PPR, but with a the low pulley ratio I needed a higher-than-expected PPR. It's almost like UC is factoring in the pulley ratio twice.

Anticipated PPR for low speed of 342PPR, but divide by my pulley ratio of 0.56 and I get 612ppr (very close to the 607 I landed on)
Anticipated PPR for high speed of 147PPR, but divide by my pulley ratio of 1.3 and I get 113ppr (which is exactly what I landed on)

I won't go so far as to call this a bug in the encoder/pulley ratio calcs, but I'm at least having trouble wrapping my brain around it.

So for anyone else on this path, with a pulley-drive spindle, but with the encoder on the motor, here's how you find your PPR for the spindle setup in UC:

((Encoder PPR / pulley ratio) X 4) / pulley ratio or if we want to be fancy (encoder PPR X 4) / (pulley ratio)^2

Thanks for listening to be babble on about this.

Re: Adding an encoder to my spindle motor

PostPosted: Thu Sep 03, 2020 8:46 am
by Robertspark
There was another post on here (but I cannot find it or I would have linked to it) where the uccnc user was running an encoder off a motor shaft with a belt / gear drive to a spindle but could not get it to run right. (from memory he was doing threading) and tried all manor of things with the pulley ratios etc.

the thing was, uccnc needed (again from memory!) the encoder to be located on the spindle, or at least for the index pulse to be provided from the spindle.

these threads may be of help.

viewtopic.php?f=4&t=1387&hilit=encoder
viewtopic.php?f=2&t=1674&start=10&hilit=encoder
viewtopic.php?f=19&t=1592&hilit=encoder