Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: resalles on December 01, 2015, 03:15:34 PM

Title: Spindle calibration, how I manage to get it working
Post by: resalles on December 01, 2015, 03:15:34 PM
I have a 3 axix CNC converted Conquest mill (from Chester UK) controlled by Mach3/Geckodrive G540 and recently got quite happy to make it work with the VFD (RPM controlled by Mach3).

For that I simply disconnected the potentiometer from the mill speed control  and replaced it by an analog optocoupler and a resistor. I know G540  VFD is already isolated, but the mill circuit board was powering the low voltage electronics directly from the 220V using a voltage divider... so it got me scared to simply plug the G540 directly.

The advantage of this approach is that I got a working VFD almost for free. The disavantage is that it is highly non-linear. The spindle only starts to turn at about 30 RPM when I command 400 RPM, it  gets close to the commanded value at about a 1000RPM then it undershoots.

So I thought "Lets use the Mach3 spindle calibration and it will work fine"... Well, wrong... for some reason the calibration, at least in my version of Mach3 would not work. Probably it works for correcting small deviations but for my cheapo VFD it was hopeless...

So I read some threads here about this problem and it seems somewhat usual. People referred to a file named "Linearity.dat" so I could not resist taking a look at it.

Long story short, the linearization strategy implemented in Mach3 is actually works great. The problem seems to be the function that generates the file, it probably does not assume that a VFD could be as bad as mine  :D.

So I wrote an Excel table that takes as input the commanded RPM vc Real RPM and produces a  "Linearity.dat" file that works fine.

I am attaching the Excel file so that you guys can try it out. Can´t guarantee anything but that it worked for me. But if some of you have the same issue, I hope it helps.

The way it works is the following:

1- Only make changes to the GREEN cells.
2- Enter your min and max RPM. It will generate a list with 101 input values for you to fill.
3- For each entry, command your machine to spin at the COMMANDED column (blue), take note of the real RPM it is spinning and enter it in the MEASURED column (green)
4- Click the CREATE FILE button. It will run a macro that writes a linearization file. That is the  "Linearity.dat" file that Mach3 is able to read.
5- Shut down Mach3 and copy that file as to replace the one you have. In my case it happens to be at "C:\Mach3\macros\Mill_RS".
6- Start Mach3 and try to see if the RPM is correct now.

Hope it helps.


 
 
Title: Re: Spindle calibration, how I manage to get it working
Post by: Tweakie.CNC on December 02, 2015, 01:10:00 AM
Excellent information Resalles, thanks for sharing.

Tweakie.
Title: Re: Spindle calibration, how I manage to get it working
Post by: Fastest1 on December 02, 2015, 08:01:32 AM
I am just about to take this plunge. Will be a good resource. I have had issues on previous machines setting the correct speed very accurately.
Title: Re: Spindle calibration, how I manage to get it working
Post by: rcaffin on December 27, 2015, 04:25:48 PM
Hi Resalles

Just exactly what I needed.
But it does not work for me.

The problem is that I want to create an ultra-linear file to reset my system, and the code fails at the last line. When you do a MATCH at line 103 AND column H is a copy of column G, the code ends up looking for an entry in line 104, and there is no entry there.
So I fixed that by adding another line (speed 101).

However, it still does not write out any file that I can find.
Suggestions?

Cheers
Roger
Title: Re: Spindle calibration, how I manage to get it working
Post by: rcaffin on December 27, 2015, 06:20:48 PM
UPDATE:

The Linearity.dat file is created in MyDocuments, not in the folder the XLSM file resides, for reasons I have not pursued. You can copy it from there to the Mach/macros folder, replacing the old file.

IF all you want to do is to kill a faulty linearisation file, then just delete it from the Mach/macros folder. If Mach3 cannot find this file, it will create a new 100% linear version when it starts. Then you can do the autocal routine again.

If you want to create a new Linearity.dat file, I recommend you first adjust the maximum pulley speed to the right value (and save settings) before you exit Mach3 and before you kill the Linearity.dat file. This may not in fact be required as the linearity file does not seem to hold any absolute data - I have yet to check.

Cointrary to what many have said, the spindle autocal routine does work. However, if your system has a noisy or inadequate spindle pulse feedback, the result may not be exactly what you want. In that case, first fix your hardware.

Peter Homann's method of tweaking the maximum pulley speed may work but it is entirely a work-around, and does not actually liearise the spindle speed. it just tweaks the maximum (or some selected value).

You can NOT freely increase the maximum speed in the spreadsheet without updating the observed spindle speed column, as that may create invalid data in some spreadsheet cells (#REF I think).

Cheers
Roger
Title: Re: Spindle calibration, how I manage to get it working
Post by: rcaffin on December 28, 2015, 06:24:28 PM
Further update:

It seems that the very first setting of the spindle speed, before any M3 command, only references the maximum pulley speed, and does not consult the linearity.dat file. My observations are thus:

If I adjust the max pulley speed value so that it corresponds to the output from my PWM system at 100%, then the first S setting gives the right result. So setting the spindle driver to give 3000 RPM at 100% input AND setting the max spindle speed to 3000 RPM does give the right spindle speed the very first time. This is very close to what Peter Homann was suggesting.

But if I set the max spindle speed to 2000 RPM while the spindle driver HW is set to deliver 3000 RPM at 100% PWM input, then the first S command will still scale off the 3000 RPM. S1000 will give 1500 RPM for instance.

Ah, but an S1000 AFTER the M3 command seems to load the Linearity.dat file and calculate what PWM ratio is need to get 1000 RPM. So if I want to limit the spindle speed to something lower than the HW can provide, I have to do it like this:
F100 S100
M3
S1000

Yet another slight bug in Mach3 I guess.

Cheers
Title: Re: Spindle calibration, how I manage to get it working
Post by: rcaffin on December 31, 2015, 02:22:51 AM
Yet another update:
Spindle calibration works fine in MILL mode.
I am still having a few issues in LATHE mode. I usually have to issue a spin command twice to get close to the calibrated spin, otherwise it runs faster - sometimes a little faster, sometimes a lot. Sigh.

The comment was made somewhere that there is little difference between spinning at 1500 RPM and 1600 RPM. This may be so on a Mill, but on a Lathe it can mean the difference between sitting right on tool/part resonance and being way off resonance and quiet. Mumble.

Cheers And Happy New Year
Roger
Title: Re: Spindle calibration, how I manage to get it working
Post by: rhtuttle on January 04, 2016, 03:53:10 PM
I converted my Sieg lathe (Microlux 7x14) to CNC this spring.  I have been able to get approximate spindle speed to work. 

Since the spreadsheet has only one column do you use the highest/fastest spindle gearing or doesn't it matter?

TIA
Title: Re: Spindle calibration, how I manage to get it working
Post by: midyo on March 20, 2016, 10:49:22 AM
If mach is calculating the rpm, then why does'nt mach adjust the speed or is that just too simple? Am I misssing something?
Title: Re: Spindle calibration, how I manage to get it working
Post by: rcaffin on March 20, 2016, 05:02:21 PM
Mach can control the spindle speed IF and only IF you are using the direct parallel port interface.
If you are using an external engine such as the SS, it cannot.

Mach does not 'calculate' the RPM: it just measures the Index pulses coming back.

Cheers
Roger
Title: Re: Spindle calibration, how I manage to get it working
Post by: midyo on March 21, 2016, 03:51:29 AM
OK, well I have a UC100 so that's that. I'm thinking I might take it out though if it will mean better spindle control for threading etc?
Title: Re: Spindle calibration, how I manage to get it working
Post by: rcaffin on March 21, 2016, 04:30:28 AM
I use Mach3 .062, an ESS, and a single Index pulse. I turn on spindle averaging in Mach.
I get quite good, even excellent, threading. But I do take small cuts so the load on the spindle drive is small.

Cheers
Roger
Title: Re: Spindle calibration, how I manage to get it working
Post by: midyo on March 21, 2016, 06:03:24 AM
To be fair I do get pretty good results threading as is, what do you find to be the best feeds and speeds. It does seem to me that slower is better. I spin the chuck at 100RPM and take 0.05mm cuts usually. I just always get the feeling it could be better though!
Title: Re: Spindle calibration, how I manage to get it working
Post by: midyo on March 21, 2016, 06:04:10 AM
Also, whats the reason for using an older version?

cheers
Title: Re: Spindle calibration, how I manage to get it working
Post by: rcaffin on March 21, 2016, 06:35:08 AM
Hi midyo

Spin: always a function of material and diameter. I have no trouble threading 7000-series Al or brass at 400 RPM on diameters up to 20 mm. To me, the limiting factors are sync distance and withdrawal speed. They might depend on your machine. Cut depth - not much, but always enough to actually 'cut'.

Yes, .062 is older than .066 or .067, but ...
.067 was only briefly available and was withdraw, afaik.
.066 is 'recommended' by the Artsoft web site, but users have had problems with it and most experienced users recommend dropping back to .062 . I suspect that whatever bug fixes they attempted with .066 made too many other things worse.
.063, .064, .065 - I don't think they were ever released.

Cheers
Roger
Title: Re: Spindle calibration, how I manage to get it working
Post by: midyo on March 21, 2016, 03:58:07 PM
Back to .062 it is then!
Title: Re: Spindle calibration, how I manage to get it working
Post by: davidimurray on August 10, 2016, 04:59:40 PM
Yet another update:
Spindle calibration works fine in MILL mode.
I am still having a few issues in LATHE mode. I usually have to issue a spin command twice to get close to the calibrated spin, otherwise it runs faster - sometimes a little faster, sometimes a lot. Sigh.

The comment was made somewhere that there is little difference between spinning at 1500 RPM and 1600 RPM. This may be so on a Mill, but on a Lathe it can mean the difference between sitting right on tool/part resonance and being way off resonance and quiet. Mumble.

Cheers And Happy New Year
Roger


The spreadsheet is excellent and has done a great job of calibrating my lathe spindle speed. I have the same issue that you have regarding having to request the spindle speed twice. Did you ever find a fix for this?
Title: Re: Spindle calibration, how I manage to get it working
Post by: rcaffin on August 10, 2016, 05:59:36 PM
I suspect (but do not know) that the problem is deep inside Mach3. I suspect that the spindle is set running before the system checks for pulley upper speed limit, so the PWM ratio generated the first time is wrong. Just one of those quirks in mach3 that we all love ...
With that in mind, my solution is to issue the following commands:

S1000
m3
s1000

This seems to work fine. In fact, the actual value for the first spin command does not really matter: it could be s200 for that matter. The second spin command does work.

Cheers
Roger
Title: Re: Spindle calibration, how I manage to get it working
Post by: davidimurray on August 12, 2016, 03:59:47 PM
Thanks Roger

Looks like I will have to use the same workaround.

Cheers

Dave
Title: Re: Spindle calibration, how I manage to get it working
Post by: davidimurray on August 24, 2016, 03:58:10 PM
Tried a little work around tonight that seems to be working.

Edit the M3 macro and replace it with -
SetS=getoemdro(817)
DoSpinCW()
Code "S" & SetS


Now it automatically loads the speed twice when you use an M3 which means the spindle goes to the correct speed.

Not sure how the screen buttons work, might need to change them to call M3.

Title: Re: Spindle calibration, how I manage to get it working
Post by: rcaffin on August 24, 2016, 05:55:11 PM
Ah so!   :-*
What an excellent idea. I must try that out myself.
Thank you.
Roger
Title: Re: Spindle calibration, how I manage to get it working
Post by: resalles on September 20, 2016, 06:43:41 PM
Yet another update:
Spindle calibration works fine in MILL mode.
I am still having a few issues in LATHE mode. I usually have to issue a spin command twice to get close to the calibrated spin, otherwise it runs faster - sometimes a little faster, sometimes a lot. Sigh.

The comment was made somewhere that there is little difference between spinning at 1500 RPM and 1600 RPM. This may be so on a Mill, but on a Lathe it can mean the difference between sitting right on tool/part resonance and being way off resonance and quiet. Mumble.

Cheers And Happy New Year
Roger


The spreadsheet is excellent and has done a great job of calibrating my lathe spindle speed. I have the same issue that you have regarding having to request the spindle speed twice. Did you ever find a fix for this?

Thanks davidimurray, good to know the spreadsheet was useful to someone!
Sorry I haven't been checking this post for a while...
You know, this need of  setting-speed-twice have been annoying me too. Sure it is not the best way to use workarounds, but the info you guys posted really helped me to make it work!
Cheers!
Title: Re: Spindle calibration, how I manage to get it working
Post by: terenceang on November 11, 2016, 06:33:54 AM
Thanks resalles for the script.

I got Spindle calibration to work with your script.

Here are the step i took to get it to work.
1. I set the pulley to 1, min to 0, max to 1000.
2. turn on the spindle, set speed from S0 till the spindle start to move. note the speed (mine is about 110 to 120 RPM)
3. Max out the motor speed by type S1000 into the MDI, speed was about 12928
4. change the min spped to 120 and max to 12928 ( I think can set to 12500 or anything max speed toy like)
5. key in the min and max in the spreadsheet
6. Type the speed from from the spreadsheet and key in the measured speed, repeat 100 times.
7. generate the Linearity.dat file.

it works within 200rpm + -
Title: Re: Spindle calibration, how I manage to get it working
Post by: cwciwatch on March 17, 2017, 09:54:54 PM
Thanks resalles for the script.

I got Spindle calibration to work with your script.

Here are the step i took to get it to work.
1. I set the pulley to 1, min to 0, max to 1000.
2. turn on the spindle, set speed from S0 till the spindle start to move. note the speed (mine is about 110 to 120 RPM)
3. Max out the motor speed by type S1000 into the MDI, speed was about 12928
4. change the min spped to 120 and max to 12928 ( I think can set to 12500 or anything max speed toy like)
5. key in the min and max in the spreadsheet
6. Type the speed from from the spreadsheet and key in the measured speed, repeat 100 times.
7. generate the Linearity.dat file.

it works within 200rpm + -

Thank you very much!
Title: Spindle calibration, how I manage to get it working
Post by: KelvinG on March 22, 2017, 05:02:00 AM
I have a 3 axix CNC converted Conquest mill (from Chester UK) controlled by Mach3/Geckodrive G540 and recently got quite happy to make it work with the VFD (RPM controlled by Mach3).

For that I simply disconnected the potentiometer from the mill speed control  and replaced it by an analog optocoupler and a resistor. I know G540  VFD is already isolated, but the mill circuit board was powering the low voltage electronics directly from the 220V using a voltage divider... so it got me scared to simply plug the G540 directly.

The advantage of this approach is that I got a working VFD almost for free. The disavantage is that it is highly non-linear. The spindle only starts to turn at about 30 RPM when I command 400 RPM, it  gets close to the commanded value at about a 1000RPM then it undershoots.

So I thought "Lets use the Mach3 spindle calibration and it will work fine"... Well, wrong... for some reason the calibration, at least in my version of Mach3 would not work. Probably it works for correcting small deviations but for my cheapo VFD it was hopeless...

So I read some threads here about this problem and it seems somewhat usual. People referred to a file named "Linearity.dat" so I could not resist taking a look at it.

Long story short, the linearization strategy implemented in Mach3 is actually works great. The problem seems to be the function that generates the file, it probably does not assume that a VFD could be as bad as mine  :D.

So I wrote an Excel table that takes as input the commanded RPM vc Real RPM and produces a  "Linearity.dat" file that works fine.

I am attaching the Excel file so that you guys can try it out. Can´t guarantee anything but that it worked for me. But if some of you have the same issue, I hope it helps.

The way it works is the following:

1- Only make changes to the GREEN cells.
2- Enter your min and max RPM. It will generate a list with 101 input values for you to fill.
3- For each entry, command your machine to spin at the COMMANDED column (blue), take note of the real RPM it is spinning and enter it in the MEASURED column (green)
4- Click the CREATE FILE button. It will run a macro that writes a linearization file. That is the  "Linearity.dat" file that Mach3 is able to read.
5- Shut down Mach3 and copy that file as to replace the one you have. In my case it happens to be at "C:\Mach3\macros\Mill_RS".
6- Start Mach3 and try to see if the RPM is correct now.

Hope it helps.


 
Could someone send me a copy of VB macro in this spreadsheet?  The one used to create the .dat file. Everytime I download the spreadsheet excel tells me macro is corrupt and deletes it.

Thanks,
Kelvin

Sent from my SM-P900 using Tapatalk
Title: Re: Spindle calibration, how I manage to get it working
Post by: Sanea1986 on April 15, 2020, 05:10:18 PM
It work for my NEWever VFD.
Thanks a lot.
Title: Re: Spindle calibration, how I manage to get it working
Post by: hobbybob on May 15, 2020, 11:52:30 AM
Hi Roger,

Hope you are still active on this forum.
Indeed i get the #REF! errors.

I want to measure from 500 to 24000. But if i input anything over 1500 in D3 i get the #REF! errors.
You write above:

You can NOT freely increase the maximum speed in the spreadsheet without updating the observed spindle speed column, as that may create invalid data in some spreadsheet cells (#REF I think).

How can i use your sheet and be able to measure from 500 to 24000 to create a nice linearity.dat file ?


Title: Re: Spindle calibration, how I manage to get it working
Post by: rcaffin on May 15, 2020, 06:32:34 PM
Hi Hobby

Ah - not my spreadsheet actually. I did play around with it a bit but the download was missing bits.
In the end I simply used a linear dat file and left it at that. FAR more important for me was using the latest ESS driver and getting it to work for threading - which it does.
The problem with the first S command after starting Mach3 remains. One gets used to it ...

Sorry about that.
Cheers
Roger
Title: Re: Spindle calibration, how I manage to get it working
Post by: ScroungerLee on July 10, 2020, 07:52:21 PM
I had to register again just to post this, hope it helps someone someday.

Here is the macro from the spreadsheet talked about above, attached is a screen shot of the macros in the spreadsheet

Code: [Select]
Rem Attribute VBA_ModuleType=VBAModule
Option VBASupport 1
Sub spindle_correction_write_bin()
  Dim row As Long
  Dim x As Double
 
   
    Open "Linearity.dat" For Binary As #1
   
   
    For row = 3 To 103
        x = Cells(row, "N").Value
        Put #1, , x
    Next
    Close #1
End Sub
Title: Re: Spindle calibration, how I manage to get it working
Post by: modbog on November 29, 2020, 10:30:20 PM
I recently changed drives from a Gecko G540 to a Leadshine MX4660 and later realized it has a 1.1V drop in its PWM to analog circuitry so the 0-10V output is actually 0-9V. As a result my spindle speed no longer tracked with S commands.

After searching found some threads about Linearity.dat, including this one. Unfortunately, I didn't have a copy of excel on my computer so I wasn't able to use the macro to generate the Linearity.dat file. I ended up writing a small python script to take a csv of measurements and output the dat file. Referencing it here in case someone else finds it useful: https://github.com/modbog/mach3linearity

it does some interpolation so I didn't have to take that many measurements to get a pretty accurate result. Here's the input from my test. Left column is the requested RPM, right column is the observed value using a digital tach:

Code: [Select]
0,0
1000,0
2000,1456
3000,2480
4000,4095
5000,5419
6000,6745
7000,8076
8000,9411
9000,10745
10000,12080
11000,13416
12000,14748
13000,16088
14000,17416
15000,18756
16000,20100
17000,21443
18000,21555
19000,21555
20000,21555
21000,21555
21555,21555

After calibration I got pretty accurate measurements.

Code: [Select]
0,0
1000,0
1500,1505
2000,2006
3000,2998
4000,3993
5000,4991
6000,5999
7000,7003
8000,7992
9000,8998
10000,9993
11000,10992
12000,11993
13000,12998
14000,13998
15000,14992
16000,15998
17000,17000
18000,17998
19000,18990
20000,19996
21000,21299
21561,21584

Title: Re: Spindle calibration, how I manage to get it working
Post by: ewqfsac on December 07, 2020, 12:55:25 AM
Very useful information sharing, thank you very much.