PCF8574 with ULN2003 as relay driver. :How to ensure initial state is OFF?

The question is essentially a continuation of this old thread :

I am using the attached circuit to driver 6 relays with a ULN2003 driven by a PCF8574.

The problem is that, at power on, the relays a left in a random state, most times they momentarily switch ON and then OFF.

The problem of random initial state could be solved with pull-up resistors at the output of the PCF8574. However, in this case, the initial state is always ON (till software switches output to OFF) while the requirement is for the initial state to be OFF.

On the other hand using pull-down resistors at the output of PCF8574 instead, is not an option since the PCF8574 would then be unable to drive the outputs high due its the low driving current capabilities.

Replacing the ULN2003 with an PNP darligton array equivalent would be a solution, (they stay OFF till the base is driven low). Is there a PNP equivalent of ULN2003?

Any other ideas would be mostly welcome!

Thanks for your support.

It seems you're using only 6 outputs. You could add a 74HC04 hex inverter between the two chips. Leo..

Other solution could be a use of an inverters before ULN or to use changeover instead of switching relays, both of course with the pull-up resistors on PCF8574.

to use changeover instead of switching relays

This would mean that ralays with outputs in the 'OFF' state will have their coil be energized which is not a good idea for lots of reasons

Same problem here

Finally I replaced PCF8574 & co by a single arduino pro mini working as a slave TWI device to drive my relay board.

Maybe overkill, but still cheap, easier to wire, and allows any custom drive (initial values, secure minimum time between switches, ...).

So what is the problem with adding an inverter IC.

We don't know WHY you want to use an expander. Maybe you don't know that you also can use the analogue inputs as digital outputs. Leo..

Finally I replaced PCF8574 & co by a single arduino pro mini working as a slave TWI device

You mean you have two arduinos in operation. One master and one slave just to drive the relays directly by the arduino outputs?

So what is the problem with adding an inverter IC.

It looks like the way to go is to use an inverter IC indeed.

I am using an expander because the other pins are used as other i/o.

Watcher: You mean you have two arduinos in operation. One master and one slave just to drive the relays directly by the arduino outputs?

Yes sir

(no direct relay drive. It's a sainsmart board, optoisolated etc.)

My purpose was to build a kind of TWI driven power strip

|500x133 |500x193

(also contains one ACS712 driven by the slave arduino)

Very interesting project bricoleau! So who is sending the commands to TWI?

The main system is based on an arduino mega, as a I2C master. See here (sorry i'm french)

That strip was designed for a specific use, but i'm working on a generic one that could be used as a simple I2C device (any purpose).

Very nice! So how far can you go with i2c? Shielded cables i would imagine? The enclosure looks very cleanly cut where the rj45 socket is and the lcd screen. Always difficult job to get right!

TY

I don't need long cables so i can't tell you about far i2c.

The rj45 hole was a great job. My dremel is my best friend. I made a big drilling template, to make a smaller drilling template, fixed on the enclosure with a kind of wooden scaffolding, to make this rj45 hole at the end. And same thing for the USB hole below.

I was so proud of myself... until my wife said "All this work for THAT ??" :stuck_out_tongue_closed_eyes:

nice work. I too like dremel.

I made a similar aquarium controller project, but I made it very compact, I literally put everything inside the outlet strip (chauvet).

also contains one ACS712 driven by the slave arduino)

So , you have one ACS712 for each channel/relay ?

and then for the analog measurement, did you use the analog input pins of the Arduino or did you use an external A/D converter chip?

I need to have only one current sensor, for the relay dedicated to heating system.

Firstly i used a couple PCF8574 (relays) + PCF8591 (ACS712) over I2C. Since i got in trouble with PCF8574 and relays, i replaced all this by a slave I2C arduino pro mini.

It is more accurate for driving the ACS712 over I2C. 8 bits ADC PCF8591 => 10 bits ADC arduino

Also, sensing 220V AC 50 Hz current needs multiple access to ACS712, to get min/max values. The arduino pro mini handle this. The main arduino sends an order ("start read ACS712") and asks for value one second later.

An arduino pro mini could handle up to 4 ACS712 with analog inputs (4 = 6 - SCL & SDA).

In my case, the use of an arduino pro mini offers much more possibilities, compared to combining basic integrated circuits.

Wiring is also easier.

PCF8591 (ACS712) over I2C.

ADS1015 could also be an option as well for addressable ADC over I2C

how do you use the acs712? do you attach it to the AC line? I could incorporate this into my project.

I did a search, I if I understand it correctly, you wire the acs712 in series with the load? so if I wire it in series with the relay, once relay switched is closed, it can start measuring the load current right? For AC measurement, does it give you RMS value?