2
\$\begingroup\$

I have an input signal of 24 V which can source some 5 mA from the proximity sensor.this signal needs to be given to microntroller.

When the input signal from 5.1 V to 24 V the controller should read it as high and when the input is 5 V and less than that microcontroller should read it as low.

What is the best way to approach this problem statement?

\$\endgroup\$
6
  • 2
    \$\begingroup\$ What voltage sources do you have available? \$\endgroup\$ Commented Jun 25 at 16:55
  • \$\begingroup\$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. \$\endgroup\$ Commented Jun 25 at 16:58
  • 5
    \$\begingroup\$ This sounds like a school work problem. Since you have asked this same question in several forums and threads, please show us your work so far. \$\endgroup\$ Commented Jun 25 at 17:19
  • \$\begingroup\$ Please edit your question and add a link to the datasheet (not an Amazon / Ali-what's-it web page). I suspect that you don't understand how the switch output circuit works. \$\endgroup\$ Commented Jun 25 at 17:55
  • 1
    \$\begingroup\$ the title does not match the rest of the post ... 1 is not synonymous with high \$\endgroup\$ Commented Jun 25 at 22:11

4 Answers 4

10
\$\begingroup\$

The usual way to accomplish this is with a comparator. I use the classic LM393 here:

schematic

simulate this circuit – Schematic created using CircuitLab

It compares two potentials, \$V_P\$ and \$V_Q\$, outputting high (+5V here, since that's the supply I've used) when \$V_P>V_Q\$, and low (0V) otherwise.

Potential \$V_P\$ is a fraction of the input \$V_{IN}\$:

$$ V_P = V_{IN}\frac{R_2}{R_1+R_2} $$

Potential \$V_Q\$ is a fraction of the supply:

$$ V_Q = 5 \times \frac{R_4}{R_3+R_4} $$

I have arranged things such that when \$V_{IN}=+5.1\rm V\$, then \$V_P = V_Q = 0.65\rm V\$. I have also included about 0.1V of hysteresis, using positive feedback via R6, to prevent oscillations at the threshold. It means that for \$V_{OUT}\$ to go high, \$V_{IN}\$ must exceed +5.1V, but to return low again it must fall under +5V.

It's important to respect the acceptable input voltage range of the comparator (see the datasheet), so R1 and R2 are chosen to ensure that even a 24V input will not cause P to exceed that.

Here's a simulation showing \$V_{IN}\$ (blue) rising and falling slowly, and the resulting \$V_{OUT}\$ (orange):

enter image description here

\$\endgroup\$
3
  • 2
    \$\begingroup\$ all thoes resistors just so you can power the LM393 from 5V instead of 24v? \$\endgroup\$ Commented Jun 26 at 1:41
  • 3
    \$\begingroup\$ @JasenСлаваУкраїні - good point. The user didn't say he had a 24V source, only a 24V sensor signal. I made an assumption, that is as likely false as true. \$\endgroup\$ Commented Jun 26 at 1:52
  • \$\begingroup\$ The TS really needs to tell us whether there is any power available besides the signal from the sensor. \$\endgroup\$ Commented Jun 26 at 20:47
5
\$\begingroup\$

what is the best way to approach this problem statement

I would suggest to you that you consider what I'm saying below.

With an uncertainty of 100 mV between 5 volts and 5.1 volts, it's not clear what you want to happen but, if you accept that this 100 mV uncertainty can be regarded as hysteresis (can be very useful) then you will be best served by using a comparator that can handle the 24 volt input range and produce the relevant (but unspecified) logic levels at the output.

\$\endgroup\$
5
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

Here's a basic sketch of a comparator being used to work out if a voltage is more or less than 5V, given a 24V supply. The voltage dividor gives 5V.

I have made no attempt to add filtering, overvoltage protection, etc.

\$\endgroup\$
1
  • 4
    \$\begingroup\$ Perhaps some hysteresis would be useful. \$\endgroup\$ Commented Jun 26 at 8:29
-5
\$\begingroup\$

You can use this:

schematic

simulate this circuit – Schematic created using CircuitLab

M1 must have a threshold voltage of 5V. The source which drives the high/low voltage levels must be below 5V to drive the mosfet directly into saturation.

\$\endgroup\$
3
  • \$\begingroup\$ please follow convention when drawing schematic diagrams ... input on left, output on right, +V on top, ground at bottomless \$\endgroup\$ Commented Jun 25 at 22:14
  • 4
    \$\begingroup\$ This circuit will not work. First, the threshold voltage of a MOSFET is not a tightly controlled parameter, and is not nearly precise enough to meet the requested criteria. Second, if the FET does start to conduct at 5.1 V, the output voltage will be just above 0 V (Vin - Vth). Third, the output voltage will vary as the input varies between 5.1 V and 24 V. When the input is 24 V, your circuit could present 19 V to a 5 V device downstream. \$\endgroup\$ Commented Jun 25 at 23:51
  • \$\begingroup\$ Others have explained why this will not work. If you decide to, you can delete this answer which will also remove the downvotes from your reputation. \$\endgroup\$ Commented Jun 26 at 10:21

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.