Hello Guest it is April 20, 2024, 05:55:06 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - gidyupp

Pages: 1
1
Mach4 General Discussion / DRO Modbus Question
« on: January 03, 2018, 03:49:06 PM »
Now for a question for the Gurus:
I am trying to add a DRO to show the actual spindle speed as reported by the VFD.  As shown a couple of posts above, I have a modbus register setup (modbus0/actualRPM) that is working, but I need help with the code.
I have a DRO created named 'droTrueSpindle', and have the following code at the end of the PLC script:

Code: [Select]
local vfdspeed=mc.mcRegGetHandle(inst,"modbus0/actualRPM");
scr.SetProperty('droTrueSpindle','Value',tostring(vfdspeed));

What am I doing wrong?

2
Mach4 General Discussion / Re: Mach 4 Machtric 2.2kw VFD Modbus
« on: January 03, 2018, 03:40:13 PM »
One thing I should have mentioned, The automation Direct VFD uses Modbus decimal registers starting at the standard address of 40,001, M4 assumes the address start at 40,000 so you only enter the index number, so 40001 becomes "1", 42331 becomes "2331", etc.  In other words, subtract 40,000 from the addresses shown in the AD manual.

3
Mach4 General Discussion / Re: Mach 4 Machtric 2.2kw VFD Modbus
« on: January 03, 2018, 03:29:59 PM »
Part 2:
The code to make it work
NOTE: SOME OF THIS HAS BEEN MODIFIED FROM THAT POSTED EARLIER IN THIS THREAD TO WORK FOR MY SITUATION, PARTICULARLY THE NAMES I GAVE THE MODBUS REGISTERS AND THE FACT THAT MY VFD USES SEPARATE REGISTERS FOR RUN AND DIRECTION. Again, I'm no programmer so if someone sees an error, please let me know.
 
Replaced leftup code for CW/Stop button:
Code: [Select]
--SpinCW()
--local inst = mc.mcGetInstance();
--local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
--local sigState = mc.mcSignalGetState(sigh);
--if (sigState == 1) then
--    mc.mcSpindleSetDirection(inst, 0);
--else
--    mc.mcSpindleSetDirection(inst, 1);
--end

local inst = mc.mcGetInstance();
local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
local sigState = mc.mcSignalGetState(sigh);
if (sigState == 1) then;
    local rc = mc.mcCntlGcodeExecuteWait(inst,"m5");
else;
    local rc = mc.mcCntlGcodeExecuteWait(inst,"m3");
end;

Replaced leftup code for CCW/Stop button:
Code: [Select]
--SpinCCW()
--local inst = mc.mcGetInstance();
--local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
--local sigState = mc.mcSignalGetState(sigh);
--if (sigState == 1) then
--    mc.mcSpindleSetDirection(inst, 0);
--else
--    mc.mcSpindleSetDirection(inst, -1);
--end

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;

Added line to leftup code for stop button:
Code: [Select]
Shutdown();
CycleStop();

Added line to leftup code for reset button:
Code: [Select]
Shutdown();
local inst = mc.mcGetInstance()
mc.mcCntlReset(inst)
mc.mcSpindleSetDirection(inst, 0)
mc.mcCntlSetLastError(inst, 'diagReset')

Added lines to the end of the screenload script:
Code: [Select]
---------------------------------------------------------------
--  Spindle Shutdown
---------------------------------------------------------------
function Shutdown();
    local inst=mc.mcGetInstance();
    mc.mcScriptExecute(inst,"m5.mcs",0);
end;
---------------------------------------------------------------
-- Cycle Stop function.
---------------------------------------------------------------
function CycleStop()
    mc.mcSpindleSetDirection(inst, 0);
    mc.mcCntlSetLastError(inst,"Cycle Stopped");
    mc.mcCntlCycleStop(inst);
end

---------------------------------------------------------------

Added to the Up Script for the enable button:
Code: [Select]
Shutdown()

Added lines to the end of the PLC script
This was added after the existing “end” statement and before the “--this is the last thing we do….” Line:
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/speed");
mc.mcRegSetValue(hfreq,freq);
scr.SetProperty('dro(128)','Value',tostring(RPM));

Added three macro files to the Profile/Macros folder:
m3.mcs:
Code: [Select]
function m3();
local inst=mc.mcGetInstance();
local hcont=mc.mcRegGetHandle(inst,"modbus0/run"); --run command (0=stop, 1=run)
local hcont1=mc.mcRegGetHandle(inst,"modbus0/direction");--added for direction control (0=fwd, 1==rev)
mc.mcSpindleSetDirection(inst,1);
mc.mcRegSetValue(hcont,1); --set to 1 to run
mc.mcRegSetValue(hcont1,0); --set to 0 for fwd
end
if (mc.mcInEditor() == 1) then
    m3()
end

m4.mcs:
Code: [Select]
function m4();
local inst=mc.mcGetInstance();
local hcont=mc.mcRegGetHandle(inst,"modbus0/run");--run command (0=stop, 1=run)
local hcont1=mc.mcRegGetHandle(inst,"modbus0/direction"); --added for direction control (0=fwd, 1==rev)
mc.mcSpindleSetDirection(inst,-1);
mc.mcRegSetValue(hcont,1); -- set to 1 to run
mc.mcRegSetValue(hcont1,1); --set to 1 for reverse
end
if (mc.mcInEditor() == 1) then
    m4()
end

m5.mcs:
Code: [Select]
function m5();
local inst=mc.mcGetInstance();
local hcont=mc.mcRegGetHandle(inst,"modbus0/run");
mc.mcSpindleSetDirection(inst, 0);
mc.mcRegSetValue(hcont,0);
end
if (mc.mcInEditor() == 1) then
    m5()
end

NOTE: I do not know if the hardwired E-stop function will stop the VFD through software.  Mine has a hardwired E-stop connected to the VFD to force it to shutdown so I'm set.  If your's is not hardwired to the VFD you may need to experiment.

I think that's all of it.
Good luck!

4
Mach4 General Discussion / Re: Mach 4 Automation Direct VFD Modbus
« on: January 03, 2018, 03:17:15 PM »
Hi,
I'm replying to this older thread as I used it as a guide to get an Automation direct VFD working via Modbus.  I had it working with Mach3 and struggled with Mach 4.  I figured I'd summarize the steps I took so future readers may have it a bit easier.  I'm no programmer and I have only a vague understanding of script code, so I probably won't be the best guy to offer support.

This is all based upon the work of joeaverage and Zuxztah, I appreciate the help!

First off, I set up the modbus (Configure>plugins>Modbus) as follows:




The registers for my particular VFD are:
2331  VFD Speed in Hz (includes an implied decimal place, so 4000 = 400Hz)
2332  VFD run command (0=stop, 1=run)
2333  VFD direction command (0=fwd, 1=rev)

8456  Feedback of actual motor speed in RPM (not required, I'm working on a DRO to display this)

Before you do anything else, make sure modbus comms are working by looking at the modbus diagnostic window (Diagnostic>Modbus-Newfangled Solutions)
The following scren shot shows my system running in reverse at 24000 RPM (400HZ):
The green indicators are good, if anything is red you need to fix it.


To make the above communication work, you need to modify the following paramiters in the VFD (via the VFD keypad, this is straight out of the VFD manual):

P3.00: 03 or 04 Operation Determined by RS-485 interface.
Keypad STOP is enabled (03) or disabled (04).

P4.00: 05 Frequency determined by RS-485 communication
interface.

P9.00: xx Communication address 1-254

P9.01: 01 9600 baud data transmission speed

P9.02: 05 MODBUS RTU mode
<8 data bits, odd parity, 1 stop bit>.

To be continued....

5
I'm interested in this as I have the GS3 drive.  Would like to use serial MB if possible.  I have the Automation Direct USB to modbus converter.
I was going to spend some time to figure it out but no point re-inventing the wheel if a solution is already out ther.

Regards,
Mark

Pages: 1