1
\$\begingroup\$

I have an MCU (1.8 V logic levels) driving an NPN transistor to turn an relay on/off. The relay has a 12 V DC coil with resistance of 1028R per datasheet. This would require a current of 12/1028 = 11.6mA to drive.

The transistor has a min gain of 100 per datasheet. Hence a min base current of 11.6 mA/100 = 0.116 mA required.

Analysing the circuit, (ignoring 22k resistor for simplicity) the base current is set to (3.3 - 0.7) / 1k = 2.6 mA (>> required 0.116 mA). This should be more than enough to saturate the transistor and ensure that the relay is on.

The problem is that the relay does not always turn on (seen as a production issue). The transistor circuit looks good to me. I'm wondering if the TXS0108E level translator is part of the problem. Or am I not driving the relay properly?

I will put the scope on the circuit shortly but any help would be appreciated.

enter image description here

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Is your 12V stable, doesn't decrease for some reason? Are both 1v8 and 3v3 grounded together? Are they stable? Try to connect 1v8 to A8 with wire. \$\endgroup\$
    – user208862
    Commented Nov 12, 2021 at 12:10
  • \$\begingroup\$ It is not clear if you have already used the TSX0108e. If you are sure the 1v8 signal can drive the NPN BJT properly, then there is not point of using any level up shifter. BTW, TSX0108 is good for open drain I2C circuits. I would recommend a converter with push/pull /totem pole output. \$\endgroup\$
    – tlfong01
    Commented Nov 12, 2021 at 12:12
  • \$\begingroup\$ One other thing is that the relay coil is a inductive load, There might be some complications such as (1) you are switching too fast. Usually 10Hz is OK, more than that the relay might not follow. \$\endgroup\$
    – tlfong01
    Commented Nov 12, 2021 at 12:15
  • \$\begingroup\$ Hi, thank you for the input. All supplies are stable. Grounds are connected. The TSX0108e is already in the production design so I can't take it out (it is driving other signals as well as it is a multi-port device). Switching is much slower than 10Hz - more like once every few hours. \$\endgroup\$
    – RoyalAce
    Commented Nov 12, 2021 at 14:31
  • \$\begingroup\$ All ICs should be understood by their internal functions, not just by their name, and voltage level translators are one of the major candidates for misunderstanding. It looks like whoever designed the circuit saw it as a 'magic voltage converter' and I have seen the same thinking in many circuits. As others have said, no voltage translation is needed anyway. But: always read the datasheet, always understand the internals of the part you have. As seen here, it's a wasteful and expensive toll on company profits just because the designer could not be bothered to first read and fully understand. \$\endgroup\$
    – TonyM
    Commented Nov 12, 2021 at 17:54

3 Answers 3

4
\$\begingroup\$

Yes, the birectional level translator is a part of the problem.

In fact, it most likely is the cause of the problem.

A bi-directional logic level shifter with automatic direction control is just unsuitable for the task of driving the transistor.

The level shifter is meant for logic level signals, which are within the specs of logic levels.

The transistor base input with the resistors most likely does not fit into specs for a valid logic input or output for the chip. It is possible that due to component manufacturing tolerances the level translator might determine that the transistor is a low logic output so it changes direction and starts to drive the MCU output pin.

Even if some boards have passed the production testing, it still means that there is a design flaw and the problem can appear systematically during product use. All it takes is some component aging or minor changes in temperature or capacitance so power supply voltages rise rates differ, and the level translator will start driving the pin wrongly.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ +this a thousand times. Bidirectional level translators are just a disaster waiting to happen, unless you use them exactly as the chip designers envisioned them. In this particular case, most probably the output resistance of the driver of the bidir translator is just a tiny bit too high, thus the unreliable operation. A quick and dirty fix might be any combination of unpopping the 22k, swapping the 1k with something much lower, or powering the bidir with 5V or something like that. \$\endgroup\$ Commented Nov 12, 2021 at 13:00
  • \$\begingroup\$ Thanks. I'm going to put the scope on the base of the transistor then switch the device and measure a number of times. I will then try with the 22k removed and the 1k lower - do you have a recommendation for the lower value please? Also, if I remove the 22k, will that not cause an issue when the MCU is booting and the output is in high impedance state? I like your suggestion as it can easily be introduced without wire mods in production. \$\endgroup\$
    – RoyalAce
    Commented Nov 12, 2021 at 14:41
  • \$\begingroup\$ @Justme - thank you for the education. \$\endgroup\$
    – RoyalAce
    Commented Nov 12, 2021 at 14:42
1
\$\begingroup\$

The first false assumption is ;

The transistor has a min gain of 100 per datasheet. Hence a min base current of 11.6 mA/100 = 0.116 mA required.

This is incorrect. A common saturated transistor switch will only have 10 to 20% of its hFE depending on your tolerance for Vcs(sat) and actual Ic selected. This tends to be around 10% of the max IC for maximum hFE. Your Ic selection will have some hFE but may no longer be plotted in datasheets as they have trimmed down datasheet content these days. Look for datasheets that have them on similar types. I have viewed thousands to come to these conclusions. Take my word and trust me or do your own due diligence.

This is why all Vce(sat) specs use Ic/Ib ratios nearest to the standard values of 10% or 20% of hFE with ratios of 10,20 or 50 for Ic/Ib conditions on Vce(sat) specs.

Thus if hFE can be <=150 Ic/Ib=10 is used.
If hFE is >150 but less than 250, then Ic/Ib=20 is added or used instead.
If hFE> 250 to 2000 minimum then Ic/Ib=50 is used. Diodes Inc also includes Rce=Vce(sat)/Ic challenging FET RdsON performance but much greater cost yet lower Coss, in their special designs of this type. Thus, using this rated ratio, you now have a Thevenin Voltage divider with coil R.

This is why your Relay is unreliable. False assumptions.

(we all make false assumptions sooner or later, so don't sweat it)

You do NOT NEED a level translator to drive an NPN

With 0.7Vbe from 1.7V Your driver is certainly << 50 Ohms.

You can simply use a lower R without any 22k unless your port is an input for too long on powerup.

Verify your uC Vol/Iol=Zout tolerances at Vdd.

Never assume until you are certain.

\$\endgroup\$
2
  • \$\begingroup\$ I strongly suggest you read the data sheet for the BJT in question and note the minimum operating voltage for the relay. \$\endgroup\$
    – Andy aka
    Commented Nov 12, 2021 at 14:55
  • \$\begingroup\$ Thank you Tony. Removing the level translator would not be the best route as the boards are already in production and a wire mod adds complication above just changing some R values. Educated myself about using transistors as an amplifier vs a switch. So redoing the calculations: As before, relay requires 12/1028 = 11.6mA to drive. Using a transistor gain of 10 (instead of 100) 11.6 mA/10 = 1.16 mA required. As before, the base current is set to (3.3 - 0.7) / 1k = 2.6 mA. This is greater than the 1.16mA required or have I misunderstood? \$\endgroup\$
    – RoyalAce
    Commented Nov 12, 2021 at 15:06
0
\$\begingroup\$

Just drive the BJT directly from the 1.8 volt logic at around 1 mA (with a suitable series resistor of course) and it should be fine. The BJT is a good choice on min hFE at low saturation voltages so, you just don't need a level shifter. The relay will pull-in at 9 volts so there's no issue there either. It has to be problems with the level shifter (not needed).

Of course, if your 12 volt rail is bad then that'll be the problem but, assuming it's good, it's only the level-shifter that is messing things up.

\$\endgroup\$
2
  • \$\begingroup\$ Thank you. I would prefer to avoid rework in production and as the translator is already in circuit, it would require a wire mod to remove it on this specific port of the device. But I take your point. \$\endgroup\$
    – RoyalAce
    Commented Nov 12, 2021 at 14:38
  • \$\begingroup\$ Sometimes you just have to bite the bullet. You asked for reasons and the data sheet for the level translator contain those reasons. \$\endgroup\$
    – Andy aka
    Commented Nov 12, 2021 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.