I am using a system with a raspberry pi and multiple d-type flip flop (CD74HC273), its role is to be able to control several digital outputs with a web app.

I use 8 raspbery GPIO bits as data/input bits on each flip flops, and n GPIO bits to select one flip flop and disable the others (with master reset input), so I can control 8 x n digital outputs.

I worked fine when I tested it with leds, so I tried switching to 5v relays, which is the actual goal (below the link to the kind of relay integrated circuit I am using) https://www.amazon.fr/XCSOURCE-Bouclier-Optocoupleur-Arduino-TE213/dp/B00ZR3B252/ref=sr_1_6?__mk_fr_FR=%C3%85M%C3%85%C5%BD%C3%95%C3%91&keywords=relais+5v&qid=1579683668&sr=8-6

But I realized that those are activated by low state input, which is problematic, because 74HC273 output is low state by default if not activated, so activates relays by default, which I don't want.

I am pretty new at electronics, so I don't really know how to fix this problem.

What would be the best solution ? :

  • Can I find "active high" relays ?

  • Can I find another type of flip-flop that works in the same way, "copying" the input level to the output on clock pulse, but with a "master set" input, all ouputs to high state by default ?

  • Should I use 8-bits inverters on every 74HC output ?

  • Any great solution I did not think about ? :)

Here is a "sketch" of the circuit (although I don't know exactly what goes on underneath the hood in the integrated relay circuit, that would be the ""?"" bit, but I guess this is a pretty standard component): enter image description here

EDIT: found the schematics for the "??? relay module":enter image description here

EDIT : link to supplier documentation for the electrical lock

Thanks a lot !!

  • \$\begingroup\$ I wouldn't drive relays directly from a 74HC output. How much current does a relay need to activate? The 74HC only drives up to about 20 mA (4mA). In addition, have you installed a flyback diode to the relay, or do the relay have a built-in diode? To your question, inverting is quite simple: just wire the other end of coil either to the ground or to the +5V. Would be nice if you support us with a circuit of your try! \$\endgroup\$ Commented Jan 21, 2020 at 22:22
  • \$\begingroup\$ Hi Tom, actually what I said what not exactly correct, I am not using a relay by itself but one of those little cards with built in diode / transistor with vcc/ground/signal pins on the low current end. So I don't have direct access to the coil. I'll try to draw a sketch of this in the morning (it is night time in France ). Thank you ! \$\endgroup\$
    – Ouhbelle
    Commented Jan 22, 2020 at 0:32
  • \$\begingroup\$ Original post edited with more details ! \$\endgroup\$
    – Ouhbelle
    Commented Jan 22, 2020 at 10:12

1 Answer 1


I think it would be very helpful for the community if you explain us for which application on the secondary side you want to build this circuit. I'm confused about your "relay" (not a simple relay) shown in your link above. The relay itself is a good isolator, so the primary side (arduino) is completely galvanically isolated from your 12V system and there is no need to add an optocoppler to it. The optocoppler is useless. Rather, the optocoupler needs an additional current, space, costs and last but not least, it also ages and may fail. I also found a good replacement of your shown relay similar but with a high-level trigger e.g. here: https://www.amazon.fr/dp/B07V1X2RSP/ref=psdc_2908498031_t3_B07BVXT1ZK?th=1

But I would build such a circuit by myself. BTW, I hope you'll place some C (10nF or 100nF) to the 74HC273 IC for stabilization the power supply.


simulate this circuit – Schematic created using CircuitLab

Update: @Ouhbelle Probably this is the circuit of the relay I have linked? Because this schematics has two important problems. The transistor's Collector and Emitter have to be swapped. And the diode (LED) in the signal line my cause problems in the long run. You know company Eumig? - They put in something like this to do some sort of rectification. After a couple of months, one after the other devices have failed. And ruined their business. Imagine, if the signal (from 74HC) is 0, and the transistor ages and get higher temperatures, there is a little flow from 5v reverse current from C to the B of the transistor and it could start a current flow heating up the transistor. Remedy: Short-circuit (bypass) the LED and change resistor to a higher value of about 1k - 2k2 or you could place an additional resistor from B to GND.

I think for your application, you do not need a relay - why not using the same circuit which I demonstrated - just exchange the relay with your lock and drive the lock from a 12V at the upper side; then it would be better to use another D1 possibly a 1N4007 etc. ? For higher currents, you could also replace the BC547 with a low-side MOSFET.

Edit: Just a suggestion schematics: https://easyeda.com/oe1tkt/hc273_lock

The R4 is optional but when powering up, it does hold the IRL3103 MOSFET Gate to GND when there are same statics through the contol curcuit. the diode D1 has to be as closed to the LOCK (connector). Additionally a varistor would secure the MOSFET. You should also limit the current through the 12V supply, eventually with a fuce. BTW: Your hand schematics has a little problem with the CLK and MR line (the MR signel is the CLR in my schematics) and with this signal I can reset both or more ICs. With the CLK signal I can choose wich D-FF to set. Compare your and my schematics .... enter image description here

  • \$\begingroup\$ The goal is to unlock 12V - 0,8A electrical locks on every secondary side. I want to be able to repeat this circuit maybe 50+ times to be able to handle a set of lockers, which lock can be controlled by an app This is why I went for a "prebuilt relay module" to be able to use it easily and repeat it as much as needed. I found the supplier schematics and have added it to the original post. \$\endgroup\$
    – Ouhbelle
    Commented Jan 23, 2020 at 14:11
  • \$\begingroup\$ Thanks for taking the time to help ! Just to make sure I understand your solution, do you recommend not using a relay at all, but connecting directly the lock between a 12V power source and a transistor collector end ? Do you still need a flyback diode if not using a relay ? Does it work the same way with a MOSFET ?Other information, the lock is activated by a pulse (20ms if i recall correctly), and we do not need to maintain current through it. \$\endgroup\$
    – Ouhbelle
    Commented Jan 23, 2020 at 17:38
  • \$\begingroup\$ Yes semiconductors are more reliable then relays, and also yes the lock b/w 12V power and transistor's collector. When ur lock has a little inductivity, then a flyback diode is needed which suppress the sudden voltage spike seen across the inducivity load when its supply current is suddenly interrupted by the transistor's switching off. The voltage peak would destroy the transistor. When you share a datasheet of the lock, we can calculate a usable transistor and other params for your circuit. BC547 drives only 100mA, power MOSFETs are nice, but you have to take care to drive them correctly. \$\endgroup\$ Commented Jan 23, 2020 at 23:42
  • \$\begingroup\$ I don't really know about the inductivity for the lock, I do have a datasheet for the lock but I am not sure it answers the question, (and it is in french). I added a link in the original post anyway. The supplier emphasized the fact that this lock is not designed to take current for more than 20ms at a time (this is handled by the software end with clock pulses on 74HC). If needed, what extra information should I ask the supplier ? \$\endgroup\$
    – Ouhbelle
    Commented Jan 24, 2020 at 12:06
  • \$\begingroup\$ It would be good to know the worst case inrush current for the locks. Anyway, an additional flyback diode is cheap and does not disturb the functionality. Found: Tension d'activation ouverture : 12 à 24 VDC Intensité : 0,8A à 12v et 2A à 24V Temps d’activation 500ms (moins de 1s) Temps de réponse < 20 ms Consommation : 24w The 20ms is only the response time; So we can calculate with 1 A, 12 V and 1 sec. activation.Please allow me 3-4 days for a proposal. \$\endgroup\$ Commented Jan 24, 2020 at 12:28

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.