help: motor with external power, MOSFET

.

Hi, first post from a beginner to both electrokits and arduino, so keep that in mind and please bear with me.

I recently bought a Duemilanove. I have worked through some of the examples on this site, mostly playing around with some tiny servos. So far so good.

Now I need to control a more powerful motor and would like advice (very basic advice) on how to most easily get it to work with arduino. I want to control the motor and at the same time control and power some mini servos through Arduino (powered by 5V computer USB).

I have salvaged these from an old Lexmark printer:

  • a motor: RS-385PH. It drove a belt that moved the ink cartrige arm along a rail. I want to reuse that whole motor and rail setup to lift something up/down in my project. The motor has two wires. Reversing the positive reverses the motor rotation.

motor reference sheet: http://www.mabuchi-motor.co.jp/cgi-bin/catalog/e_catalog.cgi?CAT_ID=rs_385ph
(I am not sure which of the two submodels I have; the label only says RS-385PH)

Connecting the motor directly to the power adapter works but I need to lower the motor speed somehow.

Based on a quick browse in the "Getting Started With Arduino" book by Banzi I think I need a MOSFET to let arduino switch adapter power on/off for the motor. But I'm not sure what type and what else I need.

Questions:

  1. Can I lower the motor speed? How? (not mechanically using gears)
  2. What MOSFET specs would fit well with the components above?
  3. How do I control the motor rotation direction from Arduino? What components do I need for that?
  4. Can someone help me with a sketch on how to connect it all on my breadboard?

Since you are a beginner I would recommend to start with a motor driver shield. Once you understand it you can go on and design your own (if you want to do so). The shields usually have tested designs and come with libraries that fit to the shield.

http://www.ladyada.net/make/mshield/

Other vendors offer such shields as well.

Udo

And read the comments here if you need more power:
http://www.ladyada.net/make/mshield/use.html

Udo

Thanks. Though the motor shield would involve extra costs. I want to avoid that if possible and stick to salvaged components I have already.

Also, the specs for that shield says "2 connections for 5V 'hobby' servos". I need to use more tiny servos, 4 I think. But maybe that can be done with that shield somehow too.

I should also add that I do not need to vary the motor speed during operation.

Did you look at the example code? It allows to vary motor speed. If you do not want to buy the shield you can still analyze its design and how they do it. Then you can decide how you want to do it. If you have no experience you may find that 20 bucks is not that expensive. Be prepared to spend either this or >10 hours till you get everything straight. Of course if your goal is to learn, then you might be better off without a shield :slight_smile:

Udo

You probably need to do some searching for "H-bridge" as this is what is usually used to control DC motor speed and direction.

The motor shield I referenced has a H bridge.

Udo

The motor shield I referenced has a H bridge.

Correct, but the poster indicated he wanted to DIY instead of using the motor adapter.

Ok, I will try to do it without the shield. I do not need to vary the motor speed, only change direction, so that might make it easier. Thanks for the "H bridge" keyword, I'll start reading up on that.

I'm back from some reading. However most guides I find presuppose terminology, circuits etc that I don't yet grasp.

I now think that a stepper motor would be useful for my project. Luckily, the printer I took apart had a 4 wire stepper motor (at least that's what I think it is):
http://img576.imageshack.us/img576/3589/65081283.jpg
It only has the label J01A37QT and I can't find any details on that. But since it was in the printer then the printer power adapter (30V) must be possible to use for it.

I found a guide for stepper motors with arduino here:
http://www.tigoe.net/pcomp/code/category/arduinowiring/51

It uses a L293D chip and I have found a good place to buy that for ~4$ (The motor shield Udo linked to also has the L293D but would cost me more than 20$ as I would have to buy it from abroad (I don't live in the US))
I also need 2 transistors and 4 resistors, according to the schematic on that site.

Any comments on that guide and schematic before I move forward? It is from 2004 so I suspect the code needs updating. But the circuit should work, right?

I read a bunch of threads on this topic again... Still not sorting things out.

Specific questions I'm trying to answer:

  1. will the biolar stepper two-wire circuit work with the Duemilanove? (http://www.tigoe.net/pcomp/code/category/arduinowiring/51 ; it is from 2004 and things might have changed so that is why I'm asking.)

  2. that circuit includes L293D, resistors, stepper motor, power supply AND "NPN transistor". When I search "NPN transistor" in an electronics store I get a large number of hits. How do I find out what "NPN transistor" to use for that circuit?

  3. the same webpage also includes a circuit image for four wire control of stepper motor that is simpler: only parts needed are a chip, motor and power supply. The text above that circuit reads: "The easiest way to reverse the polarity in the coils is to use a pair of H-bridges. The L293D dual H-bridge has two H-bridges in the chip, so it will work nicely for this purpose." The chip in the image is labelled "H-Bridge SB754410NE", not "L293D". I can't find the SB754410NE in any webshop in my country. Is there some replacement chip that would work in the same way?

  1. Yes this will still work.

  2. These are small signal switching transistors so anything like a BC183 will do. Look for an Ic of at least 100mA and a gain of 200+

  3. Drop the SB from the front and just search for a 754410

P.S. It would help to say what your country is.

Thanks, going for BC183's.

Now resistors: The circuit lists two types of resistors (1k Ohm & 10k Ohm). My store lists several resistors with those data but with different Watt data. Would 0,25W ones work?

Yes, the will be fine.
You could calculate the power you need, it is simply voltage times current.
http://www.thebox.myzen.co.uk/Tutorial/Power.html

Thanks, I now have all the parts needed. My last hardware step is now to position the parts correctly.

From a data sheet ( HTTP 301 This page has been moved ) I figured out what orientation of the L293D that matched the circuit (the half circle on one edge of the chip should be facing north from the perspective of the circuit image).

edit: orientation issues solved:

  • resistors lack polarity, so can be placed either direction.

  • Transistor NPN base (B), collector (C) and emitter (E) on the circuit symbol are defined here: Transistors
    B, C and E mapping for physical leads on the BC183B are depicted here:
    datasheet BC183B
    (Please correct me if I'm wrong here - the data sheet file name says BC183B but the sheet states 183,L BC184L and some others)

the data sheet file name says BC183B but the sheet states 183,L BC184L and some others

The letter at the end indicates what sort of pin out the transistor has. Your data sheet is for the B type of pinout. If you have the L type of transistor see the L type data sheet for that pinout.

dtic, I know you're not there yet, but when you do get your h-bridge built, whatever you do, don't go from full-speed forward to full-speed reverse; give the motor ample time to come to a stop (we're not talking a lot of time here; a few ms at most) before reversal. Not doing so (unless your h-bridge is built for it) can blow one or more of the transistors/mosfets (or controller IC, depending on its design and "intelligence"/protection) because of a double-whammy current/back-EMF surge...

Ok, back from very important world cup affairs! :slight_smile:

Grumpy_Mike: My transistor is a BC183B (package label reads "BC183B TO-92 NPN 30V 100mA")

But I was confused because the datasheet from my previous post had a filename that read BC183B but the actual datasheet image read 183L.

Another "BC183B datasheet" search now gives these two hits which both list CBE in opposite order to the previously posted datasheet. The new ones are:
http://www.datasheetdir.com/BC183B+download

So I think the previously posted datasheet has a mislabeled filename (and webpage description) and that the other two give the correct pinout for my component (image from datasheetdir file):

cr0sh: thanks for the advance advice! My next planned step after the circuit was to read up more on the arduino control of the stepper motor and then do basic tests on stepper motor control. But I'm not sure how to get to grips with how to control it through testing WITHOUT thereby risking the problem you describe.

edit: circuit done:

The circuit now has several cables that are +5 and ground. I need to figure out to where exactly to connect them all. What goes where on the Arduino? Can I connect all the +5 cables to the same +5 port on the Arduino?

thanks for the advance advice! My next planned step after the circuit was to read up more on the arduino control of the stepper motor and then do basic tests on stepper motor control. But I'm not sure how to get to grips with how to control it through testing WITHOUT thereby risking the problem you describe

If you're driving a stepper motor using an h-bridge, it's not really being used in "full h-bridge" mode (more like quarter or half mode, depending on the stepper type). There, you still have to take precautions, and use some "common sense" on how you are driving things and how your code is written, but I was making the (wrong) assumption that you were driving a regular DC motor, where what I said about running from forward to reverse does apply.

Something to keep in mind; generally for many h-bridge ICs there exist controller ICs that interface with the h-bridge (speaking for DC motors again, although similar chips exist for steppers), and you supply direction and PWM (or sometimes a binary speed value), along with a few other parameters (by setting the pins as needed). These chips take care of these issues, generally by monitoring the current of the h-bridge and other outputs, so that if you did something like slamming the direction back and forth rapidly, the controller will intelligently bring the motor to a stop and then reverse. They also sometimes incorporate different "strange" (things which don't make sense on first application, like driving the motor backwards briefly as it is running, during a certain point in the PWM - weird things like that) drive modes to make the h-bridge more efficient and work better.

Similar modes exist for the stepper driver chips for h-bridges, to allow you to specify a speed and direction, and the driver takes care of ramping the speed up, ramping it down, or special modes like half-stepping, micro-stepping, smooth-"stepping", etc.

Both of these kinds of chips can generally be used in your own custom h-bridge designs (whether you are building one using discrete transistors/mosfets or an h-bridge driver chip). They can make for a design that is easier to use from the processor standpoint, as well as to provide modes that would be difficult or time-consuming (programming time, mainly - but also testing) to implement.

:slight_smile: