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

    Read io input

    Scheduled Pinned Locked Moved
    Duet Hardware and wiring
    3
    13
    553
    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.
    • pouic1313undefined
      pouic1313
      last edited by

      Hi,
      I try to read an io input state on io6 on Duet3d 6HC, without success.

      I found this topic : Simple question: How to read from IO

      But in my case when i send :

      M950 J6 C"io6.in"
      M308 S6
      

      i receive "ok" for the first command and an error for M308 :

      Error: M308: Sensor 6 does not exist␊
      

      So, on this pin is a IR sensor with a opamp schmitt trigger.
      The output is 0V or 3.3V

      Do you have an issue for that ?

      cosmowaveundefined dc42undefined 2 Replies Last reply Reply Quote 0
      • cosmowaveundefined
        cosmowave @pouic1313
        last edited by cosmowave

        @pouic1313 I read an input in daemon.g with the following command: sensors.gpIn[0].value.
        In your case it will be: sensors.gpIn[6].value

        Mankati FSXT+, DeltaTowerV2, E3D MS/TC

        1 Reply Last reply Reply Quote 1
        • pouic1313undefined
          pouic1313
          last edited by

          Does i need to create a "deamon.g" file into my sd card ?

          cosmowaveundefined 1 Reply Last reply Reply Quote 0
          • cosmowaveundefined
            cosmowave @pouic1313
            last edited by cosmowave

            @pouic1313 It is not explicit needed to read an input state.
            If you create a daemon.g file in the "sys" folder, you have a frequently called routine (every 10 seconds by default). There you can put in your meta commands for doing what ever you want...

            Mankati FSXT+, DeltaTowerV2, E3D MS/TC

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

              @pouic1313 what do you want to do when you have read the input? If you want to execute something or not depending on the state, you can use this:

              if sensors.gpin[6].value != 0
                ... put your code here ...
              

              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 0
              • pouic1313undefined
                pouic1313
                last edited by pouic1313

                Hi @dc42,
                I work on a pick and place machine.
                Actually, I am experiencing problems with error monitoring when taping components.
                My feeder contain just one IR sensor to stop advance tape.

                After several run, we need to add one IR sensor to detect the presence of the component in tape (the state what i want to read, related to this topic) and if the stepper motor stall when tape is advanced (i think is an other subject).

                Actually i just use the Gcode:

                G1 H1 A10
                

                Tape is advanced as long as the IR sensor is triggered
                so i want to read my IR sensor (component is present) just after the tape is advanced.

                In accord with @cosmowave i just need to add "deamon.g" file in my "sys" folder conf, and with my gcode ? send : sensors.gpin[6].value
                to continue or raise an error ?

                cosmowaveundefined dc42undefined 2 Replies Last reply Reply Quote 0
                • cosmowaveundefined
                  cosmowave @pouic1313
                  last edited by

                  @pouic1313 Yes. You can create the "daemon.g" in your sys folder on the sd card. In this daemon.g file you can put your code which will be executed every 10 seconds.

                  In my daemon.g i read the input state with following code:

                  if sensors.gpIn[0].value = 0						; check that the input is still low
                      .....
                  

                  Mankati FSXT+, DeltaTowerV2, E3D MS/TC

                  pouic1313undefined 1 Reply Last reply Reply Quote 0
                  • pouic1313undefined
                    pouic1313 @cosmowave
                    last edited by pouic1313

                    @cosmowave
                    Can we set the time between each maesure ? 10 seconds are very long

                    i can't find any documentation for deamon.g file where do you find this feature?

                    cosmowaveundefined 2 Replies Last reply Reply Quote 0
                    • cosmowaveundefined
                      cosmowave @pouic1313
                      last edited by

                      @pouic1313 You can put your commands in a while loop with delay in daemon.g.

                      while true
                        ;do your stuff
                        G4 S1 ; Delay 1s = daemon.g is called every second 
                      
                      

                      Note: You need to define a delay, otherwise the cpu can not do other things! But the duration of the delay is up to you. It should not be to low, the cpu needs time to do other things!

                      Mankati FSXT+, DeltaTowerV2, E3D MS/TC

                      1 Reply Last reply Reply Quote 0
                      • cosmowaveundefined
                        cosmowave @pouic1313
                        last edited by

                        @pouic1313 Some infos are here:
                        https://docs.duet3d.com/en/User_manual/Reference/Gcode_meta_commands

                        Mankati FSXT+, DeltaTowerV2, E3D MS/TC

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

                          @pouic1313 you only need a daemon.g file if you want to monitor the input continuously. Otherwise, just test it at those places in your GCode where you want to check it.

                          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

                          pouic1313undefined 1 Reply Last reply Reply Quote 0
                          • pouic1313undefined
                            pouic1313 @dc42
                            last edited by

                            @cosmowave
                            oh yes i found it thank! I already check this page but I didn't find the last time

                            @dc42
                            I can't test it now, i need to wait monday 👍

                            1 Reply Last reply Reply Quote 0
                            • pouic1313undefined
                              pouic1313
                              last edited by

                              Finally I use the endstop reassignment with M574 and i can read the status with M119 command
                              Thank for your help!

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