I am a newcomer in this wonderful world of electronics trying to design my own PLC.

So far I have designed a single output stage that I think will work, but it would be great if i could have any of you experts confirm my thoughts and calculations..

I have selected the following components (mostly based on lowest cost at RS components):

The shift register can source 6 mA and the IR LED in the optocoupler have a forward voltage of 1.2 V. R1 should then be (5-1.2)/0.006 = 633R (680R)

The collector-emitter voltage of the optocoupler is 0.1 V when fully saturated, the LED has a voltage drop of 1.2 V. To drive the LED at 20 mA, R2 should be (12-0.1-1.2)/0.02 = 535R (560R)

When no current is driven through the IR LED in the optocoupler, the gate of the MOSFET will be pulled high by R2. When the output is enabled the gate will be pulled to 1.3 V which would bring Vgs to -10.7 V and thus turn the MOSFET fully on.


  1. Are my calculations/assumptions correct?
  2. How do I know whether the transistor output of the optocoupler is saturated or not?
  3. Do I need any other components in order to protect the output stage?

Schematic of circuit

  • \$\begingroup\$ Looks like your P channel might be backwards, in that configuration current is going to flow through the protection diode and out port 1 all the time. Assuming a load is going on port 1 \$\endgroup\$ – Some Hardware Guy Sep 27 '12 at 22:04
  • \$\begingroup\$ You need to swap the drain and source of your P-channel MOSFET. The way it is now, the body diode will always conduct. \$\endgroup\$ – Dave Tweed Sep 27 '12 at 22:06

Yes, your calculations are correct. However you're limiting the Gate swing on the Mosfet and thus limiting it's operational range. I'd throw D1 on a parallel output from U2. Clever idea but not advised.

And yes, the PMOS is backwards, hat tip to @SomeHardwareGuy & @DaveTweed.

  • \$\begingroup\$ Can you tell me why it is not advised? The specified maximum gate swing is -12V. My thought was that driving the mosfet to its maximum rating is a bad idea..? \$\endgroup\$ – mwinther Sep 28 '12 at 5:28
  • \$\begingroup\$ Also, do i need a freewheeling/snubber diode across port1 and ground, or will the diode in the mosfet protect the mosfet? I am going to switch inductive loads.. \$\endgroup\$ – mwinther Sep 28 '12 at 6:09
  • \$\begingroup\$ It's not advised because it limits the operational range on the output. It may be fine for your application. With that LED in there the gate voltage will be at best 1.3 V and assuming a Vth of 0.5 Volts port1 can't go below 1.8V without the transistor moving from saturation into the triode region. You now say your're driving inductive loads so it should be OK as Q1 will be switching the load to the 12V rail. \$\endgroup\$ – placeholder Sep 28 '12 at 15:37
  • \$\begingroup\$ snubber diode?- It would be safer to start with an external one, measure the current and then see if the device can handle it. (on edit) But in reality the diode needs to go across the load so the diode in the PMOS isn't wired correctly. \$\endgroup\$ – placeholder Sep 28 '12 at 15:41

Why so complex? Why is an opto-coupler needed? The grounds are the same on both sides of the opto so this negates the reason for having one. Maybe i'm missing something relevant?

My possibly-silly alternative would have the shift register output driving an NPN transistor's base via a 10k resistor. Transistor can be BC547/847 type. Emitter connects to ground and collector connects to 12V via the 560R resistor. P channel fet gate connects to collector. Source to +12v etc.. LED can be in series with transistor collector.

enter image description here

You still need to add the snubber diode for inductive loads


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.