587,193 active members*
3,225 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > G-Code Programing > Need some help with conditional expressions, I'm lost.
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2016
    Posts
    4

    Need some help with conditional expressions, I'm lost.

    Hello, I should probably preface this and say that I'm not a programmer, and I can't seem to find out how to make this work, so here it goes, hopefully someone can help.

    I've got a situation with my 3d stereo lithography printer where I'm in need of different feedrates and/or travel distance depending on the current layer being printed.

    $CURSLICE reports the current layer. How would I format the code to accomplish the following....

    if the $CURSLICE is less than 10 layers, use this value, if between 10-100 layers, use this value, and if greater than 100 layers, use this value?

    Thanks in advance.
    -Mike

  2. #2
    Join Date
    Feb 2006
    Posts
    1792

    Re: Need some help with conditional expressions, I'm lost.

    You would need to look into your software manual. Should be pretty simple.

  3. #3
    Join Date
    Feb 2016
    Posts
    381

    Re: Need some help with conditional expressions, I'm lost.

    if X <= 10 then
    Do
    else if X >10 and <= 100
    Do
    else
    Do
    end if

  4. #4
    Join Date
    May 2016
    Posts
    4

    Re: Need some help with conditional expressions, I'm lost.

    Quote Originally Posted by Louis_Cannell View Post
    if X <= 10 then
    Do
    else if X >10 and <= 100
    Do
    else
    Do
    end if
    Not sure if it supports If & end if, I will give it a shot this weekend and see.

    sinha_nsit
    You would need to look into your software manual. Should be pretty simple.
    The firmware is called Marlin https://github.com/MarlinFirmware/Marlin, lots of 3d printers use it. Here is the wiki page explaining the Gcode, but it doesn't go into detail https://github.com/MarlinFirmware/Ma...Code-in-Marlin. I can't seem to find any examples anywhere showing some of the more advanced code either to see how to format it.

    The software is pretty unique, it was made for SLA 3d printers, it's called Creation Workshop. It makes mention of expressions on page 18. https://dl.dropboxusercontent.com/u/...UserManual.pdf

    This is from the manual....
    In addition to using thevariables noted above, you can also perform simple expression evaluation using the variables along withconstants. The following operators are supported:Numeric operators:+, -, /, *, %Equality operators:<, >, >=, <=, !=Grouping,)There is also an if-then expression that can be used. This takes the form of:[condition]?[true statement]:[false statement]

  5. #5
    Join Date
    Feb 2016
    Posts
    381

    Re: Need some help with conditional expressions, I'm lost.

    if in marlin you should set up in slicer very simple in simply 3d that I use/

  6. #6
    Join Date
    May 2016
    Posts
    4

    Re: Need some help with conditional expressions, I'm lost.

    Quote Originally Posted by Louis_Cannell View Post
    if in marlin you should set up in slicer very simple in simply 3d that I use/
    Do you have an example of this type of expression so I can see how the expression is formatted? I have the ability to manually add Gcode to different parts of the sliced model using Creation workshop. So if you have it working and you are using Marlin, it shouldn't matter what program creates the code, it should all work. What I'm looking for is to change the X motor feed rate depending on the current layer being printed, I would need this changed three times throughout the model, for example a feedrate of 10 for the first 10 layers, feedrate of 25 between layers 10-100, and finally a feedrate of 100 after layer 100.

    I can get two changes with this expression (curslice is reporting the current layer), this is a simple true/false expression.....

    F{$CURSLICE < 10?10:100}
    This says that if the current slice is less than 10 layers, use 10 as the feedrate, if over 10 layers, use a feedrate of 100. This works great, but I need to add the third margin of layers so I can have it change feedrate three times throughout the entire print.

  7. #7
    Join Date
    Feb 2016
    Posts
    381

    Re: Need some help with conditional expressions, I'm lost.

    do you not already have the ability to set bottom layer exposure times in options for the first 10 layers, then use your true false to control the 2nd 3rd
    Only getting minute whilst compiling system to look at this but from a brief scan I would guess the format may well be nested along the lines of
    F{$CURSLICE < 10?10:F{$CURSLICE > 100?100:25}}

  8. #8
    Join Date
    May 2016
    Posts
    4

    Re: Need some help with conditional expressions, I'm lost.

    Quote Originally Posted by Louis_Cannell View Post
    do you not already have the ability to set bottom layer exposure times in options for the first 10 layers, then use your true false to control the 2nd 3rd
    Only getting minute whilst compiling system to look at this but from a brief scan I would guess the format may well be nested along the lines of
    F{$CURSLICE < 10?10:F{$CURSLICE > 100?100:25}}
    Yes! That is exactly what I'm looking for. That should work perfectly. Thanks you!!!

Similar Threads

  1. Conditional looping. Is it possible?
    By zedodia in forum Mach Software (ArtSoft software)
    Replies: 6
    Last Post: 06-15-2015, 03:08 PM
  2. Conditional M-code activation
    By nwlynn in forum Fanuc
    Replies: 9
    Last Post: 08-02-2010, 07:56 AM
  3. Conditional and Loop Statements in Mach3
    By Monotoba in forum Uncategorised MetalWorking Machines
    Replies: 5
    Last Post: 04-25-2010, 03:12 AM
  4. Conditional gcode execution in Mach3
    By bobeson in forum Tormach Personal CNC Mill
    Replies: 5
    Last Post: 12-14-2009, 03:39 AM
  5. Conditional loop problem
    By eagle73 in forum Controller & Computer Solutions
    Replies: 0
    Last Post: 12-19-2008, 11:14 PM

Tags for this Thread

Posting Permissions

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