Completely confused with ULN2003ADR

Hello guys,

Now for a scarily idiotic question. I am totally confused with how a ULN2003ADR works. My application is this:

I have an atmega 2560 chip which is supposed to be switching 2 normally open solid state relays. These relays need 24V to run.
I am of the understanding correctly or otherwise that the best method is to have the output pins (MCU8 & MCU9) pass through an optocoupler first prior to the ULN2003. This works fine and the second side of optocoupler is powered via 12V2 which is taken from the 24V power supply for driving the relays and dropped down through an LM2596-ADJ to 12V. This bit works correctly.

Now, this is where my confusion comes in. I was thinking that a ULN2003ADR has the input pins on the left (signal coming from out of the relevant optocoupler), this then goes through the ULN2003 and if the signal is high allows the 24V applied to the COM pin on the ULN2003 to pass down the relevant output pin. HOWEVER, this does not work in my case and I am getting 0V at the output pins.

After doing some more googling, it looks as though others are applying 24V to one side of the relay and to COM on the ULN2003. Does this mean that the ULN is effectively "switching" the gnd?

See attached my schematic. To be clear, the Atmega is being powered completely separately and the 12V2 is coming from the 24V supply so they have shared GND on the optocouplers and ULN2003.

Now for the cheeky bit, I would be really glad of any links of info I should read up on to fill the gaps in my knowledge, AND I would be exceedingly grateful if someone could spell out exactly what I am doing wrong with this and how it should be done. I have got to the brain ache stage with it!

When an input (B) goes HIGH the output (C) is connected to the E pin.
When an input (B) is LOW the output (C) is disconnected (floating)
Post a data sheet for the solidstate relays

Correct. ULN only works that way. The others you saw using it had the right idea.

Seems kinda pointless, if the 12V and 24V supplies share common ground. What was the theory behind including those?

EDIT: ah, sorry. The a Mega doesn't share the same ground as the 12V & 24V supplies? If so, then the optos do have a purpose!

What are the rectangle symbols? Normally I would assume they were resistors, because that is the European symbol for a resistor, but you also use the "zig-zag" American symbol for resistors in the same diagram? Did you intend the rectangle to mean something different to the zig-zag?

Processing: 0900766b816f2c11 (1).pdf...

Sorry here is the datasheet. Very glad of your input. So how should I practically wire all of this up? I have had some ULN2003ADR's delivered today so I'll be playing around with a breadboard.

There is something wrong with the data sheet upload.
Do you have a link to a website?

Circuit application of (one section) ULN2003 Power Buffer (Fig-1):


Figure-1:

Hi All,

Thanks so much for the input, all very helpful.

Sorry about the datasheet not uploading correctly, I was travelling and trying to do it from my phone.

0900766b816f2c11.pdf (243.6 KB)

With regards to the optos, yes that is why, because they don't all share the same grounds.

The schematic uses the different sorts of for my convenience whilst drawing (very poor practice I know). Basically the zigzags are standard resistors, the rectangular type are resister arrays.

So as mentioned I played around with a arduino going straight into the l/h side of a ULN2003 and an led on the other side. This worked perfectly when "switching" on the gnd.

Moving back to my pcb, I then changed the connections to my relay so that I was connecting the -24V to the relay pin on the board and connected the +24V side of the relay direct to +24v. Now, I have the indicator light on the relay constantly glowing, and when I set the output to high it glows brighter. Either way the relay is permanently on. What am I doing wrong guys, can't believe I am getting so muddled up on something so simple.

I am clutching at straws here but have I got the optocoupler connections wrong as well? I have found this diagram here, is this how they should be?

I got this from the opto datasheet.

EL357N-G Series (2).pdf (857.2 KB)

Once again, thanks @jim-p @GolamMostafa @PaulRB for your help on this. My issue with the relay always being on is still present but I now have some readings for you. When the output pin on the atmega is high, I am getting 12.4V on the emitter as I expected and when it is off this goes to 0V.

However, when I test the output pins of the ULN2003 I am getting 24.1V and 23.8V respectively.

Is this because I should be using the optocoupler to switch the GND not the 12V2?

OK. You don't need the ULN2003.
In your diagram for the optocoupler, put your relay where RL is, Vcc=24V
Rin should be 510 ohms

Thanks @jim-p, so it is okay practice to pull it straight from the optocoupler? I was told by a friend this isn't best practice. I should have asked him why but didn't.

This is the datasheet for the optos I am using

EL357N(A)(TA)-G (1).pdf (2.1 MB)

For your particular relay, this is all you need

1 Like

The pin numbers on the relay should be 2=A1+ and 6=A1-

1 Like

Thanks very much @jim-p I will go and breadboard that straight away :grinning:


The datasheet shows that the voltage and current limits of the opto-isolator exceed the needs of the relay, so should be ok.

But you do also need a flyback diode across the relay coil pins. Without that, the opto-isolator and other components could be damaged.

Thanks @PaulRB .

I have tried the circuit posted by @jim-p and have the following:

5V onto opto anode via a resistor
GND onto cathode

Separate 24V supply GND onto the collector
Output from emitter into A2 on the relay (A1-)
24V to A1 on the relay (A1+)

The result is, whatever the state of the opto the led on the relay glows dimly.

I have been doing a few more trials and blown a few optos and ulns in the process.

Is there something funky with that type of relay or something? Is it that is uses so little power it has just enough of a gnd connection when the ULN is low that it can make the connection?

Tearing my hair out now!

If you connected everything exactly as shown in my schematic, it should work.
If you blew some opto then you are doing something wrong.

Sorry @jim-p took me a while to get back onto it.

When I blew the optos I was playing around with switching the +24V not the GND.

I have reconfigured the breadboard to exactly what you proposed and the relay is always coming on regardless of where there is a signal into the opto.

I also have a 12V relay (Omron GLE14-12V) which I am getting the same results with. Interestingly, I am powering it using a benchtop power supply which I have set to 12V. When it is all connected the relay fires immediately the power is connected and the power supply drops to 7.99V! It is one of these with plenty of power so confused why it is doing this.

I cannot find a datasheet for the GLE14-12V

I know the EL357N opto will work with the RIF-0-RPT-24DC relay, it may not work with the other relay. You may also damage the EL357N with the other relay.
If the RIF-0-RPT-24DC relay is always comming ON with nothing connected to the opto input (pins 1,2), then the opto is bad.

Thanks Jim, I will try changing the opto again and going back to the RIF-0-RPT-24VDC. I am getting the correct voltage switching on the Opto when feeding it through the ULN20003 which is why I didn't think that was the issue.