Rotary Encoder - Power Source for small Fork Light Barriers with NI 9401
Sinking 2 mA 0.4 V maximum means the source resistance is 0.4V/2mA = 200 Ohms which can deliver 15mA with a small series current limiting Resistor. If using IR LED's with 1.2V drop from 5V then a total series resistance of 3.8V/15mA= 250 Ohms. If the driver is 200 Ohms and LED is about 10 Ohms then a series R of about 40 Ohms is needed.  If a RED LED is used with 2V drop and about 15 Ohms internal resistance and you want Iol = 15mA then 5V-2V=3V then 3V/15mA=200 ohms same as the CMOS drive in the "0" state and the CMOS driver would pull down the cathode directly causing Vol to rise to 3V with the Anode on 5V.  Note that it is no longer TTL logic levels but since we are not interfacing the LED driver to other logic this is ok.

The current levels, slot width,  Emitter efficacy and detector sensitivity all affect the received photo voltage so that the blocked condition must attenuate the light sufficiently to create a valid logic level with equal margin to the transmitted signal saturating the detector. This is a subtle design characteristic of on off light detection using hysteresis in the detector. The optical path of the emitter must be carefully blocked to reduce the angle to allow light to be blocked between slots when aligned and with a gap about the same as the width of the block.  This is where care in the optical signal to noise ratio is critical. Signal being transmitted light and Noise being stray light that leaks past adjacent slots. So both the emitter and detector need  apertures about the same as  the slot dimensions. ( fine tuning or calculations are necessary to determine optimum aperture size to match the channel or slot and blocked gap between.) 

This becomes the critical test of your electro-optical design is how much margin you have in detecting pass/block encoder wheel levels to allow for 30% aging of the emitter and all other sources of aging (dust blockage , supply variation, etc)
This is about the limit of using the CMOS as a current driver.  There are other methods using transistors as well.

The position of the 2 detectors then gives the quadrature alignment of 90 degrees and the edges of detection controlled by optical path, sensitivity ,  %hysteresis and "any sources of stray light" . Normally IR is best with daylight blocking filters in the detector or in enclosed encoders, RED is used as it is a few pennies "cheaper" but not better, but perhaps easier to see stray light the first time.

You can create any aperture size by a controlled hole size and the depth of LED emitter surface relative to the hole.  It is best to use high optical gain small angle emitters and moderate angle detectors but not too small that alignment becomes critical. A 15 degree LED is ok or maybe 30 deg but signal is lost with beamwidth and 8 degree "may be" too little and sensitive to alignment.  So consider the path loss in emitter, aperture, slot, detector aperture and detector to choose the balanced highest margin on/off levels. Consider all the factors of alignment before careful position of emitter and detector for optimal performance.  ( See how the pros do it and take measurements)

Obviously a laser emitter gives the best precision but also has the highest aging rate for intensity so some method of regulating the emission levels with an internal reflective PD sensor and lowest temperature rise on the laser Diode in order to achieve longest possible life at , even though at a greater cost for ultra high resolution or long gap encoder applications.  This is how I expect some commercial "fork" detector encoders to work, obviously costing much more than a mouse wheel, but then expected to be much better.

This reminds of an article I wrote on how to design a better reliable "flop flop" in a toilet water flap valve or "how to design a better mouse-trap" with the same attention to Murphy's Law.