Protection scripting for zero detection

I want to protect myself from starting a print when some pre-conditions have not been met.  Specifically, the machine must go through its alignment procedure, the Z axis must have been probed, and the XY zero must be set.  This is purely a self-protection mechanism.  The urgency is due to a crash last night that destroyed the work and nearly caught the basement on fire.

I believe I can accomplish this through "@set value" and "@if".  Please correct me if I'm wrong, or give me additional guidance. 

What I believe I have to do is, in the G-Codes section for the printer, for any command or event that will reset my printer state, I need to unset my variables that keep track of pre-conditions.  When each pre-condition command is run, the variables will be set.  And in "Run before job", I check the pre-conditions and if any is not true call "@stopPrint 0" (I don't want it to kill and drop the router while it's running).

Is this the "right thing to do"?



  • Yes, if you use @set for any set precondition that would work. There is a run on connect script where you can reset them for initial value. Use global scope for your variables. For some things like homing this is even directly available:


    Printer state based on commands being sent to printer. When printer is controlled outside Felix Server the values may be wrong!

    • pos_x - X position of printer when all moves are finished.
    • pos_y - Y position of printer when all moves are finished.
    • pos_z - Z position of printer when all moves are finished.
    • is_x_homed - Was x homed during connection.
    • is_y_homed - Was y homed during connection.
    • is_z_homed - Was z homed during connection.
    • is_a_homed - Was a homed during connection.
    • is_b_homed - Was b homed during connection.
    • is_c_homed - Was c homed during connection.
    • power_on - Is software power enabled. This is used for the power on/off button.
    • relative - Are positions interpreted relative.
    • e_relative - Are extruder positions interpreted relative.
    • online - Connection status to primary instance, 0 = unconnected, 1 = connected, 2 = trying to connect
    • condition - Printer condition:
      • 0 = Unknown - Before connection is established
      • 1 = Ready - We expect commands to be executed
      • 2 = Shutdown - Printer was shut down for operations by intermediate host
      • 3 = Killed - Printer has killed it self waiting in endless loop. Needs reset.
      • 4 = Ignoring - Due to some error not all commands get executed
      • 5 = Offline - intermediate host thinks printer is not enabled
    • conditionReason (1.4.0) - Line causing print condition in case of errors.
    of course is homed doe snot mean firmware ha snot disabled motor and you could have moved it by hand. We can not detect such things. 
  • I managed to use this idea to achieve my goals.  I have custom code run for homing, so I'm setting my own global.precondition_* values instead of using the is_?_homed, simply because I want the home to be done one way and one way only.  I also want the operator to establish a zero point which is unique for each project, and to probe Z, so using my own global variables is ideal for this case.

    This list will certainly be useful as I attempt to automate steps and make sure I don't do something wrong.
Sign In or Register to comment.