Use a series resistor that is connected to your input. Then at that input put a couple of diodes: one connected to 3.3V, and the other connected to ground.
Just use a discrete small-signal MOSFET with a drain resistor to +3.3 V. There are automotive types available with gate protection against transients.
Don't forget it will invert the input, but your firmware should take care of that.
Just use a discrete small-signal MOSFET with a drain resistor to +3.3 V. There are automotive types available with gate protection against transients.
Don't forget it will invert the input, but your firmware should take care of that.Or put the resistor between the source and 0V and connect the drain to +3.3V.
Just use a discrete small-signal MOSFET with a drain resistor to +3.3 V. There are automotive types available with gate protection against transients.
Don't forget it will invert the input, but your firmware should take care of that.Or put the resistor between the source and 0V and connect the drain to +3.3V.
That would require a MOSFET that turns on at 1.7 V gate voltage, which is not easy to find.
What frequency is the square wave?
The easiest method is to use a series resistor, say 10k to 1M, before the MCU input. The internal ESD protection diodes will clamp the input voltage at about 0.6V above the MCU's power supply.
Just use a discrete small-signal MOSFET with a drain resistor to +3.3 V. There are automotive types available with gate protection against transients.
Don't forget it will invert the input, but your firmware should take care of that.
You should consider whether galvanic isolation might be beneficial.
If so, you could combine it with an optocoupler for level translation.
It depends on how fast your signals are, what protection needed and how clean (signal integrity) you need the signal be.
For automotive application interfacing into sensitive equipment, complete galvanic isolation using optocoupler is favored. Considering that automotive 13.8v line can surge to very high voltage at load dump, even peaking at 60V(!)
Otherwise if the source is already surge-suppressed, you can use pretty much any logic level shifter. With comparator, the idea is to pull-up the comparator's open drain/open colector output into target voltage. Obviously the comparator itself is supplied from the (higher) source voltage. Unless specifically noted in the datasheet, never put voltages higher than supply voltage on any IC and expect it to work flawlessly.
About low voltage MOSFET. Almost all MOSFET Vgs(th) is pretty low in the ~2V area, and even lower for signal MOSFET. You don't need to get past Miller voltage just to conduct a few microamperes.
If you don't mind signal inversion, with 5V you could just stick a 5V tolerant hex inverter in there.
As soon as a poster says "automotive" i know they are in a world of trouble!
firstly, automotive isn't "12v"!! Typical "normal" signal voltages range from as little a 8v (most oems now protect down to 6 to support cold cranking requirements) up to around 15v (14.7v is a typical alternator output setpoint)
However, abnormal events mean you need to be robust from -13vdc to around 90vdc (for 12v nominal systems)
ime, you cannot have too much input protection!
Assuming your device has a correctly specified and protected power supply architecture (if the micro itself goes bang because some one has just jump started their car and placed the jump leads the wrong way around then it's a bit late to be worrying about input protection for any logical input etc!) then you need to try to include as much resistance as possible, commensurate with providing a sensible noise rejection. As most vehicles have a common ground (the body shell) galvanic isolation is rarely required (it can be useful in certain circumstances, for example interfacing to devices with high di/dt or high dv/dt)
For "simple" low frequency (<10khz) inputs i use a fixed resistive divider, followed by a voltage clamp (either diodes to Gnd / vcc, or a zener, depending on how near the rails i need the input signal to get), followed by more resistance, and then into the micro input pin. The second lot of R prevents excessive current flow through the micros internal clamping diodes and allows your out board clamps to shunt current away as necessary. I also add a select amount of capacitance to ground, a "small amount" directly on the input (needs a high enough voltage rating remember!) before the first resistive divider to provide a lower AC sink impedance (to try to shunt high frequency noise straight to ground) and then some more capacitance forming a low pass filter after the divider (frequency set to suit your input frequency range).
You also may consider using a series diode or zener to prevent reverse current flow if the vehicle battery is connected backwards and to push up the minimum input voltage which is considered to be "high" to give yourself some head room from ground potential.
No alternator helps from "load being disconnected suddenly when it's sticking out 100A" type surges, but obviously makes no difference to any other (common) automotive environment surge!
Consider what does the additional mosfet bring you? You need to protect that Mosfets Gate, just like you need to protect the gate of the Mosfet (or similar device) in your microcontroller. In the event of a unprotectable surge (ie a surge that exceeds your protection system) that mosfet is dead, in the same way that the micro's input conditioning circuitry would be dead. End result is the same (there are some highly safety critical systems where you'd protect the micro at all costs because it's doing other stuff that is critical, but for your device, non functionality is non functionality is it not? Is there any other 'knock on' effect of possibly killing the micro itself?)
If you can present a valid reason for having an "active" input buffer, and considering that you don't have any requirement for low current consumption, or a requirement (particularly) high input impedance or bandwidth. i'd consider using a Transistor and not a Mosfet to get away from the Vgs limitation and obvious failure mode inherent in that semiconductors architecture.
But at just 1kHz, and with a (relatively speaking) massive input voltage range you can just install a huge series resistance into your input chain, and so effectively put in place a lot of over voltage protection easily. If you look up the voltage levels and hysteresis for your particular micro's input, you can easily work out a suitable voltage division and limitation mechanism to robustly protect that input.
ime, keeping things simple, but robustly engineered and validated is the trick for automotive electronics (and i design these for a living)
My principal "Five Commandments" are:
1) Power supply to the logic must be BULLETPROOF
2) Install the max impedance possible between the real world and your device, where ever signals cross the boundaries
3) Use the least possible number of parts. 1 less part = 1 less thing to fail
4) Protect ANY conductive path into your device from at least the following : 1) continuous connection to Vbatt+10% and continuous connection to -Vbatt
5) if you can achieve 4) for what ever reason, document that fact to your clients in an obvious and EXPLICIT way.
Wow, there've been a lot of responses on this so I'll try to address them all - thanks guys!What frequency is the square wave?
The easiest method is to use a series resistor, say 10k to 1M, before the MCU input. The internal ESD protection diodes will clamp the input voltage at about 0.6V above the MCU's power supply.
Frequency will be around the 0-1kHz range, duty cycle of at least one signal is fixed at 20%, the others I don't know the duty cycle of (the requirements I've been given are not super detailed).
From what I've read, the ESD diodes aren't designed for this kind of service and could be damaged/do degrade when used in this manner. I had considered a zener diode in parallel with the input or 2 Schottky diodes as others have suggested, however I'm concerned about loading the transducer (at least one post I've come across was complaining of loading issues even with 10s of kOhms of input resistance).
Quote from: max_torque on Yesterday at 11:20:37 PMNo alternator helps from "load being disconnected suddenly when it's sticking out 100A" type surges, but obviously makes no difference to any other (common) automotive environment surge!
Consider what does the additional mosfet bring you? You need to protect that Mosfets Gate, just like you need to protect the gate of the Mosfet (or similar device) in your microcontroller. In the event of a unprotectable surge (ie a surge that exceeds your protection system) that mosfet is dead, in the same way that the micro's input conditioning circuitry would be dead. End result is the same (there are some highly safety critical systems where you'd protect the micro at all costs because it's doing other stuff that is critical, but for your device, non functionality is non functionality is it not? Is there any other 'knock on' effect of possibly killing the micro itself?)
If you can present a valid reason for having an "active" input buffer, and considering that you don't have any requirement for low current consumption, or a requirement (particularly) high input impedance or bandwidth. i'd consider using a Transistor and not a Mosfet to get away from the Vgs limitation and obvious failure mode inherent in that semiconductors architecture.
But at just 1kHz, and with a (relatively speaking) massive input voltage range you can just install a huge series resistance into your input chain, and so effectively put in place a lot of over voltage protection easily. If you look up the voltage levels and hysteresis for your particular micro's input, you can easily work out a suitable voltage division and limitation mechanism to robustly protect that input.
ime, keeping things simple, but robustly engineered and validated is the trick for automotive electronics (and i design these for a living)
My principal "Five Commandments" are:
1) Power supply to the logic must be BULLETPROOF
2) Install the max impedance possible between the real world and your device, where ever signals cross the boundaries
3) Use the least possible number of parts. 1 less part = 1 less thing to fail
4) Protect ANY conductive path into your device from at least the following : 1) continuous connection to Vbatt+10% and continuous connection to -Vbatt
5) if you can achieve 4) for what ever reason, document that fact to your clients in an obvious and EXPLICIT way.
I was thinking the MOSFET would give me a high impedance input with negligible change in rise/fall time, a large input range as VGS(th) is small, and it would be easier to protect the MOSFET, as I only have to worry about transients >20V as opposed to the MCU that needs protecting from anything above 3.6V.
Having said all that, I posted in the beginner section because I don't know what I don't know and what I do know may be completely wrong.
From the MCU datasheet:
VIL: -0.3V min, 0.99V max (0.3 x VDDIO)
VIH: 2.31V min (0.7 x VDDIO), 3.6V max (VDDIO + 0.3)
Vhys: 150mV min, 500mV max
VIL leakage current: 5nA typ @ TA = 25°C, 30nA max @ TA = 85°C
VIH leakage current: 2nA typ @ TA = 25°C, 18nA max @ TA = 85°C
There's also an on-die series termination resistor of 36 ohms, but I think it can be ignored, as the ratings are at the pin, not after the resistor.
So where do I go from here for the calculation?
I tried following the example here: https://electronics.stackexchange.com/questions/124620/maximum-resistance-that-can-be-put-in-series-with-an-input-to-a-pic-microcontr
I assumed assuming TTL noise immunity of 400mV (but maybe I should be using 500mV or 150mV from the MCU's hysteresis?).
Max voltage across input resistor: 0.99V - 400mV = 0.59V
Max current: 30mA @85°
Max input resistor: 0.59V/30nA = 19.66 Mohms
...Which seems very large, and I'd imagine would cause issues...
So, would I take this (or perhaps a smaller value) and use that as the input resistor of a voltage divider and try to pick a ground resistor that would give VIH + 400mV for a Vin of 12V?
5V input
Min high input voltage = 2.31V + 400mV = 2.71V
R1: 10Mohms (<19.6Mohms)
R2: 12Mohm
Vout: 5*12/22 = 2.72V
12V input
Vout = 12 * 12/(22) = 6.54V
I would need a clamping diode for this scenario
Am I on the right track here?
That's a fairly low frequency, so the extra rise/fall time due to a resistor and get input capacitance won't matter.
The ESD won't be damaged, so long as the current is limited to a safe value. A 100k resistor will limit the current to 87?A.
How about using a potential divider and a clamping diode, such as the BAT54S, if you really want to avoid the ESD diode conducting, although it would be an issue at such low currents? Two 1M resistors would give the MCU, 2.5V with 5V in and it would be clamped to just over 3.3V, when the input voltage is above 6.6V. The current draw from the transducer will be negligible.