Re: [Emc-users] A new lathe encoder option.

2021-07-21 Thread dave engvall



"The solution is to either add more counts per revolution or use a ten 
timesmore complex control algorithm."


IIUC then the real problem here is statistical. That is the sample size is too 
small to be significant. Maybe an over-simplification of the issue but:

I think there are a couple of ways to approach this. (1) time stamp the 
index pulse.
               (2) use a high count encoder and scale as necessary. 
This is clearly limited by the response of the  optics    for the disc.  
100 - 200 KHz for the inexpensive stuff.
I don't think there is a one size fits all solution. In electronic terms 
lathe spindles are pretty slow and have a lot of angular momentum. Most 
lathe spindles

rpm range is not a lot over 5-6 binary bits.


Just late evening rattling the cage. (off coffee until sunrise).

Dave






Could you solve the noise issue with a phase-locked loop?

Yes, this would be a far better solution. But I didn't want to
re-write the encoder counter from scratch.

Ideally you would use two PLLs, one for the pulses and one for the
index, to predict the pulse gap and extrapolate through it.

--
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
� George Fitch, Atlanta Constitution Newspaper, 1912

___Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users





___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] A new lathe encoder option.

2021-07-21 Thread dave engvall



"The solution is to either add more counts per revolution or use a ten 
timesmore complex control algorithm."


IIUC then the real problem here is statistical. That is the sample size is too 
small to be significant. Maybe an over-simplification of the issue but:

I think there are a couple of ways to approach this. (1) time stamp the 
index pulse.
         (2) use a high count encoder and scale as necessary. This 
is clearly limited by the response of the  optics  for the disc.  
100 - 200 KHz for the inexpensive stuff.
I don't think there is a one size fits all solution. In electronic terms 
lathe spindles are pretty slow and have a lot of angular momentum. Most 
lathe spindle

rpm range is not a lot over 5-6 binary bits.
I've actually considered putting a disc brake on the spindle. Not 
exactly joking.


Just late evening rattling the cage.

Dave







Could you solve the noise issue with a phase-locked loop?

Yes, this would be a far better solution. But I didn't want to
re-write the encoder counter from scratch.

Ideally you would use two PLLs, one for the pulses and one for the
index, to predict the pulse gap and extrapolate through it.

--
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
� George Fitch, Atlanta Constitution Newspaper, 1912

___Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users







___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] A new lathe encoder option.

2021-07-21 Thread Chris Albertson
The noise here is not electrical noise on the cables.  We assume the signal
is perfect square waves.This is "quantization noise".

Here is what happens...   Say you have 50 slots on the spindle and the
motor is turning at 100 RPM.   This is 1.67 revolutions per second so 350
pulses per second.  Now let's say your PID algorithm samples the encoder
100 times per second.  On average, it will get 3.5 pulses, but the count
must always be a whole number so sometimes it gets 3 and sometimes 4.  Each
time, the PID sees this as an error and tries to correct it.
 Quantization noise is what happens when the measurement lacks enough
resolution.

Noise is defined as an error in the signal and there will always, on
average be 1/2 count of noise error in the signal, even if it is
electrically perfect.  If the typical number of counts is 100 per period
than a 1/2 count noise is only 0.5% but at low speed where you expect only
2 counts the 1/2 count error is 25%

The solution is to either add more counts per revolution or use a ten times
more complex control algorithm.

On Wed, Jul 21, 2021 at 3:36 PM John Dammeyer 
wrote:

> It's been a while since I did quadrature programming but if you have two
> sensors don't the two work together to validate signals because they can
> only change under certain conditions.  So noise can't totally screw things
> up.
>
> Now having said that of course I did change from US Digital on my DC
> Servos to CUI because they were impacted by noise and over time there were
> more counts in one direction than the other.  So a return to zero wasn't
> the original zero.
>
> So I'm probably all wet.  But 60 pulses per rev is a lot different from
> thousands.  Might be better to clean up the signals at the source before
> they are ever counted.
>
> John
>
>
> > -Original Message-
> > From: andy pugh [mailto:bodge...@gmail.com]
> > Sent: July-21-21 11:54 AM
> > To: Enhanced Machine Controller (EMC)
> > Subject: Re: [Emc-users] A new lathe encoder option.
> >
> > On Wed, 21 Jul 2021 at 19:49, Chris Albertson 
> wrote:
> >
> > > Could you solve the noise issue with a phase-locked loop?
> >
> > Yes, this would be a far better solution. But I didn't want to
> > re-write the encoder counter from scratch.
> >
> > Ideally you would use two PLLs, one for the pulses and one for the
> > index, to predict the pulse gap and extrapolate through it.
> >
> > --
> > atp
> > "A motorcycle is a bicycle with a pandemonium attachment and is
> > designed for the especial use of mechanical geniuses, daredevils and
> > lunatics."
> > � George Fitch, Atlanta Constitution Newspaper, 1912
> >
> >
> > ___
> > Emc-users mailing list
> > Emc-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/emc-users
>
>
>
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users
>


-- 

Chris Albertson
Redondo Beach, California

___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] A new lathe encoder option.

2021-07-21 Thread John Dammeyer
> From: andy pugh [mailto:bodge...@gmail.com]
> Counter-mode is a compromise for those short on pins. What this index
> mode offers is something better than the other current one-wire
> alternative which is A and Z on the same pin, where a spurious count
> puts you a whole turn out..
> 
> --
> atp

I hadn't realized you were trying to avoid some sort of A and Z on the same 
pin.  
John




___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] A new lathe encoder option.

2021-07-21 Thread andy pugh
On Wed, 21 Jul 2021 at 23:36, John Dammeyer  wrote:
>
> It's been a while since I did quadrature programming but if you have two 
> sensors don't the two work together to validate signals because they can only 
> change under certain conditions.  So noise can't totally screw things up.

Indeed, which is partly why quadrature is much better.

Counter-mode is a compromise for those short on pins. What this index
mode offers is something better than the other current one-wire
alternative which is A and Z on the same pin, where a spurious count
puts you a whole turn out..

-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] A new lathe encoder option.

2021-07-21 Thread John Dammeyer
It's been a while since I did quadrature programming but if you have two 
sensors don't the two work together to validate signals because they can only 
change under certain conditions.  So noise can't totally screw things up.

Now having said that of course I did change from US Digital on my DC Servos to 
CUI because they were impacted by noise and over time there were more counts in 
one direction than the other.  So a return to zero wasn't the original zero.

So I'm probably all wet.  But 60 pulses per rev is a lot different from 
thousands.  Might be better to clean up the signals at the source before they 
are ever counted.

John


> -Original Message-
> From: andy pugh [mailto:bodge...@gmail.com]
> Sent: July-21-21 11:54 AM
> To: Enhanced Machine Controller (EMC)
> Subject: Re: [Emc-users] A new lathe encoder option.
> 
> On Wed, 21 Jul 2021 at 19:49, Chris Albertson  
> wrote:
> 
> > Could you solve the noise issue with a phase-locked loop?
> 
> Yes, this would be a far better solution. But I didn't want to
> re-write the encoder counter from scratch.
> 
> Ideally you would use two PLLs, one for the pulses and one for the
> index, to predict the pulse gap and extrapolate through it.
> 
> --
> atp
> "A motorcycle is a bicycle with a pandemonium attachment and is
> designed for the especial use of mechanical geniuses, daredevils and
> lunatics."
> � George Fitch, Atlanta Constitution Newspaper, 1912
> 
> 
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] A new lathe encoder option.

2021-07-21 Thread Gene Heskett
On Wednesday 21 July 2021 17:19:05 Chris Albertson wrote:

> If you feed those averages to the PID controller, that PID is reacting
> to old data and you get either very sluggish control or oscillation.
>
> The best way is to predict the future and the have the control
> programmed to make that predicted future the future you want.That
> hockey quote comes to mind, "I don't skate to the puck, I skate to
> where the puck will be."  PID algorithms using averaged data are even
> worse and "skate to where the puck used to be."
>
> A PLL is actually a predictive model of the spindle that tells you
> where the index will be at any point in time, past or future.  It
> works in as much as spindles don't teleport randomly to different
> angles and RPMs but exhibit predictable behavior.   For very short
> periods of time, (one servo cycle) the prediction is very good.
>
This spindle could, it is being controlled by one of jon's PWM-Servo 
amps, which is a full 4 quadrant controller. A 1hp rated motor at 9.7 
amps and 90 volts, but the power supply is about 127 volts with enough 
microfarads that a cold turnon trips a 30 amp breaker instantly.

And my home made optical disk encoder had so much quantization noise I 
actually caught it stopping at 50 rpms occasionally, and the nylon gears 
were being slapped around like all the bearings had square balls in 
them. Pgain was limited to the 2.5-3 range. I installed a 1024 ppr 
encoder on the back of the motor and wrote some hal to calibrate it 
again. Pgain can now go as high as 40 but its plenty stiff enough at 20, 
and below 500 revs its so quiet I have to look at it to see if its 
turning. That PSU gets soft started by having a 50 ohm, 200 watt 
resistor in series with it for the first 4 seconds, and now it lives on 
a 20 amp breaker even with the iron chirping because the servo limit is 
about 17.5 amps. I thought that would be hard on brushes, but its been 
running that way for 5 years now. On the same brushes.

G0704's are rated for 2250 fwd, 1100 in reverse when grizzy ships, but 
with that PSU, it does 3 grand in both directions.  Whats not to 
like? :) I had to run the change direction thru some hal to slow it, 
otherwise the Z can't keep up and errors off, but it still does that 
bottom of the stroke reverse in a g33.1 in 400 milliseconds at 1500 res.

Using that same idea in the sheldon, with has a vfd, reverse overshoot at 
100 revs is done in .25 of a turn with an 8" chuck north of 30 lbs 
mounted.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page 


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] A new lathe encoder option.

2021-07-21 Thread Chris Albertson
If you feed those averages to the PID controller, that PID is reacting to
old data and you get either very sluggish control or oscillation.

The best way is to predict the future and the have the control programmed
to make that predicted future the future you want.That hockey
quote comes to mind, "I don't skate to the puck, I skate to where the puck
will be."  PID algorithms using averaged data are even worse and "skate to
where the puck used to be."

A PLL is actually a predictive model of the spindle that tells you where
the index will be at any point in time, past or future.  It works in as
much as spindles don't teleport randomly to different angles and RPMs but
exhibit predictable behavior.   For very short periods of time, (one servo
cycle) the prediction is very good.



On Wed, Jul 21, 2021 at 12:18 PM Gene Heskett  wrote:

> On Wednesday 21 July 2021 14:46:26 Chris Albertson wrote:
>
> > Could you solve the noise issue with a phase-locked loop?  THis takes
> > advantage of the fact that the spindle has momentum and the
> > accelerating forces are limited.
> >
> > It is a common technique in electronics, you build a good, clean local
> > oscillator and then take your frequency measurement from that, rather
> > than from the noisy real-world data.  But at the same time, you
> > compare the phase of the local oscillator with the real data  and make
> > tiny adjustment to the local oscillator.
> >
> > What is really happening is that you only look at edges if they happen
> > near the expected time and weigh them, scoring to how near the
> > expected time so statistically almost all the noise is ignored.
> >
> > You can try averaging, but it does not work nearly as well and has a
> > long lag.
> >
> That I have tried, taking the sum of the last 4 edges, but the lag was
> showing and it was still too noisy to work well.
>
> > On Wed, Jul 21, 2021 at 1:19 AM andy pugh  wrote:
> > > On Wed, 21 Jul 2021 at 05:36, andrew beck 
> > >
> > > wrote:
> > > > Andy what do you think is the max rpm that this will read reliably
> > > > do you think?
> > >
> > > It will handle a higher speed than a full quadrature setup as it
> > > only needs to see one edge.
> > > I have run it up to 16000 rpm (in the video) with a 50,000ns base
> > > thread.
> > >
> > > The problem with counter-mode is noise rejection, noise is seen as
> > > pulses and gets added to the position. (This isn't unique to the
> > > missing-tooth index, this is counter-mode in general)
> > >
> > > --
> > > atp
> > > "A motorcycle is a bicycle with a pandemonium attachment and is
> > > designed for the especial use of mechanical geniuses, daredevils and
> > > lunatics."
> > > — George Fitch, Atlanta Constitution Newspaper, 1912
> > >
> > >
> > > ___
> > > Emc-users mailing list
> > > Emc-users@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/emc-users
>
>
> Cheers, Gene Heskett
> --
> "There are four boxes to be used in defense of liberty:
>  soap, ballot, jury, and ammo. Please use in that order."
> -Ed Howdershelt (Author)
> If we desire respect for the law, we must first make the law respectable.
>  - Louis D. Brandeis
> Genes Web page 
>
>
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users
>


-- 

Chris Albertson
Redondo Beach, California

___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] A new lathe encoder option.

2021-07-21 Thread Gene Heskett
On Wednesday 21 July 2021 14:46:26 Chris Albertson wrote:

> Could you solve the noise issue with a phase-locked loop?  THis takes
> advantage of the fact that the spindle has momentum and the
> accelerating forces are limited.
>
> It is a common technique in electronics, you build a good, clean local
> oscillator and then take your frequency measurement from that, rather
> than from the noisy real-world data.  But at the same time, you
> compare the phase of the local oscillator with the real data  and make
> tiny adjustment to the local oscillator.
>
> What is really happening is that you only look at edges if they happen
> near the expected time and weigh them, scoring to how near the
> expected time so statistically almost all the noise is ignored.
>
> You can try averaging, but it does not work nearly as well and has a
> long lag.
>
That I have tried, taking the sum of the last 4 edges, but the lag was 
showing and it was still too noisy to work well.

> On Wed, Jul 21, 2021 at 1:19 AM andy pugh  wrote:
> > On Wed, 21 Jul 2021 at 05:36, andrew beck 
> >
> > wrote:
> > > Andy what do you think is the max rpm that this will read reliably
> > > do you think?
> >
> > It will handle a higher speed than a full quadrature setup as it
> > only needs to see one edge.
> > I have run it up to 16000 rpm (in the video) with a 50,000ns base
> > thread.
> >
> > The problem with counter-mode is noise rejection, noise is seen as
> > pulses and gets added to the position. (This isn't unique to the
> > missing-tooth index, this is counter-mode in general)
> >
> > --
> > atp
> > "A motorcycle is a bicycle with a pandemonium attachment and is
> > designed for the especial use of mechanical geniuses, daredevils and
> > lunatics."
> > — George Fitch, Atlanta Constitution Newspaper, 1912
> >
> >
> > ___
> > Emc-users mailing list
> > Emc-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/emc-users


Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page 


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] A new lathe encoder option.

2021-07-21 Thread andy pugh
On Wed, 21 Jul 2021 at 19:49, Chris Albertson  wrote:

> Could you solve the noise issue with a phase-locked loop?

Yes, this would be a far better solution. But I didn't want to
re-write the encoder counter from scratch.

Ideally you would use two PLLs, one for the pulses and one for the
index, to predict the pulse gap and extrapolate through it.

-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] A new lathe encoder option.

2021-07-21 Thread Chris Albertson
Could you solve the noise issue with a phase-locked loop?  THis takes
advantage of the fact that the spindle has momentum and the accelerating
forces are limited.

It is a common technique in electronics, you build a good, clean local
oscillator and then take your frequency measurement from that, rather than
from the noisy real-world data.  But at the same time, you compare the
phase of the local oscillator with the real data  and make tiny adjustment
to the local oscillator.

What is really happening is that you only look at edges if they happen near
the expected time and weigh them, scoring to how near the expected time so
statistically almost all the noise is ignored.

You can try averaging, but it does not work nearly as well and has a long
lag.




On Wed, Jul 21, 2021 at 1:19 AM andy pugh  wrote:

> On Wed, 21 Jul 2021 at 05:36, andrew beck 
> wrote:
> >
> > Andy what do you think is the max rpm that this will read reliably do you
> > think?
>
> It will handle a higher speed than a full quadrature setup as it only
> needs to see one edge.
> I have run it up to 16000 rpm (in the video) with a 50,000ns base thread.
>
> The problem with counter-mode is noise rejection, noise is seen as
> pulses and gets added to the position. (This isn't unique to the
> missing-tooth index, this is counter-mode in general)
>
> --
> atp
> "A motorcycle is a bicycle with a pandemonium attachment and is
> designed for the especial use of mechanical geniuses, daredevils and
> lunatics."
> — George Fitch, Atlanta Constitution Newspaper, 1912
>
>
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users
>


-- 

Chris Albertson
Redondo Beach, California

___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] A new lathe encoder option.

2021-07-21 Thread andy pugh
> I went with a hollow shaft (40mm bore) encoder directly to the lathe spindle

Which is a far superior choice, but if you have the hardware to count
a 1024 slot encoder with full quadrature you are probably not the
target market for the single-wire mode of the software encoder.

-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] A new lathe encoder option.

2021-07-21 Thread Rob C
I am guessing that these may therefore be an option too

http://trigger-wheels.com/store/contents/en-uk/d5.html

you can get custom ones / made to your measurements too

I went with a hollow shaft (40mm bore) encoder directly to the lathe spindle

one of these (or a variant of)
https://m.aliexpress.com/item/1180162296.html?trace=wwwdetail2mobilesitedetail

On Wed, 21 Jul 2021, 09:22 andy pugh,  wrote:

> On Tue, 20 Jul 2021 at 23:40, John Dammeyer 
> wrote:
>
> > There is no reason a second sensor couldn't be added to provide
> quadrature?
>
> It might work. I didn't test it.
>
> It only detects the gap when counting up. But other than that the use
> of quadrature is not specifically excluded.
>
> Shall we say that the behaviour in quadrature mode is "undefined"
>
> --
> atp
> "A motorcycle is a bicycle with a pandemonium attachment and is
> designed for the especial use of mechanical geniuses, daredevils and
> lunatics."
> — George Fitch, Atlanta Constitution Newspaper, 1912
>
>
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users
>

___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] A new lathe encoder option.

2021-07-21 Thread andy pugh
On Tue, 20 Jul 2021 at 23:40, John Dammeyer  wrote:

> There is no reason a second sensor couldn't be added to provide quadrature?

It might work. I didn't test it.

It only detects the gap when counting up. But other than that the use
of quadrature is not specifically excluded.

Shall we say that the behaviour in quadrature mode is "undefined"

-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] A new lathe encoder option.

2021-07-21 Thread andy pugh
On Wed, 21 Jul 2021 at 05:36, andrew beck  wrote:
>
> Andy what do you think is the max rpm that this will read reliably do you
> think?

It will handle a higher speed than a full quadrature setup as it only
needs to see one edge.
I have run it up to 16000 rpm (in the video) with a 50,000ns base thread.

The problem with counter-mode is noise rejection, noise is seen as
pulses and gets added to the position. (This isn't unique to the
missing-tooth index, this is counter-mode in general)

-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users