1. Hey guyz. Welcome to the All New Phlatforum!



    Sign Up and take a look around. There are so many awesome new features.

    The Phlatforum is a place we can all hang out and

    have fun sharing our RC adventures!

  2. Dismiss Notice

Missing X and Y if first Z cut is at (0,0)

Discussion in 'SketchUcam Bugs' started by Bob R, Jan 30, 2017.

  1. Bob R

    Bob R New Member

    Offline
    Messages:
    2
    Trophy Points:
    1
    Location:
    Westport, MA
    I've uncover what appears to be a bug. Here's how to recreate it:

    Set the safe zone to include negative X and Y, so you can operate the tool around (0,0).

    Use the Set 0,0 offset tool, and set it to (0,0). This is necessary since the safe zone origin is not at zero.

    Place a Plunge or CounterBore at (0,0).

    Generate to G-Code.

    Here's an example of the generated code:
    Code:
    %
    G90 G21 G49 G17 F254 
    M3 S15000
    G00 Z3.175
    G00 Z0.500
    G01 Z-5.000 F254 
    G00 Z0.500
    G00 Y0.000 Z0.500
     Z3.175
    M05
    M30
    %
    
    Notice that the code causes the tool to plunge down to Z = -5.000, but it NEVER sets the X or Y coordinates. This works if and only if the machine started with X and Y at (0,0), which is not a good assumption.

    The code needs to explicitly set X and Y after setting Z to the safe travel value, but before the Z value is set to go below this. The code should not assume the machine has started at (0,0).

    I noticed this problem when I had move the tool 10 mm to the right of (0,0) to set my Z to zero. My work piece already had a hole at 0,0 and I was having the G-Code do a counter bore. I couldn't touch down at (0,0) since there was already the hole there. The result was an unintended hole at (10,0).

    Note that if the first instruction to cause Z to cut into the workpiece is not at X=0 AND not at Y=0, then then G-Code generated works fine. If either X=0, or Y=0 then that coordinate is missing.
     
  2. swarfer

    swarfer Moderator Staff Member

    Offline
    Messages:
    808
    Trophy Points:
    28
    Location:
    Grahamstown, South Africa
    Hi, what an interesting bug you have found!

    I will fix it for the next release but meantime you can fix your copy so you can get your stuff done...
    open the file PhlatMill.rb in Notepad (it will be in the Sketchup plugins folder)
    starting at line 11 you see the lines
    Code:
    @cz = 0.0
    @cx = 0.0
    @cy = 0.0
    
    which you must change to
    Code:
    @cz = -0.001
    @cx = -0.001
    @cy = -0.001
    
    which will force the output of the 'G0 X0 Y0' line that you need.

    The bug is caused by the optimization statements that try to only output X and Y if they are different from the previous value, but in your case they are initialized to 0 and so are not different from the center of your counterbore and so are not output when they should be.
    By setting them to -0.001 we force the output. -0.001 is a highly unlikely value for the first object to sit at (-:
     
  3. Bob R

    Bob R New Member

    Offline
    Messages:
    2
    Trophy Points:
    1
    Location:
    Westport, MA
    Thanks Dave. Yes that fixes it.

    Can I set this value to something like 1e30, or a programming equivalent of NaN so I know I won't accidently have the problem if I output -0.001 as a real starting coordinate? I don't want to break the code that parses that text file by typing in a value that it will barf at.
     
  4. swarfer

    swarfer Moderator Staff Member

    Offline
    Messages:
    808
    Trophy Points:
    28
    Location:
    Grahamstown, South Africa
    Yeah, rather a big number than a small one. (NOT NaN though! that will generate exceptions)
    This is because Sketchup's internal units are decimal inches and the equality comparor only works down to 0.001".
    It is doing A is equal to to B if ((A-B).abs < 0.001)
    this means that it thinks 0.0015 is equal to 0.001 AND 0.002 <-:

    In most (hopefully all) of the G-code generator code I use my own comparitor to compare to 0.0001" (a method called NotEqual) but I cannot be certain that Sketchup will not helpfully mess that up somewhere.
     

Share This Page