For my application I have to read 12V pulses from a optical encoder into a GPIO pin of a Raspberry Pi. What could be the best solution to convert 12v HTL signals to 3.3V for RPi GPIO input? Is a level shifter, resistor+clamping diode or an opto isolator good for this application?
I would bet that a couple resistors and a clamping diode are ok if the environment is not too hostile (big motors, long cables, high currents...).
You can also add a small capacitor in parallel with the diode, it aids in reducing spikes if any. The resistor R1 could (or probably should) be slightly bigger.
Look at CD74hc4050. It is designed for level shifting. http://www.ti.com/lit/ds/symlink/cd74hc4049.pdf
"They have a modified input protection structure that enables these parts to be usedas logic level translators which convert high-level logic to a lowlevel logic while operating off the low-level logic supply. For example, 15-V input pulse levels can be down-converted to 0-V to 5-V logic levels. The modified input protection structure protects the input from negative electrostatic discharge. "
Available as DIPs also. https://www.digikey.com/product-detail/en/texas-instruments/CD74HC4050E/296-9213-5-ND/376792
Better response times (faster) than the old CMOS stuff.