I've com up with the following design. I feel I've used too many components, don't know. but I have some reasons for anything included in the design.


  • PULSE_A : some low frequency (50~1000Hz) low duty cycle pulse from MCU. (STM32F407)
  • R2 : limiting the MCU pin current (because there are around 20 such outputs, and the overall current sunk from MCU might get high)
  • R3 : to make sure Q5 turns off fast when pulse from MCU goes low. (necessary?)
  • U2 : optocoupler (have to use this exact part, which unfortunately inverses the input high/low)
  • R4 : limits the current to the IR LED inside the Optocoupler
  • U1 : an inverting Schmitt trigger logic IC (to make the output of the whole circuit in phase with the input)
  • R5 : Don't know if necessary, wanted to make sure there's nothing between HIGH\LOW states.
  • R6 : to limit the current from 74HC14 output
  • R7 : same as R3
  • Q6 : to charge the MOSFET gate (Q7)
  • R9 : to protect the MOSFET gate capacitor.
  • R8 : do discharge the MOSFET gate capacitor faster.
  • Q7 : the actual switch to R_LOAD. it's an N-Channel high power MOSFET, and its RDSon is rated @Vgs=8V in datasheet

Question : how to improve this? are resistor values valid? I'm not sure whether it's a good idea to copy 20 series of these components for the rest of PULSE_B, PULSE_C etc. outputs.

Datasheets :

EDIT2: Based on comments, I changed my mistakes into this scheme : Updated scheme Can someone please confirm that the MCU is correctly isolated now ?

EDIT3 : Changed it a little more. grounds are the same again. and added a resistor to the second BJT to limit it's Ic current to GND. I know it's still flawed, cuz it's like the first scheme and I'm told it's not isolation (but didn't tell me what's wrong) Edit3

with all respect and gratefulness toward all who read and answer or point me to some direction to learn sth, what's with this multi-level answering thing going on? tell me what's wrong about the isolation. you've told me the MCU pin is not isolated but why it isn't? I wouldn't ask a single question if I assumed the scheme to be working/flawless.

  • \$\begingroup\$ What are you trying to do? You say (in the schematic) that you want 24V pulses, but where are they going? What are they driving? Why do you need isolation? \$\endgroup\$
    – vir
    Nov 25, 2023 at 22:18
  • 3
    \$\begingroup\$ What do you want to improve, what counts as an improvement? Half of the parts could be useless because what matters is you have a logic output with some specs and you need to drive the load with some specs, which are barely known. For example, the optoisolator does not isolate anything, why is it in the circuit? The FET would like more than 5V on gate but it is given less than 5V. \$\endgroup\$
    – Justme
    Nov 25, 2023 at 22:24
  • 2
    \$\begingroup\$ @Bikay Based on the schematics you are not providing 8V from a 9V rail. The transistor is driven as emitter follower, with presumably a 5V powered 74HC14. The resistive divider R6&R7 will drop that to 4.5V and after Vbe drop of Q6 it might be aroud 4V or a bit less. \$\endgroup\$
    – Justme
    Nov 26, 2023 at 0:05
  • 1
    \$\begingroup\$ If you need isolation, you need to have separate power supplies and separate grounds on each side of your optocoupler. So use the 9 V power supply for everything on the right, and don't connect the 9 V ground to the 5 V ground. \$\endgroup\$
    – Hearth
    Nov 26, 2023 at 16:21
  • 2
    \$\begingroup\$ The optocouplers are not mythical isolation devices. They are simply a LED and a phototransistor in same package. While they can and could be used in a circuit for isolating two completely independent circuits from each other, your circuit uses same ground and same 5V supply on both sides of the optocoupler, so your circuit provides no isolation with the optocoupler. And you might not even need to or can't keep the supplies isolated. Now, the opto still provides an air gap between Q5 and 74HC14, but is there really need for that, and if it is, why? \$\endgroup\$
    – Justme
    Nov 26, 2023 at 16:42

1 Answer 1


enter image description here

Let's start from the right.

The MOSFET datasheet mentions a gate charge of Qg=40nC ; i=dq/dt so if you drive the gate with 1mA it will switch in 40µs (more or less). Your switching frequency is only 1kHz so you don't need to switch very fast to minimize switching losses (faster switching causes your wiring to radiate more noise).

But you say you want 1% duty cycle on a 1kHz period and that's a 10µs on-time, so if we want the MOSFET to reach full conduction before it turns of, then it should switch in less than a few µs. Let's go with 2µs, so we need 20mA gate drive.

The simplest solution would be to use MOSFETs with 5V gate drive, with one 74AC octal buffer like 74AC245 driving 8 MOSFETs with 5V. But since yours requires 9V this option is not available. Fortunately MMBT3904 costs 2 cents. Now back to your circuit.

If you want to switch inductive loads you need a freewheeling diode between the drain of your MOSFET and the positive supply. Otherwise when turning off the inductive load you'll get a voltage spike on the drain which will reach the avalanche breakdown of the MOSFET (~150V). The MOSFET is rated for this but it will absorb all the energy stored in the inductive load, so it may end up overheating, it depends on the load, frequency, etc. With a freewheeling diode it takes much longer for the current to fall but the inductive energy is mostly dissipated in the solenoid's internal resistance, and it is presumably bulky enough to withstand this.

I strongly disagree with the pullup R9. It's going to dissipate lots of power (0.81W per resistor on 9V, 20W for 24 resistors) all the time because it wants to turn the MOSFET ON and Q6 is preventing that. Also R10 is unnecessary, it prevents Q6 from being able to pull the MOSFET gate to ground, so it'll never turn off.

U1A is unnecessary: if you want to invert the output of an optocoupler, simply swap it with the pull resistor. So the 5V power supply on the isolated side also goes.

enter image description here

Here's a suggestion. I used a push pull driver (Q1 Q2) for the MOSFET to get decent gate current without wasting too much power in a pulldown resistor. R1 sets switching time. The current transfer ratio of your opto is pretty good so R3 can be increased a bit.

enter image description here

Note I've split the grounds, otherwise there is no isolation. If you join the grounds, then the optocouplers are useless, and the simplest solution is to drive the MOSFETs directly with a bunch of 74ACT245, the cheapest solution to get 8 channels voltage translation from 3.3V to 5V with >20mA output current.

Since 80VDC is involved, I feel some form of isolation is completely justified. Another option is to put a USB isolator on the programming cable that goes with the micro.

  • \$\begingroup\$ Thanks for corrections and suggestions. In your circuit, 1. could you please tell me what R8(3k3) and the one below it,(3k3 or 4k7) do? 2.can I use 3906 and 3904 for all BJTs used? and 3. Since the 9V rail is actually from battery, is it recommended (or possible at all) to split the 9v gnd from the loads side as well? \$\endgroup\$
    – Bikay
    Nov 27, 2023 at 0:56
  • \$\begingroup\$ The mislabeled one (4k7) pulls the two transistor bases to ground when the opto is off. R8 limits base current of Q2 when the opto is on. 2. yes 3904 3906 are absolutely fine. 3. no you can't split the 9V from the loads because it's driving the MOSFETs and they're connected to the loads. \$\endgroup\$
    – bobflux
    Nov 27, 2023 at 1:10
  • \$\begingroup\$ "R8 limits base current of Q2 when the opto is on" by opto being on you mean the led is on or the phototransistor side conducting? If I got it right, Q1 charges and Q2 discharges the MOSFET gate. Based on the Fig1 in the last page of optoisolator datasheet, in your suggested circuit, the mcu signal is reversed (i.e. duty cycle %99) on load side? \$\endgroup\$
    – Bikay
    Nov 27, 2023 at 1:39
  • \$\begingroup\$ When MCU output goes to 3V3, Q3 conducts and lights the opto's LED at about 5mA. The phototransistor turns on and it conducts a current equal to the LED current multiplied by your opto coupler's current transfer ratio which is at least 130% from the datasheet, so we would get 6.5-30mA on the output transistor side of the opto. That doesn't happen because the two 3k3 resistors are too high value for that much current, but it forces the output of the opto to hit close to 9V. Then Q1 charges the MOSFET and turns it on. So the FET turns on if the MCU's output is high. \$\endgroup\$
    – bobflux
    Nov 27, 2023 at 7:33
  • 1
    \$\begingroup\$ Yes the LED light turns the transistor on. So if you put the transistor between supply and output, when it's on, it pulls the output up and doesn't invert. If you put it between output and ground, when it's on it pulls the output down, so it inverts. In the datasheet the transistor is on the bottom, so it inverts, but you can use it the other way around too... \$\endgroup\$
    – bobflux
    Nov 27, 2023 at 11:27

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.