This is based on my previous question here: How to accept switched GND or switched Positive on a 3v3 MCU input
But I want to go further so I think it is best to ask a new question.
My device is much like a PLC where each pin can be reconfigured through software.
I am using a STM32F105 which is 3v3
I would like to keep pin count to an absolute minimum so I was wondering if there was a way to have one pin that was reconfigurable to the following:
- Accept a input switched to GND
- Accept a input switched to 30VDC
- Accept a 0-15vdc analog input
- Provide a Analog output 0-15vdc
- Provide a Digital out of either 5v or 12v selectable through software.
- Provide a Ground for external sensors.
The reason I need to have these reconfigurable pin is because I cannot change the hardware I am connecting to, sometimes I may need to connect to a switch switched to ground, another time a sensor that outputs 0-5v.
Sometimes I need to simulate a sensor, switch or other device.
Sometimes a sensor is a variable resistor connected to either ground or positive and I would need a way of simulating this through the MCU.
Is there a way of doing this, if yes what would be the best way?
The only way I can think of is to have a group of SPDT analog switches connected to each input such as MAX14763 or the quad MAX394, would this work?