Author Topic: Digital I/O circuit with optocouplers on PSoC5  (Read 826 times)

0 Members and 1 Guest are viewing this topic.

Offline AlinikTopic starter

  • Contributor
  • Posts: 10
  • Country: it
Digital I/O circuit with optocouplers on PSoC5
« on: January 28, 2025, 05:02:36 pm »
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!


 

Offline radar_macgyver

  • Frequent Contributor
  • **
  • Posts: 755
  • Country: us
Re: Digital I/O circuit with optocouplers on PSoC5
« Reply #1 on: January 29, 2025, 02:08:43 am »
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.pdf

Depending on your application, you may not need the complexity, and can remove some of the above (eg: the bridge rectifier).
 
The following users thanked this post: Alinik

Offline AlinikTopic starter

  • Contributor
  • Posts: 10
  • Country: it
Re: Digital I/O circuit with optocouplers on PSoC5
« Reply #2 on: January 29, 2025, 11:24:13 am »
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.

« Last Edit: January 29, 2025, 01:23:57 pm by Alinik »
 

Offline radar_macgyver

  • Frequent Contributor
  • **
  • Posts: 755
  • Country: us
Re: Digital I/O circuit with optocouplers on PSoC5
« Reply #3 on: January 29, 2025, 04:55:38 pm »
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).
 
The following users thanked this post: Alinik

Offline AlinikTopic starter

  • Contributor
  • Posts: 10
  • Country: it
Re: Digital I/O circuit with optocouplers on PSoC5
« Reply #4 on: January 30, 2025, 02:52:56 pm »
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.
 

Offline radar_macgyver

  • Frequent Contributor
  • **
  • Posts: 755
  • Country: us
Re: Digital I/O circuit with optocouplers on PSoC5
« Reply #5 on: January 30, 2025, 05:56:36 pm »
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.
 
The following users thanked this post: Alinik

Offline AlinikTopic starter

  • Contributor
  • Posts: 10
  • Country: it
Re: Digital I/O circuit with optocouplers on PSoC5
« Reply #6 on: January 31, 2025, 02:53:38 pm »
Thank you again for your answers.
I investigated further on the Internet and I think I found some possible implementations that would suit me.
From https://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/kqRJ5Ky


That seems like a good solution to me. So my implementation is now this:
https://imgur.com/a/XN1pozC




« Last Edit: February 03, 2025, 03:54:50 pm by Alinik »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf