Go Down

Topic: 2x MEGA controlling a relay (Read 968 times) previous topic - next topic

toxsickcity

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

LesserMole

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




septillion

I want to install the same code which does exactly the same thing, but with different sensors
Same code, different sensors... I doubt that ;)

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.
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

toxsickcity

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

LesserMole

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?


septillion

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 ;)
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

LesserMole

TLC nonsense?
Quite a few meanings for TLC here: my favourite is "Three Letter Code" :)


toxsickcity

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

LesserMole

sorry i forgot each Sensor needs two PWM for lighting, BLUE and RED..
Sensors have outputs? I'm confused.


toxsickcity

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

septillion

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

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. :)
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

LesserMole

told the solution in reply #2. :)
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.)


adwsystems

#12
Feb 16, 2018, 12:26 pm Last Edit: Feb 16, 2018, 12:26 pm by adwsystems
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.

LesserMole

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

Quote
wander off on some tangent rather than answer the question.
..... I'm keen to see what a more direct route is.

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.


LesserMole

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.


Go Up