Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. DC Motor rotation detection with mySensors

DC Motor rotation detection with mySensors

Scheduled Pinned Locked Moved Hardware
16 Posts 6 Posters 2.3k Views 5 Watching
  • 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.
  • jeremushkaJ Offline
    jeremushkaJ Offline
    jeremushka
    wrote on last edited by
    #1

    I have created a node to control a sliding yard gate. I have added a second node to detect if the gate is closed or opened and to show the status in domoticz. So, far it has been working pretty well for the past 2 months.

    However, i cannot the exact position of the gate when it is partially opened or closed. Indeed, the same push button from remote control or from domoticz is used to open and closed this gate.
    Example: if i press the push button on the remote control to open the gate, the gate will start to open. I press again, the gate will stop. I will receive the status as the gate is opened. Then, if i press to the function on domoticz , the gate will start to close, etc...etc... Howeer, the status will keep "OPEN" until the gate will completely be closed. That's the point!

    I have no way to know the exact position of the gate and the last status from mysensors node.

    I am thinking to detect the rotation sense of the motor to know if the gate is in "opening mode" or "closing mode".

    Does someone knows a component or a system to detect the rotation way of a DC Motor (+24V) ?

    dbemowskD zboblamontZ 2 Replies Last reply
    0
    • jeremushkaJ jeremushka

      I have created a node to control a sliding yard gate. I have added a second node to detect if the gate is closed or opened and to show the status in domoticz. So, far it has been working pretty well for the past 2 months.

      However, i cannot the exact position of the gate when it is partially opened or closed. Indeed, the same push button from remote control or from domoticz is used to open and closed this gate.
      Example: if i press the push button on the remote control to open the gate, the gate will start to open. I press again, the gate will stop. I will receive the status as the gate is opened. Then, if i press to the function on domoticz , the gate will start to close, etc...etc... Howeer, the status will keep "OPEN" until the gate will completely be closed. That's the point!

      I have no way to know the exact position of the gate and the last status from mysensors node.

      I am thinking to detect the rotation sense of the motor to know if the gate is in "opening mode" or "closing mode".

      Does someone knows a component or a system to detect the rotation way of a DC Motor (+24V) ?

      dbemowskD Offline
      dbemowskD Offline
      dbemowsk
      wrote on last edited by
      #2

      @jeremushka Use an h-bridge something like this. With this you can regulate speed with PWM and direction with a high or low signal on a pin. Granted this is a dual H-Bridge, if you only needed to run a single motor, just look up a single H-Bridge rated at the amperage of your motor draw.

      Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
      Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

      1 Reply Last reply
      0
      • jeremushkaJ Offline
        jeremushkaJ Offline
        jeremushka
        wrote on last edited by
        #3

        It looks interesting to control the motor direction, speed with PWM. However, i do not wish to regulate the speed of the motor. Just to get the directions.
        However with H-bridge system, i do not know how we can just get the status of the running direction of the motor ?

        dbemowskD 1 Reply Last reply
        0
        • jeremushkaJ jeremushka

          It looks interesting to control the motor direction, speed with PWM. However, i do not wish to regulate the speed of the motor. Just to get the directions.
          However with H-bridge system, i do not know how we can just get the status of the running direction of the motor ?

          dbemowskD Offline
          dbemowskD Offline
          dbemowsk
          wrote on last edited by
          #4

          @jeremushka you would then just use a full 5v signal to the enable pin which would then run the motor away full speed. Then just use the direction pin to control your direction.

          Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
          Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

          YveauxY 1 Reply Last reply
          0
          • dbemowskD dbemowsk

            @jeremushka you would then just use a full 5v signal to the enable pin which would then run the motor away full speed. Then just use the direction pin to control your direction.

            YveauxY Offline
            YveauxY Offline
            Yveaux
            Mod
            wrote on last edited by
            #5

            @dbemowsk The OP doesn't want to move in different directions, he wants to know where the gate is in all positions:
            "However, i cannot the exact position of the gate when it is partially opened or closed"

            @jeremushka You need to determine the position of the gate, either by tracking the motor or the position of the gate.
            Would it be possible to add an encoder to the motor? Or maybe attach a wire to the gate which turns an encoder or potentiometer?

            http://yveaux.blogspot.nl

            1 Reply Last reply
            0
            • jeremushkaJ Offline
              jeremushkaJ Offline
              jeremushka
              wrote on last edited by
              #6

              Yes true. I just want to know the position of the gate without any actions on the motor speed, directions etc...

              I nee dto check out if i can connect an encoder to the DC Motor. Or maybe it exists some board to connect directly the motor on it ?

              dbemowskD 1 Reply Last reply
              0
              • jeremushkaJ jeremushka

                Yes true. I just want to know the position of the gate without any actions on the motor speed, directions etc...

                I nee dto check out if i can connect an encoder to the DC Motor. Or maybe it exists some board to connect directly the motor on it ?

                dbemowskD Offline
                dbemowskD Offline
                dbemowsk
                wrote on last edited by
                #7

                @jeremushka My mistake, I thought you were also looking to reverse direction. For the position, I would put either a rotary encoder to count pulses or a potentiometer as the gate swings it's arc and then figure out the number of pulses needed for a full swing of the gate or pot position. Then from there you can do the math to figure out either percentage of open or closed, or the degree of arc for position.

                Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
                Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

                1 Reply Last reply
                0
                • jeremushkaJ Offline
                  jeremushkaJ Offline
                  jeremushka
                  wrote on last edited by
                  #8

                  No problem :). For rotary encoder, you mean somthing like this to connect the wires to the DC motor? [https://m.ebay.com/itm/Rotary-Encoder-Module-Brick-Sensor-Development-Board-For-Arduino/310702417391?epid=11007575121&hash=item48574ea5ef:g:LXwAAOSwuzRXdgFL]

                  YveauxY 1 Reply Last reply
                  0
                  • jeremushkaJ jeremushka

                    No problem :). For rotary encoder, you mean somthing like this to connect the wires to the DC motor? [https://m.ebay.com/itm/Rotary-Encoder-Module-Brick-Sensor-Development-Board-For-Arduino/310702417391?epid=11007575121&hash=item48574ea5ef:g:LXwAAOSwuzRXdgFL]

                    YveauxY Offline
                    YveauxY Offline
                    Yveaux
                    Mod
                    wrote on last edited by
                    #9

                    @jeremushka you have to connect the encoder shaft to the motor shaft in some way. The electronics go to an Arduino.

                    http://yveaux.blogspot.nl

                    1 Reply Last reply
                    0
                    • jeremushkaJ Offline
                      jeremushkaJ Offline
                      jeremushka
                      wrote on last edited by
                      #10

                      I have just checked the DC motor. I have 2 wires for power supply and 2 wires probably to control it and connected to the controller board. I cannot connect the rotary encoder.

                      YveauxY 1 Reply Last reply
                      0
                      • jeremushkaJ jeremushka

                        I have just checked the DC motor. I have 2 wires for power supply and 2 wires probably to control it and connected to the controller board. I cannot connect the rotary encoder.

                        YveauxY Offline
                        YveauxY Offline
                        Yveaux
                        Mod
                        wrote on last edited by
                        #11

                        @jeremushka not sure what all the wires are for. Pictures could help...
                        You need a motor with integrated encoder, or need to couple the motor drive shaft to the encoder, using gears or something.

                        http://yveaux.blogspot.nl

                        1 Reply Last reply
                        0
                        • E Offline
                          E Offline
                          executivul
                          wrote on last edited by
                          #12

                          Get the motor voltage down to measurable 0-5V by a resistor network and see rhe direction.
                          Get the motor current by a hall/direct current sensor.
                          Measure the time to open/close and you can guesstimate pretty accyrately the position and/or direction.

                          1 Reply Last reply
                          0
                          • H Offline
                            H Offline
                            heller44
                            wrote on last edited by
                            #13

                            Utrasonic distance measurement. Mysensors unit is nice and reliable as well.

                            dbemowskD 1 Reply Last reply
                            0
                            • H heller44

                              Utrasonic distance measurement. Mysensors unit is nice and reliable as well.

                              dbemowskD Offline
                              dbemowskD Offline
                              dbemowsk
                              wrote on last edited by
                              #14

                              @heller44 Wouldn't the ultrasonic method have problems with a gate moving in an arc?

                              Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
                              Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

                              H 1 Reply Last reply
                              0
                              • jeremushkaJ jeremushka

                                I have created a node to control a sliding yard gate. I have added a second node to detect if the gate is closed or opened and to show the status in domoticz. So, far it has been working pretty well for the past 2 months.

                                However, i cannot the exact position of the gate when it is partially opened or closed. Indeed, the same push button from remote control or from domoticz is used to open and closed this gate.
                                Example: if i press the push button on the remote control to open the gate, the gate will start to open. I press again, the gate will stop. I will receive the status as the gate is opened. Then, if i press to the function on domoticz , the gate will start to close, etc...etc... Howeer, the status will keep "OPEN" until the gate will completely be closed. That's the point!

                                I have no way to know the exact position of the gate and the last status from mysensors node.

                                I am thinking to detect the rotation sense of the motor to know if the gate is in "opening mode" or "closing mode".

                                Does someone knows a component or a system to detect the rotation way of a DC Motor (+24V) ?

                                zboblamontZ Offline
                                zboblamontZ Offline
                                zboblamont
                                wrote on last edited by
                                #15

                                @jeremushka Perhaps instead of looking at the electronics for indication, look at what physically drives the sliding gate closed?
                                If it is a cog/rail type, it should be possible to detect rotation of the cog with a magnet and reed or similar and count off rotations?

                                1 Reply Last reply
                                0
                                • dbemowskD dbemowsk

                                  @heller44 Wouldn't the ultrasonic method have problems with a gate moving in an arc?

                                  H Offline
                                  H Offline
                                  heller44
                                  wrote on last edited by
                                  #16

                                  @dbemowsk original query was for a sliding gate.

                                  Anything else I would say just use 2 pairs of microswitches and if there is any ambiguity, drive direction until a change is noted. Keep it simple.

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  18

                                  Online

                                  11.7k

                                  Users

                                  11.2k

                                  Topics

                                  113.1k

                                  Posts


                                  Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • MySensors
                                  • OpenHardware.io
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular