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.
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.
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.
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.
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.
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.
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
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
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.
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).
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.
Comments
I am sure many of the folks on this forum know how. What sort of speed and resolution requirement?
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.
and that is my motor feature
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.
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.
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?
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.
and the radius of my wheel is 0.34 mm
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.
I thought their approach looked pretty good.
Here's an example of a more conventional approach.
This above encoder disk reminds me of erco's "Retrobot."
Here's an example of the CNY70 sensors being used in a tight space.
This last example showed someone trying to fit a quadrature encoder inside a servo. I did something similar with P5587 sensors.
Judging by the hand holding the wheel I would guess the 0.34mm wheel radius is a typo.
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.
i bought my motors from h
http://www.banggood.com/RC-Car-Pack-Diameter-65mm-Tire-+-Motor-+-Connector-p-912829.html?p=ZF2018679409201407S0&admitad_uid=8f3e20c65c2fc053cdf09940aa76c77d
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.
What is the deadline?
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.
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).
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.