Microcontroller – Isolated and Amplified MCU Signal (Optocoupler+BJT+Mosfet)

isolationmicrocontrollermosfetopto-isolator

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.

Schematic

  • 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.

Best Answer

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.