Hello Guest it is October 09, 2024, 09:20:50 PM

Author Topic: Modbus and VFD in Mach4  (Read 7149 times)

0 Members and 1 Guest are viewing this topic.

Modbus and VFD in Mach4
« on: July 12, 2015, 12:14:39 AM »
Hi all,

First time posting - sorry I am green.

I have a question about setting up communication between my VFD using Modbus in Mach 4, evaluation version.  I would like to get my VFD working before buying the lic.

FYI, I have no issues communication to my VFD using Mach3 or QModBus.  

Simply, I would like to understand what code needs to be placed into the "m3" LUA script to tell the spindle to run CW.  

This what I have tried:  mc.mcRegSetValue("modbus0/DIR0-0", 01)  

Let's assume that I configured the Modbus plug-in correctly.

Thanks for your help,  Rick
Re: Modbus and VFD in Mach4
« Reply #1 on: July 12, 2015, 06:00:59 PM »
Okay, it was my Modbus configuration.  I forgot to +1 to the "Modbus Register"  On Teco EV VFD the Run, Stop, Reverse, Forward is register 230 or 00E6H (in HEX).  I just needed to input 231 (230+1) to get VFD running.  As for the code in Mach4 "m3". This worked for me:

function m3()
inst=mc.mcGetInstance()
mc.mcCntlSetLastError(inst, 'Spindle CW');

hregDIR = mc.mcRegGetHandle(inst, "modbus0/DIR");
mc.mcRegSetValue(hregDIR, 11);

end

Note: 00 = Stop, 01=CW, 11=CCW.

Now I need to find out what variable holds the "S" (speed)

To be clear:  When I load a NC program and I have a line with S2000 M3 in it to set the speed and spin direction,  I need to understand what variable holds the "S2000" so I can capture it and send it to my VFD.

I'll post my finding when I figure it out.  

Thanks, Rick

 
Re: Modbus and VFD in Mach4
« Reply #2 on: July 13, 2015, 02:03:45 AM »
I'm going out on a limb here....

#variable 2131 = current spindle sfpm
#variable 2132 = current spindle speed

another option is to create a marco to run at start which searches the gCode file for all S words and assigns those speeds into a global table or register(s) and redirect those values to your VFD when the required gCode Line Running is about to change the spindle speed. idk, I think I just talked myself in a circle...i'm tryin, just brainstorming...
Re: Modbus and VFD in Mach4
« Reply #3 on: July 16, 2015, 01:31:04 AM »
Well going out on a limb is something you do well!  Variable 2132 is exactly what I was looking for and my machine is working well. A big THANK YOU to you Screwie Louie!!

Here is the code that works for me.

Local SPD = mc.mcCntlGetPoundVer(inst, 2132);
hregSPD = mc.mcRegGetHandle(inst, "modbus0/SPD");
mc.mcRegSetValue(hregSPD, SPD);

I put this code into Operator/Edit Screen/PLC Script.  I read it runs in a continuous loop every 50mS or so.  So my code just keep looking for a change in the "S" speed in the NC code.

This may not be the best place for the code but what do I know, I'm a mechanical engineer.   ;)

I hope this helps whomever is attempting to run their TECO VFD over Modbus.

Rick 
Re: Modbus and VFD in Mach4
« Reply #4 on: July 16, 2015, 11:51:12 AM »
Is there any information been posted on the forum as to why the Mach3 plug-ins do not work with Mach4, in particular the sebastien  (royaumedeole.fr) plug in that works well with Mach3?
N.

Offline dude1

*
  •  1,253 1,253
Re: Modbus and VFD in Mach4
« Reply #5 on: July 16, 2015, 03:45:16 PM »
it a different program it`s Lua not vb
Re: Modbus and VFD in Mach4
« Reply #6 on: October 28, 2018, 08:16:36 PM »
Hi Guys,

ive made a very easy setup tutorial for the MACH4 MODBUS and Spindle Control
watch the full post and tutorial here:
http://www.machsupport.com/forum/index.php/topic,38560.new.html#new

regards cncprint.blogspot  Grin