Try to learn from the Optocoupler H11G1 design guide. That may help you.