[SOLVED]Drive servo with BJT

Couple days I cant solve the problem with driving servo via S8050 npn bjt.

Configurations is common emitter. When connecting hobby servo directly to +5v and GND rails I can control it without any issues. power to 5V rail is supplying Arduino uno through +5v pin. As far as I know unos power regulator can supply up to 800ma peak current. Unos 328p is bypassed with shorting reset pin to ground.

when testing with multimeter I can clearly see peak current of 1A and dimming leds on uno board as well but servo is working pretty good like that.

Now the main part of the problem.

I connected S8050 to servo. Base is pushed by 3.3v Attiny pin with 270ohm resistor on the way. So current to the base is 12ma.

Motor is connected this way vcc pin to +5v rail powered by arduno uno. servo ground to collector of bjt. Emitter to common ground. flyback diode also installed across servo.

The problem is that it seems servo is not getting enough voltage or current sometimes. When sending pwm its rotating to same direction always. pwm signal is good … tested hooking up servo VCC and GND directly to rails.

tried Darlington configuration with 2xS8050 didn't help either.

any advice to solve this problem ? I am thinking of increasing voltage to servo to 6v don't know yet if this will help with this issue.

thanks.

can draw and post a schematic if needed.

surepic:
can draw and post a schematic if needed.

You should have started with that, since I (maybe it's just me?) can't picture what you're trying to do.

Just get an external supply for the servo, 4x AAs for example, hook the grounds together, and Sorted.

Can you explain what you're trying to achieve with that transistor? It sounds like you're trying to switch power to the servo on and off by effectively disconnecting the ground. I'm having trouble seeing any reason to attempt that (ignoring for the minute that low-side switching doesn't work in this context).

Steve

surepic:
As far as I know unos power regulator can supply up to 800ma peak current. Unos 328p is bypassed with shorting reset pin to ground.

None of that makes sense.

To use a BJT transistor to switch 800 mA - if indeed the servo does not require more that that - you need to supply 80 mA to the base which the Arduino cannot do.

You need a logic-level pFET to switch the positive rail.

@neiklot schematic now is attached. external supply directly to servo without control will waste more current than leakage current of transistor if its switched off.

@slipstick you are right I`m trying to drive servo from low side.

@Paul_B explanation of the quoted part:
If my assumption is right then power regulator of uno board is providing 800ma peak current. If 328p will be powered it will suck current while being powered on but by bypassing power to 328p via reset to gnd I`m eliminating current path to 328p.

Servo does require supply to deal with stall current. I measured stall current and startup current is around 1A. Motor is towerpro MG995 and as per their datasheet min voltage is 4.8v and stall current 1.25A. But if thats true then why arduino uno regulator with 800ma is dealing with servo stalls without any problems? I connected directly to power rails without bjt and servo is working like a charm. I`m thinking can it be that transistor voltage drop is enouvgh to lower voltage to servo more than 0.2v then it will be around 4.7v or lower which can cause erratic behaviour.

Amplification of 10 can be corrected via darlington config which I did but again that didnt help.

What I didnt tried yet is +6v to motor and sziklai pair.

Why don't you just do a myServo.detach()?

Then it won't be getting the continual pulses to remind it where to go, and as far as I'm aware, won't be drawing any current.

Because myservo.detach has nothing to do with motor coils.

@neiklot schematic now is attached. external supply directly to servo without control will waste more current than leakage current of transistor if its switched off.”

surepic:
Because myservo.detach has nothing to do with motor coils.

We live and learn: I just measured 6mA on a myservo.detach()-ed HK13158 servo, so about the same as an led.

But what's your application that the power consumption is a thing?

OP image:

If you are powering the servo from the UNO, DON’T.

You will damage the UNO in short turn.

Larry currently i dont have voltage regulator i know its not smart to use unos output to power servo. Its jst for experiments. I will get one regulator for 6v tomorrow.

@Neiklot currently its not battery powered but i need to finish this part to switch to bms. So transistors will be swapped to fets eventually but as i am stucked in bjt problem i want to solve it and understand the issues then proceed.

Im probably wrong but dont you need a signal pin being fed with pwm and power hooked to V+ and ground hooked to V-? I only see 2 pins for your motor in the schematic? shouldn't there be 3?

tjones9163:
Im probably wrong

You're right, but what I think the OP is getting at is how to cut the power to the servo, as opposed to controlling it. So yes, the third wire is needed to control the servo, but I guess not relevant to a discussion about cutting the power.

Thats right i draw the part which has issue. Not to make things even more complicated.

Motor is getting its pwm through 3rd wire.

Small update:
Checked vce and its 0.28-0.3v when motor is running so i think motor is starving voltage as per datasheet minimum should be 4.8v but with collector to emitter drop its getting 4.7v.

surepic:
Thats right i draw the part which has issue. Not to make things even more complicated.

Motor is getting its pwm through 3rd wire.

Small update:
Checked vce and its 0.28-0.3v when motor is running so i think motor is starving voltage as per datasheet minimum should be 4.8v but with collector to emitter drop its getting 4.7v.

gotcha, just making sure im not going crazy, and by reading this post i also know how high and low side switching work.(After a quick google search).
Thanks

surepic:
Checked vce and its 0.28-0.3v when motor is running so i think motor is starving voltage as per datasheet minimum should be 4.8v but with collector to emitter drop its getting 4.7v.

4.7V is very unlikely to stop a servo working. A specification of 4.8V for hobby servos really means 4 x 1.2V nominal NiMH rechargeable batteries and people regularly run them down to 4.2-4.4V before recharging without any problems.

Steve

Its not stopping it its behaving erratically. Really hard to explain the behaviour but will do my best:

When motor is fed with 2ms pulse shaft is rotating to some direction.
Now when fed pulse is reduced to 1ms motor still is turning to same direction as with 2ms pulse.

Rechecked same process without bjt i.e. servo hooked up directly to rails doesnt show that problem. 1ms pulse is turning shaft to opposite direction of 2ms pulse.

Hope this description helps. Or i can make a small video.

Small addition to description:
If base current is getting below 10ma then motor is starving for current its starting to make noise and shaft is not moving. Im feeding it with 20ma base current to be safe.

I've never tried controlling a servo when it's ground connection is not connected to signal ground but to a voltage which is either floating at 5V or is the transistor Vce above the Arduino ground. It doesn't sound like a good idea and it's probably one reason why everyone recommends high-side power switching.

Steve

There was something interesting in your suggestion so tried the pnp config S8550 bjt. This time ground of servo is tied to ground.

But exact same problem. Absolutely no difference with previous npn config.

Tried 5.5v unregulated supply same problem if done through bjt. So my assumption of vce voltage drop was wrong and its not causing this issue.

Was thinking of buying 6v regulator hoping will fix the problem but it wont. Ran out of ideas.

Problem solved

By adding flyback diode across bjt .

Thanks everybody for support.

surepic:
Its not stopping it its behaving erratically. Really hard to explain the behaviour but will do my best:
...
If base current is getting below 10ma then motor is starving for current its starting to make noise and shaft is not moving. Im feeding it with 20ma base current to be safe.

Explained in #3.

surepic:
Problem solved
By adding flyback diode across bjt .

We will see ...