Hello Guest it is March 28, 2024, 08:56:33 AM

Author Topic: Custom M-code for punching  (Read 3914 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 »
Hi

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

Regards

KTM

Offline Graham Waterworth

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

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 :-

O0001
#1=481.48
#2=273.08
#3=(#1-#2)/14
G00 G90 X#1 Y49.89
M98 P0002 L14 (RUN SUB 14 TIMES)
M30

O0002 (SUB)
M25 (PUNCH)
G00 G91 X-#3
G90
M99

Graham.

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?

KTM
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
wend


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

Thanks
Brian
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com