Shop OBEX P1 Docs P2 Docs Learn Events
DC motor encoder — Parallax Forums

DC motor encoder

hi all i want to ask if anyone here know how to build an encoder for a DC motor
«13

Comments

  • kwinnkwinn Posts: 8,697
    ahmed7 wrote: »
    hi all i want to ask if anyone here know how to build an encoder for a DC motor

    I am sure many of the folks on this forum know how. What sort of speed and resolution requirement?
  • rjo__rjo__ Posts: 2,114
    edited 2016-06-07 04:15
    I've done it using a part (don't remember which:) that basically has an LED and a detector for the light... you need two.
    Then you need a wheel with some notches... through which the LED light passes when in the notch and doesn't pass when not "in" the notch. Then you place your emitter/detectors so that one is blocked when the other is detecting the light... and you have it... a dc motor encoder. I did my wheel using a CNC mill, but you could scavenge all the parts from a mouse(the mechanical wheel type), then you just have to get your gearing straight, build your connector to your DC motor and you are done.

    That's the general idea, anyway.

    If you will say exactly what you are trying to do(the motor... how it is installed, etc), I'm sure others will jump in with the kind of specific information you are going to need.
  • well thanks this is my robot
    and that is my motor feature
    824 x 618 - 83K
  • and that is my motor feature
    492 x 173 - 22K
  • and i'm trying to build an encoder to determine the wheels angle
  • The easiest way to add encoders to a robot is to start with motors which have attached encoders. These motors are an example of the easy way.

    It's possible to add encoders to a wheel but these encoders aren't as precise as encoders on the motor. Here are a few links I found about encoders.

    http://forums.parallax.com/discussion/118861/homebuilt-robotic-platform-aka-retrobot/p1

    http://forums.parallax.com/discussion/comment/844258/#Comment_844258

    http://forums.parallax.com/discussion/143183/diy-motor-feedback-from-mouse-parts/p1

    http://forums.parallax.com/discussion/149740/rare-wheel-encoder-sensors-available-strike-now/p1

    http://forums.parallax.com/discussion/151340/quadrature-encoders-for-the-activitybot/p1

    For a balancing robot, I think you'll need to use quadrature encoders. Single channel encoders can be "tricked" into thinking they're moving when they're really just vibrating.
  • ercoerco Posts: 20,248
    Duane Degn wrote: »
    The easiest way to add encoders to a robot is to start with motors which have attached encoders.

    Sounds a bit like Steve Martin on How to Get a Million Dollars and Not Pay Taxes:

    1) Get a million dollars
    2) Say "I forgot"

    But seriously ahmed7, Duane's right in that it's possible but difficult for beginners to add encoder to a project. If you can afford new motors with built-in encoders then you will save yourself a lot of headaches.

  • rjo__rjo__ Posts: 2,114
    ahmed7

    AHHHH!!!! a balance bot... or you are missing two wheels:)

    Don't listen to ERCO or Duane, they have no sense of adventure.
    They are afraid that you are going to waste a lot of time and then fail.

    I on the other hand think you are going to waste a lot time and then succeed.
    On other hand, if you don't want to waste a lot of time... listen to Duane and Erco.
    If you are still interested in building one, let's see a picture of the terminal end of the wheels... where the wires go in.
    Do you have a moving shaft sticking out? Any place to mount anything?



  • Looking at the motors it is hard to tell if the motor shaft protrudes through the end cap. It looks like it may be sealed.
    I have a set of gear motors where the motor shaft slightly extended beyond the bearing, maybe a mm or two, at most. I was able to super glue an encoder wheel with post I scavenged from an old ball type mouse to the end of the motor shaft. It was extremely frustrating because you have to hold the wheel & post in perfect alignment with the motor shaft so that it won't wobble when the motor turns. If I remember correctly, I used Gorilla Super Glue, it has a thicker consistency and seems to bond the plastic to the metal. I then mounted the optical interrupter to the motor body so that the slot enveloped the disc. Hot glue did the trick there. It still holds up and works great. However, you have to make sure none of the super glue migrates down the shaft into the bearing,
    As everyone else says, much better to use a motor with encoder in place.
  • well this is my wheel
    and the radius of my wheel is 0.34 mm
    2560 x 1920 - 2M
    2560 x 1920 - 2M
    2560 x 1920 - 2M
    2560 x 1920 - 2M
  • and i'm planning to do it using the CNY 70
  • Duane DegnDuane Degn Posts: 10,588
    edited 2016-06-07 22:29
    ahmed7 wrote: »
    and i'm planning to do it using the CNY 70

    Making quadrature encoders using a pair of CNY70 sensors on each wheel should be possible but not very easy.

    You might be able to use a strip inside the wheel like this person.

    DSCF0057.JPG

    I thought their approach looked pretty good.

    Here's an example of a more conventional approach.

    rotary-encoder-add-on.jpg?w=800

    This above encoder disk reminds me of erco's "Retrobot."

    66366.jpg

    Here's an example of the CNY70 sensors being used in a tight space.

    assembly.jpg

    This last example showed someone trying to fit a quadrature encoder inside a servo. I did something similar with P5587 sensors.


  • thanks Duane Degn those could be really helpful
  • kwinnkwinn Posts: 8,697
    ahmed7 wrote: »
    well this is my wheel
    and the radius of my wheel is 0.34 mm

    Judging by the hand holding the wheel I would guess the 0.34mm wheel radius is a typo.
  • hhhh sorry it is 0.034m a typing error
  • rjo__rjo__ Posts: 2,114
    Is the arrow in the picture pointing to a cap or the end of a shaft, does it rotate?

    I can't make out the specifications on the motor.... they wouldn't help me much,
    but we have some guys that will be able to give you a pretty good idea if the motors
    are a good match for the load above.

    This is looking good for a perfectly level floor... nothing laying around. Ideally, you
    would want this to be able to climb hills... that's going to take some distance sensors...
    there are lots of ways to configure them... and ERCO is the man when it comes to just the right
    sensor at just the right price.
    441 x 381 - 20K
  • rjo__rjo__ Posts: 2,114
    edited 2016-06-08 02:17
    Here's why I ask the question about what the arrow points to...
    On my application, I was fitting an encoder to a wheel chair and a shaft was sticking out the other end, where the wires are attached...
    It turns out that this was the shaft of the motor itself... what came out the business end and actually turned the wheels,
    was a shaft that was driven by a reduction gear. So, if you attach an encoder where the wheel is, you get the resolution on
    your encoder wheel... but if you luck out, and that is a cap over the motor shaft and the motor is running through a reduction gear, like mine
    ... you get the resolution of the encoder multiplied by the size of the reduction in the gearing.

    So, I ended up with angular resolution on the order of about .15 degrees... otherwise it would a matter of degrees, quite a difference.

    I like Duane's approach... it really makes the mechanical issues far less complicated to deal with... but the question is
    where does it go... on the wheel or hopefully on the other end of the motor?... fingers crossed.

  • kwinnkwinn Posts: 8,697
    There must be some change in the voltage as the brushes transition from one commutator to another in a brushed dc motor, so I wonder if it would be possible to use the signal generated at the motor terminals as an encoder input?
  • yes i liked Duane's approach too, but this is really causing me headache because i must not only build an encoder for the tow wheel but use the reading of the encoders and make it adaptable on Matlab/Simulink with the rest of the code of the robot
  • rjo__rjo__ Posts: 2,114
    So you don't run into a time crunch, figure out how you want it to work... then do the MatLab/Simulink... then build it:)
    What is the deadline?
  • the robot actually work but it still vibrate a lot and to maint stability i need to build an encoder, and i must finish before this sunday, i know that i don't have a lot of time and i'm an amateur but i think that i can do it
  • rjo__rjo__ Posts: 2,114
    Where are you going to get parts by Sunday? I would design it get a complete list of parts and sources, make a drawing, give Duane credit in the paper... put the code into the simulation and forget it.
    If the bot works at all, you should get an A... do a really nice job on the encoder design and put it into well commented code... A++.

    You are officially out of time... even if you skip school the rest of the week... which I have done and highly recommend, you are pushing it to wrap this up in a nice and tidy little package... what you say about the bot is far more important than the bot itself.

    You might not like to write, but you have to and now is the time to start:) You are avoiding it. Use your own language... these are robots, nobody wants to see good grammar, they want to see a genius in action. Hop to it.

  • rjo__rjo__ Posts: 2,114
    Have you exhausted yourself on how you are ramping the motors?
  • i used the L298N
  • rjo__rjo__ Posts: 2,114
    did you try adding a little weight at the top or bottom... just to see what effect it has?

  • and your words look really encouragement
  • ahmed7 wrote: »
    the robot actually work but it still vibrate a lot and to maint stability i need to build an encoder, and i must finish before this sunday, i know that i don't have a lot of time and i'm an amateur but i think that i can do it

    I've never built or programmed a balancing bot but I'm pretty sure a bot can be balanced well without encoders. My guess is the P.I.D. algorithm needs to be tuned.

    Another possible issue is the power supply. It looks like you're using a 2 cell LiPo pack. The L298N h-bridge drops the voltage from the batter to the motors so they might not be getting enough power. The size of the battery looks okay but I think a 3 cell pack (of similar capacity) would work better.

    The motor wires sure look thin. I think you should use thicker wires from the h-bridge to the motors. You don't want to just twist wires to the motor either. You'll want a good soldered connection between the wires and motor terminals. The wires from the battery to the h-bridge should also be reasonably thick (16 gauge should be okay).

  • well Duane Degn i made a lot of tests and the lipo 2 cell
  • I was just looking at some more of the photos. It looks like you're using 24 gauge wire are your power lines. These thin wires might be causing you some of your problems.

    If you don't have thicker wire, you can use multiple strands of your thinner stuff.

    If you need to use the thin wire shown in the photos, I suggest cutting off the connectors and stripping about 5mm of insulation off the wire ends so they make a good connection with the screw terminal on your h-bridge board. The wires to the motors should be soldered to the motor tabs.
Sign In or Register to comment.