How to ping Z-probe state



  • What command can I send from the console to check the current Z-probe state?





  • @Veti
    Thanks. Can you help me with the correct syntax for the following conditional statement? I'm trying to increase the power to a light when the probe makes contact with the bed.

    ;check state of zprobe and if 1 increase power to light
    if zprobe = 1
    M106 P2 S255 ;increase power of light to full power



  • i dont see the probe status in the object model

    https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands



  • if sensors.endstops[3].triggered
        M106 P2 S255 ;increase power of light to full power
    

    Just change the "3" to the correct end-stop number for your z-probe. This likely won't work with the BLTouch because it is only triggered briefly, but for an inductive sensor or the likes, it would work.



  • @NexxCat When I run what you have suggested I receive the following error. Do you know what I may be overlooking?

    Error: in file macro line 1 column 4: meta command: array index out of bounds



  • @code7 What Z-Probe are you using?



  • I'm using a conductive Z-probe that triggers when the nozzle makes contact with the bed.



  • @code7 Does it show as an end stop in DWC under "Machine Specific"? There's a readout of the end stops on the right hand side, labelled beginning 0.

    EDIT: Disregard the above. Z-Probes are elsewhere in the object model it seems. I'm not 100% sure as I'm not at my printer right now, but maybe try looking at sensors.zprobes[0].value

    That's a guess based on looking at the code.

    EDIT 2: Try this:

    if sensors.probes[0].value[0] > 1
        M106 P2 S255 ;increase power of light to full power
    


  • @NexxCat Thanks. I'll test it out. This is my first attempt using meta commands.

    If I wanted to trigger another event when the probe is not triggered would I just swap the direction of the carrot ">" to "<" ?

    Also, can you give me an idea of how I can implement the "else" syntax or another syntax in another macro to stop this routine?



  • @code7 You could try something similar to this, which is also a bit neater 🙂

    if sensors.probes[0].value[0] != 0
        ; Z-Probe triggered
    else
        ; Z-Probe not triggered
    
    ; Non conditional gcode continues here
    

    This would be the reverse, checking for the probe not being triggered:

    if sensors.probes[0].value[0] == 0
        ; Z-Probe not triggered
    else
        ; Z-Probe triggered
    
    ; Non conditional gcode continues here
    

  • administrators

    @code7 said in How to ping Z-probe state:

    What command can I send from the console to check the current Z-probe state?

    You mean the triggered/not triggered status?

    22/09/2020, 12:11:06 	echo sensors.probes[0].value[0]>=sensors.probes[0].threshold
    false
    


  • @NexxCat Thanks. This works great.

    Is is possible to continually run this code in real time while printing?

    @dc42 Yes that is what I meant. Thanks.



  • @code7 You can use daemon.g for that, but I have no experience with using it. Check this thread: https://forum.duet3d.com/topic/14701/daemon-g-usage-cases



  • @dc42 Do you see any issues with me using daemon.g to continually check the state of the probe only during print moves? I currently have a macro that runs when the filament is retracted and ends when the filament is un-retracted. I need a way to turn down a power supply within 1 second of the probe losing contact with the conductive metal print.


  • administrators

    @code7 said in How to ping Z-probe state:

    @dc42 Do you see any issues with me using daemon.g to continually check the state of the probe only during print moves? I currently have a macro that runs when the filament is retracted and ends when the filament is un-retracted. I need a way to turn down a power supply within 1 second of the probe losing contact with the conductive metal print.

    You can do that using a loop in daemon.g, however I suggest you include a G4 delay in that loop of perhaps 500ms, to prevent it using too much CPU time.



  • @dc42 OK. I'll give it a try.

    In regards to running real-time loops in daemon.g, would it be possible to use a loop in daemon.g to call for a variable that can reduce the feedrate mid-print to 1% while a long single line segment is being printed? Ideally I would be able to pause mid deposition, but I know the current command needs to complete before a pause can be invoked.


Log in to reply