Using a BC847 SMD vs BC547 (Solved - software issue) - Page 1
Forum section: electronics / beginners

author: kristakis
author_rank: Contributor
timestamp: March 15, 2023, 08:14:17 am
content: I have an ATMEGA32U4 driving a BC547 with 1K to trigger a relay (HK19) and it works great. There's a 1N4004 to handle coil collapse and the relay uses 30mA when on. If I put the relay straight onto 5V then it pulls 40mA.Now I have changed the BC547 to a BC847 to shrink things down a little and am finding that the relay is only getting 22mA which is not enough to fully close it. Interestingly it moves internally enough to cause some contacts to change but it's not reliable.The datasheet for the BC847 says VBEsat. is 700-900mV for Ic 10-100mA and I'm seeing 750 which feels about right. I understand that I can use a Hfe of 10 if I'm just using this as a switch so for an Ic of 40mA I need an Ib of 4mA. With 5-0.7 gives 4.3/0.004 = 1075R for Rb so my 1K should be enough.FWIW I tried 500R and 2K and didn't see any difference so I'm guessing I'm driving it as hard as I can? The ATMEGA is not using any other pins so as far as I know I'm not running into it's 100mA port limit. Disconnecting the base I am getting 5V from the ATMEGA.Does anyone have any ideas? I can post schematics but it's not a complex circuit. Is there a different part I should be using perhaps?

author: mariush
author_rank: Super Contributor
timestamp: March 15, 2023, 08:40:07 am
content: As long as your transistor allows for more current than what the solenoid needs, you're fine. I would aim for at least 50mA, so around 5mA on the base of that transistor with a hFe of 10. Basically, account for solenoid getting old, for variations in temperature, for peak currents when started cold etc etcThere are lots of cheap transistors with beta/hFe in the 50-100 range, for example MMBT3904 -https://www.digikey.com/en/products/detail/diodes-incorporated/MMBT3904-7-F/814494- or MMBT2222 -https://www.digikey.com/en/products/detail/diodes-incorporated/MMBT2222A-7-F/814503- and they're pennies if you buy a bunch of them.For calculating base current, see the tutorial below, but it's ok to just "eyeball" it and round the resistor value to something standard like 270/330/470/560/680/820/1000 ohm.Alternatively you could use a n-channel mosfet and a resistor from gate to source to discharge it when you want to turn it off.

author: Vovk_Z
author_rank: Super Contributor
timestamp: March 15, 2023, 08:43:26 am
content: I gues with Ic = 40 mA hfe still has to be more than 100 (according to dstasheet). Have you measured the Vce across a transistor?I guess there is something wrong. In general BC847 has to work in the same way as BC547. Their thermal properties are the only difference.

author: wraper
author_rank: Unknown
timestamp: March 15, 2023, 08:55:00 am
content: Either you connected it wrong (like C-E swapped) or it's not real BC847. Also It's much better to use a small mosfet instead as at 5V there is too much voltage drop on BJT compared to voltage needed for 5V relay.

author: kristakis
author_rank: Contributor
timestamp: March 15, 2023, 11:40:42 pm
content: Thanks everyone for the info and suggestions. I had a 2nd transistor on the board and tried it instead and it worked. As I was modifying the code to setup that other pin I noticed i had neglected to set the pin mode for the first one.Code:pinMode(RELAY1, OUTPUT);So I set that and it started working! This was an educational learning experience and now I'm looking at FETs for the next revision.thanks everyone.

author: Nominal Animal
author_rank: Super Contributor
timestamp: March 16, 2023, 07:33:42 am
content: Thanks for letting everyone know!In case it is of interest, the reason you observed the effect you did is that when the GPIO pin is an input, setting the output high actually just enables the internal pull-up resistor (which is something between 20kΩ and 50kΩ). The pull-up resistor limits the current from VCC to the BC847 base, just as if you had the base connected to VCC via something like 21kΩ to 51kΩ resistor, which is why the BC847 passed some current, but not as much as you expected.(I'm only a hobbyist myself, but personally happen to like both ATmega32u4 and NXP BC847C,215 and BC857C,215 transistors in SMD –– even I can hand-solder SOT23 ––, because NXP provides pretty good SPICE symbols for them for simulating my sausage-fingered designs:BC847C,BC857C.)