Hello Guest it is April 29, 2024, 08:59:03 AM

Author Topic: Mach4: Need help with a macro for lathe turret.  (Read 2218 times)

0 Members and 1 Guest are viewing this topic.

Offline Graham Waterworth

*
  • *
  •  2,673 2,673
  • Yorkshire Dales, England
    • View Profile
Re: Mach4: Need help with a macro for lathe turret.
« Reply #10 on: December 05, 2021, 10:24:54 PM »
The drawing you posted are too small to read so its hard to tell just what is needed.

If you have a pulse for every tool then that is the one you need to check.

if moving from tool 1 to tool 3 you will have 2 pulses one for tool 2 and 1 for tool 3,  so you need a table of waits.

some thing along the lines of

moves = currenttool - nexttool + 8

if moves = 8 then
  message("tool is already in position")
else
  "unlock turret"
  "start turret running"
  if moves = 1 or moves = 15
    "wait for signal to go low"
    "wait for signal to go high"
  end if
   if moves = 2 or moves = 14
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
  end if
   if moves = 3 or moves = 13
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
  end if
   if moves = 4 or moves = 12
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
  end if
   if moves = 5 or moves = 11
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
  end if
   if moves = 6 or moves = 10
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
  end if
   if moves = 7 or moves = 9
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
    "wait for signal to go low"
    "wait for signal to go high"
  end if
"stop motor"
"check inputs for correct poition"
"lock turret"
"set current tool to next tool"
End
« Last Edit: December 05, 2021, 10:33:03 PM by Graham Waterworth »
Without engineers the world stops
Re: Mach4: Need help with a macro for lathe turret.
« Reply #11 on: December 06, 2021, 09:08:34 AM »
Aaronky; I use the Click PLC all the time here in the shop.  Mostly I put them on machines with Mach4 to handle most of the IO and trivial tasks I don't want to code in Mach4.  I even use the Click for lathe turret tool changes. 
Chad Byrd
Re: Mach4: Need help with a macro for lathe turret.
« Reply #12 on: December 06, 2021, 09:11:49 AM »
OK that's making more sense now. I also posted a link with a better detailed drawing a few post after that. The response time is fairly fast in my opinion. Do you feel this is better and more reliably done with a plc? Or is mach4 and a smoothstepper fully capable?
Re: Mach4: Need help with a macro for lathe turret.
« Reply #13 on: December 06, 2021, 09:13:37 AM »
Good to know Chad, thanks for your input. Do you feel like the plc and module I posted would be sufficient? The control board and the turret use 24v so it should be compatible I think. Are the click units fairly easy to create the logic for?
Re: Mach4: Need help with a macro for lathe turret.
« Reply #14 on: December 06, 2021, 09:19:18 AM »
Yes, I always get ethernet, mainly because I use TCP Modbus communication between the Click and Mach4 and it is much faster file transfer.  As long as you only need the 8 in and 6 out that should work. 
As far as creating logic.  It is all ladder logic, if you know how to do that then it is fairly straight forward; if not, YouTube is your friend.  The first time I ever used a PLC was to do a tool change on a Hurco VMC; fairly extensive but I got it figured out pretty quick. 

On this forum, I'm sure everyone will have their own opinion, use a PLC or just code the tool change.  To me, if you are using a stepper or servo for turret position, I would code it.  If you are using switches, counting mechanism, or some other mechanical way of determining position, I would personally use a PLC because it is easier for me to do.   
Chad Byrd
Re: Mach4: Need help with a macro for lathe turret.
« Reply #15 on: December 06, 2021, 09:29:47 AM »
I think that is the route I'll go. How do you use the another ethernet with mach. Do you have several rj45 inputs? Or a switch?
I have 6inputs and 2 outputs with the toolchanger. How does the plc communicate if I cannot use ethernet? I would need 3 more inputs so a total of 9 so I could tell the plc between those 3 inputs which of the 8 tools to call? Or is that wrong?
Re: Mach4: Need help with a macro for lathe turret.
« Reply #16 on: December 06, 2021, 09:39:46 AM »
I have a switch that connects the HiCON motion controller and the Click PLC to the computer.
https://www.machsupport.com/forum/index.php?topic=34228.0  This thread is helpful getting modbus communication set up, and I think it has an M6 macro in there as well.
Chad Byrd
Re: Mach4: Need help with a macro for lathe turret.
« Reply #17 on: December 06, 2021, 11:53:39 AM »
I looked through it briefly, it will be very helpful when I go to set it up. What kind of ethernet switch do you run?
Re: Mach4: Need help with a macro for lathe turret.
« Reply #18 on: December 06, 2021, 02:48:01 PM »
Can I just use the USB 3.0 instead of the ethernet on the plc?
Re: Mach4: Need help with a macro for lathe turret.
« Reply #19 on: December 06, 2021, 03:25:01 PM »
I have never used USB PLC so I do not know.  We have had luck with cheap switches off of Amazon or eBay.  I now get the expensive ones from automation direct; I know these won't mess up on me. 
Chad Byrd