DC Motor rotation detection with mySensors



  • 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) ?



  • @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.



  • 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 ?



  • @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.


  • Mod

    @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?



  • 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 ?



  • @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.



  • 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]


  • Mod

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



  • 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.


  • Mod

    @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.



  • 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.



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



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



  • @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?



  • @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.


Log in to reply
 

Suggested Topics

  • 87
  • 8
  • 5
  • 7
  • 7
  • 5

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts