Hello Guest it is April 18, 2024, 11:50:28 AM

Author Topic: Probably simple but...(G-Code help)  (Read 24867 times)

0 Members and 1 Guest are viewing this topic.

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Probably simple but...(G-Code help)
« Reply #20 on: January 11, 2016, 03:08:40 PM »
Apart from my little oddity with the G04, I need a little help with control logic - brains etc, here's what it needs...

The variable #15239 / 1239 is set to 1 or 0 by G-code in the probe subroutine, this variable is monitored by a brain which activates/deactivates output2 (extends or retracts the probe)

This works perfectly UNLESS g-code is loading or you do a path re-gen and it runs the code again as it does when loading - this has the effect of slapping the probe up and down multiple times as it reads the subroutine at every call.

So I am looking for a smart way to block operation when its parsing code.

I have tried to use the other output and the variable AND'ed together in the brain, which works BUT not when i do a dry run or drill holes with the torch as output 2 controls my extract fan and that is off when dry running or drilling so that idea fails.

Is there a smart way to do this please???
« Last Edit: January 11, 2016, 03:11:38 PM by Davek0974 »

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Probably simple but...(G-Code help)
« Reply #21 on: January 11, 2016, 03:25:11 PM »
Use while Isloading() to block the function so that when it is loading the file it cannot function. With a brain you should be able to monitor teh Isloading LED. Just thinking off the top of my head.

I am not sure what you mean by dry run. Do you run teh entire program ??   I do use a dry run feature but it only runs teh outside contour of the part to see IF it fits the material and it does NOT run the TOM or fire the torch when it runs.

(;-) TP

Re: Probably simple but...(G-Code help)
« Reply #22 on: January 11, 2016, 03:28:35 PM »
Apart from my little oddity with the G04, I need a little help with control logic - brains etc, here's what it needs...

The variable #15239 / 1239 is set to 1 or 0 by G-code in the probe subroutine, this variable is monitored by a brain which activates/deactivates output2 (extends or retracts the probe)

This works perfectly UNLESS g-code is loading or you do a path re-gen and it runs the code again as it does when loading - this has the effect of slapping the probe up and down multiple times as it reads the subroutine at every call.

So I am looking for a smart way to block operation when its parsing code.

I have tried to use the other output and the variable AND'ed together in the brain, which works BUT not when i do a dry run or drill holes with the torch as output 2 controls my extract fan and that is off when dry running or drilling so that idea fails.

Is there a smart way to do this please???

why do you need to use a brain.... why not an M-code to trigger the output directly?
Rob

Albert Einstein ― “If you can't explain it to a six year old, you don't understand it yourself.”

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Probably simple but...(G-Code help)
« Reply #23 on: January 11, 2016, 03:35:06 PM »
Use while Isloading() to block the function so that when it is loading the file it cannot function. With a brain you should be able to monitor teh Isloading LED. Just thinking off the top of my head.

I am not sure what you mean by dry run. Do you run teh entire program ??   I do use a dry run feature but it only runs teh outside contour of the part to see IF it fits the material and it does NOT run the TOM or fire the torch when it runs.

(;-) TP


How do you control your dry run? It sounds easier than mine which does the full run with TOM and I had to add code to allow it to run motion without an arc-ok signal ;)

WhileIsLoading - would that work during Regen Path too and where would I use it ? I an using G-gode and brain no macro's :)

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Probably simple but...(G-Code help)
« Reply #24 on: January 11, 2016, 03:37:33 PM »

why do you need to use a brain.... why not an M-code to trigger the output directly?

I started out using a macro but was shown it was better to use g-code and a brain - i'll try and find the thread

Here we go...
http://www.machsupport.com/forum/index.php/topic,31543.0.html
« Last Edit: January 11, 2016, 03:40:19 PM by Davek0974 »
Re: Probably simple but...(G-Code help)
« Reply #25 on: January 11, 2016, 03:49:37 PM »
Thanks, where is the list of #vars??  Can you toggle other things too like OEMbuttons and LED's etc?

Rob
Rob

Albert Einstein ― “If you can't explain it to a six year old, you don't understand it yourself.”

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Probably simple but...(G-Code help)
« Reply #26 on: January 11, 2016, 04:01:34 PM »
There is a list, will see if i can find it, you can do quite a few things with a brain

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Probably simple but...(G-Code help)
« Reply #27 on: January 11, 2016, 04:32:36 PM »
In sheetcam I Changed teh ouside profile to include a line after teh M3 runs.  It is the Oword for Gcode subs.

(outside profile)
code
code
M3   (fire the torch)
o549
code
code
etc

Then from a button you use a Trick to directly GOTO teh Oword inside the Gcode program. This only works in ONE direction so there is no need for a return M99 as there is nothing to return to.

Code"M98 P549"
End

The prgram will jump directly to teh Oword(o549) and start running the outside profile . The outside profile is the tail end of the Gcode so when it completes it simply rewinds and is ready to run OR repeat the dry run if needed.

(;-) TP

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Probably simple but...(G-Code help)
« Reply #28 on: January 11, 2016, 04:48:23 PM »
Lets see if i grasped this,

you add a line to the POST to place o549 after the outside profile start, then add a button to your screen that calls that part of the code bypassing the M3

To do a dry run you press your new button and NOT the normal start button??

Sounds way better than my version :)

Its a pain running the full code just to check fit etc.



Edit
I can't find "outside profile" anywhere in the sheet cam post docs, is it available in all posts?
« Last Edit: January 11, 2016, 05:00:00 PM by Davek0974 »

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Probably simple but...(G-Code help)
« Reply #29 on: January 11, 2016, 06:14:09 PM »
YOu have teh idea here is a excert from the Gcode program and the Section where teh Post is modified to add teh Oword. You add teh Post code to teh OnPenDown() section.



N6040 X1.0409 Y9.8085
N6050 G28.1 Z0.50
N6060 G92 Z0.0
N6070 G00 Z0.1370
N6080 G92 Z0.0
N6090 G00 Z0.1200
N6100 M03
N6110 G04 P0.3
o549
N6120 X1.0409 Y9.8085
N6130 G01 Z0.0800 F20
N6140 G02 X1.1015 Y9.9299 I0.0911 J0.0304 F130.0
N6150 G01 X1.1047 Y9.9303 F130
N6160 G02 X1.1475 Y9.9024 I-0.0008 J-0.0480 F130.0
N6170 G01 X1.1496 Y9.8986 F130
N6180 G02 X1.4537 Y9.2508 I-2.1754 J-1.4162 F130.0




function OnPenDown()
   if(dist >= (refdistance/scale)) then
      dist = 0
--      modaltext (" G00")
--      text(" Z")
--      number (pierceheight  * scale, "0.0000")
--      eol()
      post.ModalText(" G28.1 Z")
      post.Number(zrefslowdown, "0.00")
      post.Eol()
      post.ModalText(" G92 Z0.0\n")
      post.ModalText (" G00")
      post.Text(" Z")
      post.Number (switchoffset, "0.0000")
      post.Eol()
      post.ModalText(" G92 Z0.0\n")
      post.ModalText (" G00")
      post.Text(" Z")
      post.Number (pierceHeight  * scale, "0.0000")
      post.Eol()
   else
      post.ModalText (" G00")
      post.Text(" Z")
      post.Number (pierceHeight  * scale, "0.0000")
      post.Eol()
   end
   if (preheat > 0) then
      post.Text ("\n G04 P")
      post.Number (preheat,"0.###")
      post.Eol()
   end
   post.Text ("\n M03\n")
   if (pierceDelay > 0) then
      post.Text (" G04 P")
      post.Number (pierceDelay,"0.###")
      post.Eol()
   end
   
   if  (string.find(operationName, _("Outside Offset") )) then
     post.TextDirect("o549 \n")
     post.Text (" X")
     post.Number (Sline1,"0.0000")
     post.Text(" Y")
     post.Number (Sline2,"0.0000")
     post.Eol()
   end
   
   

end