A 12v battery is being charged from a solar panel. When battery is 12v solar panel is disconnected from battery and connect the load with battery. And again solar panel is connected with battery when battery voltage is say 10v. How to switch simply? Which one is preferable, optocoupler or mosfet? and how they are interconnected for proper switching?
Just use some low-voltage-drop diodes, such as Schottky diodes, to ensure that the battery will not try to energize the solar cell.
Here, the solar cell is represented using the photodiode symbol D1, which is the closest thing available in the schematic editor. Current can flow from the photocell only if it develops a voltage which exceeds that of the battery by at least about 0.25V, a difference that is needed to forward-bias the Schottky diode D2. When this condition does not exist (for instance, the light is too low), then the Schottky is not forward biased and prevents the reverse current flow from battery to D1.
Here is a version of the above schematic which incorporates a more detailed discrete component model of the cell:
Assuming you have no other power supply except for the battery and the solar panel, and assuming that it is always daytime...
Here's how to do it. You have two zeners for voltage reference, 10 and 12 volts. You would also have a SR latch, which controls whether the solar cells are connected. You would have 2 transistors. When the battery's voltage gets to be above 12, the voltage flows through the zener, turns on the transistor, which then sets the SR latch, and the solar panel gets disconnected. When the voltage is below 10, the other transistor resets the SR latch, connecting the solar panel.
And you could use optocoupler, MOSFET, or even a relay! It doesn't really matter in this case, as long as you choose one with the proper power rating. However, I recommend optocoupler because it doesn't store residual charge or get damaged by static electricity (MOSFET), or have mechanical wear and tear (relay).