7186
« on: January 27, 2017, 04:33:32 AM »
Hi Zuxztah,
last instalment of code.
This needs to go at the end (or near the end) of your PLC script:
---------------------------------------------------------
-- 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,0) end;
if RPM<mc.mcSpindleGetMinRPM(inst,range) then RPM=mc.mcSpindleGetMinRPM(inst,0) end;
local freq=RPM/6;
local hfreq=mc.mcRegGetHandle(inst,"modbus0/freq");
mc.mcRegSetValue(hfreq,freq);
scr.SetProperty('dro(128)','Value',tostring(RPM));
Note that I have a DRO (dro(128)) that I display the target RPM. Also I used pound variable 2132 to get the current commanded speed,
there is an API function but it didn't work for me.
Just as a matter of interest do you use the 'Always on Top' feature of the Diagnostics/Regfile expand modbus0? Its the pin icon, click it
and you can view your two Modbus registers as you fiddle with the buttons/MDI/Speed_OverRide. Really handy.
Craig