# Optocoupler to switch 24V using Arduino

I am currently redesigning a circuit to switch a spring applied brake using an Arduino Micro. The current circuit looks like this (please excuse if I'm using wrong symbols, I'm learning by myself):

The the important part is the right half, BRAKE1 is the spring applied brake with a resistance of 137 Ohm. This is the datasheet and the brake is found on page 84 MCNB 2GR.

At the moment I am using a 2N3904 transistor to switch the 24V which is generated from a Mean Well RS-100-24 DC power supply. I have found an issue with the circuit that I have soldered where when connecting the GND from the 24V DC source to the GND of the Arduino, I get a voltage of ~1.9V on my digital pins on the Arduino. If I disconnect the GND cable, the 1.9V are gone. (during this test, the 24V positive cable was disconnected) I have also noticed that connecting an oscilloscope including its GND will remove the 1.9V.

From my research it leads me to believe that it might be a ground loop problem. As such I would like to electrically isolate the Arduino and the 24V circuit using an optocoupler to switch the 24V on and off with a 5V digital signal from the Arduino.

There is so much information on optocouplers and here in chapter 3 I read that the available output current with an optocoupler is limited to small values. From the break datasheet I gather that it takes 0.175A of current which seems to be too much. How would I redesign my circuit to include an optocoupler and which optocoupler whould be necessary, considering I'm not sending data but only an on-off signal that doesn't need to switch back and forth too frequently?

the available output current with an optocoupler is limited to small values.

You cannot directly switch a relatively high-current load with an optocoupler. But it can be used as a pre-amplifier (or pre-driver) for a switching transistor.

How would I redesign my circuit to include an optocoupler and which optocoupler whould be necessary, considering I'm not sending data but only an on-off signal that doesn't need to switch back and forth too frequently?

Recommending specific parts is rated as off-topic here. Nevertheless, I'll recommend you to use any 817 series optocouplers as they are too common and very easy to find anywhere in the world. The ones with relatively higher CTR (Current transfer ratio) would be better, so HCPL817 (any CTR rank starting from B) can be a good option.

CTR for an optocoupler is simply a ratio of collector current to LED current. You can think of it as something like hFE of BJTs.

As for using it to switch a load, here's a circuit you can use:

simulate this circuit – Schematic created using CircuitLab

I selected BC547 as the load switching transistor because it has relatively high hFE (I personally tend to use 2N390x for relatively faster switching applications). Since the BJT should operate in saturation mode here, a base current of one-twentieth to one-tenth of the load current is sufficient (this is a practical tip for small-signal BJTs). So, for $$\\mathrm{I_C=175mA}\$$, the minimum base current could be $$\\mathrm{I_B=I_C/15=12mA}\$$ is quite sufficient.

$$\\mathrm{I_B}\$$ of the BJT flows through the optocoupler's transistor. Assuming a 1V drop across the optocoupler's transistor at 12mA, the current limiter resistor for BJT's base could be $$\\mathrm{R2 = (24V - 1V)/12mA = 1k9}\$$. The nearest standard value is 1k8. R5 is there to guarantee the off state of BJT (i.e. to prevent any base-emitter instability which can cause an accidentally turn-on).

Assuming the minimum CTR of the optocoupler is 100%, the required minimum LED current is 12mA. The forward voltage drop of optocoupler LED is around 1.1V at 12mA, so the current limiter resistor is $$\\mathrm{R1 = (5V - 1.1V)/12mA \approx 3k3}\$$.

While this requires more investigation to find out why you are getting that voltage just by connecting the GND wire, here is the optocoupler circuit you want:

simulate this circuit – Schematic created using CircuitLab

LED and transistor combination is an optocoupler (PC817 for example). You drive it similar to how you would drive an LED. For the external transistor that is driving the brake, you attach a Pullup resistor. I have shown 1K but you can make the right calculations and set the right value. Whenever you want to turn the brake OFF, you need to give a HIGH signal to the optocoupler. The optocoupler output transistor will pull the gate of external transistor LOW and the brake will turn OFF.