3
\$\begingroup\$

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?

\$\endgroup\$
6
  • \$\begingroup\$ How fast are the pulses coming in (frequency)? This will help determine whether you can use opto-isolators or not. \$\endgroup\$ Commented Mar 17, 2020 at 15:07
  • 1
    \$\begingroup\$ First check the datasheet to see if the encoder can be run off a compatible voltage. "12V TTL" doesn't make sense : TTL is generally 5V. \$\endgroup\$
    – user16324
    Commented Mar 17, 2020 at 15:23
  • \$\begingroup\$ I saw the datasheet.its 12 HTL \$\endgroup\$
    – kunal p
    Commented Mar 17, 2020 at 15:31
  • \$\begingroup\$ The pulse frequency is 1 pulse every 2ms. \$\endgroup\$
    – kunal p
    Commented Mar 17, 2020 at 15:32
  • \$\begingroup\$ @kunalp Ok good, this is well within the range of most opto-isolators. Easy solution. \$\endgroup\$ Commented Mar 17, 2020 at 17:40

2 Answers 2

4
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

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.

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.