Author Topic: Conditional programming  (Read 1458 times)

0 Members and 1 Guest are viewing this topic.

Offline zedodia

  • Active Member
  • Posts: 8
    • View Profile
Conditional programming
« on: March 19, 2018, 08:14:51 PM »
I’ve heard before and read many time Mach 3 doesn’t support conditional programming. Though the posts are many years old. Has this changed at all with an update or anything? (While end if else end)

Does Mach 4 support these conditional programmes? (Ie should I attempt an upgrade from 3 to 4)

Still not sure how to do VB scripts yet and there’s no simple tutorial on them I can find either.
Quite simply (at first) all I want to do is set a program to loop while the Z height changes each loop. This would be much better than copying all the code and pasting with a new Z height.

Offline joeaverage

  • Active Member
  • Posts: 4,520
    • View Profile
Re: Conditional programming
« Reply #1 on: March 19, 2018, 11:17:07 PM »
Hi,
conditionals in Gcode files are part of MacroB programming having being made famous by Fanuc.

Mach4 Industrial has MacroB programming whereas Mach4 Hobby does not. Mach3 doesn't have it and given
all Mach3 development ceased five years ago it will never have MacroB.

Craig
My wife left with my best friend...
     and I miss him!

Offline rhtuttle

  • Active Member
  • Posts: 346
    • View Profile
Re: Conditional programming
« Reply #2 on: March 20, 2018, 11:02:51 AM »
What Craig said is true.  You can do what you said though.

#1=.050 ; starting z value
M98 P1234 L10  call subprogram 10 times
M30

o1234
;do your moves
#1=[#1-.003] ;decrement Z
M99
%



Otherwise you need to use VB scripts.

HTH

RT

Offline zedodia

  • Active Member
  • Posts: 8
    • View Profile
Re: Conditional programming
« Reply #3 on: March 20, 2018, 10:05:34 PM »
Makes sense. Just can’t get it to call a sub. Please see if this is right or what I’m missing.

Main prog is on the desktop called test.nc and sub is called 02.tap and is in the subroutines folder in Mach 3.

Test.nc
————

G0X0Y0Z0
F2000.0
G1 X100.0 Y0
G1 X100.0 Y100.0
G1 X0 Y100.0
G1 X0 Y0

M98 P02 L1


———prog finish——-

02.tap
————

G1 X200.0 Y0
G1 X200.0 Y200.0
G1 X0 Y200.0
G1 X0 Y0
M99

———subprog finish———

It works in NCplot but will not work in Mach 3. Any clues?

Offline zedodia

  • Active Member
  • Posts: 8
    • View Profile
Re: Conditional programming
« Reply #4 on: March 20, 2018, 10:22:22 PM »
Just noticed that every gcode program hangs at ‘please wait.... generating toolpaths”

So I’ll have to sort that first I feel. Weird. Never had this drama before.

Update**** restart windows and I can load progs again. But still won’t load subs.
« Last Edit: March 20, 2018, 10:25:50 PM by zedodia »

Offline rhtuttle

  • Active Member
  • Posts: 346
    • View Profile
Re: Conditional programming
« Reply #5 on: March 20, 2018, 10:27:07 PM »
Your m98 is calling p02

You don't have a
o02
You have a
o2 defined

Offline zedodia

  • Active Member
  • Posts: 8
    • View Profile
Re: Conditional programming
« Reply #6 on: March 20, 2018, 10:31:23 PM »
Sorry I don’t understand. Do I need to add o02 into the script?

Offline rhtuttle

  • Active Member
  • Posts: 346
    • View Profile
Re: Conditional programming
« Reply #7 on: March 20, 2018, 10:37:28 PM »
M98 calls a subroutine not a tap/gcode file.  The subroutine is defined after.the main gcode(m30) and starts with the letter o followed by the same numbers that follow the p parameter in the m98 call.

Offline zedodia

  • Active Member
  • Posts: 8
    • View Profile
Re: Conditional programming
« Reply #8 on: March 20, 2018, 11:09:38 PM »
Ah ok. So the subroutine is still within the same file.test.nc.

So I don’t need to put anything in the mach3/subroutine folder? Doing this works on ncplot with the looping z increment but in Mach 3 it doesn’t alter the z increment.

Code now is:

Test.nc
————
#100=10.0. (Z)
G0X0Y0Z0
F2000.0
G1X100.0 Y0 Z#100
G1X100.0 Y100.0
G1X0 Y100.0
G1X0 Y0

M98 P02 L5
M30

O02
G1X200.0Y0Z#100
G1X200.0Y200.0
G1X0Y200.0
G1X0Y0
#100=[#100+10.0]
M99

————prog finish———-

Am I missing anything else?

So what’s the subroutine folder for then?


Offline zedodia

  • Active Member
  • Posts: 8
    • View Profile
Re: Conditional programming
« Reply #9 on: March 20, 2018, 11:31:33 PM »
BAM!!! Needed a ‘%’ after M30 and M99 and it looks promising.