# How to design a circuit that the input signal type(positive or negative) can be selected via software configuration

Firstly, Hello to all, I am trying to design a circuit for automotive application that circuit will read positive and negative input signals in the same pin via selecting the type of input in the software. I designed a prototype circuit to do it.You can see it in this picture.

I refered a digikey article. Link of the article is here Protecting Inputs in Digital Electronics. When I want to read positive signal (9 V - 32 V). I will set internal pull-down resistor and input will be active high. When I want to read negative signal (0 V) I will set internal pull-up resistor and input will be active low. Internal pull-up and pull-down resistor value of the STM32F042C6 vary between 25k to 55k but typical value is 40k. Do you have any recommendation to improve design of the circuit ?

Edited: If I don't use pull down resistor.While reading positive signal.The capacitor(C1) will not be discharged after I switch(SW1) from positive signal to floating(not connected) and I will still read it as a high input.In this picture you can see that the input of the mcu is hanging arround 2.96V when the input not connected and the pull down resistor not selected.Is there any way to solve this problem without using pull down resistor?

• I have studied the schematic but see no evidence of a negative voltage source. Do you mean that you want to (not "wanna") read positive and zero-volt input signals? – Transistor Mar 17 '20 at 20:32
• I meant to read positive and zero volt input signals.@Transistor – mrt Mar 18 '20 at 11:57

• With SW1 grounded R2, R4 and R1 form a potential divider on the input. The input voltage will be given by $$\ V_i = \frac {1.01}{40 + 1.01}3.3 = 81 \ \text {mV} \$$. This should be well below your logic low minimum allowable voltage.