MCU pin connection - Page 1
Forum section: electronics / beginners

author: Miha
author_rank: Contributor
timestamp: February 07, 2023, 09:50:18 am
content: Hello.MCU port need to receive diskret signal (0V/12V) 1kHz max.I plan to use only 100k resistor to limit port current and some ceramic capacitor for noise immunity, like in the picture? Will MCU port protected well when 12V signal present?

author: Siwastaja
author_rank: Super Contributor
timestamp: February 07, 2023, 10:15:30 am
content: That's good. Will work even without the pull-down resistor R5 (unless it's needed in case the source cannot actively pull down).The 100k will limit the current to something easily handled by the protection diodes within the MCU (which usually can take a few mA). 100k + 100p will offer semi-decent ESD protection. What you will see is Vcc+0.3V at the input pin of the MCU, clamped by the internal protection diodes. Note that if the signal is present during power-down, the signal can supply power to the Vcc node of the MCU, until the supply capacitors fill up enough to try to boot the MCU.RC time constant will be 100k*100p = 10 µs, which sounds quite sensible given the maximum input frequency of 1kHz. If you are not worried about the delay (phase shift) and won't need to go beyond 1kHz, you can use somewhat larger capacitor, maybe up to 470-1000pF, for even better filtration against high frequency noise, and ESD.

author: Ian.M
author_rank: Super Contributor
timestamp: February 07, 2023, 10:24:15 am
content: Why not make R5 39K to better match the potential divider output to the MCU's logic levels?@Siwastaja: Assuming R5 is not removed, err . . .shouldn't you be using the Thevenin equivalent resistance for the time constant calculation?

author: Miha
author_rank: Contributor
timestamp: February 07, 2023, 12:41:17 pm
content: Quote from: Siwastaja on February 07, 2023, 10:15:30 amQuote from: Ian.M on February 07, 2023, 10:24:15 amThanks for detailed and fasts responses! Now I fully understand schematic behaviour, and all underwater rocks, that you pointed me (MCU parasitic powering and signal delay on the MCU port).Yes, I will decrease R5 for better match MCU level to 12V signal level.Quote from: Ian.M on February 07, 2023, 10:24:15 amI think to estimate the response time it is enough to calculate the R*C.

author: Siwastaja
author_rank: Super Contributor
timestamp: February 07, 2023, 01:46:17 pm
content: Quote from: Ian.M on February 07, 2023, 10:24:15 amObviously yes, but then again the time calculated would indicate the time to reach 63.2% * 6.0V = 3.792V. With R5 removed, source resistance is now 100k and not 50k, but the voltage after one time constant has passed is now 63.2% * 12.0V = 7.584V.In both cases, the ESD diodes are already clamping the voltage before one time constant.R5 will help dissipate the capacitor faster.If reproducing the exact duty cycle, or delay, is of any importance, I would recommend simulating the circuit in Spice. MCU input pin can be modeled as two generic schottky diodes, one going to GND and other to ideal +3.3V voltage source.If you want to keep R5, then yes it's a good idea to lower its value to form a better matched voltage divider. Just don't go too far not to eat into logic level margins. Use the lowest possible actual value of that "12V" and make sure the output is then at least 3.0V or so.