Maker Pro
Maker Pro

pwm to control a dc motor

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
The image is correct.

Make r1 such that the base current for q2 is large enough to drive the motor current.
Assuming a static current gain of 40 and an Ice of 1A, the base current for Q2 is 1A/40 = 2.5mA. The voltaeg across r1 is 3V-Vce(Q1)-Vbe(Q2)= 2.3 V (approx.) So R=2.3 V / 2.5 mA = 92 Ohm. Try 100 Ohm.
Fpr Q1 the calculation is the same: Ib = Ice/40 = 2.5 mA/40 = 6.25 µA. The voltage across R is 3V-Vbe(q1)-Vbe(Q2) = 1.8 V (approx., assuming the IC can put out full 3V). So R=1.8 V / 6.25 µA = 28 kOhm (choose 27 kOhm standard value).

Harald
 

mariomoskis

Mar 13, 2012
82
Joined
Mar 13, 2012
Messages
82
i think that the values are like this(because i observed the current consumed by the motor and when i don´t have the gearbox,this current is 0.25A, and with hearbox the current is 0.3A) and the gain is 25(at least it is the worst case that i saw in its data sheet

then i have the next:
current at the base of q2 is : 0.3/25=0,012A
voltage across R1=3-0.7-0.2=2.3V
so R1=2.3/0,012=191ohmios

voltage across R=5-0.7-0.7=3.6V,because the compactrio will give a digital output of amplitude 5V
current at the base of q1=0,012/25=0,48mA (i should be good because i need a current between 0,1mA and 2mA)
R=3,6/0,48=7.5kohmios

then this should work well now?is it correct?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
BD135,sorry

Both BD135s?

You are probably better off using a 2N222 to drive the BD135

then this should work well now?is it correct?

You really should be designing for 2A current to the motor at least.

I've given you this advice previously and I've even suggested a mosfet that would do the job admirably.

Why are you so reluctant to accept advice?
 

mariomoskis

Mar 13, 2012
82
Joined
Mar 13, 2012
Messages
82
because i don´t have a mosfet,i just have transistor 2n2222a and bd135

the problem is about how to know the current consumed for the motor,why i have to take 2A,if when i have only a supply voltage 3V conected directly to the motor,the motor consumed 0.25A and when i use the gearbox this current is 0.45A?
you said that the peak can be higher,but the average isn´t go to be higer. so how can we know exactly the current to calculate the values of R and r1.because i need to know more or less exactly that the value at the base of the first transistor(q1) must be between 100microA and 2mA
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
because i don´t have a mosfet,i just have transistor 2n2222a and bd135

OK. I thought you didn't have a BD135 some time ago either, but hey, these things cost money, so I understand the reluctance to go out and keep throwing money at component suppliers.

the problem is about how to know the current consumed for the motor,why i have to take 2A,if when i have only a supply voltage 3V conected directly to the motor,the motor consumed 0.25A and when i use the gearbox this current is 0.45A?
you said that the peak can be higher,but the average isn´t go to be higer. so how can we know exactly the current to calculate the values of R and r1.because i need to know more or less exactly that the value at the base of the first transistor(q1) must be between 100microA and 2mA

The reason is that the motor only consumes those amounts of power at a MINIMUM.

You really need to design your circuit to operate in a closer to worst case scenario. If not work, at least not destroy itself.

Using the 2N2222 and a BD135 should give you far higher gain than a pair of BD135s, and far higher current carrying capacity than using a 2N2222 -- and that's how you build a Darlington, you use a small transistor to drive a larger one.

I would allow for the maximum (2mA) base current.

If someone grabs the output of the gearbox, the current could rise to an amp or even more. The average may be lower, but if your duty cycle is 80% then that 2A becomes 1.6A, and that's still pretty high.
 

mariomoskis

Mar 13, 2012
82
Joined
Mar 13, 2012
Messages
82
so ok,i will use q1(2n2222A) and q2(BD135), then if we take the worst case,we have:
current consumed 2A gain of 2n222a=35 and gain of BD135=25

so in the circuit with R and r1
http://imageshack.us/photo/my-images/717/darl2.jpg/

i will have the next values:
current at the base of q2 is: 2/25=0.08A
voltage across r1 is:3-0.2-0.7=2.1V
then r1 must be lower than: 2.1/0.08=26ohm

voltage across R is: 5-1.4=3.6V
and the current at the base of q1 is: 0.08/35=2.2mA
then R must be lower than: 3.6/2.2=1.6kohm

so i will have 2.2mA at the base of q1,but i can´t have more than 2mA because as i said compactrio can have only current between 100microA and 2mA in its digital output, so what can i do to reduce this value of current?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
OK, the first thing is that with reduced collector current through the 2N2222, you will probably have a higher gain. I'd suggest at least 50. So if we assume gains of 50 and 35, then your overall gain is around 1750.

With a base current of 2mA, you should be able to achieve a collector current around 3.5A. This will be enough to push the transistor into saturation for lower currents.

R1 simply needs to allow around 85mA across about 3V, so 310 ohms should be fine.

R2 will be 2mA across about 3.5V, and that's about 1.8k.

I'm assuming 5V to drive the transistors and the motor, otherwise you'll not get the full 3V across the motor. Your calculations are closer for a 3V supply.

The major difference is that you don't allow for the slightly higher gain of the transistor.

Remember that the gains are probably going to be higher, so you'll have more margin.
 

mariomoskis

Mar 13, 2012
82
Joined
Mar 13, 2012
Messages
82
ok,i am going to try it and i will say you the results

and i thought about to set a power resistor 1ohm or 0.5ohm ,between the colector of q2 and the parallel wire (motor diode),
and i will know the current which is really at the colector of q2
to do it,i will check the voltage across the resistor with the osciloscope and later calculate the I, so i will be able to know aproximately the current which is really at the colector, what do u think about it?
 

Wabajig

Apr 14, 2012
75
Joined
Apr 14, 2012
Messages
75
That seems like very poor advice.

Why on earth would you want to do that?

It sounds like you want to place the transistor across the supply rails, and drive the motor using the current flowing between the 555s output and the base of the transistor. Is that what you really mean?

Yes, +supply tied to the collector. He said the max voltage coming out of the 555 is 7v. Soo, take 7v - 3.3v zener - .6v for Base-emitter junction and you have a 3v supply for motor which is connected emitter to ground. This works like a series pass supply. Also I would put a 10k ohm resistor from base to ground, so the transistor will get out of saturation faster. And don't forget to put a 10uf cap across the motor, keeps the noise down.
 
Last edited:

mariomoskis

Mar 13, 2012
82
Joined
Mar 13, 2012
Messages
82
finally i can´t get this current because the waves are so distorsionated about the motor,and it is impossible to check the different of voltage

R1 simply needs to allow around 85mA across about 3V, so 310 ohms should be fine.

i think that to calculate R1 we have to do 3(Vcc)-0.2(Vce1)-0.7(Vbe2)=2.1V
and the current is Ic2/gain2=2/25=0.08A
*so R1 is=2.1/0.08=26 ohm(then if this is the max value to get saturation,i try 24ohm)
so the current will be finally 2.1/24=0.0875mA


and for R it is correct, at the output of CRIO i have 5V,so the voltage across R is 5(output)-0.7(Vbe1)-0.7(Vbe2)=3.6V,
the current at the base is 0.0875/40=2.1mA
* and R must be maximum 3.6/0.0021=1.8K
and ok,it will give me a current at the base of 2.1 mA,but it is the limit,but the gain will be higher than i guessed,so this current really will be lower and it won´t be a problem,yes??and i think to that the current that we guessed of 2A will be lower too,so it will help too

then finally with this values of R and R1 that i calculate *,i have with 50%duty cyle a average voltage across the motor of 2.3V(so much i think),with duty cyle of 20% i have 1.5V,and with duty of aprx100% i will have aprox 3V

why is that happen?i hope to have: average voltage across the motor of 1.5V with 50% dudy cycle,and about 2.2 with 75%
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Your calculations of resistor value seem about right.

The gain will be higher, possibly much higher (expect maybe an order of magnitude). This will be a good thing.

The voltage across the motor will be a complex issue and you should not expect it to vary as simply as you expect. Looking at the waveform on a scope would be more instructive.

You will achieve results similar to what you expect, but they will also vary somewhat with frequency.

You are now essentially supplying AC to an inductor. The change of current through it depends on the inductance of the windings of the motor and the load.
 

mariomoskis

Mar 13, 2012
82
Joined
Mar 13, 2012
Messages
82
ok,i checked that both transistors are saturated and the current at the base is 1.7mA because with the oscilloscope i measure the different of voltage across R = 3.2V so it look well

the results of voltage across the motor for differents duty cycle that i got are:
0.7V(10%) 1.1V(13%) 1.5V(18%) 2V(30%) 2.34V(50%) 2.68V(80%) 2.85V for duty aprox 100%

my multimeter has an option about measure the gain(hfe) of one transistor,how should i conect the wires of the multimeter to the transistor and measure the gain¿¿
 

mariomoskis

Mar 13, 2012
82
Joined
Mar 13, 2012
Messages
82
the voltages across the motor were measured with the oscilloscope

but i still think that that voltages should be lower, because i tried to control the dc with a power operational amplifier(i think that you have seen the post http://imageshack.us/photo/my-images/401/dudaq.jpg/) and in this case i have voltages like 1.5V(50%) 2.1V(75%) .... so i think that it is the normal results
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
the voltages across the motor were measured with the oscilloscope

How?

Was that the peak voltage, or some average that you figured out?

Or have you placed a capacitor across the motor?

Can you show us an image of the waveform you see across the motor?

And specify the frequency you're using.

but i still think that that voltages should be lower, because i tried to control the dc with a power operational amplifier(i think that you have seen the post http://imageshack.us/photo/my-images/401/dudaq.jpg/) and in this case i have voltages like 1.5V(50%) 2.1V(75%) .... so i think that it is the normal results

I'm not sure there are "normal" results.

The big issue is that you're still not using a high enough voltage to result in a full 3V ever being seen by the motor. Admittedly 2.85 is close, but that will probably drop under load.
 

mariomoskis

Mar 13, 2012
82
Joined
Mar 13, 2012
Messages
82
to measure that voltage,i put the oscilloscope between the colector of the transistor and the motor,in dc mode,frequency is between 100 hz and 500hz

so i can see a square wave which has values between 1.4V and 0.2V for 25%
1V and 0.2V for 50%
0.8V and 0.2V for 75%
0.6V and 0.2V for 95%

then the motor has average voltage 1,6V ,2V, 2.2V and 2.4V for the case that i said,is it correct?or are then peak voltages?
this values are little lower than the values i got with the multimeter
which are the really voltages that has the motor??


for example when i try to measure the square wave at the output of the crio,with the oscilloscope i saw a square wave with values between 0 and 5V, and with the multimeter i measure a voltage=2.5V
so about this,i deduce that the oscilloscope measures peak voltages and the multimeter measures averages voltages
or maybe this isn´t true for the case that i measure with the multimeter or oscilloscope the voltages when the motor affect to the wave, because at the output of crio the motor doesn´t affect to that waves
do you understand what i mean?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
to measure that voltage,i put the oscilloscope between the colector of the transistor and the motor,

If your circuit is this, then that makes no sense because the collector of the transistor is connected to the motor.

You need to look at the voltage across the motor, not between anything.
so i can see a square wave which has values between 1.4V and 0.2V for 25%
1V and 0.2V for 50%
0.8V and 0.2V for 75%
0.6V and 0.2V for 95%

Consequently, those readings don't mean much at all to me.

then the motor has average voltage 1,6V ,2V, 2.2V and 2.4V for the case that i said,is it correct?or are then peak voltages?
this values are little lower than the values i got with the multimeter
which are the really voltages that has the motor??

No, you measure the voltage across the motor with the scope, you don't try to calculate it from something else.
 

mariomoskis

Mar 13, 2012
82
Joined
Mar 13, 2012
Messages
82
i explained it bad,the voltage that i said you that i measure with the oscilloscope was between the motor,no under it


the question is:
if i measure the voltage at the output of crio,which has a sqaure wave of 5V amplitude,for example for 50%:
with the oscilloscope i measure the square wave between 5V and 0V
but with the multimeter i masure a voltage =2.5V
so i decuce that the multimeter measure average and the oscilloscope peak,is it correct?
then if it is right,will be it right too for all the measures that i will do at the circuit?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Let's just start with what you see across the motor.

At low frequencies you should see a square wave varying between 0 and some voltage. That voltage should not vary with the mark/space ratio.

What is that voltage?

Do you see the mark/space ratio changing?
 

mariomoskis

Mar 13, 2012
82
Joined
Mar 13, 2012
Messages
82
i think that i know the problem

all is about the frequency,i saw the next:

i use a frequency=1Hz,and in this case of course i get for 50% duty 1.5V across the motor,the normal situation

but for example when i do this frequency higher the average voltage across the motor is higher than when i did the same for a lower frequency,because the inductance of the motor is being more important with more frequency. so the problem isn´t about that i am measuring wrong voltages,the problem is about the motor and its inductance,do u understand what i want to say?

then i think that i can´t solve this problem because i am using frequencies of 100hz and 500Hz, do you know some way to reduce this?
 
Top