just a remark on your schematic and my last message.
Try to remove the R2 in your schematic and _link_ the pin 6 (optocoupler) directly to +5V. _link_ pin 5 to a resistance that goes to gnd (you can simply move R2 from the collector to the emitter). Than the V_out (pwm output) will be pin 5. Make some trials to find the optimal emitter resistance.