problem with INPUT_PULLUP being triggered by external relay

Hey. so i've come across a problem that i can't figure out. my arduino nano is controlling a 2 relay module. one relay controls an air solenoid valve, and the other relay controls a small vacuum/pump motor.

In the setup, i have the air solenoid valve cycle for 4 seconds to release any air that's in the system and turn off, and then waits for the start button press to start the program. But for some reason, whenever the air solenoid valve is cycled within the setup, or manually cycled before i hit the start button, it's somehow triggering the INPUT_PULLUP for the start button, and automatically starting the program, and bypassing the start button all together.

I first thought that the air solenoid was giving off a surge of power which was effecting the arduino and tripping the start button. So i've isolated the air solenoid by using diodes hoping it would fix the problem, but it didn't help any.

so the only thing i can think of around this problem would be changing the INPUT_PULLUP to an INPUT instead, and then triggering it with a 5v signal with hopes of it fixing the problem of prematurely triggering.

any other ideas on what could be causing the problem?

thanks

Please post your code and a simple schematic of your project.

How is the Arduino and its peripherals powered ? It sounds like the Arduino is rebooting. Put a print into setup() so that you can monitor when it runs

one thing that could be the issue is the 3 pin jumper on the rear of the relay module. and i've tried to find out exactly what's it's for, but haven't found a straight answer. Right now it's set to default, which is JD-VCC, which from what i've read is that is supposed to isolate the relay using the octocoupler. I believe... or i could have it backwards. or do I need to remove the jumper and run a separate VCC and GND to those pins to make it isolated.

can someone please explain the function of that jumper, and if i am supposed to run separate power and ground to it?

Well covered by Terry King here
http://arduinoinfo.mywikis.net/wiki/Relay-Board-How-To

Remove the jumper.

I have the same issue with a pinball machine i am converting from EM to computer control, the coils will fire randomly or mostly the arduino just resets and starts over. There is a world of advice on this stuff, but it seems to be these coils give off a lot of EMI and that surging thru your arduino and doing a lot of stuff none of it desirable. I have had problems for three days now, may just work on other things for now.

It is very possible this jumper is similar to the one in the cct. below.
Try similar setting seen.

OptoRelay4X_Wiring.png

Oh, and i was using input_pullup and changed to input and that made the problem way worse. just a thought.

Thanks for the info. I was able to get it fixed. I tried removing the jumper and isolating the relay module, and that didn't work. and tried a couple of diodes in line to attempt to stop the EMF from effecting rest of the circuit, and that didn't work.

what i had to do was install a 1K resistor between the V+ and the ground on the big solenoid to redirect the EMF to the power supply ground and not surge the system and trigger the arduino when it shouldn't running.

to larryd, if you x out the ground to arduino where does the relay get ground? The different power supply?

to wildcat99s, is your coil powered by AC or DC. Mine are all AC so I don't know if a resistor would do me any good.

sevenoutpinball:
to larryd, if you x out the ground to arduino where does the relay get ground? The different power supply?

You may have missed there is an ‘external power supply’ that powers the relay coil part of the circuit.
+5v to JD-VCC and 0v to the GND terminal.

The GND with the Red X is on the Arduino, i.e. not connected. 5v from the Arduino goes to the relay Vcc terminal, then through the opto LED and out to an INx pin, then back to the Arduino output pin where it can go the GND when we do a digitalWrite(x,LOW) to that output pin.

Similar circuit as seen in yellow . . .
Note, this 8 channel relay board has a 3 pin connector where the external 0v is connected, however, it could have been just as easily connected the the GND screw terminal.

sevenoutpinball:
to wildcat99s, is your coil powered by AC or DC. Mine are all AC so I don't know if a resistor would do me any good.

I'm using 12v dc solenoids.

but after hitting the reset button 100 times and allowing it start up. i'm still running about 25-50% error rate on startup. And it gets worse it is the closer the circuit board is too the solenoid. so there's a chance it's getting proximity EMF. which might be effecting the nano as well. so i'm gonna try some extra shielding to see if it helps.

It wouldn't surprise me if half of my problems is coming from the cheap chinese nano clone that i have. like i noticed that i have to follow specific steps to get the board to sync with my computer. like i can't turn on the external power supply first and then plug in the USB, or the board will not connect. i have to plug in the usb first, and then turn on the external power (if i want the solenoid/pump to run as well). Which that is something i can deal with since i'm only using serial to work out the bugs. but i've also noticed that the serial will only work if the nano is the only thing on. if my solenoid or pump is working, the serial stops after the first loop, but the loop continues to run as it should.

i also suppose it could be caused by the shared power supply and my voltage regulators, 7805 for the relay module and 7809+diode = 8.3v powering the nano. so i'll guess i'll have to hook it up to my oscilloscope to see if i can see some excess emf or ripple/spikes or drops. the entire circuit, solenoid and pump only draws about 1.1 amps so i'm sure it's something simple or stupid causing the errors because everythings works as it should on the microcontroller level, but as soon as i hook up a solenoid and a small DC motor, it all goes haywire.

But I don't understand, previously you said you had gotten it to work reliably. I did a pinball machine two 24vac coils two years ago and it works fine, this year with 53vac coils and not so much.

Please post your code and a simple schematic of your project.

Asked in reply #1 and unanswered.

like i noticed that i have to follow specific steps to get the board to sync with my computer. like i can't turn on the external power supply first and then plug in the USB, or the board will not connect. i have to plug in the usb first, and then turn on the external power (if i want the solenoid/pump to run as well). Which that is something i can deal with since i'm only using serial to work out the bugs. but i've also noticed that the serial will only work if the nano is the only thing on. if my solenoid or pump is working, the serial stops after the first loop, but the loop continues to run as it should.

This is strange,

Instead of blaming the nano clone, I'd be looking at your wiring and hardware configuration.

to larryd, so somehow the digitalWrite to the arduino grounds thru the "separate supply" even tho both the pin and 5v are connected to the relay. To me that would be like having two flashlights and both ground thru one battery but each has voltage from it's own voltage. I don't see how the would work, but what do I know.

wildcat99s:
I'm using 12v dc solenoids.

but after hitting the reset button 100 times and allowing it start up. i'm still running about 25-50% error rate on startup. And it gets worse it is the closer the circuit board is too the solenoid. so there's a chance it's getting proximity EMF. which might be effecting the nano as well. so i'm gonna try some extra shielding to see if it helps.

It wouldn't surprise me if half of my problems is coming from the cheap chinese nano clone that i have. like i noticed that i have to follow specific steps to get the board to sync with my computer. like i can't turn on the external power supply first and then plug in the USB, or the board will not connect. i have to plug in the usb first, and then turn on the external power (if i want the solenoid/pump to run as well). Which that is something i can deal with since i'm only using serial to work out the bugs. but i've also noticed that the serial will only work if the nano is the only thing on. if my solenoid or pump is working, the serial stops after the first loop, but the loop continues to run as it should.

i also suppose it could be caused by the shared power supply and my voltage regulators, 7805 for the relay module and 7809+diode = 8.3v powering the nano. so i'll guess i'll have to hook it up to my oscilloscope to see if i can see some excess emf or ripple/spikes or drops. the entire circuit, solenoid and pump only draws about 1.1 amps so i'm sure it's something simple or stupid causing the errors because everythings works as it should on the microcontroller level, but as soon as i hook up a solenoid and a small DC motor, it all goes haywire.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Can you please post your code, between code tags?

Do you have the bypass capacitors fitted around the LM7805 and LM7809 regulators?
What is your power supply?

Can you post a picture of your project so we can see your component layout?

Thanks.. Tom... :slight_smile:

I’ll be able to post the code and pic of the circuit later today. Before i added the resistor on the solenoid, i had an error nearly 99% of the time. The resistor cut that down to about 50% error rate. I can cycle the arduino over and over, and it may work fine 4-5 times in a row, mess up, work, mess up a time or two, and work for another 2-3 times and just bounces back and forth. But it only messes up whenever the solenoid is hooked up. If i disconnect it, it seems to work perfect every time. yesterday, i worked on it for a good 6 hours and was a little premature on posting some stuff. But it can get frustrating.

one of the reasons why i wanted to blame the arduino clone, because the problems i’m having it connecting to the computer is problems that other people have had that i’ve read in reviews and other problems.

With the voltage regulators, yes, i have caps on the input and output. and after thinking about it more last night and this morning, i have an idea on how i can eliminate the surge. I’m thinking i have a misplaced diode in the circuit.

sevenoutpinball:
to larryd, so somehow the digitalWrite to the arduino grounds thru the "separate supply" even tho both the pin and 5v are connected to the relay. To me that would be like having two flashlights and both ground thru one battery but each has voltage from it's own voltage. I don't see how the would work, but what do I know.

This comes up every now and then so it's worth going through.

The schematic below shows the major components involved when an Arduino controls a relay on an optoisolated relay board.

Note:
The YELLOW highlight shows the current flow from the Arduino through the relay optoisolator and back to the Arduino GND via the Arduino output.

The GREEN highlight shows the relay current flow from the external 5V power supply through the relay coil and back to the external 0 volts (GND).

You should see the two current paths are electrically isolated from each other.

hey. so it's gonna be tonight or tomorrow before i'll be able to work on my project and post the code and pictures. I had a little disaster happen on saturday afternoon i'm trying to resolve. I have a 270 gallon freshwater aquarium in my living room, and the front panel broke it's seal and i lost about 30 gallons on the carpet, but it was really close to giving all the way out. So i've been busy trying to keep the fish and the filter alive while i strip the silicone and redo it all. and it sucks ass... but it could have been worse. at least all the fish are still alive.

but while it's apart, it's getting an upgrade. I'm gonna put a metal strap around the top to keep it from ever wanting to split the seam again.

hey all. so i was able to get my project fixed, when i connected the resistor between the hot and ground on the solenoid, it helped, but didn't fix it, so i was on the right track but was wrong. i should have used a flyback diode instead of the resistor. I put a diode on the solenoid and the pump, and it fixed the random errors i was having. I've already cycled it about 20 times and it works perfectly every time.... and even the serial is working now, which is something that always glitched whenever the solenoid popped.

So I knew it had to be something really simple for the fact if i disconnected the loads, then it all worked like it should, but with the loads, it was random errors. and if i had a coding or wiring error, it would glitch every time, and the randomness of the error was driving me crazy

But thanks for all the info on the relay module.