The emitters of the optos should be connected to ground, the -ve of your 24V source and the FET gates should be connected to the collector of the FETs.
Oh, now I get it (I read the sentence wrong). Do you mean like this?
The circuit as you drew it is just not going to work. Transistors work with current flow, there is no where for the current to flow if you connect the emitter directly to the FET's gate because a FET has such a high input impedance.
I though that if I connect a 7.5 V power supply through the optos and to the gates of FETs, the optos will block the path when they are off, and when they are on, they will let the current through and to the gates of the FETs, which will then turn on. At first I though about using the 24V supply for this too, but then I saw the limit on the FETs : +-20V absolute max.
Probably stupid thinking, seemed logical to me though since I know very little about electronics (for now).
The gate is like a capacitor, so while a small amount of current will flow into it to build up that charge, no current will flow through the gate once it's built up, and the MOSFET will still conduct.
Ohh, so thats why the solenoids stayed on (when I reconnected the pwr, ofc) even if I turned off the power and then turned it on again.
For an opto-coupler that pulls the gate up to turn it on (N-channel FET) you need to also keep a pull-down to ground to the gate, so that the gate turns off when the opto-coupler is not transmitting current. Perhaps a 2 kOhm pull-down will be sufficient, if you're not trying to switch the FETs at too high an on/off frequency.
Im actually not sure if my optos are pullup or pulldown. I didnt know where I can get this information. grumpy_mike mentioned they are pulldown on previous page
No prob about the frequency, they will work slowly
So basically, I add a connection between the gate of FET and -ve of 24V source (trough 2kOhm resistor)? Wont that transmit power to all other FETs as well, so when one is open, all are open?
The transistor in an opto coupler can only pull down, so there is nothing to supply the voltage to the FETs gate.
That means they are actually inverse of what I need?