0
\$\begingroup\$

I am asked to build a 5 V /24 V circuit interface using an ATMEGA328P.For that i built a little comparator circuit to get a 5 volt level on a I/O pin .
My problem is that the output of the comparator can be high while the I/O pin can be configured as a 5 volt output . I thought a little then decided to add a 4.8 zener diode as below.[Edited]

Is this circuit safe to use? enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ Your diodes will block all current, so it won't work. What do you mean "the sensor using this circuit can be high while the pin is also high"? \$\endgroup\$ Jul 30 '15 at 16:19
  • \$\begingroup\$ Why is the pin configured as output? Why are you using a comparator; does the sensor output an analog signal? \$\endgroup\$
    – CL.
    Jul 30 '15 at 17:11
1
\$\begingroup\$

R1 connected in series with the supply is not a good idea. The comparators can draw as much as 2mA (0.8mA typical) and you have zero common mode range to spare.

R8 also seems pointless- you will get only 2.5V signal from the comparator.

You can leave R2 in place, increase to 20K and replace D1 with a resistor as Kevin suggests (maybe 2K).

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ If the Pins is configured as output and is outputing a low level does the 5 volt from the comparator sound risky for it? \$\endgroup\$ Jul 30 '15 at 19:23
  • \$\begingroup\$ No, it is just 5V thorough the pullup resistor from the comparator plus the series resistor.. so 22K in my example, and only 230uA. The comparator output is open-collector so it can only pull down. \$\endgroup\$ Jul 30 '15 at 19:46
0
\$\begingroup\$

Since the comparator is an open collector output there is no problem if the output is high while connected to the MCU whose output is driving high. There is a problem if the comparator is driving low and the MCU is driving high as there will be a conflict and a large current could flow.

I would remove r8 and replace D1 with a 10K resistor (value very non-critical could be 470 ohm - 22K).

Now if the comparator output and the MCU pin are in conflict the current will be limited to a safe level.

\$\endgroup\$
2
  • \$\begingroup\$ When i did so ,i have no more a 5 volt output when the comparator is high and MCU low. \$\endgroup\$ Jul 30 '15 at 17:51
  • \$\begingroup\$ Doesn't the pin marked 1 on your schematic go the MCU? In that case I don't understand what you are attempting. Can you describe more fully. I thought you were interfacing a 24v signal into an MCU. \$\endgroup\$ Jul 30 '15 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.