Image

Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Need guidance: Sensing 12 V and protecting hall sensor input

+2
−0

I’m working on a throttle interface circuit for a BLDC motor controller using an STM32 MCU, and I would like some suggestions for two things — 12 V sensing and hall sensor input protection.

The throttle module outputs the following signals:

  • Hall sensor output: 0 V to 4.5 V range (analog signal proportional to throttle position).

  • Forward/Reverse switches: Digital outputs that switch 12 V when pressed.

These signals come through a 4ft long cable from the throttle mounted on the machine housing, where users can touch the assembly. The 12 V line originates from the STM32 controller board’s buck converter output (12 V rail) and goes to the throttle circuit which has it's own LDO to convert 5V for the hall sensor.

I’m evaluating options for:

  1. Safely sensing the 12 V signal on the MCU side (3.3V). I have tried below transistor circuit which works just fine but zener diode (BZX84 Zener Diode 3.3 V 250 mW ±1%) can leak after repeated surges. Which is better design considering ESD or overvoltage conditions.?

Transistor

Here is the another way (Opto based). Is there any advantage with this design? Opto

2. Proper ESD and surge protection for the hall sensor line (0–4.5 V analog input). I am using TVS DIODE VRWM 5V and clamping voltage of 12V and after voltage divider added BAT54 to keep the rail within 3.3V and GND. I have added 33 ohm on the MCU side for taming surge voltage, is it okay to add? also Any General input protection considering the cable length and possible ESD/hot-plug events ?

HALL IN

What would be the best approach here for robust and noise-immune interfacing?

EDIT: Based on Lundin's comment, I have created this quick circuit.

New circuit

History

0 comment threads

2 answers

+1
−0

This is your proposed circuit for sensing a 0-12 V signal into a 0-3.3 V digital input:

Image

The 0-12 V input signal is the result of user interface buttons. They are therefore rather "slow" signals. Humans don't notice or don't care about delays up to 50 ms from button to action. I would allot most of that time to debouncing in the firmware, but a 1 ms or so delay in the hardware is acceptable, even desirable.

Another observation is that the B-E junction of the transistor already limits the base to one diode drop above ground. D4 does nothing in the reverse direction, so it being a Zener is pointless.

I would make R8 as high as possible, then adjust R9 so that the R8/R9 divider just about turns on the transistor roughly in the middle of the input voltage range.

Here is a recommendation:

Image

I started with making R1 100 kΩ. That's plenty high enough to allow easy clamping of nasty spikes. D1 clamps negative spikes to protect Q1, and Q1 itself clamps positive spikes due to its B-E junction.

Let's assume 700 mV as the B-E drop when the transistor is on. At ½ of the input (6 V), the R1/R2 divider would produce 700 mV when R2 is 13.2 kΩ. 15 kΩ is the next common value up.

With the input at 12 V, the current thru R1 is (11.3 V)/(100 kΩ) = 113 µA. R2 will draw (700 mV)/(15 kΩ) = 47 µA of that, leaving 66 µA into the base of Q1.

The maximum current thru R3 is (3.3 V)/(10 kΩ) = 330 µA. That divided by the 66 µA of base current means we only need the transistor to have a gain of 5. Any small signal NPN can do that with plenty of margin.

Let's see what input voltage range this circuit can handle for a prolonged time. The limit is the power dissipation of R1. Let's say it's just a 0805 surface mount part that can dissipate 125 mW continuously. Sqrt[(125 mW)(100 kΩ)] = 112 V. You can safely say the input is allowed to be ±100 V indefinitely.

So this circuit puts only a slight (100 kΩ) load on the input, has a threshold to guarantee detecting 0 and 12 V levels, tolerates up to ±100 V, and presents a solid 3.3 V digital signal to the microcontroller.

Short term transients, like static discharge, are harder to quantify. However, the 100 kΩ input resistance and bi-direction clamping to ground should be more than sufficient unless you are trying to protect against something quite unusual.

History

0 comment threads

+0
−0

The BJT is overkill and might have issues of its own (voltage spec, ESD etc) and you don't need to switch a lot of current either. Also a plain zener is too slow to help against spikes, you need a TVS.

Similarly with the optocoupler, it is overkill and in general just a last resort in case you suspect very bad conditions on-site (bad grounds etc). Additionally, an optocoupler turns into a useless waste of space when you use same grounds on the primary and secondary as in your schematic - it literally does nothing except adding BoM cost. Beware of the Arduino optocoupler disease!

The most standard way to do this is a simple voltage divider as in my answer here: https://electronics.stackexchange.com/a/756620/6102 Which is more or less identical to your 2) schematic so that's what I would use. It doesn't matter if it's a MCU or a hall effect sensor you need to protect. Simple, inexpensive, safe.

Except you can use a much higher series resistor towards the MCU, the value is by no means critical but high resistance means better protection of the MCU pin in case of mishaps.

Also consider that the Schottky diodes will have some forward voltage so you won't cap the signal level to exactly 3.3V but rather to 3.3V + Vfwd. BAT54 got roughly 0.3Vfwd so you should place it towards a +3V ref in case the exact voltage is important.

History

1 comment thread

I have posted the circuit based on your suggestion. Is that the right way? (2 comments)

Sign up to answer this question »