Hi guys, complete noob here... Working with the basics and trying to control a nerf gun with the arduino.... I've got a 5volt relay controlling the switching of the gun. You can see the setup here..
My problem is, when I test the relay using an LED everything works fine but when I use the 6 D batteries (9volts approx) the relay seems to be sticking. it will intermittantly fire for longer than the 500ms delay I'm setting... I'm wondering if the current is too high causing the relay to stuck. Does that happen? I'm using an OMR C105-H relay.
My simple code is...
int count = 1;
// Variables will change:
void setup() {
pinMode(10, OUTPUT);
}
void loop() {
while(count < 2){
delay(5000);
digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(10, LOW); // turn the LED off by making the voltage LOW
count++;
}
This relay's coil will draw 20mA under 5V when engaged. But it is possible that the in-rush current is higher. So if you are driving the relay directly via an output pin, the pin might not be capable of driving the coil directly. You can test this by measuring the voltage drop across the relay once the pin output goes high.
In any event, you probably should use a simple transistor to drive the relay (also use the catching diode).
AlphaZeta:
This relay's coil will draw 20mA under 5V when engaged. But it is possible that the in-rush current is higher.
I think the initial current would usually be lower, due to the inductance of the coil. But it is absolutely vital that you fit a flyback diode across the relay coil otherwise there will be a big voltage spike when the Arduino tries to switch the coil off. This could easily be enough to damage the Arduino's output driver, and/or cause logic faults within the Arduino.
Ok thanks for the help guys... So what would be the benefit of using a transistor in this setup? If I'm using a 5v relay and the supply power (power to the nerf gun) is coming from an outside source(batteries) I don't know why I need one. I know that the transistor can act as a switch but isn't that what the relay is doing? Pardon my stupidity.
Also, should the diode go between the output pin and one side of the relay?
And how do I determine what diode to use?
Relays are eletromechanical devices - they have to physically move lumps of metal to switch.
This requires more power than moving ityy-bitty electrons, so more current.
Possibly more current than your output pin can provide.
Thanks AWOL. I actually tested the circuit with an LED first and it all worked great. It was when I switched the to the NERF gun and external power supply that things got a bit wonky. I'm hoping If I use a flyback diode this will help but my logical(though uneducated) conclusion is saying that too much current is flowing through the relay... See this here... their relay is much much larger... Arduino Nerf sentry gun build: Soldering the relay - Make:
I'm hoping If I use a flyback diode this will help but my logical(though uneducated) conclusion is saying that too much current is flowing through the relay.
It won't. It will keep the relay from frying the Arduino when it toggles an electrical load, but it will have no effect on how much current the relay tries to draw.
You -must- use a transistor of some kind to power the relay. There is just no way around it. Even if you can get it to work on the bench, it won't work for long, and you'll end up frying your arduino.
Relays can definitely stick... I have a test program that I'm currently working on that uses a 4-channel relay module. For testing purposes, I have 4 small lengths of an LED strip wired up to the relays. These LED strips need 12VDC, so I have a 12V battery for the voltage that is being switched by the relays and just using the Arduino pins to provide the rest of the power and signals to the relay. Eventually, this will be switching something else, but scaling it down to this makes it easier to debug.
One thing that I've noticed is that after uploading new code to the processor, all the relays cycle during the upload and afterwards, they are all off (as indicated by the red LEDs onboard the relay module). But, ONE relay is apparently stuck since even though the red LED is off, the LED strip section that it controls is still on. If I send it a signal to turn it off or on, nothing changes, nor does it click. On the other hand, if I cycle one of the other relays, the problematic one starts working. So, that got me to thinking that it might just be stuck. To test it out, I uploaded the code again so that this would happen again and then I gave it a light tap. The relay clicked and went off.
Relays are definitely a weak point. I have used thousands and have replaced scores from failures.
I might be the only one who could not get a single of the OP's links to work...
when posting, you should put in links to the parts you have.
the picture in post 12 shows a properly developed circuit, with transistor to drive the relays and properly selected and installed diodes. without knowing what you have the suggestion to add a diode comes up. it is confusing and does not apply to the pre-fab relay modules.
lastly, you have a bit of an X/Y problem.
you tried to ask a question about a specific device, general knowledge sort of questiong, but then also tried to apply that to an application.
Your application SCREAMS to use an FET. no need to carry a 12 volt car battery just to power the power hungry relay.
an FET uses almost no power and can deliver more DC current (yeah, direct current current is much poor grammar)
dave-in-nj:
Relays are definitely a weak point. I have used thousands and have replaced scores from failures.
I might be the only one who could not get a single of the OP's links to work...
when posting, you should put in links to the parts you have.
the picture in post 12 shows a properly developed circuit, with transistor to drive the relays and properly selected and installed diodes. without knowing what you have the suggestion to add a diode comes up. it is confusing and does not apply to the pre-fab relay modules.
lastly, you have a bit of an X/Y problem.
you tried to ask a question about a specific device, general knowledge sort of questiong, but then also tried to apply that to an application.
Your application SCREAMS to use an FET. no need to carry a 12 volt car battery just to power the power hungry relay.
an FET uses almost no power and can deliver more DC current (yeah, direct current current is much poor grammar)
It's an older thread that I was just providing a bit more info in case someone stumbles across it like I did. It's not really surprising that the links are not valid (assuming they were valid to begin with). The link that I used for the image of the 4-channel relay module is valid as of 12/15/2018, but I would not bet on it still being valid in a few more years.
In post#12 you mention a 12volt source and I see a picture of a 4-relay module.
Don't expect that an Uno can power four relay coils from it's 5volt pin when powered from 12volt.
You will fry the 5volt regulator if more than one relay is active for some time.
Logic level fets is the way to go for common 12volt LED strips, not relays.
Leo..