i think i just lost you,
Wire PWMn and GNDn terminal on the optocoupler side by the method I said, and don't connect the GND of the 5V circuit.
let me see if i have this right, im a little confused about the 5v circuit ground,
i connected 5v from pcf8574 psu to pwm1 and output from pcf8574 to gnd1, then i connect a seperate psu to the mosfet board to power the solenoid without connecting grounds from 5v psu and 12v psu. this should provide isolation? is this what your telling me?