Pages: [1]   Go Down
Author Topic: PWM to transistor to small DC motor - strange effect?  (Read 1662 times)
0 Members and 1 Guest are viewing this topic.
Melbourne
Offline Offline
Jr. Member
**
Karma: 2
Posts: 83
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I've never really used transistors before - this is my first project where I need one as most of my stuff thus far has been very small and powered straight off the Arduino (sensors, bluetooth etc).

What I'm basically doing is this:

Arduino reads a 10K pot on Analog input 0 to get a value.

Arduino outputs on pin 9 an analogue signal to the base of the transistor.

Transistor is an NPN BC 547 type if that is relevant.

Connected to the transistor is a small 6V DC motor and then obviously it's connected to a battery - in this case 9v (because that's what I had lying around and yes I know 9v through a 6v motor will kill it - it's recycled and I'm just playing to learn at this stage before embarking on something more real).

The program essentially just reads the analogue in value and passes an analogue write to the output - the circuit and everything works but for one really odd thing I can't explain and I can't frame a search correctly on google to understand what's happening.

I was printing out the current value from the pot just so I could see what was going on when I noticed this.

As I move up the range from 0 - 1023 I increase the RPMs of the motor as you'd think using PWM. However the *actual* range is more like 0-250 after which if I hit 255 the engine stops dead...

If I increase the value on the input again it will wind up slowly until it hits about 500ish and then stop again and like this all the way to 1023 in really regular 250ish value cycles.

I don't understand why this would happen or why it's cyclical - I could understand that maybe at 250 I saturated the transistor so it stopped but then why does it ramp upwards again and why is it so exactly cyclical and consistent?

There's a good likelihood I've done something stupid but I'm hoping it's just some effect I don't know about or there's some other explanation?

Any thoughts would be very greatly appreciated.

Cheers
ajfisher


Logged

Melbourne
Offline Offline
Jr. Member
**
Karma: 2
Posts: 83
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Richard,

Thanks for that quick, detailed and helpful reply - much appreciated.

I didn't realise that I needed a current limiting resistor between the transistor base and the Arduino pin output so thanks for that (circuit I had adapted from ITP site didn't have one) - now I know. Further to this, so I can calculate the resistor that is correct (basically I guessed by using successively smaller ones until I overcame the stall speed of the motor smiley-wink ) what piece of data am I looking for? I understand how to do this with LEDs but not sure if I'm using the motor, the transistor or the combo of both to work this out.

Great pickup on the analogwrite() function as that was what I forgot and it turns out from my earlier testing that if you write bigger than an 8 bit number to an analogue pin it must drop the most significant bit and leave the remainder - thus why I could create perfect cyclical behaviour at exactly 250ish intervals.

So now I've mapped it I just need to understand more about this calculation...

Thanks heaps.
ajfisher
Logged

Melbourne
Offline Offline
Jr. Member
**
Karma: 2
Posts: 83
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks again Richard - very helpful. I need to fix a fuse in my meter (measuring current from solar panel on wrong setting the other day smiley-wink ) but on a more academic note. As there's no details for this motor so I have no idea what it's specs are other than it's 6v as it's marked on it would the best way to measure it's current draw be to use something like my 9v battery through a potentiometer to the motor then using the meter measure it's current draw as I turn down the resistance (technically I guess I'll need 2 meters so I can measure the voltage and current at the same time) - that should give me the stall current and then it's max load as well yes?

Technically at that point I could choose the *right* transistor to go with it and my arduino so they are properly matched and know the right resistor to put into it.

Cheers
ajfisher
Logged

Melbourne
Offline Offline
Jr. Member
**
Karma: 2
Posts: 83
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

One other thing I've noticed with these transistors is that on the data sheet you are looking at something like a 100-800x gain and using my meter I can see the one I'm holding has a gain of 332x (I'm assuming that's what I'm measuring). To me it looks like that is a surprising amount of range but a very specific value off the meter.

I guess this leads me to ask the following:

1. Can I control the amount of gain actually achieved by the transistor (I suppose I can directly through the amount of current passed in or not but I'm more asking about the transistor itself not it's input)?

2. Assuming I can't do (1), do I then assume my gain is going to be 332x with this transistor specifically and then do my calculations from this? If that's the case if I have to change the transistor for some reason do I then need to recalculate the input resistor value again as well so I'm supplying the right current into the new transistor?

Apologies for all the questions - I haven't used transistors before so they are quite new in my thinking and understanding how they all work.

Cheers
Andrew
Logged

Offline Offline
Full Member
***
Karma: 11
Posts: 147
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

One other thing I've noticed with these transistors is that on the data sheet you are looking at something like a 100-800x gain and using my meter I can see the one I'm holding has a gain of 332x (I'm assuming that's what I'm measuring). To me it looks like that is a surprising amount of range but a very specific value off the meter.

I guess this leads me to ask the following:

1. Can I control the amount of gain actually achieved by the transistor (I suppose I can directly through the amount of current passed in or not but I'm more asking about the transistor itself not it's input)?
The most usual way to use transistors is to have a feedback resistor. With that, the gain of the circuit is determined by the ratio of the feedback resistor to the load resistor and is independent of the gain of the transistor.  Variations in gain then don't matter. It's too complicated to explain briefly but some googling will get you circuit examples.
Logged

Melbourne
Offline Offline
Jr. Member
**
Karma: 2
Posts: 83
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Richard,

Thanks again for a really concise yet thorough answer. I feel like I have a much better grip on this now than I did yesterday after hours of googling that was going nowhere. Now I know what to expect from the component I can do some more playing and see what I can come up with smiley-wink

Cheers
ajfisher
Logged

Pages: [1]   Go Up
Jump to: