KitCad  - Page 1
Forum section: electronics / projects

author: mely
author_rank: Newbie
timestamp: June 01, 2025, 08:48:53 am
content: 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.

author: John B
author_rank: Frequent Contributor
timestamp: June 01, 2025, 09:42:10 am
content: Basically just swap the input and reference voltages on the other comparator.https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWcMBMcUHYMGZIA4UA2ATmIxAUgoqoQFMBaMMAKABZIJCU2RtC8IHIT4DwIPAB0AzmAQym82fHgyM0JepQywKqtulodevTJQbwMyO04huvBISoYEKCk-FTZSxcdPStNQ0-eBADI2UTVUMLMCsWMG4JPH08QTSqfkE3ABM6ADMAQwBXABsAFwZSuhyocSoYTgSkjJA2FOTaD1yCkoqqmvq6xtYAJ073Z1dJut04FnHhUXSOrNn4FgAlCfaqVrZ24bbaI5gELYmUNMvHI45qBqgNC92KDBFsPAd3u+doN0eZwuCB+CAOFCuFHBj3u6iQgOeAHc7Dw3iJXiCRNZkRifq9sNNsWiod8Pl8oCxkZi+OT7DTeETqWDeHTmRTkXSCW58YSWJ8JCAAGIQR66EBMEAANQA9hVCgBzOgsIA

author: reodor
author_rank: Contributor
timestamp: June 01, 2025, 10:32:05 am
content: 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.

author: Ian.M
author_rank: Super Contributor
timestamp: June 01, 2025, 03:28:39 pm
content: 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.