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