First project - help with code and vibration motor

Hi guys,
I could do with some help with a vibration motor. This is my first attempt at something that isn’t LEDs and resistors. It’s meant to cycle on / off with a 1s frequency. It’s via 3.3 and ground, with control from PWM output 3. It just sits there and does nothing. The code is below, it compiles and uploads OK. If I put an ammeter between output 3 and ground it alternates high and low, which makes me think the code is OK. I’ve tried two Uno’s and tried both 9v and USB power. The motor works and I’ve tried three. I’ve swopped out every component one at a time and re-tried after each swop out. The schematic is attached.
I have power and ground on the rails of the breadboard OK. I have alternating high-low from output 3 via a 1K resistor to the base of an NPN transistor to the emitter to ground OK.
I’ve nothing at the collector and so nothing from the collector to either side of the diode, the capacitor or the motor.
I’ve three doubts - the connectivity / quality of the breadboard (getting another), my interpretation of the schematic and my understanding of what I should be getting at the components. I ‘get’ ohm’s law at an abstract level but not when I’m putting the ammeter on the board – especially how to read current. I get the same voltage either side of the resister (I know it’s a device to lessen current) but – what??!
I understand this is dead basic newbie stuff, but I think I’ve been methodical and have followed the ‘go away and read documentation for two or three hours’ advice!! Cheers in advance, Al.

const int motorPin = 3;
void setup ()
{
pinMode (motorPin, OUTPUT);
}
void loop ()
{
digitalWrite (motorPin, HIGH);
delay (1000);
digitalWrite (motorPin, LOW);
delay (1000);
}

OK, first, lets make sure we have our language strait. When you say ammeter are you really talking about a voltmeter or multimeter? If you really are talking about an ammeter, then it sounds like you're connecting an ammeter from the output to, what, ground? If so, you're shorting the Pin3 output to ground.

This looks like a good YouTube video on how to use a multimeter and how to make various measurements: How to Use a Multimeter for Beginners - How to Measure Voltage, Resistance, Continuity and Amps - YouTube

So, make sure you are using a voltmeter or if it's a multimeter, then make sure you have it set to DC Volts. Then:

First I would check the voltage at the 3V3 pin. It should not vary. If it periodically (i.e. once every 2 seconds), drops, and then a second later, rises back up (for example, is 3.3 for a second, then falls to something like 1.8 for a second, then pops back up to 3.3), then the motor is placing too great a current demand on the Arduino's internal regulator -- which is what I'm fairly certain is going on here.

Second, if the 3.3V line is not fluctuating (radically), then perhaps your motor can't run at 3.3V -- you said that the "Motor works", but it wasn't clear, to me, exactly how you made that determination (I wasn't sure if when you said "...and tried both 9v and USB power", if you were connecting that power to the Arduino, then powering the motor directly off the 3V3 pin, OR if you were connecting these voltage sources directly across the motor. Do you know what this motor is rated at: voltage wise and current wise?

According to the Arduino website, Arduino Uno 3V3 pin can supply up to 50mA, but that's probably a conservative value. The datasheet for the LP2985-33DBVR sets the max current at 150mA, but that's at the minimum dropout voltage, so it might be less, depending on how much heat is generated by dropping 5V to 3.3V. It has internal current limiting, and thermal shutdown, so that is what will determine how much current you can get out of this thing. And, in fact, the datasheet has a "Peak Output Current" rating of 350mA -- but that may not last long (i.e. thermal shutdown will, likely, kick in -- a temporary condition that will clear once the regulator cools down enough).

Also, when driving a motor, there is "start-up" current to contend with. That's the amount of current needed to overcome static friction and inertia. That current is a bit more than the current it typically draws when spinning or driving something mechanical. If the supply, or driver transistor, can't contend with this start-up current, you're either gonna get nothing happening, or "magic smoke" ;D

This looks like a good YouTube video on how to drive a motor using an Arduino Uno. A MOSFET is featured in this video, but the concepts are similar enough to make it of value. Notice how the motor is powered directly off a 9V battery, and NOT the Arduino supply. The transistor, used to drive the motor, basically, switches power to the motor, directly from the battery. The Arduino is what "flips" the switch: Arduino DC Motor Control Tutorial - YouTube

Thanks ReverseEMF. Yes, multimeter and can do dc volts just not much else.
Solid 3.29 dcv out of the 3v3 pin. It cycles high to low when I put the multimeter between output 3 and ground. The motor has yet to run on my project at all. Runs fine off 2 AA’s. it’s rated at 3.5v and 75mA.
At the moment, the motor is tomorrow’s problem. When I put the multimeter where the motor should be, I have zilch, nada and nought. :relaxed:

AThanks ReverseEMF. Yes, multimeter and can do dc volts just not much else.
Solid 3.29 dcv out of the 3v3 pin. It cycles high to low when I put the multimeter between output 3 and ground. The motor has yet to run on my project at all. Runs fine off 2 AA's. it's rated at 3.5v and 75mA.
At the moment, the motor is tomorrow's problem. When I put the multimeter where the motor should be, I have zilch, nada and nought. :relaxed:

O.k. a couple of problems. You have written on your diagram that the 3.3V pin can deliver 50mA safely. Then you've connected it to a motor that needs 75mA and you're surprised that it doesn't work?

Also that transistor will lose a fair amount of the 3.3V, probably more that you think because you're not providing nearly enough base current to switch it fully on. Where did you get the value 1k for the base resistor from?

Steve

Physwiz:
When I put the multimeter where the motor should be, I have zilch, nada and nought. :smiling_face:

Are you replacing the motor with a resistor? If the collector is just floating, then, of course zilch. And what slipstick said.

Thanks Slipstick. Sorry ReverseEMF, your reply is beyond me. The 50 / 75mA problem you explain is kind of academic. I have nothing on the multimeter at all where the motor should be on the schematic. Even one mA would be a start

Physwiz:
The 50 / 75mA problem you explain is kind of academic. I have nothing on the multimeter at all where the motor should be on the schematic. Even one mA would be a start

I'm really having a hard time understanding what you're trying to say.

oK. I’ve removed the motor from the breadboard because as you say there may be insufficient current to drive it.
I put the leads of the multimeter where the motor should go (+ve and -ve in my pencilled marks on the sketch) and there is 0v.

One thing I'm noticing, based on your little drawing of a transistor: if that's a bottom view of the 2N2222 (it's more likely that it would be a PN2222), then you have your transistor backwards. Reverse the Emitter and the Collector.

Also, several times, decades ago, 1N4001's in circuits similar to this (where the role of the rectifier is to absorb Reverse EMF) wound up failing. Since then, I have always used, at least 1N4004's (maybe overkill but, they cost the same, so why not!).

Update: I just checked Mouser, and it appears that 1N4004 are, actually, less expensive than the 1N4001.

Physwiz:
Thanks Slipstick. Sorry ReverseEMF, your reply is beyond me. The 50 / 75mA problem you explain is kind of academic. I have nothing on the multimeter at all where the motor should be on the schematic. Even one mA would be a start

Yes, so I'm realizing part of our language problem. You said that you had "nothing" on the multimeter. What that says to me is -- your multimeter was not turned on, or it's broken. From my point of view, I can't be sure if you even know how to turn a multimeter on. Then, when you say "you see 0v, well, friend, that ain't nothin' -- 0 volts is something -- it's a reading of zero volts. ;D

Also, "...where the motor should be..." gives me an inkling that you meant that you put the meter across the points where the motor was previously connected, but then I'm scratching my head, because why would anyone do that? So, did I misinterpret what you wrote? Or, is this a noob mistake? So, for us to help you, it would be great if you were a little more descriptive :wink:

Yes, I’m really struggling with that. It’s marked bc337 but I’ve seen that unit used for other purposes with different pins. It’s also too fiddly. I’ve just ordered some TIP120 replacements that seem clearer

Slipstick - nothing is zero volts. I can turn it on and read the volts just fine if I create a basic led circuit.
At the moment my motor is just decoration on my breadboard. Looks great, but it’s about as useful as as a veranda on a submarine. So I removed it and put the meter where it sat. Nothing (zero) volts.

Did you take any notice of my suggestion that your resistor on the base of the transistor (which is apparently a completely different one from what you originally said) is too high to switch the transistor on properly?

I suggest you try about 270 Ohms and instead of powering the motor from the 3.3V pin try 2 or 3 x AA batteries which will be able to supply the current needed.

Steve

Yes. I’ve 330 and 220. Where would I put the power onto the circuit so that the output 3 still controls the transistor?

Physwiz:
Yes, I’m really struggling with that. It’s marked bc337 but I’ve seen that unit used for other purposes with different pins. It’s also too fiddly. I’ve just ordered some TIP120 replacements that seem clearer

A TIP120 is not a good choice for this application. It's a Darlington transistor and thus has a very high VCE(sat). What's that, you say? Very simple - it's the voltage from the Collector to the Emitter when the transistor is turned "on". And for a darlington, that can be 1.4V or more -- hard to say what it will actually be in this case, since the TIP120 transistor isn't meant to be used at such a low collector current and with such a low voltage. After the Collector-Emitter junction (or "path") drops it's voltage (something like 1.4V), there won't be much left for the motor.

Really, the best bet would be to use an N-channel MOSFET, or a TIP31C. If you use the TIP31C, then put a 220Ω resistor on the base. That will allow around 20mA on the base, for a good 0.4V to 0.5V VCE(sat), all the way up to 2A at the Collector. And, if it turns out you need a little more head-room on the Collector side (i.e. the motor still isn't running properly), then try a 120Ω ¼W resistor on the base, for Collector current up to 3.5A.

A good MOSFET would be: STP16NF06L p/n 2001373 at Jameco. It's a cheap Logic Level N-channel device with plenty of headroom, and with a channel "on" resistance of only 0.1Ω worst case, any voltage drop across the Source-Drain will be negligible.

And, BTW: I'm not sure what you mean by "too fiddly".

Physwiz:
Yes. I’ve 330 and 220. Where would I put the power onto the circuit so that the output 3 still controls the transistor?

Connect the Collector (on the transistor) to the minus lead on the motor, and the positive lead, of the motor, goes to some external source, like the positive side of two or three AA cells in series (as advised by slipstick). And, of course, the negative side of the battery (i.e. the 2 or three AA's in series) goes to the Emitter (on the transistor).

Fixed. Thanks