Schorschi
Posts: 277
Joined: Thu Nov 22, 2012 9:38 pm

Recommend GPIO expander (like PCF8574) but default/initial state is not input?

Sat Apr 21, 2018 9:11 pm

Can anyone recommend GPIO expander (like PCF8574) but default state is not as input? I have used the PCF8574 for a number of projects, but now have a project where I need the default/initial state to be output LOW? The input state is triggering the downstream devices unfortunately and I need to avoid this.

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 6436
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: Recommend GPIO expander (like PCF8574) but default/initial state is not input?

Sat Apr 21, 2018 10:28 pm

Schorschi wrote: Can anyone recommend GPIO expander (like PCF8574) but default state is not as input? I have used the PCF8574 for a number of projects, but now have a project where I need the default/initial state to be output LOW? The input state is triggering the downstream devices unfortunately and I need to avoid this.
The MCP23008's external /RESET (or Power-On-Reset) state is with the GPIO's & OLAT register low but it does require some initialisation code before "use in anger". Unlike the PCF8574, which is a "quasi-input" device, with virtually no registers, just requiring the output's to be set high and then (externally) pulled low to be used as inputs, the MCP23008 has to be (re-)programmed, via its internal registers, to switch from output to input mode. Are you using the PCF8574 as a (true) I2C expander, or for some other purpose? If the latter, could you use one of its outputs to gate the problem downstream connection (or another Pi GPIO) until you've written 0's to it?
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B, B+, and a A+) but Buster on the P3B+, P4B's & P400. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

stevend
Posts: 419
Joined: Fri Oct 11, 2013 12:28 pm

Re: Recommend GPIO expander (like PCF8574) but default/initial state is not input?

Sun Apr 22, 2018 7:20 am

Most, if not all, configurable I/O devices will power up with the I/O pins set as inputs.
You need to pick one with an option of push-pull outputs, where you can configure the pins to outputs during startup without momentarily glitching them high. IIRC the MCP23008 that Trevor suggested would do this.
Add a pulldown resistor between each I/O pin and 0V (typically in the 10K to 100K range).
And make sure that the circuitry driven by the output doesn't pull the output high during power up. (An N-channel MOSFET, such as the BSP75, is a good device to drive from the pin).

Return to “General discussion”