2x MEGA controlling a relay

Hello all,

I have a question with using 2x separate Arduino MEGAs

I want to install the same code which does exactly the same thing, but with different sensors
I will be using a digitalWrite to switch on a relay lets say PIN34

MEGA1 will have the first 7 sensors
MEGA2 will have the second 7 sensors.

I would like it if they can both toggle the same relay without damaging each other

EG:
If I grab PIN 34 from MEGA1 and MEGA2 and wired it together to the relay.

Would the MEGAs work fine? or do I need some kind of signal diode? splitting the MEGA.

thankyou

Stick the outputs into an OR-gate so when either or both is high, the output from the OR is high.

toxsickcity:
I want to install the same code which does exactly the same thing, but with different sensors

Same code, different sensors... I doubt that :wink:

Then first, what the heck are you making that you think you need 2 MEGA's? A single Mega already has 54!!! I/O.

On to the question, do both Arduino's need to control the relay in both states? Or do they only have to be able to turn it on? (Which means Arduino A can't turn i off when Arduino B has i turned on.) In that case simple diode in like to the driver (probably a transistor, because you can't connect a relay directly) will do.

I will have 14 sensors.

7 per mega.
MEGA1(HDD1,HDD2,HDD3,HDD4,HDD5,HDD6,HDD7)
MEGA2(VGA,PSU,CPU,MOBO,FAN,DVD,PUMP)

I will create an ARRAY to tie all 7 sensors to a highest temp.
the pins
29,30,31,32 will be tied to RELAY 1,2,3,4

so when the HDDs get hot they can activate the relays depending on heat.
and when the components on MEGA 2 get hot the SAME 4 relays should get tripped.

this is my idea, this already works on 1 MEGA
just thinking how to get more..

I need to use PWMs and TLC nonsense is out of the question. waste of my bloody time

Or you could feed the output from Arduino B back to an input on Arduino A, which will control the relay based on its own sensors and what it gets from B.

But if you do that you might as well put all the sensors on one Arduino in the first place. Keen to hear why you don't do that?

TLC nonsense? And for what do you need PWM?

And I still count 14 sensors and 4 relays (= 18 pins). Deendig on he sensor you can even do this on a single Uno / Pro Mini / Nano, let alone two(!!!) Mega's...

But okay, I told you the answer for your problem already :wink:

septillion:
TLC nonsense?

Quite a few meanings for TLC here: my favourite is "Three Letter Code" :slight_smile:

sorry i forgot each Sensor needs two PWM for lighting, BLUE and RED..

Blue-->Red on thermal,
LED strips, and each pwm will drive a MOSfet IRFZ44n

toxsickcity:
sorry i forgot each Sensor needs two PWM for lighting, BLUE and RED..

Sensors have outputs? I'm confused.

the sensors tell mega how hot everything is.. all 14 components...
and then I have code which converts the thermals into usable data that creates a FADE between the BLUE and RED Channel on the LED Strip creating an effect that glows the device blue or red indicating how hot it is.

The sensors also tell 4 RELAYS connected to a (Fan) each relay activating a higher speed on that said fan

so my NTC sensors --> MEGA --> LEDs & Relays

Magic, TLC-less (meaning of LesserMole) sensors :smiley:

You might want to start posting more details of the complete project if you want more details help. Otherwise, told the solution in reply #2. :slight_smile:

septillion:
told the solution in reply #2. :slight_smile:

And #1 and #4.

I'm not seeing where the 2nd Mega comes in, since Mega #1 has a sh!t load of pins, but that might be because you haven't shown yet how all the pins on the 1st one are deployed.

(Still wondering what TLC means here.)

LesserMole:
I'm not seeing where the 2nd Mega comes in, since Mega #1 has a sh!t load of pins, but that might be because you haven't shown yet how all the pins on the 1st one are deployed.

Pin count means nothing if they can't do what you need. Based on the detail provided, the OP needs 14 analog inputs (more than 1 UNO, but fits in 1 MEGA) and then there are 2 PWM outputs based on each sensor for total 28 PWM outputs which is more than 1 UNO or MEGA. Therefore the OP has choose to split the program into two identically programmed MEGAs.

All that detail is irrelevant to the question asked (how to drive one relay from two output pins). Instead of answering the question (and possibly letting the OP dig a bigger hole, but that is their problem) you all wander off on some tangent rather than answer the question.

Options for the OP question:

  1. Run both inputs into a 74xx OR gate
  2. Built relay driver from a transistor that will allow for the output to be ORed
  3. Connect Mega 2 to Mega 1 and let Mega 1 drive the relay
  4. Form an OR gate from relays by connecting both Megas outputs to 4 relays then connect each pair of relays to the 4 relays that drive the fan (total of 12 relays or 3 4x relay boards)

Cons for each

  1. Requires perf board wiring
  2. Requires more perf board wiring
  3. Results in the programs are no longer identical
  4. All parts are off the shelf but no dealing with 3 relay board and 12 relays.

Pick your poison.

adwsystems:
Options for the OP question:

  1. Run both inputs into a 74xx OR gate

Which is EXACTLY what I said in #1, with a link to 7432, 5 minutes after the OP posed the question, so if that's what you mean by

wander off on some tangent rather than answer the question.

..... I'm keen to see what a more direct route is.

adwsystems:
Pin count means nothing if they can't do what you need. Based on the detail provided, the OP needs 14 analog inputs

He didn't actually specify the sensors so I didn't know they are analog, and that's why I was asking how the pins are deployed.

adwsystems:
3. Connect Mega 2 to Mega 1 and let Mega 1 drive the relay

And THAT's what I said in #4, 30 minutes after the question was asked.

adwsystems:
Instead of answering the question (and possibly letting the OP dig a bigger hole, but that is their problem) you all wander off on some tangent rather than answer the question.

So you're an even more terrible reader then the OP than...

And yeah, peripherals can be an issue but I thing OP makes it way more complicated then it need to be by using two huge Mega's. Single Pro Mini + PCA9685 + mux is all you need :slight_smile: Newbies tend to dig deeep deep wholes because they only see obvious but hard ways to do stuff.

And if you want to use the output of Arduino A to drive an input of Arduino B, add a resistor in series (10K+) to stop possible damage because of phantom powering.

LesserMole:
Which is EXACTLY what I said in #1, with a link to 7432, 5 minutes after the OP posed the question, so if that's what you mean by

LesserMole:
And THAT's what I said in #4, 30 minutes after the question was asked.

I know you did. I was just relisting all the options to skip over the tangent questions related to redesigning the OPs project.

LesserMole:
..... I'm keen to see what a more direct route is.

Just answer the question. How many pins he is using on the Mega and the fact there are a ton of them is irrelevant. If he wants to use two Megas then that is his choice. Just stick to the question.

LesserMole:
He didn't actually specify the sensors so I didn't know they are analog, and that's why I was asking how the pins are deployed.

With my experience, 9 of 10 times sensors are analog. There are analog sensors that provide a digital output due to internal thresholds, etc. and switches can be used as sensors and are 9 of 10 times digital (there are some devices with the word switch in the name that provide an analog output). With that background, if a question is posted and states 'sensors' then I interpret the layout to be using analog inputs. If that's wrong then the OP should have stated that fact in the first place and that's on them, not me.

septillion:
So you're an even more terrible reader then the OP than...

Except that I'm not of the people the one delving into the OPs design choices and reworking their project.

septillion:
And yeah, peripherals can be an issue but I thing OP makes it way more complicated then it need to be by using two huge Mega's. Single Pro Mini + PCA9685 + mux is all you need :slight_smile: Newbies tend to dig deeep deep holes because they only see obvious but hard ways to do stuff.

I agree that is also a fine alternative, if he has the stuff to built it out and wire to it together. Two Megas and 2 4x relay boards takes nothing more than jumper wires to connect. The lowliest Arduino noob can do that.

adwsystems:
If that's wrong then the OP should have stated that fact in the first place.

Pretty much my point.

Don't be so bloody grumpy: lighten up. If we want grump, we can go to stack exchange.

adwsystems:
If he wants to use two Megas then that is his choice. Just stick to the question.

Next year it's 40 years since I graduated as an engineer. Engineering success is about peer review, questioning choices, testing. Even though OP is the design authority in this case, it behooves others to ask about choices.

That said, I actually don't give a rat's if OP buys 14 Megas, one for each sensor. I was more curious than anything....

I'm gone from this one. OP has my suggestions in #1 and #4, use them, don't use them.