Poll

How do I use an LM393 to light a red LED below 7.5V and a green LED above 7.5V?

idk
1 (33.3%)
idk
2 (66.7%)

Total Members Voted: 2

Author Topic: KitCad  (Read 1030 times)

0 Members and 1 Guest are viewing this topic.

Offline melyTopic starter

  • Newbie
  • Posts: 1
  • Country: si
KitCad
« on: June 01, 2025, 08:48:53 am »
Hello,

I’m trying to add a way to monitor when the voltage in my system is below 7.5V (this is for school), and my teacher suggested using the LM393. I need it set up so that when the voltage is less than 7.5V, my red LED will light up, and when the voltage is above 7.5V, my green LED will light up instead. In other words, the green LED should be on as long as the voltage is over 7.5V, and when it falls below 7.5V, the green LED should turn off and the red LED should light up until the voltage goes back above 7.5V.

I’ve uploaded a screenshot of my current circuit. The LM393 and the two LEDs are located near the top middle, but I’m not sure how to connect them properly.

If anyone knows how to do this, I would be very grateful for the help.
 


Offline reodor

  • Contributor
  • Posts: 36
  • Country: no
Re: KitCad
« Reply #2 on: June 01, 2025, 10:32:05 am »
One input of the comparator must be connected to a fixed reference voltage, while the other must be connected to the variable input voltage, or a fixed fraction thereof.

In its simplest form, you would put a fixed 7.5 V on one pin, and then the variable voltage on the other. The problem with this solution is that the comparator must have a supply voltage that is greater than any of the input voltages. Also, you'd have to somehow create the fixed 7.5 V even when the variable voltage is below 7.5 V. You'd essentially have to have a separate power supply for the comparator and voltage reference. This is usually not practical.

In stead, you can compare fractions of the desired voltages. Try using voltage dividers to create suitable voltages for the comparator inputs.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 14134
Re: KitCad
« Reply #3 on: June 01, 2025, 03:28:39 pm »
The L7805 regulator's 5V output voltage cannot be trusted as a reference for the comparator, because its typical dropout voltage is 2V, and worst case, its output can start drooping a bit above that, far too close to the desired 7.5V input threshold.  You therefore require a voltage reference for the comparator.   The PIC18F25K22 MCU has an internal voltage reference (the FVR, datasheet section 21.0) that can output to a pin, nominally 1.024V, 2.048V or 4.096V depending on its PGA setting, but it isn't very accurate.   The lowest cost solution would probably be a potential divider from the unregulated supply feeding one of the PIC's analog input pins, and a routine in the firmware to check it, with calibration of the FVR and divider at 7.5V unreg in to set the threshold. 

However you probably need a standalone solution, that is independent of the PIC.   My preference would be to use a TLV431, as combined comparator and reference, turning on the green LED when Vin is over 7.5V (sensed by a potential divider to its REF pin), and a N-MOSFET with a Vgs min. threshold >1.2V gate connected to the TLV431 output (cathode pin), inverting it to drive the red LED.   
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->