I am working on a circuit using a comparator for a school project, but in testing it is not acting as expected. Specifically, the output is not going all the way to the higher rail voltage attached to the comparator. I am using the LM311, an open collector comparator. This can be changed if that would fix my problem. I have tried varying values for a pull up resistor but I still cannot get all the way to the Vcc value I want (this project is my first exposure to pull up resistors and I am not sure how to choose values.) This circuit is designed to turn on the mosfet (or BJT) and charge a capacitor so that the mosfet/BJT stays on for a period of time after the comparator output goes back to low.

Note: This is not the exact circuit we will be using, we will likely be switching to a BJT instead of the mosfet and resistor values will be adjusted around the capacitor. The solenoid valve values are also made up. However, I do not think this changes the general question around the comparator.enter image description here


1 Answer 1


Don't connect the solenoid to ground, connect it to Vcc and use the MOSFET with its source tied to ground - drain to the other end of the solenoid. Put the protection diode across the solenoid, cathode to Vcc.

Now, if you do this you'll most likely find that it behaves much more as you would expect it to because the MOSFET will turn on properly. You need to maximize gate-source voltage from the Vcc rail to turn it on properly. What you had before was called a source follower and with your solenoid voltage required and your limited 9V supply it would never turn on effectively. Here's a snapshot of the changes: -


simulate this circuit – Schematic created using CircuitLab

  • \$\begingroup\$ Note: doing what Andy is suggesting changes the topology from a high-side switch to a low-side switch. \$\endgroup\$
    – tcrosley
    Commented Apr 10, 2014 at 22:14
  • \$\begingroup\$ Andy, quick question: I've never put C1 at a MOSFET gate. Is it general good practice, or just for this application? (noisy solenoid, maybe?) \$\endgroup\$
    – bitsmack
    Commented Apr 10, 2014 at 23:14
  • 1
    \$\begingroup\$ @bitsmack it's not great practise because as the cap voltage starts to decay, the mosfet gains resistance and can dissipate heat before the solenoid is fully deactivated. Better to put the hold circuit in front of the comparator so the fet gets a clean on/off drive. \$\endgroup\$
    – Andy aka
    Commented Apr 10, 2014 at 23:47
  • \$\begingroup\$ Thanks. I was wondering if there was something I was missing :) \$\endgroup\$
    – bitsmack
    Commented Apr 11, 2014 at 0:11
  • \$\begingroup\$ yeah, dont have a capacitor there. The mosfet already has gate capacitance. You want voltage to change as quickly as possible on the Gate pin. Any resistance to delta-V will cause more time spent in the linear region during switching, causing more heat in the MOSFET and voltage loss over the load. \$\endgroup\$
    – KyranF
    Commented Apr 11, 2014 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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