Hello Guest it is May 13, 2021, 03:03:42 AM

Author Topic: Help with Mach 4 controlling a PLC for tool changes.  (Read 11529 times)

0 Members and 1 Guest are viewing this topic.

Help with Mach 4 controlling a PLC for tool changes.
« on: February 13, 2017, 03:25:20 AM »
I've got my PLC and Tool Changer up and running. I have no idea of how to have Mach 4 control the PLC for tool changes.

I'm using a Click PLC, which has Modbus. I also am using a Pokeys 57E if that helps.

Offline Chaoticone

*
  • *
  •  5,626 5,626
  • Precision Chaos
    • View Profile
Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #1 on: February 13, 2017, 10:00:55 AM »
Here is an example of using a ModBus capable PLC with Mach4.

http://www.machsupport.com/forum/index.php/topic,27660.0.html
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #2 on: February 16, 2017, 04:21:46 PM »
Thanks for the link, but I'm not a programmer by any means so a lot of that is gobbly gook to me.

I'm assuming there are 3 things that need to happen:

1. Mach 4 needs to be programmed for automatic tool changes.
2. Mach 4 needs to be setup to talk to the PLC.
3. The plc needs programming to operate the tool changer.

So I do know how to program PLCs and have already done so. I've never used MODBUS or anything other than internal bits, inputs and outputs. I've already written my PLC program and have it operating my tool changer perfectly. Its uses external inputs, buttons, to change positions.

Here's what I need help with:

1. What area of Mach 4 gets the programming to make automatic tool changes? Not sure how to program it or where the programming goes.
2. I don't know how to setup mach 4 to talk to the PLC.
3. Although I've written the PLC program I don't know how modbus works, do I assign internal bits instead of using external inputs? I'm sure I can figure this part out.

If anyone can help I'd appreciate it. I'd need it to be pretty dumbed down for me to understand.

Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #3 on: February 20, 2017, 09:16:15 AM »
We just finished getting a tool changer going with the Click PLC, communicating between the Click and Mach4 via TCP Modbus.

Through testing we learned that there is no need to setup Modbus "Send or Receive" functions in the Click PLC.  There is a direct relationship between the Click "Modbus Address" and the "Register#" in the Mach Modbus Configuration.

I will attach a few pictures to help you visualize what's going on.  

In the Click PLC you have a list of the Modbus Addresses.  Those will be used in the Mach4 Modbus Configuration.

In Mach4 Modbus Configuration, Start a new Modbus Connection and then add a new function.  I'll start with reading inputs from the Click.  (Refer to picture)  Start with "Read Coils", Slave Address didn't matter to me so we set it to 1, Modbus Register is what is important.  Referring to the "Modbus Addresses" Picture, look at X301, the Address is 100097, in the Modbus Register put "97" as the starting point, this is a 16 Point Input Block to for # of registers I put 16, the configuration setup will automatically realize that the #97 is the starting point.  I then named them X301-X316 to keep it a simple relationship with the Click IO Points.  

Outputs are done the same way, except the new function will be "Force Multiple Coils" and you will use the full Address Exp. 8272  (I also added a picture of Outputs Configuration)

Registers are what we use to tell the Click PLC which tool to change to by using the "Read Input Register" and "Write Single Register" functions in Mach4 Modbus.  In the setup, the Register# you use will be a direct relationship to the DS# (Data Bit) in the Click.  


Chad Byrd
Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #4 on: February 20, 2017, 09:23:56 AM »
To setup the Mach IO Config with modbus is very simple, you will notice that you have a new Device to choose from in the IO config in Mach4. 

We use Y001 in the click as a starting point for the Click PLC.  In the M6 Macro we turn on the Y001 Output on and then off.  We set a C# bit in the Click when Y001 Comes on, this C# Bit is what we use to start our tool change subprogram. 

There is also a lua function to wait for a signal before moving on.   http://www.machsupport.com/forum/index.php/topic,31092.0.html  here is thread that will help with this.  In our M6 macro, we wait for the Orient Release signal from the Click to signal Mach4 to continue its own M6 cycle to finish up the tool change on Mach's end.  And don't forget to Reset your C# bit in the last function of your tool change. 

I can add more examples if you need them later. 

Hope this helps.
Chad Byrd
Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #5 on: February 20, 2017, 09:31:08 AM »
Here is the M6 macro we have so far, this is an example of writing the register that the Click will use for the tool # and an example of the signal wait function.
Chad Byrd
Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #6 on: February 20, 2017, 12:13:15 PM »
I haven't looked it over completely yet cause Mach 4 is now not working at all. Estop condition all the time, but THANKS A BUNCH. That's awesome. I'll tackle this when I solve this other problem.
Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #7 on: February 20, 2017, 07:02:19 PM »
Ok I read over all of what you said many time. Still have a few questions.

What is the pic you posted of the Write Single Register, referring to Write Requested Carousel Position, what's that for?

How does Mach talk to the PLC do you have to put the IP address of the PLC somewhere in Mach?

Where do I put the LUA script, what folder and how do I open it to view it?


I wrote my PLC program already with internal bits 'C' to trigger each tool position. Here's some pics.

I don't get the DS registers you're talking about, so mach triggers an output for a tool change "X001" for example that inturn triggers a DS register in Click? So in my program pics you see here I would just add a DS register in front of the X001? Or does the register do something else?

My program works very simple a press of a button, virtual or physical, let's say X001 will run the program for tool change position 1. So I only need 8 inputs (8 outputs from Mach to the PLC). Then (I don't have it programmed in yet) when the tool change is finished Y106 turns on to show the tool change is completed. So I only have one output from the PLC to Mach. How would I set that up?

BTW this helps tremendously.
Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #8 on: February 20, 2017, 10:42:17 PM »
Cartierusm,
There is already an M6 Macro started in your Mach4 Profile.  Once Mach4 is opened, go to "Operator" then "Edit/Debug scripts"  it should open up to the Profile Macros.  In here will be the M6 that has already been provided.  I would suggest copying the original to keep a solid reference point.
 
Functions, write single register and read register.  I use these Registers to tell the PLC what tool to change to, I'm using a side mount tool changer that has an arm to remove the tool from the spindle and put the requested tool in the spindle all in one move.   I can give the Click and actual integer from mach4 to do this.  Registers in Mach4 can be very useful.  They were a bit tricky at first to understand how to get the information from a register and how to write to the register (change it in Mach4)
The Mach4 forum has several examples of how to use them.  
But in the Click PLC, you have different types of data bits.  You are using "C" bits these are on or off, 1 or 0.  There also data bits that can hold real values, integers.  These are labeled DS in the Click PLC.  In Mach4 you can have Modbus Registers that can be read by the Click and visa versa, Click registers that can be read by Mach.  
In your case, You could setup a Write Single Register Modbus Function to tell the Click which tool to change to.  In the ladder, you would use the "Compare" Function.  
          DS1 = 1 -----> Set C1
          DS1 = 2 -----> Set C2
          ETC.  
You would use just one DS#.

I truly am no expert at PLCs or Mach4.  I just played around until I figured out what was working well.  This is my first go at a PLC.  There are several ways to do this.  This just worked well for us.  

In the morning I will try and remember to take some screenshots of where the registers are in Mach4.  

Last thing for the night; to setup a Modbus connection.  Go to Configure.  Plugins.  Modbus.  Here you will create a Modbus connection.  Click the first Icon, here you will name your Modbus connection, I named mine Click because I'm talking to a Click.  You will setup what type of Connection it is.  I'm using the Ethernet click so I just had to put in the IP Address of the Click in the second setup screen.  
Hope this helps.  
« Last Edit: February 20, 2017, 10:45:21 PM by Cbyrdtopper »
Chad Byrd
Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #9 on: February 21, 2017, 12:17:22 PM »
Great thanks. I'll let all this sink in.