Connecting Encoders

Hello, I bought and arduino duemilanove some months ago and I have been using it quite a lot. Recently, I was thinking in putting better motors for my robotic projects and I wanted to use encoders.

I was thinking in buying this motor:
EMG30 - GearMotor with Encoder (i cant put the link as its my first post)

as it has encoders with which I wanted to start making some interesting projects. I bough aswell the arduino motor shield to connect a motor like the one up there, but I havent decided the motor yet.

The question is: where do I connect the wires of the motor and the encoders to the motor shield and the arduino board? in the specification of the motors it says:

Wire colour Connection
Purple (1) Hall Sensor B Vout
Blue (2) Hall sensor A Vout
Green (3) Hall sensor ground
Brown (4) Hall sensor Vcc
Red (5) + Motor
Black (6) - Motor

I can understand where to put number 6 and 3 (to ground), 5 to the motor shield, 4 an analogue imput of the arduino board but, what about 1 and 2?

any help will be highly appreciated! thanks.

You should be able to post links now (I think it's only the first post that has the anti-spammer restriction), but here is a link to some specs on the motor.

Your hook-up has one mistake: pin 4 is a power supply to the sensors, and should be connected to 5V.

For pins 1 and 2, you'll probably want to use interrupts to read them, as described here, because they're fairly high-resolution, and will generate lots of pulses. The encoder sensors need the 4K7 (or so) resistors to Vcc specified on the EMG30 webpage, because they're open-collector outputs.

The EMG30 is pushing the limits of the driver chips on the motor shield: you should definitely put the two motors on separate chips. And consider putting heat sinks on the L293Ds if you plan to run the motors a lot.

Ran

thanks for the fast reply.
this is the motor I was thinking about:
http://www.active-robots.co.uk/emg30-gear-motor-encoder-p-384.html

as its simple and with good resolution encoders as I just want to get some practicce with encoders. Putting 2 of them into the arduino motor shield would be too much? thats because of the 600 mA for each motor?

can you recommend me any other easy to use motor controller where I can plug them? any comment on the motors?

thanks in advance.

There are two separate L293D chips on the motor shield (I assume you're using the one from adafruit). Each chip has two half-bridge drivers rated at 600mA apiece, but that's a "peak" rating, and you also have to consider how much heat is being generated on the chip. If you're running a 600mA motor, that close to 1.5W, which is a lot for a 16-pin DIP to dissipate. If you're, say, pointing a camera, where you move for a second or two, then watch for a long time, it's no big deal: some heat will build up, but then bleed off while the chip is idle.

But, if your robot is running all over the house, or around the yard, with the motors on (almost) continuously for minutes at a time, the heat can build up faster than it dissipates. That can shorten the life of the chip. Perhaps drastically.

By using only half of each chip, you increase the area from which heat can transfer to the environment. Ditto for putting heatsinks on the chips. Cooler chips are happier, longer-lived chips in all but a few oddball cases.

I can't really recommend any other motor controllers because I haven't used them: I bought a couple of bare motor shield PCBs because I already had some L293Ds, and I wasn't really thinking about making a mobile robot (I have a couple of "fixed" projects, with smallishy motors, in mind). If you're going to build a battery-powered robot with those motors (which are pushing the limits of the L293D), I'd recommend looking into more-efficient FET-based controllers from suppliers like Pololu. They'll waste less energy, and at least some of them can handle even the stall current safely. I'm sure you can find folks around here who have experience with them that they're happy to share.

Ran

thanks for the reply.
i bought exactly that motor shield from adafruit, I rechecked and it says it give peaks of 1.2 Amps and normal 600mAmps. I might put the 2 motors in different chips as you say aswell.. Anyways I will think about putting some headsinks, do you know where I can get some?

for the pins 1 and 2, when I have it with the resistors, where shall I connect them to get the encoder value? to a normal analogue input on arduino?

any other recommendations? thanks.

Your encoders won't output a "value." They will output a square wave on each of the outputs. You can calculate the position of the encoder by counting the edges of the square waves and knowing the resolution of the encoders.

Here is an example of using a rotary encoder. Arduino Playground - RotaryEncoders

The easiest way I know of is to use the interupt pins (d2,d3) to read the encoder. This is what is used in the above example. Basically interupts when they are turned on, will look for a change in voltage on their pin, and when it happens it "interupts" your main loop and runs whatever is in the interupt routine.

If you are going to use two encoders though, there will be 4 wires so that won't work unless you just monitor one of the wires on each encoder. That will cut your resolution in half though.

OK, I understand. I might get this kit:
http://www.superrobotica.com/S300370.htm
and start getting some knowladge with encoders that I always wanted to do.

thanks everybody for your help!