I'm trying to control 24V solenoids using logic level inputs at 5V. The following circuit works when replacing both power loops with a single 9V battery, except that the voltage across the gate and source is not 0 as expected when the switch is closed.
When attached to the actual components with the correct voltages, the MOSFET always powers the drain, regardless of whether the switch is closed.
Can anyone tell me why the circuit works differently than in the simulation? How can I improve it?
https://www.circuitlab.com/circuit/p6ahpvb2fx5s/24v-output/
Edit: The load (solenoid) is represented by R8 in this schematic