Hello Guest it is March 28, 2024, 07:44:55 PM

Author Topic: How to run a script after each Gcode in single step mode  (Read 11212 times)

0 Members and 1 Guest are viewing this topic.

How to run a script after each Gcode in single step mode
« on: June 20, 2010, 06:24:35 PM »
Hi!
As title states I am trying to make Mach3 run a script after completing a G0 movement in single step mode.

The application is a turret press punch, I would like to have Mach3 run a punch macro each time it completes a G00 code. Then resume with the next G00 code after completion.  My idea right now is to use single step mode, and somehow resume with a "Start" from within the macro.

Another thought is to detect movement completion from within the macropump. But not really sure how and which would be the implications when jogging or others.

Any ideas?
Thanks!

Luis

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: How to run a script after each Gcode in single step mode
« Reply #1 on: June 20, 2010, 07:09:31 PM »
Not a good idea to have the macropump do motion control. It is dangerous. The macropump runs continuosly and can start machine movement ANY time the conditions are met. Wether you wanted it to or not AND there is no presice way to override/pause the macropump.

Every CNC punchpress I have seen controlled the punch through Gcode
Re: How to run a script after each Gcode in single step mode
« Reply #2 on: June 20, 2010, 07:43:55 PM »
Gcode or Ladder? Id never use Gcode to control a press. Seems too scary to me.

You would never pass an OSHA safety reg. Keep your phone handy to call 911.
No way to stop it in cycle and now days you have to have that feature on a PP
You might beable to write a brain function to emulate a timed double palm button safety interlock.
But no way to stop it once press is tripped. I dont think the brain is fast enough for that.
There are so many better and safer ways. Just be careful.

Offline KTM

*
  •  92 92
    • View Profile
Re: How to run a script after each Gcode in single step mode
« Reply #3 on: June 21, 2010, 11:23:41 AM »
Punching machines run in single step mode after an M-Code ie: M25. After every line of code, the pate needs to be punched and then continue until another M-code ie: M22, which cancels punching. The macropump will have to look at the M25(set) and M22 (reset) conditions.

On the safety side, there is a light barrier which is connected in the emergency stop circuit around the punching area.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: How to run a script after each Gcode in single step mode
« Reply #4 on: June 21, 2010, 07:31:07 PM »
OK IF I follow you correctly ???   WHere the M25 is a macro that does the punch?  YEP that is all ran from Gcode and you can single step it OR run in auto mode

G1 X1.000 Y1.000 F50
M25 
X2.000 Y2.000
M25
X3.000 Y3.000
M25
Re: How to run a script after each Gcode in single step mode
« Reply #5 on: June 21, 2010, 08:05:58 PM »
Thanks for the replies.

I would understand this instead:

G1 X1.000 Y1.000 F50      % No punch
M25
X2.000 Y2.000                   % PUNCH
X3.000 Y3.000                   % PUNCH
M22
X0.000 Y0.000                   % No punch

Regarding the macropump use it really wouldn't actually do motion control or press move with g.code, it will only send a signal to indicate it is time for a punch, and wait for an input signal to acknowledge its completion and then continue with the program.

Is there a way to catch a Gcode the same way M1030 does with M30??

Luis

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: How to run a script after each Gcode in single step mode
« Reply #6 on: June 21, 2010, 08:34:13 PM »
I really dont see the difference. If you want it to punch just add the Mcode to make the punch cycle where you want it. Then everything acts like a NORMAL gcode operation.  The further away from a normal Gcode process you get the harder it is to CAM

No way to catch the Gcode(;-) like you want.

This will do the same thing. AND IF you want to single step just turn on the single step.

G1 X1.000 Y1.000 F50      % No punch
 
X2.000 Y2.000        move           
M25                      PUNCH
X3.000 Y3.000        move         
M25                      PUNCH
X0.000 Y0.000        move
M30
%

OR for a different approach to the move/hold. This allows you to run in move/hold mode before punch OR turn on block delete and run auto mode.

G1 X1.000 Y1.000 F50   
 X2.000 Y2.000        move
/M1                       Optional hold
M25                      PUNCH
X3.000 Y3.000        move
/M1                       Optional hold
M25                      PUNCH
X0.000 Y0.000        move
M30
%

Re: How to run a script after each Gcode in single step mode
« Reply #7 on: June 22, 2010, 04:59:44 PM »
X2.000 Y2.000        move           
M25                      PUNCH
X3.000 Y3.000        move         
M25                      PUNCH

Is it possible to tell typical CAM software to write down a M25 (or whatever) after every G00 code ??
If not, this would be quite a pain to do manually.  :-\

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: How to run a script after each Gcode in single step mode
« Reply #8 on: June 22, 2010, 06:44:22 PM »
SURE the CAM  can handle it in the post with no problem.  

SHEETCAM would work great for this as it is very capable in 2d work like punchpressing, plasma,laser,etc.

Just put drill points at the punch locations and let SC add a drill cycle at each point AND then MOD the post to output the M25 instead of the G81 drill cycle.

Les over at SC is great at supporting his users by helping with posts mods.

THEN it is very simple to convert a standard Cad drawing to a punch file(;-)

SheetCam, Never go to work without it.  (;-)

« Last Edit: June 22, 2010, 06:50:01 PM by BR549 »
Re: How to run a script after each Gcode in single step mode
« Reply #9 on: June 22, 2010, 07:24:40 PM »
Great tip,
Thanks!