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

    Create a virtual temp. sensor based on average of multiple?

    Scheduled Pinned Locked Moved Unsolved
    Gcode meta commands
    5
    7
    248
    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.
    • SanderLPFRGundefined
      SanderLPFRG
      last edited by SanderLPFRG

      Hi,

      Since I have a very large bed I want to use multiple thermistors to more accurately measure the average temperature of the bed.

      I have tried to make a macro that calculates the average, but I cannot find how I can set a new thermistor without a pin, but that uses a variable as output;

      ; average_temp.g
      
      ; Define thermistors on mainboard
      M308 S1 P"temp0" Y"thermistor" T100000 B3950  A"Thermistor1"
      M308 S2 P"temp1" Y"thermistor" T100000 B3950 A"Thermistor2"
      M308 S3 P"temp2" Y"thermistor" T100000 B3950 A"Thermistor3"
      
      ; Get the temperatures of S1 and S2
      var temp1 = sensors.analog[1].lastReading
      var temp2 = sensors.analog[2].lastReading
      var temp3 = sensors.analog[3].lastReading
      
      ; Calculate the average temperature
      var avgTemp = (var.temp1 + var.temp2 + var.temp3) / 3
      
      ; Update the virtual sensor S4 with the average temperature
      M308 S4 P"nil" Y"virtual" A"AverageTemp" V{var.avgTemp}
      

      Is there a way to do this??

      jay_s_ukundefined 1 Reply Last reply Reply Quote 0
      • SanderLPFRGundefined SanderLPFRG marked this topic as a question
      • jay_s_ukundefined
        jay_s_uk @SanderLPFRG
        last edited by

        @SanderLPFRG The only way i can think of off the top of my head is to use daemon.g to update a global variable and then use BtnCmd to display the value

        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

        SanderLPFRGundefined 1 Reply Last reply Reply Quote 0
        • SanderLPFRGundefined
          SanderLPFRG @jay_s_uk
          last edited by

          @jay_s_uk

          Thanks for the reply. I am not familiar with the BtnCmd and editing in daemon.g...
          What exactly is this and how do I do it?

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

            @SanderLPFRG this is BtnCmd https://github.com/MintyTrebor/BtnCmd
            It can be used to create your own interfaces for DWC so its only showing the information you're interested on one or multiple tabs

            daemon.g is by default executed every 10 seconds although it could be made to run more quickly.
            Theres some more information here https://docs.duet3d.com/en/User_manual/Tuning/Macros#daemong

            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

            oliofundefined 1 Reply Last reply Reply Quote 0
            • oliofundefined
              oliof @jay_s_uk
              last edited by

              another option would be to wire the sensors in parallel and adjust the reference resistance accordingly (halving it if my memory of Ohm slaw is correct).

              <>RatRig V-Minion Fly Super5Pro RRF<> V-Core 3.1 IDEX k*****r <> RatRig V-Minion SKR 2 Marlin<>

              stuartofmtundefined 1 Reply Last reply Reply Quote 0
              • stuartofmtundefined
                stuartofmt @oliof
                last edited by stuartofmt

                @oliof said in Create a virtual temp. sensor based on average of multiple?:

                another option would be to wire the sensors in parallel and adjust the reference resistance accordingly (halving it if my memory of Ohm slaw is correct).

                If you want to go that route - then maybe 4 thermistors. Two in series and then wire those two in parallel. That way the nominal resistance would be the same as just one.

                I do have to ask though: what is your objective (in real day-to-day terms)?

                With reasonable stable conditions (i.e. no breeze across the bed) you'd expect the bed to reach a steady-state and more-or-less have a consistent distribution of temperature.

                Is the complexity you are considering providing an advantage compared with (say): Manually take the temperature at different parts of the bed and compare to the desired temperature - create a simple lookup table. Use that knowledge (moving forward) to infer the average temperature from the reported temp given by a single sensor.

                1 Reply Last reply Reply Quote 0
                • deckingmanundefined
                  deckingman
                  last edited by

                  Expanding on what @stuartofmt has said, it's unlikely that there would be a significant difference in temperatures if your bed conducts heat well (which it should). But in the unlikely event that there are significant differences, then cold spots would likely cause problems with first layer adhesion whereas hot spots are unlikely to cause any significant issues. Therefore, it would make more sense to use a single temperature sensor located at a known cold spot.

                  Ian
                  https://somei3deas.wordpress.com/
                  https://www.youtube.com/@deckingman

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