So what is the difference between a motor with an encoder and one without?
i think it kinds of read how much the motor is rotating, but can't i see that from how much current i'm giving? what are the uses for these encoders?
The encoder can for instance tell you when the motor has rotated excactly 180 degrees. this cannot be achieved by meassuring the current flow. If the motor is stalled by some sort of physical obstacle, it will drain a lot of amps without rotating at all. So your current measurring logic will tell you that the motor has spunn 6000 rotations in the last second while the encoder will correctly tell you that the wheel is stuck..
You can indeed get information from the motor that tells how fast it's turning, but you should not measure current. Instead you should switch the motor off periodically and measure the voltage it generates (known as back-EMF or counter-EMF - EMF being electromotive force). This gives you an idea of how fast it is spinning.
Here's one example of an encoder.
And another cheap option.
Your simplest one might be a microswitch which gets tapped every revolution of the wheel... Look out for and be aware of the difference between "absolute" and "incremental" (as hinted at by maneuver). All the above are incremental (even the microswitch). (Don't argue, jip. I know it's absolute at the instant the cam operates the switch and the point it gets released.)
All the info you could ever want on rotary encoders.
How will that work in a hill just steep enough to stall your motor? Wont the shutdown make the robot roll slightly backwards, then move forward again when the power is switched back on? This would tell your CPU "We're rolling backwards!" While normal rotation sensors would state "we're sorta vibrating here guys!" or "we're staring to look like a horny animal!" depending on the frequency of the on/off-switching..
sorry for the flippant tone, it's way past bed time and I'm stuck on my strollerbot
That's a good question and the answer is that the motor won't be shut off long enough for it to have some serious effect. I mean how long does it take to shut off an h-bridge and measure a voltage? I think standard ADCs can do a measurement in about 5 us.
So I guess if your robot stalls on a ramp it will stay stalled :-)
Sorry for the jip'ish tone but it's early in the morning and I'm at work and haven't got any coffee yet! :-)