Hello Guest it is September 23, 2021, 11:20:52 AM

Author Topic: Custom M-code for punching  (Read 3449 times)

0 Members and 1 Guest are viewing this topic.

Offline KTM

  •  92 92
    • View Profile
Custom M-code for punching
« on: June 07, 2007, 03:02:27 AM »

I am currently working on a Mach3 project for a punching machine. I am a PLC programmer
so it is no problem to connect to the PLC (Delta) via modbus ,but I need to create a custom m-code
for the punching function and I have no knowledge of vb script.
The M-code works as follows. M25 - stop axes ,punch (bit Register 2048 in PLC), when punch is in the return position
( register 2050 in plc) restart axis. This will punch one hole at co-ordinates X481.48 Y49.89 (start position for punching).
The H/14 defines 14 additional holes spaced evenly between the start position (X481.48)  and the end position (X273.08)
N170 G01 X481.48 Y49.89 M25
N175 X273.08 H/14



Offline Graham Waterworth

  • *
  •  2,380 2,380
  • Yorkshire Dales, England
    • View Profile
Re: Custom M-code for punching
« Reply #1 on: June 07, 2007, 03:57:00 AM »

G-Code dose not work like that, you can not get mach to split a move into 14 shorter moves, you can only do it long hand or use subs.

You can do this :-

G00 G90 X#1 Y49.89
M98 P0002 L14 (RUN SUB 14 TIMES)

O0002 (SUB)
G00 G91 X-#3


Without engineers the world stops

Offline KTM

  •  92 92
    • View Profile
Re: Custom M-code for punching
« Reply #2 on: June 07, 2007, 06:52:09 AM »
Hi Graham

Thanks for the reply. Lets begin at the beginning.
How do I write the script for the M25.m1s file to execute 1 punch cycle?

Re: Custom M-code for punching
« Reply #3 on: June 07, 2007, 10:56:02 AM »
I don't know if the modbus coms are going to be as fast as you like :( They are slow!!!!!

if I was to do this project I think I would make a script that looked like this :

'M25 Cycle Punch

ActivateSignal(OUTPUT3) '//tun on output 3 to cycle the punch
Code"G4 P.2" '//Keep the output on for .2 sec
DeActivateSignal( OUTPUT3 ) '//Turn the output off

While(GetModoutput(2)) '//see if the up has been hit
    Code"G4 P.5" '//if the up has not been hit dwell for .5 sec

None of this is tested but it will give you a start :)

Fixing problems one post at a time ;)