I am designing a device that uses an MCP23017 running at 3.3V to either check a "port" on a terminal strip as an input from a motion sensor or drive a relay/SCR/indicator from the same "port". I'm space limited so the terminal strip needs to be dual-purpose and each "port" function will be selected in software whenever the device boots up. It will, of course, not be an input AND output at the same time...
In "input" mode, GPA0 would be in input mode with pull-up enabled, and GPB0 would be LOW. In "output" mode, GPA0 would be HIZ and GPB0 would control the output state. Q3 would be 2N3904 (unless you have a better suggestion) and I need advice on a part number for Q2.
The relay and switch on the other side of the terminal strip are just there for visualization purposes to save space. In input mode pretend the relay isn't there, in output mode pretend the switch isn't there. They would not be connected to the same terminals in the real world.
Given the diagram below, can you offer some insight into the following questions?
- Is this even feasible?
- In output mode, would the 12V potential on GPA0 cause any problems over time? (It's in HIZ)
- In input mode will there be much leakage from the mosfet and will that affect sensing the input state in any way?
- Is 1N4004 the right choice for flyback diode?
- Can you recommend a P channel mosfet that is as small as possible, can handle up to 500ma and won't generate much heat?
- Are there any other issues you can spot or advice/recommendations you can give me?
I will likely add a resettable fuse on each mosfet drain as well.