Digital I/O circuit with optocouplers on PSoC5 - Page 1
Forum section: electronics / general

author: Alinik
author_rank: Contributor
timestamp: January 28, 2025, 05:02:36 pm
content: I’m working on a project with a PSoC5 and need to isolate 24V digital signals (both input and output) using optocouplers. I’d like to know if the circuit I’ve designed is suitable or if there are any improvements I should make.Digital Input (24V -> 5V for PSoC5):I’m using an ACPL-227-560E optocoupler.On the 24V input, there is a 2.2kΩ resistor in series.On the PSoC pin, there is a 10kΩ pull-up resistor.Digital Output (5V from PSoC -> 24V output):I’m using also an ACPL-227-560E optocoupler.On the PSoC side, the internal LED of the optocoupler is connected to a PSoC GPIO via a 330Ω resistor.On the transistor side, the collector is connected to 24V and the emitter to output and to ground through a 10kΩ pull-down resistor.Do you think this circuit is appropriate for safely handling the signals? Are there any other components or changes you’d recommend?I attach an image of the example circuit.I'm also not sure if the same optocoupler ACPL-227-560E used for digital inputs can also be good for digital outputs.Thanks in advance for any advice!

author: radar_macgyver
author_rank: Frequent Contributor
timestamp: January 29, 2025, 02:08:43 am
content: On the input side, ensure that the resistor used (R33) is in as large a package as you can afford (0805, 1206 or larger). If you can, get a 'pulse rated' resistor. Add a transorb to the input between the junction of R33 and the opto, and ground. The diode and resistor will protect the input in case it's accidentally connected to high voltage. You can add a bridge rectifier to allow the polarity to be reversed without damage. Add a small value (100pF) capacitor across the optoisolator LED for noise immunity. Finally, add a 4.7k resistor in parallel with the optoisolator LED to act as a load to prevent the input from activation by leakage currents and other stray sources. See the attached image from an industrial I/O module for details.On the output side, the opto by itself looks a bit wimpy, only specified at 2 mA collector current. Please see the datasheet below for how an industrial I/O module implements its outputs. A discrete transistor is used to achieve the specified 100 mA output current.https://cdn.automationdirect.com/static/specs/c214d1.pdfDepending on your application, you may not need the complexity, and can remove some of the above (eg: the bridge rectifier).

author: Alinik
author_rank: Contributor
timestamp: January 29, 2025, 11:24:13 am
content: Thank you very much for your reply!I read the attached document and it was very interesting.I implemented the recommended changes regarding the digital input by adding a TVS diode in bidirectional configuration to the input.Regarding the digital output, I changed making the implementation “simpler” so that the output is active low, in case I could connect a MOSFET to increase the current capability.

author: radar_macgyver
author_rank: Frequent Contributor
timestamp: January 29, 2025, 04:55:38 pm
content: The input circuit gooks good, except the TVS you've used (SM24-02HTG) is not a bidi TVS, it's a dual unidirectional one. It will work as shown, though you may be able to save some board space by using a SOD-123 packaged device instead. As shown, the optocoupler's LED is not protected against reverse voltage. There are some optos available which can accept both polarities (with back-to-back LEDs), but otherwise either include a bridge rectifier, or swap your TVS for a unidirectional type to protect against reverse polarity. Avoid the temptation to use a SOT23-3 dual diode to protect two channels - if one blows up the other could get damaged.The output configuration does not appear correct - the drain of Q1 should not be directly connected to +24V. You could either leave Q1 just connected to DIO_OUT_1, or include a flyback diode to +24V (in case the load attached to DIO_OUT_1 is inductive).

author: Alinik
author_rank: Contributor
timestamp: January 30, 2025, 02:52:56 pm
content: For the digital input, the configuration with which I connected the TVS SM24-02HTG is for use in bidiretional mode as recommended in its datasheet. However, I have replaced the TVS with an SZSMF26AT1G which has SOD-123 package.For digital output, I thought of changing the connection of the output on the emitter so that I would have active-high logic, possibly inserting two MOSFETs in a push-pull configuration to have the possibility of getting more output current.As easy as that sounds, implementing something for the digital outputs is more complicated for me than the inputs.

author: radar_macgyver
author_rank: Frequent Contributor
timestamp: January 30, 2025, 05:56:36 pm
content: The output circuit as shown will put +24V on the gate of the N-FET, stressing its gate oxide. FETs have a Vgs(max) parameter, usually about 20V. Industrial I/O modules typically have either 'sourcing' or 'sinking' outputs, so far I haven't come across one with a totem-pole output as you've shown. Also, your P-FET is installed backwards. Would suggest you look up how industrial I/O modules are implemented before proceeding. Perhaps also simulate or breadboard your design.

author: Alinik
author_rank: Contributor
timestamp: January 31, 2025, 02:53:38 pm
content: Thank you again for your answers.I investigated further on the Internet and I think I found some possible implementations that would suit me.Fromhttps://www.contec.com/support/basic-knowledge/daq-control/digital-io/, reading the datasheet of a Opto-Isolated Digital Output for PCI, I found this:https://imgur.com/a/kqRJ5KyThat seems like a good solution to me. So my implementation is now this:https://imgur.com/a/XN1pozC

author: Alinik
author_rank: Contributor
timestamp: February 10, 2025, 05:11:29 pm
content: Eventually for digital outputs I'm thinking of using this schematic, with type P MOSFET SI2347DS-T1-BE3 (https://www.vishay.com/docs/62827/si2347ds.pdf) and BZX84C15-7-F (https://www.diodes.com/assets/Datasheets/ds18001.pdf) Zener diode.

author: BennoG
author_rank: Frequent Contributor
timestamp: February 11, 2025, 05:51:24 pm
content: For outputs I usually use the BTS724G you will have 4 outputs in a single package capable of 3.3A per output current.https://eu.mouser.com/datasheet/2/196/Infineon_BTS724G_DS_v01_00_EN-1731319.pdfThe unit has also a lot of protection in place.Benno

author: PCB.Wiz
author_rank: Super Contributor
timestamp: February 11, 2025, 10:45:56 pm
content: Quote from: Alinik on January 30, 2025, 02:52:56 pmAn alternative is to use bidirectional optos, where the reverse led provides natural clamping, and you do not care about the polarity.You need just a single series R then.If you get gain-banded optos, you can use the gain to set a switching threshold,Small package, gain defined optos (100-300) in AC are parts like HT-3H4-BTP1-G and AT3H4B-CuH-S from lcscFor output stages, you can add an active current limit, with a transistor and resistor, that protects against short circuits.For 24V outputs I'd select a device rated well above the 30V of your PMOS part.80V is a common rating for opto parts, so that seems a practical ballpark for voltage rating.