Home
Downloads
Mach3
Plugins
CAM Post Processors
Screensets
Purchase
Support
Forum
Tutorial Videos
Documentation
Yahoo Group
Mach Wiki
Resources
Contact Us
Links
CNCZone
German Forum
Italian Forum
Korean Forum
Portuguese (Brazil) Forum
Russian Forum (RSK CNCROUTER)
Thai Forum
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
May 23, 2013, 09:11:57 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Select from and to languages
Chinese-simp to English
Chinese-trad to English
English to Chinese-simp
English to Chinese-trad
English to Dutch
English to French
English to German
English to Greek
English to Italian
English to Japanese
English to Korean
English to Portuguese
English to Russian
English to Spanish
Dutch to English
Dutch to French
French to English
French to German
French to Greek
French to Italian
French to Portuguese
French to Dutch
French to Spanish
German to English
German to French
Greek to English
Greek to French
Italian to English
Italian to French
Japanese to English
Korean to English
Portuguese to English
Portuguese to French
Russian to English
Spanish to English
Spanish to French
Machsupport Forum
G-Code, CAD, and CAM
G-Code, CAD, and CAM discussions
Newbie question on G-code looping (While, for, etc.)
Pages:
1
Go Down
« previous
next »
Author
Topic: Newbie question on G-code looping (While, for, etc.) (Read 3974 times)
0 Members and 1 Guest are viewing this topic.
Riddler
Active Member
Offline
Posts: 10
Newbie question on G-code looping (While, for, etc.)
«
on:
March 20, 2010, 03:49:05 PM »
This is driving me nuts. I am trying to write a simple G-code program for Mach 3 that needs a simple loop. I have been searching for some example code of how to do a "WHILE" or "FOR" loop and I find examples but when I go to use them in Mach 3 it keeps giving me a error on the first line. Here is a example I tried and did not get to work.
N20 $WHILE P1<= 10
N30 P1=P1+1
N40...
N50...
N60 $ENDWHILE
Here is another that I tried and did not get to work
WHILE[P1LE10] DO1
P1=[P1+1]
;ENTER CODE TO LOOP HERE
END1
I am at a total loss as to what the proper syntax and structure is for Mach 3. Can anyone help with this simple loop?
Another question, is there a PDF or tutorial some where that documents all the loops and how to properly code them? I am also looking for a good book. I have seen the reccomendations on CNC by peter smid. It sounds good but does it cover the mach 3 flavor of G-code? I talked to several people where I worked about my problem and they said it all depends on what controlled you are using. They work in 2-3 different ones and they siad that they are similar but very different also.
Confused
Scott
Logged
Graham Waterworth
Administrator
Online
Posts: 1,707
West Yorkshire, England
Re: Newbie question on G-code looping (While, for, etc.)
«
Reply #1 on:
March 21, 2010, 05:34:36 PM »
The only way to do loops at the moment is by using subs or VB macros
You can use # vars and operators but no IF's or WHILE, GOTO's or conditions LE, etc.
Search the forum for M98 and you will find lots of examples to do loops and conditions.
Graham
Logged
G-Code is on the cutting edge
Autovalues Engineering, CNC machining specialists, Bradford, England
Riddler
Active Member
Offline
Posts: 10
Re: Newbie question on G-code looping (While, for, etc.)
«
Reply #2 on:
March 24, 2010, 07:46:36 PM »
Thank you for clearing that up for me. I had found some examples that had loops but they must have been VB or something. I am going to give M98 a try on my machine tonight. I bet I can get it to work now.
Thanks
Scott
Logged
Deano
Active Member
Offline
Posts: 15
Re: Newbie question on G-code looping (While, for, etc.)
«
Reply #3 on:
July 09, 2011, 12:13:19 PM »
Quote from: Riddler on March 20, 2010, 03:49:05 PM
I am at a total loss as to what the proper syntax and structure is for Mach 3. Can anyone help with this simple loop?
Another question, is there a PDF or tutorial some where that documents all the loops and how to properly code them? I am also looking for a good book. I have seen the reccomendations on CNC by peter smid. It sounds good but does it cover the mach 3 flavor of G-code? I talked to several people where I worked about my problem and they said it all depends on what controlled you are using. They work in 2-3 different ones and they siad that they are similar but very different also.
Confused
Scott
Graham, your reply to Riddler was helpful, but his question about Mach3 g code version vs Smid slipped by. I'm searching for the same. (I posted earlier today) Your reply to Fastest1 (Subroutine confusion, Oct 02, 2010) was great, but maybe a compilation of all the great basic explanations would save hours of noobie search time.
Logged
Graham Waterworth
Administrator
Online
Posts: 1,707
West Yorkshire, England
Re: Newbie question on G-code looping (While, for, etc.)
«
Reply #4 on:
July 11, 2011, 06:14:26 PM »
Hi Deano,
what is it you want to know, give me a clue as to what you want to do and I will try and explain it in simple terms, to write a whole document would take way too long but snippets of code I can do.
Graham
Logged
G-Code is on the cutting edge
Autovalues Engineering, CNC machining specialists, Bradford, England
Graham Waterworth
Administrator
Online
Posts: 1,707
West Yorkshire, England
Re: Newbie question on G-code looping (While, for, etc.)
«
Reply #5 on:
July 11, 2011, 06:35:07 PM »
To do a simple loop you can do this :-
%
O0001 (MAIN PROGRAM)
G21 G40 G80 (STANDARD SETUP LINES, METRIC, CLEAR OFFSETS, CANCEL CANNED CYCLES)
N1 (TOOL 1)
G54 (SELECT FIXTURE OFFSET 1)
T1 M6 (SELECT TOOL 1)
G00 G90 G43 X0 Y0 Z25. H1 S2000 M3 (RAPID 3 AXIS MOVE TO START POINT IN ABSOLUTE AND START SPINDLE)
Z1. (RAPID 1MM ABOVE JOB)
G01 Z0 F150. (FEED TO TOP OF JOB)
X25. F200. (FEED OUT TO 25MM)
M98 P0002 L20 (CALL SUB PROGRAM O0002 20 TIMES)
G00 G90 X0 Y0 (RAPID TO CENTRE OF CIRCLE IN ABSOLUTE MODE)
Z0 (RAPID CLEAR OF JOB)
M30
O0002 (SUB PROGRAM)
(THIS SUB IS CALLED 20 TIMES FROM MAIN PROGRAM)
(BECAUSE IT IS IN INC MODE THE TOOL WILL MOVE Z-1MM EACH PASS AND CREATE)
(A HOLE 50MM DIA + TOOL DIA TO A DEPTH OF 20MM)
G91 (CHANGE TO INCREMENTAL)
G01 Z-1. F50. (FEED DOWN 1MM)
G03 I-25. F150. (MOVE IN A CCW CIRCLE)
M99
%
Once all the remarks are removed the code is very compact and easily changed to alter the bore size.
One thing to remember is that the L command has a range of 0 to 99.
Graham
«
Last Edit: July 11, 2011, 06:44:04 PM by Graham Waterworth
»
Logged
G-Code is on the cutting edge
Autovalues Engineering, CNC machining specialists, Bradford, England
DSLICKER
Active Member
Offline
Posts: 2
Re: Newbie question on G-code looping (While, for, etc.)
«
Reply #6 on:
October 01, 2012, 01:40:30 AM »
IF YOU WANT TO DO A MULTI FIXTURE PROGRAM YOU COULD TRY THIS
O0001
#101=1(tool number)
#102=-.02(TAPPER BLOCK)
G90
G10 L2 P1 X-10. Y-10. Z-10.(G54 WORK OFFSET)
G10 L2 P2 X-10. Y-11. Z-10.(G55 WORK OFFSET)
G10 L2 P3 X-10. Y-12. Z-10.(G56 WORK OFFSET)
T#101 M6
M0
#1=54(STARTING OFFSET)
G0 G90 G#1 X0.5 Y0. S1200 M3
G43 H#101 D#101 Z1.
G0 Z0.1
M98 P0002 L3 (HOW MANY TIMES IT TAKES YOU TO GET TO FINAL OFFSET)
G0 Z10.
M30
O0002
G0 G90 G#1 X0.5 Y0. S1200 M3
G0 Z0.1
g1 z-.1
G1 X5. Z[-.1+#102] F20.(TAPPER BLOCK)
G0 Z.1
#1=[#1+1](CURENT OFFSET PLUS 1)
M99
%
Logged
Deano
Active Member
Offline
Posts: 15
Re: Newbie question on G-code looping (While, for, etc.)
«
Reply #7 on:
February 11, 2013, 08:10:22 AM »
Thanks, Graham and Dslicker, for your response. Sorry this is so long in coming, lots of distractions and a death in the family changed the direction of my efforts for a time. I have a new problem, but I think it needs to be posted in a different thread. Thanks again.
Logged
Pages:
1
Go Up
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Mach Discussion
-----------------------------
=> General Mach Discussion
=> Mach3 under Vista
=> Mach SDK plugin questions and answers.
===> Finished Plugins for Download
=> VB and the development of wizards
=> Brains Development
=> Video P*r*o*b*i*n*g
=> Mach Screens
===> Screen designer tips and tutorials
===> Works in progress
===> Finished Screens
===> Flash Screens
===> JetCam screen designer
===> Machscreen Screen Designer
===> CVI MachStdMill (MSM)
=> Feature Requests
=> Non English Forums
===> Italian
===> French
===> Spanish
===> Chinese
===> German
===> Russian
===> Romanian
===> Japanese
===> Vietnamese
=> FAQs
-----------------------------
*****VIDEOS*****
-----------------------------
=> *****VIDEOS*****
-----------------------------
General CNC Chat
-----------------------------
=> Share Your GCode
=> Show"N"Tell ( What you have made with your CNC machine.)
=> Building or Buying a Wood routing table.. Beginnners guide..
=> Show"N"Tell ( Your Machines)
-----------------------------
G-Code, CAD, and CAM
-----------------------------
=> G-Code, CAD, and CAM discussions
=> LazyCam (Beta)
-----------------------------
Third party software and hardware support forums.
-----------------------------
=> LazyTurn
=> GearoticMotion Preliminary testing
=> Tempest Trajectory Planner
=> Contec
=> CS-Lab
=> dspMC/IP Motion Controller
=> HiCON Motion Controller
=> Third party software and hardware support forums.
=> Galil
=> Newfangled Solutions Mach3 Wizards
=> Newfangled Mill Wizard
=> Mach3 and G-Rex
=> Mesa
=> Modbus
=> NC Pod
=> PoKeys
=> SmoothStepper USB
=> Sieg Machines
=> Promote and discuss your product
-----------------------------
Tangent Corner
-----------------------------
=> Tangent Corner
=> Competitions
=> Polls
=> Bargain Basement
-----------------------------
Support
-----------------------------
=> Downloads
===> XML files
===> Post Processors
===> Macros
===> Tutorials
===> Others
===> Beta Brains
===> Screen Sets
===> Documents
===> MACH TOOL BOX
=> One on one phone support.
=> Forum suggestions and report forum problems.
-----------------------------
Mach4
-----------------------------
=> Mach4 pre-Alpha Testing
Loading...