Hello Guest it is May 14, 2021, 07:29:48 PM

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

0 Members and 1 Guest are viewing this topic.

Offline Chaoticone

*
  • *
  •  5,626 5,626
  • Precision Chaos
    • View Profile
Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #70 on: January 31, 2018, 08:27:04 PM »
Yup, then set your stuff in motion in the PLC with the C bits.

If you do it right you can drive the tool changer from 2 sources. Inputs (like push buttons) and modbus (changing bits from Mach). However your right may not require it to be driven from multiple sources so the rest of this may just be noise you have no need to hear....

Input ********* comes on, C bit ********* goes high.

In ladder, if C bit goes high, do your thing, turn that C bit off and turn on the next C bit so it does its next thing. But what happens if that C bit you just turned off is still high because the input is still on? Well, you need to check its state before you do the next thing. But you know if you check in the next rung of the PLC ladder the bit is off because you just turned it off. The ladder will turn the bit back on but not until it gets back up to the top again (which takes about as long as your scan time...... so its real quick) where the input turns that C bit on.

You get around things like this by having a register you write to for stages. Its value is used to check that things are right before doing the next step or stage. Can be a lot to think about but can be worth the effort too.

Another way to do it is have a ladder for each mode (manual/auto). One wont work if the other is on. Modbus ladder is driven by C bits, manual ladder is driven by inputs.

Lots of ways to do it. Just have to play with things until you get it working just like you want it to. When it does that, its right.
;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 #71 on: February 01, 2018, 09:27:32 AM »
That's an interesting point, using registers to keep track of progress.   I like it.     On the next VMC I'm going yk have the carousel rotate with buttons on the back of the machine as well as Mach.   We did this in a hurco to remove tools and replace tools in the carousel while the machine is running.   Our foreman has found this to be very helpful so we're going to so it again on this next machine.   I'm going to keep registers in mind with this one.   Should be a nice project!   Also, Carter is using Mach and physical buttons on his lathe tool changer.
Chad Byrd
Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #72 on: February 01, 2018, 07:04:52 PM »
Yeah, I originally had the tool changer working with an 8 position rotary switch and push button to activate the tool changes. Then when you people taught me about Modbus I just too the switch function out of my ladder program and now Mach sends those commands to the PLC. SO I can let the gcode change the tool, or type it in MDI or still use the rotary switch, but now the rotary switch now does a tool change in mach so it's changing the tool number in mach and moving it to the correct tool change position.

I'm really liking modbus and PLCs, when you realize how easy it is and how you can impliment PLCs with it, the possibilities are endless.

Almost picked up TWO Fadal 4020 VMCs yesterday!!! Auction, perfect condition, went for about $5K each, one 1992 and one 1998. Rigging and transport kept me from buying them. $4000 from LA to SF. or $3200 for one sooo.... I really need to buy a 15K trailer so I can just rent a truck and pick this stuff up myself. They had some OLD but Working perfectly Kitamura Mycenter 1's, could have got one for $50.00!! But again transport.

Offline Chaoticone

*
  • *
  •  5,626 5,626
  • Precision Chaos
    • View Profile
Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #73 on: February 01, 2018, 08:29:37 PM »
 :)
;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 #74 on: February 01, 2018, 11:31:39 PM »
Nice!   We've got a fadal 4020.  Only downfall we ran into was the homing.   They homed inside the servo, so we added home switches.   Other than that, it's a good machine.
Chad Byrd
Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #75 on: February 02, 2018, 10:32:51 AM »
I'm guessing you retro fitted that machine as well? If so why not home inside the servo too? That's what I did on Mori Lathe. My new servos has that option if you want to set it in it's own software. I'm guessing you would have done that if it was possible using the old servos?

I think though my limit switches on the Mori are pretty accurate, but I never bothered to test them because I always though that limit/homing switches weren'' that accurate. I always thought professional machines used an index on a linear scale or servo. I mean some do and some don't, I expect. Plus my machine is from 1978 who knows how worn those are.

The manuf. of the servos said I can enact the pulse index by setting it up in Mach to do it  for me. At the time I didn't know how to maybe I'll explore that now; making a one button startup routine.

Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #76 on: February 02, 2018, 01:20:16 PM »
I never thought about using the index pulse when I first started doing retrofits.   Home switches have always been adequate for our applications.   
The HiCON can use the index pulse of a servo motor.   I plan on utilizing this function on our current lathe project. I've thought about a 1 button startup as well.   Our Haas has a power up button that changes to tool 1 after it homes the machine.   Should be pretty easy to make this type of function.
Chad Byrd
Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #77 on: February 05, 2018, 03:40:45 PM »
Just because I was intrigued by Carter's thought of moving the Turret to a safe position inside the M6 macro, I decided to make a module to do this.  

I've never made a module like this, so it was a nice challenge, but I got it figured out today.  
Thanks to Daz for his Module's video, it was helpful getting it setup.
Once I got it finished, I got rid of all my unnecessary notes and code, took a step back and looked at it.  It is quite straight forward and easy to understand how to use a module.  The hardest part was getting it set up, which was easy enough to do.

local CustomFunction = {}

function CustomFunction.ToolChangePosition()
     local inst = mc.mcGetInstance()
     mc.mcCntlGcodeExecuteWait(inst, "G53 G00 X20.00 Z10.00")
     mc.mcCntlSetLastError(inst, "At tool change position.")
end --ToolChangePosition

return CustomFunction

This is all the code I have in my CustomFunction Module to move to a safe tool change position.  What is nice about this is the ability to add more Custom Functions right into this module.  I had no idea modules were  this powerful.
Chad Byrd
Re: Help with Mach 4 controlling a PLC for tool changes.
« Reply #78 on: February 05, 2018, 05:50:06 PM »
Good job.