Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    Conditional Macro : check temp and Pulse an IO

    Scheduled Pinned Locked Moved
    Gcode meta commands
    3
    12
    566
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • o_lampeundefined
      o_lampe @M7460
      last edited by o_lampe

      @M7460
      I haven't done a lot gcode conditionals lately, so I might be wrong:
      The if M105.... line looks suspicious to me.
      How does the macro know if the temp values of all sensors must be >193 or just one of them?
      Try that instead:

      if {m105 P0 S <= 193 } && {m105 P1 S <= 193} && {m105 P2 S <= 193}
         M42 P8 S1     ; don't forget to indent the following lines to link them to the if-term
      
      

      I also think that "=<" is not the right term. "<=" seems more like it, or better use "<193.1"?

      1 Reply Last reply Reply Quote 0
      • M7460undefined
        M7460
        last edited by

        Thanks @o_lampe ,

        I get the following error :

        	Error: Failed to read code from macro Allow Print to start : Failed to evaluate "{m105 P0 S <= 193 } && {m105 P1 S <= 193} && {m105 P2 S <= 193}": unknown value 'm105'
        

        It looks like the m105 is the wrong command to get a reading ....

        jay_s_ukundefined 1 Reply Last reply Reply Quote 0
        • jay_s_ukundefined
          jay_s_uk @M7460
          last edited by

          @M7460 you need to use the object model name e.g. heat.heaters[1].current

          Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

          M7460undefined 1 Reply Last reply Reply Quote 0
          • M7460undefined
            M7460 @jay_s_uk
            last edited by

            @jay_s_uk could you please explain a little more ?

            extract from my config.g

            ; Heaters
            M308 S0 P"spi.cs0" Y"rtd-max31865"   A"Top Heater"    ; configure sensor 0 as PT100 on pin spi.cs0
            M950 H0 C"out3" T1                       ; create nozzle heater output on out3 and map it to sensor 0
            M143 H0 S400                             ; set temperature limit for heater 0 to 400C
            M308 S1 P"spi.cs1" Y"rtd-max31865" A"Nozzle"     ; configure sensor 1 as PT100 on pin spi.cs1
            M950 H1 C"out1" T0                     ; create nozzle heater output on out1 and map it to sensor 1
            M143 H1 S400                            ; set temperature limit for heater 1 to 400C
            M308 S2 P"spi.cs2" Y"rtd-max31865" A"Middle Heater"    ; configure sensor 2 as PT100 on pin spi.cs2
            M950 H2 C"out2" T2                      ; create nozzle heater output on out2 and map it to sensor 2
            M143 H2 S400                            ; set temperature limit for heater 2 to 400C
            M570 H1 S30 T30 
            M570 H2 S30 T30 
            M570 H0 S30 T30
            M307 H0 R0.939 K0.115:0.000 D28.67 E1.35 S1.00 B0
            M307 H2 R0.832 K0.138:0.000 D23.81 E1.35 S1.00 B0 
            M307 H1 R1.055 K0.105:0.000 D35.82 E1.35 S1.00 B0 
            
            
            jay_s_ukundefined 1 Reply Last reply Reply Quote 0
            • jay_s_ukundefined
              jay_s_uk @M7460
              last edited by

              @M7460 all your printer details get loaded into the object model in the firmware. you can't use commands in the way you have to get information.
              There is a plugin for DWC to allow you to browse the object model in real time
              There is more information on the object model here https://github.com/Duet3D/RepRapFirmware/wiki/Object-Model-Documentation

              Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

              M7460undefined 1 Reply Last reply Reply Quote 0
              • M7460undefined
                M7460 @jay_s_uk
                last edited by M7460

                @jay_s_uk awesome ! found my heaters ! So i do not get any error on the console but my IO fires even though I'm not in the correct temp range .

                any thoughts?

                M42 P8 S0
                if {heat.heaters[0].current <193 } && {heat.heaters[1].current <193} && {heat.heaters[2].current <193}
                	M42 P8 S1     ; don't forget to indent the following lines to link them to the if-term
                	G4 P10000
                	M42 P8 S0
                `
                jay_s_ukundefined 1 Reply Last reply Reply Quote 0
                • jay_s_ukundefined
                  jay_s_uk @M7460
                  last edited by

                  @M7460 what temps are being displayed for all 3 heaters currently?

                  Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

                  M7460undefined 1 Reply Last reply Reply Quote 0
                  • M7460undefined
                    M7460 @jay_s_uk
                    last edited by

                    @jay_s_uk 17c its cold today !

                    jay_s_ukundefined 1 Reply Last reply Reply Quote 0
                    • jay_s_ukundefined
                      jay_s_uk @M7460
                      last edited by

                      @M7460 thats expected then as you're doing a less than check on all 3

                      Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

                      M7460undefined 1 Reply Last reply Reply Quote 1
                      • M7460undefined
                        M7460 @jay_s_uk
                        last edited by

                        @jay_s_uk

                        What an ass 🙂 haha thanks for all your help ! is there anything i can so to add a warning if it not up to temp then exit and stop the macro ?

                        jay_s_ukundefined 1 Reply Last reply Reply Quote 0
                        • jay_s_ukundefined
                          jay_s_uk @M7460
                          last edited by

                          @M7460 you could add either an elif with the conditions where you want the error or just an else to capture everything that doesn't meet the if.
                          The something like M118 to post the message.
                          abort can be used to stop the run on a macro https://docs.duet3d.com/en/User_manual/Reference/Gcode_meta_commands#abort-command

                          Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          Unless otherwise noted, all forum content is licensed under CC-BY-SA