Arduino Forum

Using Arduino => General Electronics => Topic started by: Sprinterdrift on Dec 08, 2012, 11:27 am

Title: Transistor issue
Post by: Sprinterdrift on Dec 08, 2012, 11:27 am
Hello everyone, first post :)

I'm planning on making a H bridge for reverse motor control, so to get started, I bought a few transistors to play with. For reference, the transistor has BC546 written on its flat part, so shoving that into Google brings up this datasheet:

http://www.datasheetcatalog.org/datasheet/philips/BC546_547_3.pdf   

My first plan (just to get the hang of working with transistors) was to have the positive lead from my 9v battery connected to the collector, the base connected to pin 6 from the arduino, and the emitter connected to one end of the motor. The remaining ends of the motor and the battery both go to ground, which goes to the GND slot in my arduino. I anticipated that switching the battery on without powering the arduino whatsoever would have no effect on the motor, since the lack of current flowing through the base would not allow any current at all to flow through from the collector to the emitter, and then to the motor. Conversely, sending a signal down from the arduino to the base (with the battery on) should have turned the motor on due to the current flowing into the base.

However, I noticed that even when the base was NOT connected to pin 6 and both grounds from the motor and the battery were also not connected to the arduino, (in other words, the arduino is completed separated from the circuit) the motor begins to turn at some frequency when the battery is in the 'on' position. That is, instead of continuous power, the motor turns on, then off, then on, and so forth. I approximate the time between consecutive ons to be between about 0.4 of a second.

This makes absolutely no sense to me, because at school I always thought that no current would flow through from the collector to the emitter if no current flowed through the base. So if anyone could shed some light on this issue, it would be greatly appreciated.

Thanks :) 
Title: Re: Transistor issue
Post by: BillO on Dec 08, 2012, 01:20 pm
Can you show us a schematic?  Your description leaves a lot of questions that can best be answered with a schematic of how you have things hooked up.
Title: Re: Transistor issue
Post by: Docedison on Dec 08, 2012, 01:42 pm
I apologize for an incomplete post, I have edited it to make a little more sense
It would help your attempt to have tried some of the examples provided in your IDE.. First. Doing so gives you a familiarity with properly using a port pin, the processor pins are Not indestructible. It's a good idea to follow some of those sometimes silly little exercises - Understand that they are there for a good reason and follow as many as you can find parts to do so...
Do them and understand why they work - This is really important as it is both microcontroller training, it is electronics training, it is Programming training And it is what you need most to work well with the Arduino product.
What I was trying to say is it is a good idea to get some familiarity with basic electronics first. Your connection to the Arduino was not the proper method to drive a transistor which is what Patduino was trying to point out. Your issue with the transistor conducting was most likely a floating base lead that is picking up a stray signal and conducting. This was in part why I advised you to study some basics first. Make a drawing (it's good practice and a good thing to learn to draw schematics) so you can post it here for commentary. I apologize for my rather terse note in the beginning... BUT you still need a little electronics training first. You have some data from an experiment and no way to understand it without some more training. There is an application called Fritzing that can be downloaded free from this forum that will help you with the schematic drawing and for making drawings of breadboards as well.
{Heavily Edited RKJ}

Bob
Title: Re: Transistor issue
Post by: dhenry on Dec 08, 2012, 02:24 pm
Quote
This makes absolutely no sense to me


Due to interference.
Title: Re: Transistor issue
Post by: patduino on Dec 08, 2012, 02:46 pm
Hi SprinterDrift,

Welcome to the forums, and congrats on your first post...

You'll need to include a 1k or 2.2k resistor inline between the GPIO pin and transistor base to limit current flow.  (These are common values you should be able to use for all of your future projects as you get the hang of them...)

The intermittent operation you describe is most likely caused by the fact that the voltages are floating - not tied together, and varying enough to trigger the transistor switch.

Pat
Title: Re: Transistor issue
Post by: dc42 on Dec 08, 2012, 05:49 pm
That transistor is way too small to switch a motor, it is rated at 100mA max continuous collector current.
Title: Re: Transistor issue
Post by: Docedison on Dec 09, 2012, 12:23 am
@ *dhenry*... so what else is new?

Bob
Title: Re: Transistor issue
Post by: Sprinterdrift on Dec 09, 2012, 02:34 pm
Sorry if I wasn't clear enough.
I've posted a schematic on imgur:

http://imgur.com/Nh4qa

My problem is that even when the base is NOT connected to the arduino, the motor is still turning intermittently when the battery is on.
@Patduino, dhenry: I thought it was some kind of interference, could you please elaborate more, or perhaps link me to a page where it explains what is going on? I'm not exactly sure what voltage floating is. Also, advice on how to stop this would be appreciated.

To add to the confusion, a short while ago I attempted the circuit again, however, this time I attached the transistor base to arduino pin 7, and both the grounds (the negative battery end and the ground motor end) to the GND pin on the arduino.

Circuit here:  http://imgur.com/mrmPv

My first impression was that this circuit was working, that is, sending a signal down pin 7 (digitalwrite(forw,HIGH)) made the motor turn on, whereas sending a LOW signal down pin 7 keeps the motor off. However, when I switched the battery off, the motor kept turning under the command of the arduino, meaning that this entire time, the motor was being powered by the signal from pin 7 instead of the power from the battery! :(

For reference I'm using one of those old blocky Lego technic motors.
Title: Re: Transistor issue
Post by: winner10920 on Dec 09, 2012, 03:56 pm
The problem is your are using the npn transistor improperly to switch the motor, both the collector and base current flow thru the emitter, so the base drive current is apparently powering your small motor, what you need to do to properly switvh the motor is to connect the motor + to the battery positive,  the motor - to the transistor collector, and the transistor emitter to the battery -
then connect the battery - to your arduino ground, and wire a resistor between the transistor base and the arduino pin, now when you output high it will turn on fully, and turn off fully when outputtting low
Title: Re: Transistor issue
Post by: winner10920 on Dec 09, 2012, 03:58 pm
For more information on using the transistor just google transistor as switch and you will find various schematics on the proper wiring
just remember your transistor is npn(switches negative), which is different from pnp (switches positive)
also because you are driving a dc motor you should have a flyback diode(google that too for examples) to prevent damage to your transistor
Title: Re: Transistor issue
Post by: dc42 on Dec 09, 2012, 04:00 pm
Do as winner says, but you also need to connect a diode in parallel with the motor to catch the back emf when you turn it off. And use a transistor with a greater current carrying capacity.
Title: Re: Transistor issue
Post by: BillO on Dec 09, 2012, 04:15 pm
Okay,

First, those transistors have typical gain ranging from 150 - 270.  This means almost any EMI in the area will cause the transistor to turn on, at least a little.  The base needs to be connected to something, so the first circuit is a no go.  2nd, the next circuit you show is also a common collector circuit, which is probably not ideal for your needs, and it would need to have a base resistor to limit the base current.  Setting it up as a common emitter would allow you get a little more potential across the motor too.  Finally, the transistor is not up to the task of running even a tiny motor.  You almost certainly need a bigger transistor and I would recommend a Darlington arrangement  which is basically 2 transistors, althogh you can buy power Dalingtons in a single device.

See the attached schematic.  It will handle a motor that draws up to 10A and is pretty cheap.
Title: Re: Transistor issue
Post by: dhenry on Dec 09, 2012, 05:12 pm
Quote
Circuit here:  http://imgur.com/mrmPv


You want the motor / load to be on the collector of your switch.

Emitter switching is OK in some cases but you switch mostly via the collector.
Title: Re: Transistor issue
Post by: patduino on Dec 09, 2012, 05:36 pm
Quote
@Patduino, dhenry: I thought it was some kind of interference, could you please elaborate more, or perhaps link me to a page where it explains what is going on? I'm not exactly sure what voltage floating is. Also, advice on how to stop this would be appreciated.


Connect a 10k resistor from the base to ground.  That'll keep the base voltage 0 when not connected to the Arduino.  It's a good idea to keep it there even when it is connected.  Voltage floating just means that the base isn't tied directly to any voltage source, so the voltage fluctuates in value, sometimes it has enough to trigger your transistor.  The 10k pull-down resistor will tie it to ground so it won't do that.  Google pull-down resistor for more.  This is a very common problem.

Also, when you connect the Arduino GPIO pin to the base, put a 1k resistor in between them.
Title: Re: Transistor issue
Post by: dc42 on Dec 09, 2012, 05:57 pm

... I would recommend a Darlington arrangement  which is basically 2 transistors, althogh you can buy power Dalingtons in a single device.

See the attached schematic.  It will handle a motor that draws up to 10A and is pretty cheap.


1. The flyback diode is on the wrong place in that schematic, it doesn't protect the transistor when the motor switches off. For that, you need a flyback diode connected in parallel with the motor.

2. IMO darlingtons should almost never be used, because they have high saturation voltage. If the motor draws a substantial current, this results in a lot of power being dissipated in the darlington, so it will get hot and need a heatsink. A power mosfet is a much better solution in such a case. If the current is not so high (say 500mA or less), then a single transistor will do the job more efficiently and with less heat generation than a darlington, especially if the transistor is a high gain low saturation type such as the ZTX851.
Title: Re: Transistor issue
Post by: BillO on Dec 09, 2012, 06:41 pm

1. The flyback diode is on the wrong place in that schematic, it doesn't protect the transistor when the motor switches off. For that, you need a flyback diode connected in parallel with the motor.

Agreed.  Thanks for catching this, maybe a bit too early on Sunday for me.  Updated schematic attached.

Quote

2. IMO darlingtons should almost never be used, because they have high saturation voltage. If the motor draws a substantial current, this results in a lot of power being dissipated in the darlington, so it will get hot and need a heatsink.

Not sure I agree it would be a factor in this particular case but generally, I do agree.

Quote
A power mosfet is a much better solution in such a case.

I agree.  The MOSFET would be my first choice as a switch like this.  We were talking about transistors though.

Quote
If the current is not so high (say 500mA or less), then a single transistor will do the job more efficiently and with less heat generation than a darlington, especially if the transistor is a high gain low saturation type such as the ZTX851.
Yes, very true.  The ZTX851 looks like a pretty good choice.

For what it's worth, the updated schematic now shows the ZTX851.
Title: Re: Transistor issue
Post by: retrolefty on Dec 09, 2012, 06:43 pm
Quote
I agree.  The MOSFET would be my first choice as a switch like this.  We were talking about transistors though.


When did a MOSFET stop being classified as being a transistor? That's what the T in MOSFET is all about!  :D

Lefty
Title: Re: Transistor issue
Post by: winner10920 on Dec 09, 2012, 07:38 pm
Another thing you should learn about is the proper way to figure out the transistor base current,  comes in handy when designing something
You take the switching current and divide it by the minimum hfe(gain) of the transistor and maybe add 5/10percent
thhen you take your base voltage(5v from arduino) minus .7v(the voltage drop acrosss the transistor) and divide that by the number figured out from the current, that will be your resistor to fully saturate the transistor with that load to minimize losses and without wasting extra saturation current or even worse not fully saturating the transistor and creating extra heat
Title: Re: Transistor issue
Post by: dhenry on Dec 09, 2012, 10:12 pm
Quote
divide it by the minimum hfe(gain) of the transistor


hFE is a concept for linear amplification and has very little meaning for switching applications. Typically, you design a circuit assuming the switcher is driven to saturation: Ic / Ib < 10.
Title: Re: Transistor issue
Post by: BillO on Dec 09, 2012, 10:13 pm

Quote
I agree.  The MOSFET would be my first choice as a switch like this.  We were talking about transistors though.


When did a MOSFET stop being classified as being a transistor? That's what the T in MOSFET is all about!  :D

Lefty

Touche!
Title: Re: Transistor issue
Post by: dc42 on Dec 09, 2012, 10:51 pm

I agree.  The MOSFET would be my first choice as a switch like this.


Mine too, if I was making a PCB for it and could use a mosfet in an SMD package, for example http://uk.farnell.com/diodes-inc/zxmn2f30fhta/mosfet-n-sot-23/dp/1583664RL (http://uk.farnell.com/diodes-inc/zxmn2f30fhta/mosfet-n-sot-23/dp/1583664RL). Unfortunately, there do not seem to be any medium-current mosfets available in non-SMD packages. It surely wouldn't be difficult to make a 1A or even 2A mosfet in a TO92 package, but all that seems to be available is the 2N7000, which has a continuous drain current limit of only 200mA. Mosfets in TO220 packages are a lot more expensive and physically too large in some applications.
Title: Re: Transistor issue
Post by: BillO on Dec 11, 2012, 06:53 pm

Quote
divide it by the minimum hfe(gain) of the transistor


hFE is a concept for linear amplification and has very little meaning for switching applications. Typically, you design a circuit assuming the switcher is driven to saturation: Ic / Ib < 10.



IC/IB < 10 is a just rule of thumb that should work for any transistor, but may not always be practical or the right thing to do.  It's not a bad rule for most cases, but you can certainly do a lot better if you take the specifications of the transistor being used into account.

While hFE is a variable quality and is only valid during linear operation, it can be used to help find a more reasonable saturation bias to get the most out of your transistor.  A transistor is in saturation when both the BE and BC junctions are forward biased.  This will occur when:

VBE>VCE, which beings to occur when IBE x hFEmin > IC.  Where the value for hFEmin is minimum for the expected IC.

In other words, saturation occurs when an increase in base current will no longer significantly increase collector current.

To insure adequate saturation we include a factor of 1.5 so that all we need is:

IBsat > (1.5 x IC) / hFEmin

If we use the transistor quoted above, the ZTX851, and we need to drive a 1000ma motor, we can get the hFEmin from the spec sheet.  Then we have:

IC = 1000ma
hFEmin=100 (between 10ma and 2A)

Therefore IBsat > (1.5 x 1000) / 100

Or, a base current of just over 15ma, which is a whole lot better for MCU use than the 100ma as prescribed by the rule of thumb.  In many cases you can get away with even less current, but this would involve testing each transistor for actual hFE at the required collector current.

BTW, this is the method and assumptions by which I arrived at the 240 ohm base resistor in my second schematic which is a conservative selection.  270 ohms would still get the job done.
Title: Re: Transistor issue
Post by: dhenry on Dec 11, 2012, 07:02 pm
Quote
IC = 1000ma
hFEmin=100 (between 10ma and 2A)


What's the corresponding Vce?

What's the power dissipation?

What's the temperature rise?

Your transistor would have exploded at that point.

The Vce(sat) vs. Ic chart provides you with better information.
Title: Re: Transistor issue
Post by: BillO on Dec 11, 2012, 07:06 pm

Mine too, if I was making a PCB for it and could use a mosfet in an SMD package, for example http://uk.farnell.com/diodes-inc/zxmn2f30fhta/mosfet-n-sot-23/dp/1583664RL (http://uk.farnell.com/diodes-inc/zxmn2f30fhta/mosfet-n-sot-23/dp/1583664RL). Unfortunately, there do not seem to be any medium-current mosfets available in non-SMD packages. It surely wouldn't be difficult to make a 1A or even 2A mosfet in a TO92 package, but all that seems to be available is the 2N7000, which has a continuous drain current limit of only 200mA. Mosfets in TO220 packages are a lot more expensive and physically too large in some applications.


It seems the manufacturers do not take much notice of the amateur/hobbyist market anymore.  Well, not that they ever used to, but at least back 20 years ago there were a lot more through-hole parts available.  That being said, the sexier new parts just were not around then.  I guess it's was hard to miss what didn't exist.

I have used the IRLU3410 quite a bit.  Sure, it's over-kill for 90% of what I use it for, but is a decent MOSFET at a decent price (about $0.75) and is much more compact than a TO220.
Title: Re: Transistor issue
Post by: BillO on Dec 11, 2012, 07:16 pm

Your transistor would have exploded at that point.


What are you on about?

VCE would be about 0.05v @ 1amp with a base drive of about about 18ma.  That's about 0.05W in my book.

Are we looking at the same device???
Title: Re: Transistor issue
Post by: dhenry on Dec 11, 2012, 07:32 pm
Page 3, conditions for hFE include Vce = 1v, for Ic = 10ma - 2amp.

That's 1w dissipation for Ic = 1amp.

Thermal resistance for to92 is 100 - 200c/w (max 150c/w for this device) -> 150c temperature increase.

The Vce(sat) chart provides you with better indication (typical) of driving the chip into saturation: 10x - 50x. So your drive requirement is anywhere from 100ma - 20ma, typical.

No margin for error.
Title: Re: Transistor issue
Post by: dc42 on Dec 11, 2012, 07:37 pm

I have used the IRLU3410 quite a bit.  Sure, it's over-kill for 90% of what I use it for, but is a decent MOSFET at a decent price (about $0.75) and is much more compact than a TO220.


I have used the IRLU8726PBF, which comes in the same packages - as you say, much more compact than a TO220 - and very low Rds(on). But I've recently discovered the ZVN4306A N-channel mosfet (1.1A continuous Id, 0.45ohm max Rds(on) @ 5V) which is in the Zetec E-line "TO92-compatible" package. There are some P-channel mosfets in the same package, but with much higher Rds(on).
Title: Re: Transistor issue
Post by: BillO on Dec 11, 2012, 07:52 pm
@dhenry

As I said hFE is only valid in linear mode.  They are quoting linear conditions for the hFE.  My example is in saturation mode.  I only use the hFEmin as a guide to calculate a suitable base current to drive the device into saturation under the conditions I quoted.

Please, take your own advice and look at the VCEsat vs. IC plot.  with the 240 ohm resistor we are driving at about 4.3V/240 = ~18ma, which would put VCEsat at bit over 0.05V.
Title: Re: Transistor issue
Post by: BillO on Dec 11, 2012, 08:09 pm
@dc42

The ZVN4306A looks like a nice compact device, but Mouser lists them at more than twice the price of the IRL3410 in the small quantities I buy for experimentation.  I wonder why they are so costly?
Title: Re: Transistor issue
Post by: dc42 on Dec 11, 2012, 08:48 pm
Yes, they are a little expensive. I guess the demand for them is lower than for the surface mount parts. if you can tolerate a high Rds(on), there are some less expensive parts in the same range, for example ZVN4206A.
Title: Re: Transistor issue
Post by: dhenry on Dec 11, 2012, 09:10 pm
Quote
with the 240 ohm resistor we are driving at about 4.3V/240 = ~18ma


That's not how that chart works.

You take your desired Ic, divide it by the 10x or 50x curve to get the Ib (100ma - 20ma). From that, you calculate your base resistor for 5v drive -> 43ohm - 200ohm.

Alternatively, your Ib with a 220ohm base resistor is 18ma, yielding a Ic of 18ma * 10x - 18ma * 50x, or 180ma to 800ma.

For switching applications, you should simply forget about hFE.
Title: Re: Transistor issue
Post by: BillO on Dec 11, 2012, 09:40 pm


For switching applications, you should simply forget about hFE.



Look, it's not that cut an dried.  They are only showing two lines, IC/IB  = 10 and 50.  There a an infinite number of possible lines you could draw in there, and they behave in a fully predictable manner.  Just because they only show 2 lines does not mean that other lines do not exist.  Or that if you wander off the space between those two lines by a tiny bit, the transistor will behave in a hugely different fashion.  A line for a ratio of 55 would be just a tiny bit higher than the line showing the ratio of 50.

My calculations are right.  The transistor, will be in saturation, VCE will be approximately 0.055V with IC @ 1amp, and it will be at less than 10 degrees above ambient temperature.

You are obviously set on this, so I will not try to convince you further.  This argument is just starting to get inane.  If you want to prove me wrong, get a ZTX851, drive the base from 5V through a 240 ohm resistor, allow 1 amp IC (5V through 5 ohms, perhaps) and take some measurements.  If it blows up, or even get's luke-warm, I'll play for the transistor and send you $5 for your trouble. Okay?

Other than that, let's agree to disagree.