0
\$\begingroup\$

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?

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

Accept a input switched to GND

You would need to configure the pin as a digital input and provide a pull-up resistor to Vdd.

Accept a input switched to 30VDC

You would need to configure the pin as a digital input and use two resistors to form a voltage divider.

Accept a 0-15vdc analog input

You would need to configure the pin as a analog input and use two resistors to form a voltage divider.

Provide a Analog output 0-15vdc

This is the one configuration that is probably not possible on any arbitrary pin, as the DAC outputs can only appear on ports PA4 and PA5.

Provide a Digital out of either 5v or 12v selectable through software.

You would need to configure the pin as a digital output and use external transistors (or an analog switch) to switch between the two voltages.

Provide a Ground for external sensors.

You could alternately configure the pin as an input (tristate) or digital output 0 (ground).

You could provide all of these options at the same time, and select which one to use via a Berg connector (jumper). The analog functionality is limited to the 16 pins that can be remapped to the 16 channels of the two ADCs.

\$\endgroup\$
0
\$\begingroup\$

Not without additional hardware.

There are some pins on the STM32F105 that can be configured to all the modes you want -- for instance, A4 and A5 both support analog input and output -- but the voltages you're describing will be a problem.

The STM32F105 can tolerate 5V inputs on some pins, but certainly not 15V or 30V. Generating 12V or 15V outputs is impossible as well.

\$\endgroup\$
2
  • \$\begingroup\$ Im not worried about additional hardware as long as it doesn't get to the point where the component count and costs outweigh the reduced pin count. Ive since updated, would the analog switch connected to each pin be a good idea? \$\endgroup\$ Commented Oct 30, 2016 at 15:06
  • \$\begingroup\$ The component cost would definitely outweigh the pin count. You'd be much better off using a separate pin for most of those functions, and only trying to multiplex in special cases. \$\endgroup\$
    – user39382
    Commented Oct 30, 2016 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.