On Sunday 23 August 2015 15:52:27 Luke Kenneth Casson Leighton wrote:
still don't feel completely happy (esp. with the schottky diode), i
I think it can be done with 3 resistors and 1 transistor used with a floating collector. Using a floating collector is better because CPU voltage can be lower than 3.3v.
I've attached a png file with a proposal. You may need to adjust the resistor values depending on the current drawn from the CPU.
When the input is floating, the transistor is on because of the 100k pull-up.
When the input is 3.3, the transistor is also on.
When the input is 0, the transistor emitter is driven to ~ 0.3V which should switch off the transistor.
When the transistor in switched on, in a saturated state, the voltage between collector and emitter is much lower than 0.6V, so the CPU will see a logical 0. When the transistor is off, the output is high impedance. You may need a pull-up resistor on the CPU board.
Please take this with a grain of salt, it's been a while since I played with transistors this way (~ 25 years...)
Hope this helps.