Optocoupler Characteristics
how the above calculations can be translated to bits per second, because everyone filters the optocouplers according to their Data rate (bps).


A 10 us pulse would be equivalent to a 100 kbps digital data rate.


  Another question is about the input current of the optocoupler. My microcontroller can only provide around 4-6mAmps through its PWM ports.


You want to look for the "current transfer ratio" or CTR. This tells you the ratio between the output current and the input current. If you put 5 mA in and the CTR is 100%, you'll get 5 mA out on the other side of the optocoupler. Whether this is enough depends on the input impedance of the load, among other things. 

For many "jelly bean" optocouplers, the CTR is less than 100%.


  So, for expample, this datasheet is from the 6N138M optocoupler. One can see under the "features" section: "Low Current-0.5mA". 


This part claims a CTR of 2000% (due to buffering transistors on the output). So if you put 5 mA in to the LED side, you can conceivably get 100 mA out of the receiver side. 

YOu wouldn't want to do this, because the absolute maximum output current rating is 60 mA. You should design your output circuit to limit the output current to substantially below 60 mA for best reliability.

Again whether that is enough depends on what load you are driving. 

You should also note that the 2000% CTR specification is only a "typical" spec, and individual samples of this optocoupler could have substantially lower CTR.

(Hat tip to @JackCreasey for pointing out a couple of the issues discussed here)


  But under absolute maximum ratings, it says that If can reach 20mA.


Absolute maximum ratings tell you how to avoid damaging the part. They don't tell you how you're expected to use the part normally.


  From what I understand, my optocoupler should be fast enough, so that it can transmit the narrowest pulse (1% duty cycle), which has a duration of 1%*(1/1000) = 10μseconds. Consequently, I need to have: tr+tf &lt; 10μsec,


Notice your 6N138 has typical propagation delays of 1 us (and maximum of 15 us) for low drive currents, so this part is probably not appropriate for your timing requirements.