Hello Guest it is April 21, 2021, 01:57:03 PM

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

0 Members and 1 Guest are viewing this topic.

Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #40 on: January 28, 2017, 02:37:19 PM »
It works now! :) I Edited the modbus configuration and also found out that I had a uppercase letter on SpinCntrl that was the problem:)

Video of it working:
https://youtu.be/yTqMH4h2jYE

Now to the last script that you told me to place close to the end in the PLC script? where do I put it? in Lua script?

Code: [Select]
RPM=mc.mcCntlGetPoundVar(inst,2132);
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));



Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #41 on: January 28, 2017, 02:41:06 PM »
Why did you name them that way?

I have absolutely no idea, I'm a newbie you know xD
« Last Edit: January 28, 2017, 02:42:40 PM by Zuxztah »
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #42 on: January 28, 2017, 02:53:55 PM »
Hi, I did just found out that the m3,m4,m5 commands doesn't listen to E-Stop? When the Spindle is running it continues to run even if I press the physical E-stop or "Disable" button in Mach,

Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #43 on: January 28, 2017, 02:55:11 PM »
Hi Zuxztah,
with the screen editor open highlight the very very topmost item of the Screen Tree Manager, your screenset, presumably one you named.
Now open the Events tab and the various scripts are listed, including the PLC script. Open it in the editor as you would a button, ie click on it
and then the rightmost extension.

Scroll down to the last statements of script:

--This is the last thing we do.  So keep it at the end of the script!
machStateOld = machState;
machWasEnabled = machEnabled;

Clearly stated these must be at the end of the script. I put the speed code immediately in front of those:

Code: [Select]
---------------------------------------------------------
--          set Target RPM DRO
---------------------------------------------------------
RPM=mc.mcCntlGetPoundVar(inst,2132);
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));


--This is the last thing we do.  So keep it at the end of the script!
machStateOld = machState;
machWasEnabled = machEnabled;

Craig
My wife left with my best friend...
     and I miss him!
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #44 on: January 28, 2017, 03:09:44 PM »
It seems to be working with S????? Command but not with the slider/SRO% functions on Mach screen,

If I send MDI

S12000 M3 it spins up at correct rpms (the vfd display shows 12000rpm) and if I change the S value it changes speed, but still no response or numbers in Mach (Spindle sliders/SRO%)
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #45 on: January 28, 2017, 03:51:58 PM »
Hi Zuztah,
couple of issues.

Easy one first: you may note in the code in the PLC script that sets the speed I put the following test:

local OVRenable=mc.mcSpindleGetOverrideEnable(inst);
if OVRenable then;
    local OVR=mc.mcSpindleGetOverride(inst);
    RPM=RPM*OVR;
end;

My guess is that your machine does not have the Spindle OverRide enabled. Either delete the test or manually write the SpindleOverrideEnable bit:

mc.mcSpindleSetOverrideEnable(inst,1);
local OVRenable=mc.mcSpindleGetOverrideEnable(inst);
if OVRenable then;
    local OVR=mc.mcSpindleGetOverride(inst);
    RPM=RPM*OVR;
end;

The next issue is a little more serious namely that the spindle doesn't turn off.

In Screen Edit mode have a look at the properties of the two screen buttons...
near the top of the properties list there are entries;

Enabled
Hidden
Enabled with Machine
Enabled States    -- which can be expanded.

Obviously you want the buttons enabled so check Enabled
Uncheck Hidden  -- so you can see it!
Uncheck Enabled with Machine  -- ie the buttons don't work with the machine disabled
Expand Enabled States and check ALL or individually check the states for which you wish the buttons to operate. You will have to experiment with
those to work out what they all mean, I sure as hell don't.

These properties define when the button works or not. It does not solve the problem of the spindle not responding to the Estop.
I think it may be necessary to modify the 'Disable' script to turn the spindle off. I will experiment some more and report back.

Craig
My wife left with my best friend...
     and I miss him!
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #46 on: January 28, 2017, 04:27:21 PM »
hello! :) It didn't work with
Code: [Select]
RPM=mc.mcSpindleSetOverrideEnable(inst,1);
local OVRenable=mc.mcSpindleGetOverrideEnable(inst);
if OVRenable then;
    local OVR=mc.mcSpindleGetOverride(inst);
    RPM=RPM*OVR;
end;

or Without the RPM= at the beginning


But With this code it works, it listens to the S-Commands, but shows no RPM in the SRO window, If the SRO is supposed to show the running RPM,
Code: [Select]
RPM=mc.mcCntlGetPoundVar(inst,2132);
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));

I think the states of the buttons are correct, when I press disable then I'm not able to start the spindle, neither to send any commands via MDI, but if I press disable or press my physical E-Stop when the spindle is on the spindle continues in the same state as before.ยจ

The button scripts for SRO%:
On Update Script and
On Modify Script it's just empty,

I don't know if you also run wxRouter.set screen set? its different from the others, and probably only scripted for basic Analog functions?  
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #47 on: January 28, 2017, 04:33:06 PM »
Hi, Somehow the Spindle-Override started working, all the buttons work now.  :) :) ;)

The only problem is that SRO% stays put at 0 and the E-Stop response.
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #48 on: January 28, 2017, 04:35:00 PM »
Hi Zuxztah,
not entirely surprised, look at what you've witten:

 RPM=mc.mcSpindleSetOverrideEnable(inst,1);

You have set the RPM to the return code of the mcSpindleSetOverrideEnable function which doesn,t make any sense at all.

Craig
My wife left with my best friend...
     and I miss him!
Re: Mach 4 Machtric 2.2kw VFD Modbus
« Reply #49 on: January 28, 2017, 04:40:26 PM »
It's still using the first code you sent, I tried with and without RPM= For the latest code but didn't work,
« Last Edit: January 28, 2017, 04:43:21 PM by Zuxztah »