I am working on my 4th of July project and just discovered yesterday that i have an issue with the relays.
I do not have time to get new relays before the 4th. Here is my issue.
The relays i received are Low Level Trigger instead of High Level Trigger. My program works fine if i had the correct relays. These relay contacts are closed with no power to them and open when 5v applied. i have not been able to find a way to accomplish this in programming but basically what i need is to have all the outputs HIGH when in an idle state. Then i can switch my program to dititalWrite LOW instead of HIGH to trigger the relay.
I am using a Mega. Is it possible to set all 54 I/O ports to be HIGH and stay that way when at what i would call and idle state? (board powered up of course)
My current program checks for a trigger input on A0 and then runs the program to sequence though the 54 relays turning them on (HIGH), the turning them off (LOW).
else (the end)
i would need to reverse the program so when "else" the I/O ports are high, which would be all the time unless the programs runs when it senses a HIGH on the trigger.
I hope this all makes sense. i am new at this but think i have given the necessary information.
Thanks in advance for any assistance.
i have not been able to find a way to accomplish this in programming but basically what i need is to have all the outputs HIGH when in an idle state.
That's what digitalWrite() is for.
Is it possible to set all 54 I/O ports to be HIGH and stay that way
Stay that way forever? You can set all pins HIGH, one at a time.
I tried to set them all HIGH in the program before my check for trigger state but it did not seem to work.
I did a digitalWrite(led1, HIGH); and went down the list. I need them to stay HIGH until A0 sees 5v and then begin the sequence. Currently the sequence is
digitalWrite(led1, HIGH);
delay(500)
dititalWrite(led1, LOW);
delay(500);
then just sequences though all 54 ports.
i would have to reverse the HIGH/LOW above to trigger the relays properly.
i just have not been able to set the default value of the ports to HIGH.
does that help any?
i would have to reverse the HIGH/LOW above to trigger the relays properly.
Yea. Why is that a problem?
Reversing the HIGH and LOW in the program would not be an issue.
With the current program on the Low Level relays, it runs fine but just turns them off when it should be turning them on and vise versa.
I can't seem to get the pins to go HIGH by default to keep the relay contacts open until i trigger the program. I am guessing that I am missing something simple here.
Write all the pins HIGH in setup. I don't understand what your problem is.
If it's just a matter of wanting to do it efficiently, then I would create an array just listing all of the pins in question. Then use a 'for loop' to write them all HIGH.
And if you've listed them in the array in the order they'd have to trigger in your sequence, then you could use the same array to play your program with a much much shorter code than what I imagine you've written as 54 copy/pasted bits.
And if so, let this be a learning experience that shows you the value of using functions. Since all of your pins are doing the same thing, you could've just written the
digitalWrite(led1, HIGH);
delay(500)
dititalWrite(led1, LOW);
delay(500);
stuff once and upon discovering your relays are active low, change just two words in your code
Remember, if you're doing the same something many times, use a for loop. It's what they're there for.
I can't seem to get the pins to go HIGH by default
Pins default to INPUT and LOW. You can set them to HIGH almost immediately. If that is not soon enough, you would need to replace the relays with ones that are in the state you want when the pin is LOW or edit the core files to change the default state to HIGH. Find the init() function, and change it. Not a trivial thing to do.
Might be simpler to buy a bucket of transistors.
I did write all 54 individual lines for simplicity for me. There are actually several different timed sequences throughout the 54 pins. I have played with arrays with one simple sequence through all pins and was successful. I know that my programming is not the most efficient, I am still trying to learn all that stuff.
Writing them to HIGH does not have to be instantaneous as long as they will stay that way until the program is played from the trigger.
In my setup, i have set them all to OUTPUT
i appreciate all the input and will give it a shot again this evening.
Do the relays have changeover contacts or normally open contacts ?
It is just the one set of contacts. The diagram shows them as normally open.
Chazz:
It is just the one set of contacts. The diagram shows them as normally open.
In that case your only option is to take the advice offered in this thread and use them as active LOW devices.
Hi,
See
"IMPORTANT NOTE: There is a issue with start-up of Arduino programs that control these relays. All of these 2,4, or 8 relay boards input controls are Active LOW, meaning that setting a pin LOW turns them ON.:
On THIS PAGE