Hello Guest it is March 28, 2024, 07:32:38 AM

Author Topic: Mach4 Spindle At Speed, Spindle Zero Problem  (Read 20811 times)

0 Members and 1 Guest are viewing this topic.

Mach4 Spindle At Speed, Spindle Zero Problem
« on: September 29, 2017, 06:24:53 PM »
Hi,

When all necessary adjustments made Mach4 does not wait spindle to come at speed entered in gcode or MDI before starting machining.

Delta brand VFD is adjusted to send signals of Spindle at speed and spindle at zero to 2 inputs and they can be seen in diagnostics page and they function ok, in spindle tab wait for spindle to stabilize is selected, but when i hit cycle start machine dive into gcode whlie spindle is still accelerating.

This is clearly a bug in Mach4, is there a solution for this?

Regards,

Hakan
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #1 on: September 29, 2017, 06:51:55 PM »
Hi Hakan,
can you confirm that the spindle setup tab you are looking at is Configure/Mach/Spindle?

If so I think you are misinterpreting the setup you are making. If as you say you've checked the 'wait to stabilise' setting then Mach will be looking
for some spindle feedback to determine whether the speed has in fact stabilised. I expect that Mach is looking for an index pulse or encoder pulse stream.

You have signals from the VFD to indicate whether its up to speed or when stopping that it is stopped. Could you not take the m3/m4 macros and add code
to delay until your upto speed signal comes true? Likewise your m5 script could wait until your stopped signal comes true before returning to the calling
program.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #2 on: September 30, 2017, 05:02:49 AM »
Hi Craig,

When i select 1 input as Spindle At Speed and 1 as Spindle At Zero shouldnt Mach4 automatically look for those signals to check whether spindle is at desired speed or at zero? otherwise why those signals are in the setup? When i said bug i meant this, those signals are not connected to anything whether u assign an input to them or not Mach4 does not take them in to consideration but it should logically.

Well i am not good at in writing codes, can you help me with that? Thanks in advance.

Regards,

Hakan
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #3 on: September 30, 2017, 05:54:45 AM »
Hi Hakan,
I don't know for sure but I believe Mach4 is expecting some sort of feedback pulse and it uses that pulse stream to calculate the
actual spindle speed and display it.
Quote
droTrueSpindle
the name of the DRO in the upper lefthand corner of the Spindle block of controls.
I've yet to find any code that describes how the DRO is updated, I think its part of Machs core nor have I worked out how a pulse input is directed
to the module.

Without some sort of pulse feedback how could Mach ever know the actual spindle speed, it's almost sure that it will differ from the programmed speed.
Exactlty how the signal is assigned and the calculations done I don't know yet.

My understanding is this is the primary method Mach uses to monitor the spindle. I imagine it could be modified to reflect the available input data,
so it could accommodate an index pulse once per rev or an encoder of hundreds of pulses per rev. I note that many VFDs have programmable outputs
to simulate an encoder. Further I note that VFDs can output an analogue voltage equivalent to spindle speed. While direct monitoring of spindle speed
may be the primary method there are alternatives.

The input signals Spindle at Speed and Spindle at Zero are inputs which have been predefined in Mach. The Probe signal is another predefined signal
but it maybe your machine doesn't use it and therefore has no input pin assigned to it. Because Probe is such a widely if not universally used input
it makes sense to have a signal name defined. It analogous fashion the two signals you're talking about are available on just about every VFD and so
make useful candidates as predefined signals.

In your case given that you have wired the controller inputs with these two signals you can assign Mach predefined signals and then use those signals to
effect behaviours you wish, for instance triggering delays in the m3/m4 and m5 scripts. You are already half way to achieving the behaviour you want or
you could abandon that approach and use the more conventional pulse monitoring approach above. May I suggest that you complete the control solution
you've already started. It will require some code additions to m3,m4 and m5. Once you have that operational then you might consider the other approach.
I think that a lot of the required functionality required to make the pulse approach work are already included in Mach and really only requires
settings to be made for it to work. You could then compare the two ideas to see which is best and learn a bunch about Mach/LUA as you do so.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #4 on: September 30, 2017, 12:40:21 PM »
Hi Craig,

"Without some sort of pulse feedback how could Mach ever know the actual spindle speed, it's almost sure that it will differ from the programmed speed.
Exactlty how the signal is assigned and the calculations done I don't know yet."

I am not trying to see spindle's rpm or Mach4 does not need to know the rpm, Delta VFD has a function which makes it send a signal when the spindle reached the commanded rpm by controller this is an internal function, for example in gcode it says M3 S6000, when Mach4 send 6000rpm signal to VFD(pwm signal) VFD reads that as commanded rpm and when spindle reaches 6000rpm it closes a relay and if u connect that relay to an input of pmdx126 u get an input signal of Spindle At Speed so when Spindle At Speed signal turns on Mach4 knows the spindle is at 6000rpm.

So the thing i am trying to do is make Mach4 to acknowledge Spindle At Speed signal as u said it is predefined in it but it does not take that signal into consideration to make the machine stand by until Spindle At Speed signal turns on.

I am not sure if you can make this by altering the M3 M4 or M5 scripts. For example at first i thought to make it work like you but in M3 script it just defines the Spindle to turn in Clockwise direction there is nothing associates with rpm, the rpm is in the gcode after M3 command so how can u read the spindle speed from each gcode by M3 script?

The logical way is this, when u assign the input to Spindle At speed function in Mach4 it should automatically says "Spindle At Speed is assigned" and "i need to wait for that signal to turn on before letting the axis move when Cycle Start pressed". This is why u have Spindle At Speed function am i wrong? Is there any other use of it? Professional machines use that signal like this and every machine waits Spindle At Speed input to turn on before diving in to gcode.
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #5 on: September 30, 2017, 01:36:53 PM »
Hi,
the desired behaviour is that the machine wait until the spindle is up to speed before setting off on its moves.

The machine must therefore measure the spindle speed and compare it against its programmed speed, that is the meaning and use of
'Wait on Spindle to Stabilise' and 'Percentage' entries on Configure/Mach/Spindle page.

If you don't want to use that functionality then use Spindle Up To Speed signal. It is as it stands just a predefined signal, it doesn't do anything.
If you wish it to do something then YOU must program that something.

It certainly is possible to modify the existing m3,m4 and m5 scripts.

I think it will be necessary to add the two signals to the Signal script.
Then have a delay in m3,4,5 until the signal state is true.

If you haven't done any programming in LUA then I suggest
https://www.lua.org/pil/contents.html

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #6 on: September 30, 2017, 02:41:44 PM »
Hi Craig,

you are telling me to learn Lua so that i can implement any function i want, i get it, what i wanted to point out in here is, if it doesnt do anything what is the meaning of predefining it, user can name any input as Spindle At Speed, so if user see a defined signal then he/she assumes it does something..

I will try to modify M3 M4 M5 scripts.

Regards,

Hakan
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #7 on: September 30, 2017, 02:53:28 PM »
Hi,
first you need to add the two signals into the signal library, its a table called SigLib in the screen load script, add the following:
Code: [Select]
[mc.ISIG_SPINDLE_AT_SPEED] = function (state)
    if (state==1) then
        AtSpeed=1
    else
        AtSpeed=0
    end
end,
[mc.ISIG_SPINDLE_AT_ZERO]= function (state)
    if (state==1) then
        IsStopped=1
    else
        IsStopped=0
    end
end,

This allows you to use AtSpeed and IsStopped global variables throughout Mach. If you have a look at the bottom of page 9 and the top of page
10 of the LUA Scripting Guide in your Mach4 Help Docs you will see that Mach4 has built-in m3, m4 and m5 which cannot in fact be altered. What
you can do is write your own m3, m4 or m5 and Mach will execute your script instead. Any functionality in Machs internal script will have to be duplicated
in your external script in addition to whatever extra 'fruity bits' you want to happen.

Next little trap is that you should name your scripts with lowercase m and the script number without leading zeros. Thus M03 is likely to result in error
whereas m3 will be fine. Remember if Mach doesn't find your script it will use its own, if you name your script badly it may miss the fact that its there.

I will gather some more info and comeback with some suggestions.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #8 on: September 30, 2017, 03:04:08 PM »
Hi,
in modern programming there is a distinction between an object and its action.

In this case we have two signals which have conveniently been predefined by the developers of Mach. We can easily connect them to an input pin
for instance but we could also connect it to some other software event.

So we have a signal defined and logically connected to a trigger of some description. We now have to define what that will mean.

You have a signal Spindle at Speed, what do you want Mach to do with it? Machs not magic nor are the developers clairvoyant....you have to decide what
behaviour the machine should exhibit and fortunately there are some clever and flexible tools for you to do that, it will require some learning.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #9 on: September 30, 2017, 03:22:50 PM »
Hi,
sick of me yet...

On the screen edit page the spindle control button at the lower right of the screen Spindle CW/Stop and SpindleCCW/Stop have two associated
event functions SpinCW() and SpinCCW(). The functions are in the screen load script and are interesting enuf even if simple.

What I suggest is that you replace the event scripts for these two buttons with:
for the left-up script for btnSpindleCW
Code: [Select]
local inst = mc.mcGetInstance();
local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
local sigState = mc.mcSignalGetState(sigh);
if (sigState == 1) then;
    mc.mcCntlGcodeExecuteWait(inst,"m5");
else;
    mc.mcCntlGcodeExecuteWait(inst,"m3");
end;

and for the left-up script for btnSpindleCCW
Code: [Select]
local inst = mc.mcGetInstance();
local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
local sigState = mc.mcSignalGetState(sigh);
if (sigState == 1) then;
    mc.mcCntlGcodeExecuteWait(inst,"m5");
else;
    mc.mcCntlGcodeExecuteWait(inst,"m4");
end;

Now when your Gcode program encounters a spindle start instruction, m3, the macro runs as normal. If you however manually turn your spindle
on it too will execute the m3 macro rather than the built in SpinCW() function which won't have the delay behaviour you want.

Will comeback with some suggestions for the all important m3,m4 and m5 macros shortly.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'