I have a small motor what operates at 3.3V at 50mA (sorry no documentation) and a Xbee radio which outputs 1mW.

I would like to allow the Digital I/O pins output on the Xbee to drive the motor though it is currently to weak. I've thought of these two solutions though I need help on either of them.

  1. The Xbee Documentation says the 1mW output is "software selectable." I have XCTU which I've been using to get the Xbee's to talk. Is there an option is XCTU to change the Xbee's output to >1mW ?

  2. Design a amplifier. I thought that maybe using a simple amplifier curcuit might work. I'm just not sure how to amplify the 1mW signal properly.

  • 7
    \$\begingroup\$ Are you perhaps confusing a 1mW RF output with the power handling capability (traditionally more likely to be expressed in mA at a voltage) of the digital output pins? \$\endgroup\$ – Chris Stratton Jun 21 '12 at 15:35

It's most likely you are confusing the RF output power with the digital outputs as Chris notes . In any case it's unlikely the outputs will be able to source/sink 50mA (usually <20mA) Their current capability should be mentioned in the datasheet though.

EDIT - I checked the datasheet which confirms the 1mW transmit (i.e. RF comms) power, but I can't find a current sink/source value for the digital pins. So with no specs to follow you have no choice but to assume they are not capable (edit - as Steven notes there is mention of a 2mA test condition for the max low/min high outputs, so this figure is likely to be the nominal source/sink rating)
EDIT 2 - I just came across this 2010 version of the xBee datasheet (I think it describes the same hardware) which has the necessary information added - they say:

The combined source and sink capabilities of the module are limited to 120 mA for all pins on the module. Module pins 11 and 15 can source/sink a maximum of 2 mA; pins 9, 6 and 13 can source/sink a maximum of 16 mA; all other pins can source/sink a maximum of 8 mA.

So there you have it, none of the IOs can handle 50mA.

This means you will need a simple transistor to handle the current. Something like this should do:

Motor driver

The NPN can be pretty much any "general purpose" transistor, and the diode can be changed for a similar part also. If you use one of the low current I/Os (pins 11 or 15) you'll have to increase the base resistor to 1.5 kΩ.

Suitable transistors:

As mentioned the BC337 or BC817 is an excellent, cheap, high gain general purpose transistor. To find more, have a look on a site like Farnell and use the very useful parametric search. For the parametric search input, we know we need an NPN transistor capable of 50mA and 3.3V (pretty much anything)
The only possible issue is the gain - since the xBee pins are low current, the higher the gain the better (we can use a higher value base resistor and save power). So if we select NPN, and then order results by hFE (current gain) we get a few pages of darlingtons at the top, then on page 9 we start seeing standard bipolars with gains of ~800.
For example the 2SD2114KS has a minimum gain of 820, so to get 50mA we need 50mA / 820 = 61uA. If we use say 200uA to be "safe" we can have a base resistor of (3.3V - 0.7V) / 200uA = 13K.
In reality this is a bit overkill and a BC337-40 or similar with a minimum gain of 250 would be fine (with e.g. a 5k resistor on base)

A suitable logic level MOSFET will do the job too as per Stevens answer, you just have to make sure the gate threshold voltage (Vth) is low enough to allow your drive signal to turn the MOSFET on adequately.
A possible issue if you are wanting to use through hole is there is not a good selection of decent logic level MOSFETs in e.g. TO-92 packages. If we apply the parametric search again, we need the same current/voltage rating, but now we need to look for a part with a threshold voltage well below 3.3V.
I say well below as Vth only indicates when the part begins to turn on, and will only pass a few uA at this level. To get the full story we usually need to look at the gate voltage versus drain-source current graphs.

So we search for: N-channel, continuous drain current >100mA, drain-source voltage >5V (to cover the 3.3V) and threshold voltage Vgs typical of <1V. There are thousands of results, but we still need to check in the datasheet just to make sure the MOSFET will be sufficiently turned on at 3.3V.
Something like the NTS4001N has a max Vth of 1.5V and according to the graph (see below) will pass ~130mA at a Vth of 2.25V. It has a pulse current of 800mA which should handle the motor startup surge.

Vgs vs Ids

  • \$\begingroup\$ will the motor limit current itself? \$\endgroup\$ – miceuz Jun 21 '12 at 22:03
  • 2
    \$\begingroup\$ Yes. The motor windings have internal resistance and as the motor turns a back EMF is generated also limiting the current. This is why the motor will draw a lot more current when stalled or starting up. \$\endgroup\$ – Oli Glaser Jun 21 '12 at 22:11
  • 1
    \$\begingroup\$ @Oli - On page 8 of the datasheet the maximum low and minimum high outputs are given at 2 mA, so I think that will be the nominal value, for lack of a better spec. \$\endgroup\$ – stevenvh Jun 22 '12 at 15:06
  • \$\begingroup\$ @Steven - Well spotted, I agree that's probably a fair assumption to make. \$\endgroup\$ – Oli Glaser Jun 22 '12 at 16:24
  • 1
    \$\begingroup\$ @Steven - Just found this later version of the datasheet whist looking at this question, which has the IO current specs on page 7. \$\endgroup\$ – Oli Glaser Jun 22 '12 at 21:42

Oli is a nice guy and such, but a BJT to switch a motor is so 2011! :-)

Especially since a few of the XBee's outputs can drive only little current (2 mA) a FET may be a better choice as a switch. Unlike a BJT, which is current-controlled, a MOSFET is controlled by a voltage on the gate.

enter image description here

Since you're working at low voltage you'll need a logic FET, which can switch at low input levels. The BSS806N has an on-resistance less than 57 mΩ and can switch several amperes at just 2 V gate voltage. The low on-resistance means that the device won't heat up at even 1 A.

You need the diode over the motor, just like with the BJT to protect the transistor against back-EMF. A Schottky diode is preferred, a BAT54 will do nicely.

  • \$\begingroup\$ Meh, you always know where you are with a good old BJT. I guess these MOSFET things have their uses too though ;-) \$\endgroup\$ – Oli Glaser Jun 28 '12 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.