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

    Simple question: How to read from IO

    Scheduled Pinned Locked Moved Solved
    General Discussion
    4
    16
    1.7k
    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.
    • JBiscundefined
      JBisc @dc42
      last edited by JBisc

      @dc42 Thanks: I will try

      M409 K"sensors.inputs"
      

      Maybe some feedback: Does it make sense to include a small example in the gcode documentation, that I will be the last person who is asking? 🙂 Normally the people search for "read io"/ "read voltage" / "get sensor value" and its hard for them/me to find something in the documentation.

      My Setup: Duet 3 MB6HC Main Board with attached RPI

      dc42undefined 1 Reply Last reply Reply Quote 0
      • dc42undefined
        dc42 administrators @JBisc
        last edited by

        @JBisc, you will need to create a GPIO port attached to your chosen pin using M950 with the J option, before you can see it in sensors.inputs.

        Yes an example would help. If you tell us what you are trying to achieve, we could use that as an example.

        Duet WiFi hardware designer and firmware engineer
        Please do not ask me for Duet support via PM or email, use the forum
        http://www.escher3d.com, https://miscsolutions.wordpress.com

        JBiscundefined 2 Replies Last reply Reply Quote 0
        • JBiscundefined
          JBisc @dc42
          last edited by JBisc

          @dc42 I believe that my scenario is not a very common one. I am working on a complex algorithm to measure the 2D/3D-geometry of my workpiece. The algorithm is to complex to implement it in gcode, therefor I implement a supersiving software layer in python (think about a python-gcode wrapper) which calculates the algorithm. Then, the supervising software optimize the 3dprinter.

          My Setup: Duet 3 MB6HC Main Board with attached RPI

          1 Reply Last reply Reply Quote 0
          • Danalundefined
            Danal
            last edited by

            Curious side question: Where are you running the Python?

            Delta / Kossel printer fanatic

            JBiscundefined 1 Reply Last reply Reply Quote 1
            • jens55undefined
              jens55
              last edited by

              Visions of automated probing are running through my head .... could be as simple as setting resolution for x and y, setting a range of x and y and telling the printer to measure every point. Might be painfully slow but hey, it could do it. Put every value into a spreadsheet which can then be imported into Fusion360 and presto, the beginnings of a model. Obviously some hand work is required.
              As a side question, just exactly how accurate is a 3D scanned object? Are the scanned objects dimensionally accurate or could manually probing increase accuracy?
              In any case, having a probing tool head for quality control of a printed object might be interesting.

              1 Reply Last reply Reply Quote 0
              • JBiscundefined
                JBisc @Danal
                last edited by JBisc

                @Danal currently on the RPI. Ohhhh Danal, you are the author of the wrapper which I use. Great to meet you here! Thanks for your amazing work. I started with forking your project (https://github.com/DanalEstes/PythonDSF)

                My Setup: Duet 3 MB6HC Main Board with attached RPI

                Danalundefined 1 Reply Last reply Reply Quote 0
                • Danalundefined
                  Danal @JBisc
                  last edited by

                  @JBisc said in Simple question: How to read from IO:

                  @Danal currently on the RPI. Ohhhh Danal, you are the author of the wrapper which I use. Great to meet you here! Thanks for your amazing work. I started with forking your project (https://github.com/DanalEstes/PythonDSF)

                  There's another choice now as well: DuetWebAPI. Requires network connectivity to the printer (can, but not required to, run on the attached Pi) and also abstracts away V2 to V3 differences.

                  Delta / Kossel printer fanatic

                  1 Reply Last reply Reply Quote 0
                  • JBiscundefined
                    JBisc @dc42
                    last edited by JBisc

                    @dc42 said in Simple question: How to read from IO:

                    @JBisc, you will need to create a GPIO port attached to your chosen pin using M950 with the J option, before you can see it in sensors.inputs.

                    If I use M950 by

                    M950 J4 C"io4.in"
                    

                    I can get only a ditgital input by calling

                    M409 K"sensors.inputs"
                    

                    which is not what i want.

                    If I define my sensor by

                    M308 S4 P"io4.in" Y"linear-analog" A"MySensor" F0
                    

                    I don't know a method to return my analog sensor value (to the RPI). Does somebody has an idea?

                    My Setup: Duet 3 MB6HC Main Board with attached RPI

                    Danalundefined 1 Reply Last reply Reply Quote 0
                    • JBiscundefined
                      JBisc
                      last edited by

                      Ok it seems to be easy:

                      just call

                      M308 S4
                      

                      to get the sensor value.

                      My Setup: Duet 3 MB6HC Main Board with attached RPI

                      1 Reply Last reply Reply Quote 0
                      • Danalundefined
                        Danal @JBisc
                        last edited by

                        @JBisc said in Simple question: How to read from IO:

                        I don't know a method to return my analog sensor value (to the RPI). Does somebody has an idea?

                        When you say "return to the Pi", what would happen? Push? Pull? what code reads it or responds or...

                        What do you want to happen?

                        Delta / Kossel printer fanatic

                        1 Reply Last reply Reply Quote 0
                        • JBiscundefined
                          JBisc
                          last edited by

                          I implemented in the following way now:

                          My python programm on the RPI sends

                          M308 S4
                          

                          and i parse the response (on the RPI)

                          Sensor 4 (MySensor) type Linear analog using pin io4.in, reading 3.8, last error: success, unfiltered, range 0.0 to 1.0
                          

                          to get the sensor value

                          My Setup: Duet 3 MB6HC Main Board with attached RPI

                          1 Reply Last reply Reply Quote 0
                          • dc42undefined
                            dc42 administrators
                            last edited by

                            You could also get it by using M409 to request that value from the object model.

                            Duet WiFi hardware designer and firmware engineer
                            Please do not ask me for Duet support via PM or email, use the forum
                            http://www.escher3d.com, https://miscsolutions.wordpress.com

                            JBiscundefined 1 Reply Last reply Reply Quote 0
                            • JBiscundefined
                              JBisc @dc42
                              last edited by

                              @dc42 said in Simple question: How to read from IO:

                              M409

                              I remember that you posted in another post that analog values are not included in the current object model

                              My Setup: Duet 3 MB6HC Main Board with attached RPI

                              dc42undefined 1 Reply Last reply Reply Quote 0
                              • dc42undefined
                                dc42 administrators @JBisc
                                last edited by dc42

                                @JBisc said in Simple question: How to read from IO:

                                @dc42 said in Simple question: How to read from IO:

                                M409

                                I remember that you posted in another post that analog values are not included in the current object model

                                Raw analog inputs are not included, but the readings from configured sensors are:

                                20/04/2020, 09:55:19 	m409 k"sensors.analog[0].lastReading"
                                {"key":"sensors.analog[0].lastReading","flags":"","result":21.5}
                                

                                Duet WiFi hardware designer and firmware engineer
                                Please do not ask me for Duet support via PM or email, use the forum
                                http://www.escher3d.com, https://miscsolutions.wordpress.com

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