Fatal Z axis movement at beginning of gcode - fixed for next version

Issue #574 new
nerdunio created an issue

Hi

I am using a tool length sensor. It is approx. 15mm higher than the PCB.

Before I start the job I let the machine measure the tool length. After the measurement, the spindle is above the sensor.

Let’s take a look at the first lines of the gcode:

G21
G90
G94

G01 F120.00
G00 Z2.0000

M03
G01 F120.00
G00 X-0.0033 Y1.5500
G01 F60.00
G01 Z-0.0700
G01 F120.00
...

This made my spindle crash into the tool length sensor with G00 (line 6)… what a firework :[

It would be much saver to move to the first position where the tool starts cutting and then move down to Travel Z .

G21
G90
G94

G01 F120.00
G00 X-0.0033 Y1.5500

M03
G01 F120.00
G00 Z2.0000
G01 F60.00
G01 Z-0.0700
G01 F120.00
...

(line 6 and 10 interchanged)

Im on 2de9bc7 Beta_8.995

Hope this can be implemented.

Regards

Manuel

Comments (18)

  1. Marius Stanciu

    Hello Manuel,

    The mentioned behavior is by design. The Travel Z parameter is controlling the height where it is safe to travel on X-Y plane. That is the reason why the move to Travel Z is done first. It is the height where the spindle will hit nothing. If you knew that you have a fixture (tool length sensor) that is raising above the Z=0 (where the PCB stays) then you could either:
    - set the Travel Z accordingly so your spindle can pass over it or
    - create Exclusion Areas (Advanced mode) so the tool (spindle) will either go over the fixture area, or go around it if choosing the strategy to do so.

    Because of what I mentioned above, I am sorry for your mishap but the current behavior have to stay as it is. Imagine that you just set the tool height on the PCB surface and then the tool will start moving on the X-Y plane without first going to the safe Z distance (set by the Travel Z parameter): it will scratch your PCB and potentially breaking the tool in the process.

    Best regards,
    Marius

  2. Marius Stanciu

    Hello Manuel,

    Regarding:

    retraction height (Connection Z) and clearance height (Travel Z)

    How do you make the difference between the two possible heights? I mean, what are the decision points?

    Currently things are like following.

    • Starting from the set origin (X, Y, Z initial points set) the tool will raise to the following height:
      Situation 1 - No Toolchange.
      a) if Start Z is set in the Edit ->Preferences to any value then the first vertical move will be to the Travel Z followed immediately by a move to Start Z, effectively meaning a total vertical move to Start Z.
      b) if Start Z is left empty in the Edit ->Preferences, the first vertical move is to the Travel Z height.
      Situation 2 - With Toolchange
      In the toolchange code, the first move is also a vertical move and it is done to a height defined by the Toolchange Z parameter. It is followed by a possible sequence of vertical moves but in the end of the toolchange event there is a move again to Toolchange Z.
    • At this height the tool will horizontally move to the first cut point.
    • Tool will be lowered at the Z cut depth, which is the cutting depth

      Tool will either be raised in a single move to the Travel Z height or in a dual move: first will move to the 0.0 depth (top of the material) with a specified speed and then followed to a move to the Travel Z with max speed. Or it is a direct move to Travel Z with a specified speed (feedrate).

    • At this height the tool will horizontally move to the the next cut point.

    • Repeat the cut-down → cut-up process until next toolchange event (if any) or until the job is finished.
    • At the end of the job, if End Z is specified (anything other than an empty line) then there is a vertical move to this height
    • After the possible vertical move to End Z, if the End X-Y parameter is specified (anything other than an empty line) there is a final horizontal move to the parking position

    So basically you want another Z height to be inserted into this process. Where would you insert it in the process outlined above, which starts from origin position to the park position?
    -Marius

  3. nerdunio reporter

    Hi

    • Starting from the set origin and move to clearance height.
    • At this height the tool will horizontally move to the first cut point.
    • Tool will be lowered at the retract height depth with G0.
    • Tool will be lowered at the Z cut depth with G01, which is the cutting depth.
    • Within the same geometry (or if the distance to the next conture is below a certain threshold) the tool retracts to retract height. Possible obstacles can be avoided with the Exclusion Areas.
    • Move to clearance height and move to next geometry, job or park position.

    Here’s how Fusion 360 does it:

    It cuts “F” as geometry, moves to “latCAM” and finish the geometry without returning to the Clearance Height. Fusion decided to split up the geometry.

    Here the same geometry in FlatCAM:

    For me, move (yellow) 1-2, 19-20 should be clearance height and all other retract height.

    Thanks Marius

  4. Marius Stanciu

    Ok Manuel,
    Just to make a resume so I see if I got it right.
    Currently:
    - what you call clearance height is our Start Z parameter when not using toolchange or Toolchange Z if using toolchange.
    - what you call retract height is our Travel Z parameter, regardless of usage of toolchange

    What you are asking for is a further improvement: to have an adaptive travel adjustment such that if the length of the travel line is bigger than a set threshold then this travel should be done at the clearance height (either Start Z or Toolchange Z depending of usage of toolchange) rather than at retract height as it is done currently (set by Travel Z parameter).

    Am I right?

  5. nerdunio reporter

    yes!

    Other than 3D milling we are mostly on a flat plane. Therefore I think it is simpler to keep the tool at Travel z all the time and move up to Start Z as soon as the path intersects an exclusion area:

    This would not require adaptive travel adjustments and additional parameters to be confused by.

    Regards

  6. Marius Stanciu

    Exclusion areas already have available 2 strategies:
    - go over and you can set the Over Z parameter
    - go around
    So, is there something that I am missing here?

  7. nerdunio reporter

    The reason why I crashed my machine is that at this point the machine moves to Travel z at the beginning of the program.

    I suggest that Travel Z is the retract height which is very close to the surface and the Start Z is the clearance height where the machine performs the tool change and tool length routine.

    Then, at the beginning of the program the machine moves to Start Z, travels to X Y of first cut, moves to Travel Z with G00, moves to cut z with G01. And if there are exclusion areas the tool either stays on Travel Z and goes around the are or goes to Start Z to goes over it.

    Now the machine moves to Travel Z and directly to Start Z.

    Yes, I could place an exclusion area around my tool length sensor but if I forget it once I will crash again and I am sure others will.

  8. Marius Stanciu

    Manuel,
    Try to set the Start Z parameter in the Edit → Preferences (relevant section). You will see that the behavior is what you are asking. So there is nothing to change. For the case where you are not using toolchange.
    If you use the toolchange (ticking the checkbox) then you will have to rely on the Toolchange Z parameter.

  9. nerdunio reporter

    I can set Start Z here:

    • edit->preferences->processing tab
    • Drilling plugin->Advanced options-> start z
    • Milling plugin->Advanced options-> start z

    It this correct?

  10. nerdunio reporter

    Ok, now the GCode is this if I have Start z set and the tool change deactivated.

    G21
    G90
    G94
    
    G01 F120.00
    G00 Z2.0000
    G00 Z30.0000
    
    M03
    .
    

    Resuting in a crash.

    And if tool change is active (which I don’t need):

    G21
    G90
    G94
    
    G01 F120.00
    
    M5
    G00 Z30.0000
    G00 X0.0000 Y0.0000
    T1
    M6    
    (MSG, Change to Tool Dia = 0.1000)
    M0
    G00 Z30.0000
    
    M03
    ...
    

    Works fine!

    What about removing line 6 of the first example in case the tool change is disabled? G00 Z2.0000 followed by G00 Z30.0000 seem reduntant to me and has crash potential.

    Thanks for your patience!

    Regards

  11. Marius Stanciu

    Crashes are possible, yet I did solved a lot of issues in my working copy (for the next release) since more than a year ago when I released the 8.994 version, I can see no crash with no toolchange and Start Z if you refer to a software crash,

    G00 Z2.0000 followed by G00 Z30.0000 seem reduntant to me and has crash potential.

    There is no way around this due of how the preprocessors are used. There is no issue and no crash potential since going first to Z = 2mm it is followed immediately by a move to Z = 30mm without any horizontal move and the vertical move just continue from z=2mm to z=30mm without any perceivable stop. It may increase a bit the traffic between the PC and controller but it’s not a big deal.

  12. nerdunio reporter

    Assuming my tool is at z=0mm, then it makes no difference. Moving to 2mm and then to 30mm is redundant but causes no problems.

    Assuming my tool is at z=60mm (above the tool length sensor) and now moving to 2mm will kill the tool, the sensor and possibly the spindle.

    Lets take a look at an example: A user imports a gerber, add isolation routing, generates gcode and saves it; the most basic usage of FlatCAM. Then he starts his machine, makes a reference move (lower left corner of the working area) and runs the gcode. Now the machine lowers to Travel Z and moves to the first cut. He choose Travel Z to be 50mm because he has some clamping in place. Because his CNC has a max z feedrate of 200mm/min he waits half a minute for one transition. Now he thinks he is clever and lowers the Travel Z to 2mm to not waste time unnecessarily. For the second run he manually move the tool away from the pcb to see the result. He saves the gcode with Travel Z 2mm and runs the program again. Unfortunately, the tool is above a clamp and the spingle crashes into the clamp… The user understands that he can choose between a big value of Travel Z to be save or choose a small value to be efficient. He’s confused because the other CAM software he uses has a clearance height and retract height which make total sense to him. In the forum he reads about the start z value and defines it in FlatCAM. Now he is happy, he has found the quivalent to the clearance height and retract height! He saves the gcode again and sadly he crashes again into the clamp but luckly the tool retracts to the start z directly afterwards. He accepts that he does not understand FlatCAM good enough to use it efficiently and sets Travel Z to 100mm be save.

  13. Marius Stanciu

    Hello Manuel,
    Now it’s clear. I did not thought about the case when the tool will not start from Z=0.0 mm.
    Try the latest commit, it should solve the issue when not using the ToolChange feature.

  14. Marius Stanciu

    Ok, I just fixed this for the Drilling Plugin too. Previously I fixed it for Milling Plugin only. So you need to download the latest sources from my repo, again.
    Sorry for the inconvenience.

  15. Log in to comment