0
\$\begingroup\$

I want to give sensor pulse to raspberry pi. The sensor signal comes from a running conveyor . The sensor gives 24v signal hence I used a optocoupler to convert the 24v to 3.3v . How should I design a best optocoupler suitable for PI.

\$\endgroup\$
2
  • \$\begingroup\$ 1. It sounds like what you did should work. 2. There is a stackexchange raspberry pi web site. 3. Unless there is a reason to use the existing signal, I would have used a magnetic pick up for several reasons. \$\endgroup\$ – st2000 Feb 2 '17 at 13:06
  • \$\begingroup\$ Are you looking for a specific optocoupler to use or a circuit design that would do what you're after? Showing what you already have so far is a good start to getting a good answer \$\endgroup\$ – Doodle Feb 2 '17 at 13:12
3
\$\begingroup\$

It seems your problem is that you have a 24 V signal that you want to get into a 3.3 V digital input.

Since the signal is coming from some industrial equipment, I agree that opto-isolating it is a good idea. So here is what you do:

  1. Pick a opto-coupler. Just about any will do since you seem to have plenty of input voltage and presumably current available. Use whatever your company already has in stock. If you don't already have something available, check out the FOD817 family. They are cheap, widely available, and have good CTR. They aren't for high speed applications, but should be instantaneous for a signal from a conveyor belt.

  2. Read the datasheet.

  3. Look at what kind of digital input is available. The best would be one that has a internal pullup, because then you need not other parts than the opto itself on the digital side. If all you have is a regular digital input, then you have to supply your own pullup resistor. 10 kΩ is usually a good value for such things.

    Either way, find how much current the opto has to sink to pull the digital input low.

  4. Divide the minimum required pulldown current by the minimum guaranteed CTR (current transfer ratio). Now at least double that. This is current you want to drive the input of the opto with.

  5. Check the specs for the 24 V signal and verify it can source the current computed in the previous step, with some margin. I'll assume it can. If it can't, you'll have to get more clever and the solution isn't as simple as hooking up a opto-isolator.

  6. Look at the minimum guaranteed signal voltage (24 V nominal might only be 22 V min guaranteed, for example), and subtract off the maximum LED voltage from the opto datasheet. This is the minimum voltage that will be across the resistor.

  7. Use Ohm's law to calculate the maximum allowed resistor in series with the LED on the opto's input side. Go one or two standard values down from that, or some value you already stock that is a bit lower than the calculated value.

  8. Connect everything up. Put the opto physically close to the digital input it drives. In other words, the long pair of wires should be between the conveyor and the opto, not the opto and the digital board.

\$\endgroup\$
2
\$\begingroup\$

Does your sensor toggle between 0V and 24V with each impulse? Are the GNDs connected? You don't need an optocoupler then but can use a much simpler circuit:

schematic

simulate this circuit – Schematic created using CircuitLab

How does this work? Easy, the +24V from the input don't ever reach the Raspberry Pi GPIO port. Only the 0V do. Your impulses toggle between 0V and 24V, remember? When the sensor outputs 24V, the diode is non-conducting and thus, the GPIO is pulled to 3.3V by the resistor. When the sensor outputs 0V, the diode is conducting and the GPIO is pulled to 0.4V by the sensor.

Depending on your Raspberry Pi GPIO pullup setup, you may even leave out R1.

\$\endgroup\$
2
  • \$\begingroup\$ I like the simplicity. What possible drawbacks are there with using this setup? (Safety/stability, etc). Perhaps a cap should be used as a filter? \$\endgroup\$ – Bort Feb 2 '17 at 13:33
  • \$\begingroup\$ The biggest drawback is you need connected GNDs. When your sensor is on a thin 10m+ cable and/or draws a lot of power through a combined sensor/power cable, you may have a noticeable ground shift which makes it impossible to pull the input to 0V. You have to check this. You have to make sure GND isn't connected to PE at the sensor (not even as noise filter caps) as this will create a ground loop. A 1nF..10nF filter cap may be applied from GPIO to GND. Lower caps aren't useful, higher may irritate the GPIO because of the slope. You need an additional Schmitt trigger then. \$\endgroup\$ – Janka Feb 2 '17 at 13:46
0
\$\begingroup\$

if the sensor generate high speed pulses use high speed optocouplers 6N137

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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