IR transmission power controlling
If you want to adjust the distance IR communication can reach, you will face this problem: transmission power adjustment.

Generally power is set at design stage to be adequate for the maximum transmission distance and is not adjusted in use. The defined range does not have a precise cut-off and, as anyone who has used a TV remote will know, factors such as beam spread, reflections from nearby surfaces, etc., are as important as distance.

That means we need to control the current through the IR led - a tsal6100 for my example.

LEDs (almost) always require current control due to their exponential relationship between current and the applied voltage.

As a software engineer what I can think of is dc-dc switch power solution. I found AL8861 and composed the circuit based on datasheet info. My question is: can this circuit work?


Figure 1. OP's proposed solution.
Your schematic has a couple of problems. Page 12 of the datasheet states

Open Circuit LEDs
The AL8861 has by default open LED protection. If the LEDs should become open circuit the AL8861 will stop oscillating; the ISENSE pin will rise to
VIN and the LX pin will then fall to GND. No excessive voltages will be seen by the AL8861.

I expect that there will be a recovery time associated with this shutdown. The second problem is that there is an inductor in the circuit. Inductors don't like you switching off the current in an instant and will generate very high voltages (\$ V = \frac {dI}{dt} \$) when you try it.

Why I asked this question? According to my understanding, for the nature of switch power, there are ripples on the output, usually few hundreds mA, this will lead to the transmission distance vary too?


Figure 2. Current versus time.
Note that the period of the current waveform is about 1.7 μs giving a frequency of almost 600 kHz. From memory, most IR transmission systems (as in remote controls) use 38 kHz so variations in light intensity will be averaged out in the receiver as the carrier frequency is so much higher than the modulation frequency.
Other than that, it's a bit hard to say as you haven't said what you are transmitting, how far and at what frequency.