585,715 active members*
3,649 visitors online*
Register for free
Login
Page 1 of 2 12
Results 1 to 20 of 22
  1. #1
    Join Date
    Mar 2004
    Posts
    1542

    parametric programming

    I'm rewritng a very old Gcode program to run on a Camsoft Pro control... FWIW, need more softjaws on a lathe that does not have reversible jaws, have to cut the teeth.

    Anyway, my last two controls allowed versions of IFTHEN and GOTO to loop sections of code over and over (until condition is met) within the Gcode program. I'm not finding a way to do this in Camsoft Pro.

    I'll get this part made by using M98, to get me by, today. I can see M98 just runs the GOSUB command. A clever person could find a way to implement loops and conditional logic within Gcodes using this, somehow.

    Anyway, my question. Can I do loops (GOTO) and conditional branching (IFTHEN) within a Gcode prgram? How?

    Karl

    P.S. This is the code I'm reworking:

    ;TEETH,ADJUST TRUE SOFT JAWS
    ;set second jaw back 0.100", third back 0.200"

    (*BLEC'*',CMST';',CNDL3,CNDR4,ZRSP0,PDOF0.05,FDOV0 *)

    %LAPPER = 0
    %ZDEPTH = 0.5000

    %START:
    %COUNTER = 0
    %ZDEPTH = %ZDEPTH + 0.025 *;DEPTH OF CUT FOR EACH PASS
    %LAPPER = %LAPPER + 1

    G92 X 0.00 Y 0.00 Z %ZDEPTH
    G90
    G00 X 0.000 Y -0.250 Z 0.00


    %LOOP:
    %COUNTER = %COUNTER + 1

    G42 T 02
    G01 X 0.008 Y 0.000 F 3.0
    G01 X 0.122 Y 0.000
    G03 X 0.096 Y 0.750 I -1.304 J 0.330
    G01 X 0.000 Y 0.750
    G02 X 0.008 Y 0.000 I -3.986 J -0.420
    G01 X 0.008 Y -0.125
    G01 G 40 X 0.2857 Y -0.25
    G92 X 0.000 Y -0.25 Z 0.00

    IF (%COUNTER LE 9) GOTO %LOOP

    G54
    G00 X 0.00 Y 0.00 Z 0.00

    IF (%LAPPER LE 5) GOTO %START *;DO ALL TEETH 5 TIMES

  2. #2
    Join Date
    Nov 2004
    Posts
    446
    Ok. I dont know bleep about G Codes but if your interface is anything like mine, this might help you..

    In my interface program.. I can use a GOTO command to jump anywhere..
    But, when I write a program into a text file, I must use the JUMP command inplace of the GOTO command..

    IF THEN still works fine..

    Did this help you? I dont have the pro version.. Mine is just Graphical OI.

    Murphy

  3. #3
    Join Date
    Mar 2004
    Posts
    1542
    Yes, gave me something to look up. I got this nonsence program to show me that IFTHEN and JUMP don't work for me:

    {COUNTER=2}
    N101 G0 X0
    N102 G0 X1
    JUMP N101
    G0 X{COUNTER}
    IF{COUNTER<5}THEN{COUNTER=5}
    G0 X{COUNTER}

    Machine ended up at X=5. I couldn't get the JUMP command right. Check my syntax above, this should have put the control in an endless loop. Machine just moved to X0 then X1 then X2 then X5

    Next I changed < to >:

    {COUNTER=2}
    N101 G0 X0
    N102 G0 X1
    JUMP N101
    G0 X{COUNTER}
    IF{COUNTER>5}THEN{COUNTER=5}
    G0 X{COUNTER}

    Program ran the same,ended at X5, I wanted the IFTHEN to just drop through.

    Have I just got some stupid sytax errors???
    Karl

  4. #4
    Join Date
    Mar 2004
    Posts
    1542
    OK, found one syntax error. Got to pull the {} after the IF. What's wrong with JUMP?

    Karl

  5. #5
    Join Date
    Nov 2004
    Posts
    446
    When I use the JUMP command, I make sure to put the line number on a line by itself.
    IE:

    N101
    !IF Bla Bla THEN JUMP N101

    Try putting your line number on a seperate line..

    Sorry I can not give you better answers.. Your software is a bit different than mine is.
    Im not even sure if it must be on a line by itself.. Its just the way I do it..

    Murphy

  6. #6
    Join Date
    Mar 2004
    Posts
    1542
    I tried every syntax variation I could think of with JUMP. No joy.

    I'll ask Camsoft on Monday.

    Karl

  7. #7
    Join Date
    Nov 2004
    Posts
    446
    Karl,

    The code you wrote did not make sense to me..

    {COUNTER=2}
    N101 G0 X0
    N102 G0 X1
    JUMP N101
    G0 X{COUNTER}
    IF{COUNTER<5}THEN{COUNTER=5}
    G0 X{COUNTER}

    It would seem to me that the computer makes COUNTER=2 then the computer executes X0 then the computer executes X1 then the computer jumps to N101 and executes X0 again..
    From my perspective, it doesnt seem as though the program will every progress to the line GO X{COUNTER} because it is running into the JUMP N101 line..
    Am I mistaken?

    When I was doing mine, I was writing allot of 3 or 4 line programs that did nothing just so I could test code... Seems that's what your doing to in order to experiment. The solution has to be simple..

    What is COUNTER ?? Is this a user defined variable of some sort? Or a function within your software like the ESTOP command? The reason I ask that is because you have the COUNTER enclosed with {} which are math brackets in my software.
    If this is some type of command that is in your software, try removing the {} all together.. The math brackets {} as I understand, are only to be used when the computer must skip forward in the line and perform a math function in order to finish a math function as in:
    IF 5={4+1} THEN BLA BLA BLA.

    Where as, if I just want to compare two simple values the command would be
    IF 5=\12 then bla bla bla
    or
    IF 5=A then bla bla bla..

    Any of this helping??

    Murphy

  8. #8
    Join Date
    Mar 2004
    Posts
    1542
    Murphy,
    This is just a junk program to test things. Makes no sence. No offence, but I can see you don't do G code.

    The Pro manual talks about different syntax for Gcode fiiles. In the control, a variable is: \## and you'd write stuff like \99=1. In Gcode, variables can have names, ie COUNTER, and assigining values must be in curlies {COUNTER=1}.

    G0 is the standard gcode for rapid to point defined in cartesion X Y Z values.

    You're right about the JUMP, the program is ignoring this command. That's what I was testing here.

    Karl

  9. #9
    Join Date
    May 2005
    Posts
    8
    I did not know that g-code supported jump without modification.

    We have a fanuc robot at work that we use those commands on but we use "jmp" instead of "jump"
    It might be a long shot, but you can see if that makes any difference.

    Our code looks like this:

    LBL[515];
    blah blah blah
    JMP LBL[515];

  10. #10
    Join Date
    Nov 2004
    Posts
    446
    Sorry I can't help you more Karl,,

    Your right about one thing.. I dont know bleep about Gcodes!!! LOL.. My CNC control has nothing to do with a normal CNC machining center..

    I have gotten pretty good at using my version of Graphical OI so I thought I would step in and try.. It was a good try .. LOL

    I hope you solve your problem..

    Murphy

  11. #11
    Join Date
    Apr 2003
    Posts
    332
    Variables, Math, Marcos, Jumps and G code usage.

    There are numerous sections of the manuals that cover these topics.

    Usage and Syntax does change between the Graphical OI, CNC Lite, Plus and Professional versions. All of the commands are the same syntax between each package, but the degree of access and power changes. For example a subset of FANUC variables and Macros are only available in the CNC Professional, while CamSoft variables and macros are available in all versions. The JUMP command is available in all versions and the syntax in the same. See below for instructions and examples for proper usage.

    The documentation is lengthy, so we are only providing a limited answer below. The best way to find answers is to electronically search using the Search for Solutions button on CNCsetup.exe or Setup.exe. You can search for answers using key words like a web-browser.

    QUESTION 121
    Can I use variables and/or do math in my G Code Program?

    The controller does have the ability to store unlimited variable names. A legal variable name is a name that begins with any letter of the alphabet. To save a value to a variable in a G Code program, enclose the math and the variable name followed by an equal sign (=) inside curly braces {}. For example, to store 5.5 to the variable

    KEEPME: {KEEPME=5.5}

    For example, to do math to an existing X axis coordinate in a G Code line where X needs to have .75 added to its value, write the G Code line like this: N100 G01 X{5.5+.75} Y6.2 F30

    For example, to add the value of a variable to an existing X axis coordinate in a G Code line, enter: N100 G01 X{5.5+KEEPME} Y6.2 F30

    For example, pre-store the values of variables at the top of the program.

    At the top of the program:
    {FIRSTX=3.489}
    {SECONDY=-4.555}
    {NUMOFPARTS=1}

    For example, to add the variable FIRSTX to the X axis coordinate in your G Code program, enter: N100 G01 X{5.5+FIRSTX} Y5


    QUESTION 197
    What are the limitations of subprograms and variables within the G code program?

    You should first be aware that we allow two formats to be used to assign variables, call macros and do math within the G code program.

    Curly Braces { } or Fanuc Style Square Brackets [ ] may be used in macros or to perform math equations. Named variables can be replaced by FANUC style # numbered variables.

    Example #1
    {MYNAME=45*TAN(MYVARB)}

    Same as:

    Example #2
    #9=45*TAN[#151]

    Whereas:
    #9 same as MYNAME
    #151 same as MYVARB
    [ ] same as { } or ( )

    These variables, in either named or numbered formats, are public/global throughout the entire time the computer remains on even between different G code programs. They will only be erased when you exit the CNC or overwrite them.

    There are three types of variables: LOCAL, USER and SYSTEM variables. LOCAL variables: These are variables that are only available locally within each subprogram. If you call a subprogram with M98, the variables in the main program are not seen by the subprogram. They are not shared. Variables automatically become local when they are placed inside a subprogram.

    USER variables: Are seen by all G code programs since the computer has been turned on. They are known as public or global and can be shared.

    SYSTEM variables: Are for the installer's internal use only in logic routines. All variables in the G code program are also kept totally separate from the SYSTEM variables that the installer used within the internal system logic. The user cannot change the SYSTEM variable values; however, the installer does have access to the USER variables and can internally read and set the USER variables within the G code program.

    Subprograms called using M98 or the command GOSUB must be complete enough to be able to run on their own, by themselves, including the use of user variables in G code, G41, G42, SmartPath or the 3-5 axes tool comp features.

    To access a SYSTEM variable from a G code program:

    Whereas in logic a SYSTEM variable gets assigned like this:
    \100={100+10}

    To make a SYSTEM variable such as \100 accessible to a G code program, reassign it to a named USER variable:
    {SIZE=\100}

    From within the G code program you would write this:
    G00 X{SIZE}


    Other Examples

    When using names as variables for math functions, note where we are using the {} and () characters because the placement of these are important for it to work correctly. LDANG is a named variable that can be used in a G code program and read into logic for calculation or directly used in the G code program. Note that the \112 variable is not valid in a G code program, only in logic files. Refer to the “Pre-Programmed G & M Programming Codes” section in this manual for examples on Fanuc style macro named variables that can be used with trig functions.

    {LDANG=45.0}
    \112={\110*COS(LDANG)/SIN(LDANG)}


    See the 2 pages Titled "Example of macro variables used in G code program."


    QUESTION 49
    How do I write logic to use a value entered by the user in a text box on the screen?


    QUESTION 237
    How can we ask the user a question so that the answer can be used in a G code program?


    JUMP
    This command enables the user to jump or switch the execution of the G code program to a specific G code line that contains a match for the parameter after the JUMP command. The parameter may be a line number, an axis position, a certain feed rate or spindle speed or just about any identical match that can be found in a G code line. The object you are jumping to must appear first in the line of G code. When found, the program will start executing at the line where the match was found. It is important that there is a space following the search item in the G code program.
    EXAMPLE: JUMP N350

    Tech Support
    CamSoft Corp.
    951-674-8100
    [email protected]
    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  12. #12
    Join Date
    Mar 2003
    Posts
    332
    I search all over to the point the lettering on F3 is wearing off.

    In CNCLite I tried a simple back and forth motion:

    N1 G10 Y20.0 F50.
    N2 G10 Y0.0
    N3 G10 Y20.0
    N4 G10 Y0.0
    N5 G10 Y20.0
    JUMP N2
    N6 G10 Y0.0

    (G10 isn't modal.)
    Nuthin.

    Tried
    !JUMP N2

    Nuthin

    Added WAITUNTIL STOP on a prior line.

    Still nuthin.

    In the "Line" box, I will see "2" after the jump line is read, but then the screen flickers just a little and then N10 is run.

    REWIND doesn't.

    Neither does GOTO

    If anyone knows how to use these commands, please step forward.
    In another controller, I just place GOTO Nxx and it does. Without being admonished to read the manual.

  13. #13
    Join Date
    Nov 2004
    Posts
    446
    The following codes are snipets from my text file program and the code(s) work perfectly so I know the syntax is fine. The file name is Program1Test.RUN

    !IF \70=0 THEN JUMP LINE000
    !IF \70=1 THEN JUMP LINE100
    !IF \70=2 THEN JUMP LINE200
    !IF \70=3 THEN JUMP LINE300
    !IF \70=4 THEN JUMP LINE400
    !IF \70=5 THEN JUMP LINE500
    !IF \70=6 THEN JUMP LINE600
    !IF \70=7 THEN JUMP LINE700
    !IF \70=8 THEN JUMP LINE800
    !IF \70=9 THEN JUMP LINE900
    !IF \70=10 THEN JUMP LINE1000
    !IF \70=11 THEN JUMP LINE1100
    !IF \70=12 THEN JUMP LINE1200
    !EOP

    LINE000
    !IF \81<>0 THEN EOP
    !\171=5 :\151=30
    !IF \6=0 THEN EOP
    !\51=\50
    ![GetLoad]
    LINE050
    !IF \1=1 THEN \6=0 :EOP
    ![PutStage1] :EOP
    !EOP

  14. #14
    Join Date
    Mar 2003
    Posts
    332
    Thanks for the offer to help. How do you know the codes work? Is your machine up?

    I tried using JUMP in a conditional IF THEN statement linked to the state of an input and....

    Nuthin.

    Machine just went right past.

  15. #15
    Join Date
    Mar 2003
    Posts
    332
    I can get logic commands to work if I bury them in an M Code in MCODE.FIL:

    !MESSAGE Waiting for BandSaw Proving Switch
    !WAITUNTIL #21=1
    -----M51

    and then

    N1 G1 Y0.0 F20.
    N2 M51
    N3 Y10.0

    but I can't just put them out in the open as:
    N1 G1 zippidee doodah
    N2 yadda yadda
    !WAITUNTIL #21=1
    N3 and continue

    I can't even get Logic Commands to work at all. Just a simple

    !MACHGO 0;10;0;0;0;0
    does nothing

    Whatever

  16. #16
    Join Date
    Nov 2004
    Posts
    446
    Are you in Design mode???

    My software calls it CARD = DEMO

    When I want to make things happen for real, I make it CARD = GALIL

    Also, are your axis all set up correctly??

    Sounds to me like this might be something in your setup.exe program maybe???

    If not, we can go back to syntax checking and stuff but it seems like you would have gotten something to work by now if there wasn't an un-checked roadblock stopping you that you don't know about.

    The commands are not that hard and I have to figure that you have experimented with several versions of the same simple code.. Therefor, lets look for something else that could be wrong..

    Hmmm.

    Murphy

  17. #17
    Join Date
    Mar 2003
    Posts
    332
    My machine is running G code motion in six axis, but I'm just getting to all the other features.
    I'm used to another application where I can write goto or wait#xx directly in a line of code without having to define it as required in camsoft.

    There is a line in the camsoft manual "Logic routines can be written into any of the Logic Control files and there are examples provided...in the "Logic Control Files" section of this manual."

    In CNCLite, you can't access the separate commands or a series of logic commcands by placing them into a .job file, they need to be put into an appropriate .fil file first.

    I thought I would be able to mix and match Gxx positions and the logic commands in a .job file. Not so.

  18. #18
    Join Date
    Apr 2003
    Posts
    332
    Keith,

    There are differences between the package you have and what murphy is using.

    Think of CNC Lite as a G code interpreter while the Graphical Operator Interface is for all types of factory automation. In murphy's package commands such as JUMP, WAITUNTIL STOP and MACHGO work right from a user file, while in a CNC package these commands only work internally. A user of CNC Lite writes in G code instead and can create and/or modify his/her G & M codes to access these logic commands.

    Tech Support
    CamSoft Corp.
    951-674-8100
    [email protected]
    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  19. #19
    Join Date
    Nov 2004
    Posts
    446
    Quote Originally Posted by camsoft
    Keith,

    There are differences between the package you have and what murphy is using.

    Think of CNC Lite as a G code interpreter while the Graphical Operator Interface is for all types of factory automation. In murphy's package commands such as JUMP, WAITUNTIL STOP and MACHGO work right from a user file, while in a CNC package these commands only work internally. A user of CNC Lite writes in G code instead and can create and/or modify his/her G & M codes to access these logic commands.

    [email protected]
    From Camsofts statement, it almost sounds as if my package is more flexible and configurable but it will not run CNC G-codes.. Where as, the CNC light package seems to be pre-set to run a CNC machine but is not capable of doing the things the Graphical OI (my package) can do because of the restraints of running CNC G-code...

    I am even confusing myself on this one...
    I wonder if Camsoft would be willing to send me a CNC Light package for free so I could figure out the differences??
    I guess I have a better chance at catching a metorite... LOL

    I will say this, at first, I thought my Camsoft package was a purchase mistake I made.. Once I figured out how it works, I would not trade it for anything...
    For my purposes, the secret to figuring it all out was to completely scrap all code examples and start from a blank screen and empty code files..

    If there is anything else I can do to help you, feel free to write me.... I got allot of help from this forum and am anxious to pay it back (sort-to-speak)..

    Murphy

  20. #20
    Join Date
    Mar 2003
    Posts
    332
    Thanks, I finally get it. Now I just need to decide how to call the logic commands; using I/O state changes with IF/THEN, (IF #21=1 THEN GOTO:START) or from the code with G & M code

Page 1 of 2 12

Similar Threads

  1. Programming PLC on Fanuc 0M
    By MetLHead in forum Fanuc
    Replies: 21
    Last Post: 02-18-2019, 06:36 AM
  2. Gsoft Online CNC Programming Tool
    By tslawnyk in forum News Announcements
    Replies: 5
    Last Post: 12-07-2007, 02:18 PM
  3. Mazak C axis programming
    By dpinson in forum Uncategorised MetalWorking Machines
    Replies: 1
    Last Post: 07-02-2005, 09:06 PM
  4. API Programming Anyone
    By Al_The_Man in forum Computers / Desktops / Networking
    Replies: 3
    Last Post: 02-15-2005, 03:31 AM
  5. Conversational CNC Programming
    By BlueChip in forum News Announcements
    Replies: 0
    Last Post: 07-24-2004, 07:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •