Resistor Pull-Up/Down Problems With Relay Driving Circuit And Darlington Transistor

Thread Starter

Mahonroy

Joined Oct 21, 2014
406
Hello,
I created a relay driving circuit using an IO extender (PCF8574) and darlington transistors (MMBTA13). I was originally not aware that the IO extender can only source 100uA of current for an output... knowing that now I would probably design this quite differently. This is why I am currently trying the darlington.

However, I have some boards that I am hoping I can get to work by swapping out components, but I am currently stuck.
Here is my schematic and a description of what is going on:
PCF8574_question.jpg

The relay can activate on and off no problem, that all works.

The problem is that on initial power up (before the IO expander has been configured), the GPIOs default to an INPUT with an internal 100uA pullup (which I assume to be 33K?). This is enough to activate the darlington transistor. Because of this, the relays activate for this short period of time, until the IO expanders GPIOs are configured as OUTPUTs.

I was experimenting with R24, I thought that if I reduced the ohm value enough that it would overpower the 33K internal pull up. 15K resistor is not enough and the relay activates on power up. 12K resistor is too much and the relay will never activate no matter what.

What do you think I should try to get this thing working, I am stumped. Thanks and any help or advice is greatly appreciated.

And again, if I was to redesign this, I think I would instead run the GPIOs into an Inverter and then into ULN2803A, but for now I am sort of stuck with this for the time being.

Datasheets:
Darlington Transistor:
https://www.fairchildsemi.com/datasheets/MM/MMBTA13.pdf

IO Expander:
https://www.nxp.com/docs/en/data-sheet/PCF8574_PCF8574A.pdf
 

dl324

Joined Mar 30, 2015
16,909
I was experimenting with R24, I thought that if I reduced the ohm value enough that it would overpower the 33K internal pull up. 15K resistor is not enough and the relay activates on power up. 12K resistor is too much and the relay will never activate no matter what.
That method depends on the particular transistor being used; with transistors from the same lot able to have different characteristics.

I'd take a completely different approach. I'm assuming this problem occurs at startup. If that's the case, just make a power on circuit that forces the darlington(s) to be off for the amount of time that it takes for the I/O configuration.
 

Thread Starter

Mahonroy

Joined Oct 21, 2014
406
How short?
Would a delay in the relay operation greater than this time be a problem in your circuit operation?
Anywhere between 3 and 10 seconds is typical. The device connects to wifi before code executes. So its possible it never connects, at which point the relays would be incorrectly on for long periods of time.

That method depends on the particular transistor being used; with transistors from the same lot able to have different characteristics.

I'd take a completely different approach. I'm assuming this problem occurs at startup. If that's the case, just make a power on circuit that forces the darlington(s) to be off for the amount of time that it takes for the I/O configuration.
I'm not following the "power on circuit".
 

Thread Starter

Mahonroy

Joined Oct 21, 2014
406
Can you program it so that enough code executes initially to put the output low before WiFi connects?
This is not possible on this device. Even if it was, there would be a split second boot up time for this to occur.

Classical power on circuit:
View attachment 137211
If you don't have 5V available, you can try 3.3V; but inverter might not be able to source enough current to saturate Q1.
Thanks for the circuit. So on power up, the 5v is inverted into a 0 (GND), which prevents curret from flowing through Q1, which would allow Q2 to activate? I'm not sure I understand this circuit.

Is this not possible to accomplish with my current circuit and different transistor/mosfet and different resistors? If I had to re-design it, wouldn't it be better to just use an inverter and a ULN2803A like I mentioned earlier?
 

philba

Joined Aug 17, 2017
959
Wouldn't an N-MOSFET make more sense here? You can use a relatively strong pull down to keep the gate from being pulled up high enough. You'd have to pick the right MOSFET, though. I played a bit with a simple spice model and found several that won't trigger with a 33K PU and 10K PD but will trigger with effectively a 1K PU (as in when the IO becomes an output high) and 10K PD. Basically the PU and PD form a divider that keeps the gate V low and only lets a small amount of current through the MOSFET (uAmps or less) that won't trigger the relay.
 

dl324

Joined Mar 30, 2015
16,909
So on power up, the 5v is inverted into a 0 (GND), which prevents curret from flowing through Q1, which would allow Q2 to activate? I'm not sure I understand this circuit.
At power on, C1 will be discharged and will hold the input to the inverter LOW until the capacitor voltage reaches VIH (V in HIGH). Until then, the output of the inverter will be HIGH, turning on Q1 which will prevent Q2 from turning on and energizing the relay.
Is this not possible to accomplish with my current circuit and different transistor/mosfet and different resistors? If I had to re-design it, wouldn't it be better to just use an inverter and a ULN2803A like I mentioned earlier?
No. When you startup your microcontroller, the GPIO's will be a weak HIGH. You need to deal with that for whatever relay driver you use.

Your attempt at using a voltage divider was a kludge that depends on the characteristics of the actual transistor being used. Change the transistor and it may no longer work.
 

Thread Starter

Mahonroy

Joined Oct 21, 2014
406
Wouldn't an N-MOSFET make more sense here? You can use a relatively strong pull down to keep the gate from being pulled up high enough. You'd have to pick the right MOSFET, though. I played a bit with a simple spice model and found several that won't trigger with a 33K PU and 10K PD but will trigger with effectively a 1K PU (as in when the IO becomes an output high) and 10K PD. Basically the PU and PD form a divider that keeps the gate V low and only lets a small amount of current through the MOSFET (uAmps or less) that won't trigger the relay.
I had ordered 2N7002 mosfets to try as well, and they also work for activating/deactivating the relay, but I was still left with the same startup problem.
Would this 2N7002 work in your spice model? The only test I did with the 2N7002 was I shorted R25, and used a 60K at R24.
 

philba

Joined Aug 17, 2017
959
Yeah, the 2N7002 seems to work in the model. Though, I'd worry about power dissipation. It has an absolute max drain current of a bit more than 100 mA. I'd worry about overheating. What's your relay's coil current?

I'd try using 10K for R24 and 1K at R23.
 
Last edited:

Thread Starter

Mahonroy

Joined Oct 21, 2014
406
Yeah, the 2N7002 seems to work in the model. Though, I'd worry about power dissipation. It has an absolute max drain current of a bit more than 100 mA. I'd worry about overheating. What's your relay's coil current?

I'd try using 10K for R24 and 1K at R23.
Hi Philba, thanks I will definitely try this! The relay coil is 0.36W, so @12 volts this looks to be 30mA.

Did you mean 1K for R25, and 10K for R24?
 

philba

Joined Aug 17, 2017
959
Yes, my bad. R25 = 1K. The 7002 may be fine then. Though, the spice model shows some odd behavior with the 2N7002 model (other mosfets don't). The current through the load (400 ohm based on your relay info above) rises (in the pico-amp range, though) and then falls in the last little bit of the simulation. No matter how long I run the sim for it does that so I'm not super confident of the simulation.
 

Thread Starter

Mahonroy

Joined Oct 21, 2014
406
Yes, my bad. R25 = 1K. The 7002 may be fine then. Though, the spice model shows some odd behavior with the 2N7002 model (other mosfets don't). The current through the load (400 ohm based on your relay info above) rises (in the pico-amp range, though) and then falls in the last little bit of the simulation. No matter how long I run the sim for it does that so I'm not super confident of the simulation.
Hi Philba, I tested this today, unfortunately it didn't work.
The 10K resistor appears to be too strong of a pulldown, so even setting the GPIO pin to output high the relay never turns on.
 

philba

Joined Aug 17, 2017
959
Here's my ltspice simulation of that. You can see the pulses input to the gate and the current (in red) through the load. You could try increasing the pulldown. Also, verify that you have the correct voltage at various points.
mosfet driver.png
 

Thread Starter

Mahonroy

Joined Oct 21, 2014
406
Here's my ltspice simulation of that. You can see the pulses input to the gate and the current (in red) through the load. You could try increasing the pulldown. Also, verify that you have the correct voltage at various points.
View attachment 137397
Thanks for the image!
I believe "increasing the pulldown" would make it worse... because currently the pulldown appears to be too strong already, which is preventing the GPIO output high from being able to activate the mosfet now.
 

Thread Starter

Mahonroy

Joined Oct 21, 2014
406
increasing the PD resistor value will make it weaker.
Correct. But before I had tried 15K pulldown instead (with the darlington), and this allowed the GPIO to control the relay... however... 15K was not strong enough to turn the relay off during that power up period.
 
Top