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.