Hello Guest it is March 28, 2024, 04:20:52 PM

Author Topic: Mach 4 Machtric 2.2kw VFD Modbus  (Read 22057 times)

0 Members and 2 Guests are viewing this topic.

Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #50 on: January 28, 2017, 04:52:53 PM »
Hi Zuxztah,
I have a new DRO on my screen, I call it the Target DRO, ie the speed I hope the spindle will achieve. The DRO you are talking about is included
in the default Mach4 screen and is called 'droTrueSpindle'.

Note also the code I used to write to my DRO:
scr.SetProperty('dro(128)','Value',tostring(RPM));

ie Mach4 regards or calls my custom DRO  'dro(128)'. My DRO stays live all the time and tells me the speed the spindle will get to if I turn it on
whereas the droTrueSpindle tells me what speed its doing at the moment. If the spindle is not running then it will be zero.

The Estop and in fact a couple of other functions require some consideration. Firstly if you have a look at the "Cycle Stop()" function (in the LUA script):

---------------------------------------------------------------
-- Cycle Stop function.
---------------------------------------------------------------
function CycleStop()
    mc.mcCntlCycleStop(inst);
    mc.mcSpindleSetDirection(inst, 0);
    mc.mcCntlSetLastError("Cycle Stopped");
end

note that it 'stops' the spindle with the mc.mcSpindleSetDirection(inst, 0); statement. It won't stop your spindle tho, you have to change the
spinCntrl register to stop it. Your m5 macro will do it or wherever you require a spindle stop you will have to code a spinCntrl register update
to stop it.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #51 on: January 28, 2017, 05:08:12 PM »
Hi Zuxztah,
have you enabled the spindle rate over-ride, I suspect not. Also have you set up at least one range in Machs Spindle page?, I suspect not.
Without it the max and min spindle speeds are both zero. Have a look at the screen shot.

For the required spindle over-ride enable try this code:
Code: [Select]
---------------------------------------------------------
--          set Target RPM DRO
---------------------------------------------------------
RPM=mc.mcCntlGetPoundVar(inst,2132);
mc.mcSpindleSetOverrideEnable(inst,1);
local OVRenable=mc.mcSpindleGetOverrideEnable(inst);
if OVRenable then;
    local OVR=mc.mcSpindleGetOverride(inst);
    RPM=RPM*OVR;
end;
local range=mc.mcSpindleGetCurrentRange(inst)
if RPM>mc.mcSpindleGetMaxRPM(inst,range) then RPM=mc.mcSpindleGetMaxRPM(inst,range) end;
if RPM<mc.mcSpindleGetMinRPM(inst,range) then RPM=mc.mcSpindleGetMinRPM(inst,range) end;
local freq=RPM/6;
local hfreq=mc.mcRegGetHandle(inst,"modbus0/freq");
mc.mcRegSetValue(hfreq,freq);
scr.SetProperty('dro(128)','Value',tostring(RPM));


Whether you chose to add dro(128) is up to you.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #52 on: January 28, 2017, 05:25:38 PM »
Yes my Mach configuration looks identical, I added a new Dro window, and named it dro(128) instead of 25

And It seems to work perfect :) it shows target rpm :) and the overide seems to be working, it's only the E-stop that's living it's own life now :)
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #53 on: January 28, 2017, 05:27:04 PM »
Hi Zuxztah,
just noticed that the screen shot shows my custom DRO at the lower right hand corner. Note it reads 18000, my commanded or target spindle
speed but the TrueSpindle DRO above and slightly to the left of it shows zero. This IS as anticipated, the spindle is not running...

Also note that I set range 0 to have a min speed of 6000 rpm. My spindle is air cooled and it gets hot if you try to run it slow.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #54 on: January 28, 2017, 05:50:41 PM »
I understand what you mean, my minimal is also 6000 rpm max 24000rpm, it's not healthy to run those spindles under that,

I understand that 6000 = 0 but mine doesn't change at all, and by that I mean the SRO window, it's always 0
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #55 on: January 28, 2017, 05:53:17 PM »
Hi Zuxztah,
now thinking about the Estop.....

Certainly as a safety measure the spindle most stop when the Estop is activated. Many users have a totally separate electrical system that kills
the power supply to the spindle and commonly the servo/stepper drivers as well. I myself do not use that system but rely on Mach to shut the
spindle down. There is some philosophical debate about that. I suspect if you were using this machine in an industrial situation then an 'automatic'
electrical supply shutoff would be legally required.

In absence of such a setup then you are going to require Mach to do something specific to shut the spindle off.

Further Estop is not the only time you want to turn the spindle off. Consider what you expect to happen if you hit the 'Enable/Disable' button,
do you expect the spindle to stop?. I do. What about the 'Reset' button? The standard script which accompanies the button shuts the spindle
down using the same statement as above which of course will not work for your setup, ie Modbus controlled spindle. What about the 'FeedHold'
button?. Do you expect the spindle to stop then?. I do not want it to stop under FedHold but maybe you do.

To my knowledge the 'Enable/Disable' and 'Reset' buttons use the CycleStop() function. Two ways of achieving it are
1) Modify the CycleStop() function to include Modbus shut-off
2)Write your own function instead of CycleStop()

I'm not aware of any argument that suggests one is better than another.

That still does not address the Estop set up however. The only way I can think of to ensure the spindle stops when an Estop signal is
encountered is to 'trap' the signal with either the signal script and/or signal table and execute a spindle shutdown function.

What do you think?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #56 on: January 28, 2017, 06:04:38 PM »
I've hooked up the Physical E-stop to kill the enable signal to the stepper drivers and to tell mach that E-stop is triggered, it would be a good idea to do that for the spindle also, but I don't know if it's a good idea to cut the power? I think about the internal electronics in the VFD? maybe it won't harm the electronics?

it's maybe not as bad as I think, it would be one thing if I had a brake (resistor) on the spindle, available to buy for my VFD,

Feed hold doesn't need any Spindle action? I'm not used to it anyway,

the 1 opinion seems like a good idea, (Modify the CycleStop() function to include Modbus shut-off)

by that you mean to send the stop command to VFD? (decimal 01 to 8192)


« Last Edit: January 28, 2017, 06:07:23 PM by Zuxztah »
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #57 on: January 28, 2017, 06:19:59 PM »
Hi Zuxztah,
I rather questioned the idea of shutting the power off the VFD as well. The manufacturer doesn't recommend it, the manual says to stop
the motor using the normal commands and THEN depower.

If you require an 'Emergency Shutdown' then you have to program you VFD to achieve that and will almost certainly require a brake resistor.

Quote
by that you mean to send the stop command to VFD? (decimal 01 to 8192)

Yes. Alternately you could code:
mc.mc.mcCntlGcodeExecuteWait(inst,"m5");
provided 'inst' is in scope at that point.

E-stop is a valid input signal but I can't find the ENUM for it just at the moment. May have to call on wiser heads.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #58 on: January 28, 2017, 06:30:06 PM »
I have a small idea! there is a run/stop Membrane switch on the VFD, and I have an external panel. it is probably easy to solder 2 wires from a relay to trigger it when E-stop is switched via an output from mach I/O

The VFD parameters are programmed to stop the spindle no matter what if I press that button.

that's the easiest solution and it's not hard on the electronics

but it would be great if it was doable to fix it in the software?

what about:

Yes. Alternately you could code:
mc.mc.mcCntlGcodeExecuteWait(inst,"m5");
provided 'inst' is in scope at that point.

in the m5 macro?


« Last Edit: January 28, 2017, 06:33:06 PM by Zuxztah »
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #59 on: January 28, 2017, 07:32:22 PM »
Hi Zuxztah,
I think its doable in software but can't get it to work at the moment. Will come back to it later when fresh.

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