Go Down

Topic: connecting Nano pin to Mega pin (digital) (Read 164 times) previous topic - next topic

Telpelango

I am working on a test automation project and currently have my main code on the Mega 2560 (with a 5'' display) and jam detection code on the Nano.

I had them communicating via SPI (nRF24L01+) before, but recently it was decided that the detection is an optional, not essential feature, and if needed the detector module (Nano with light barriers) could be connected directly to the main PCB with the Mega. So the wireless modules are scrapped.

I could completely remove the Nano and connect the light barriers directly to the Mega analog pins, but then I have a problem of them floating when no light barriers are connected.

Is it safe to connect two digital output pins on the Nano to two digital input pins (defaulted to LOW) on the Mega, with the Nano using the same 9V power as the Mega?

9V is coming from a buck converter (12V input, 1A max). I have a few more buck converters, so I could power the Nano from a separate one if 1A is not enough for Mega + Nano.

Wawa

I could completely remove the Nano and connect the light barriers directly to the Mega analog pins, but then I have a problem of them floating when no light barriers are connected.
That sentence doesn't make sense. Floating pin?
Internal pull up can also be enabled on analogue pins.
pinMode(barrierPin, INPUT_PULLUP);
Better tell us the who/where/what/when/why.
Joining two processors is not always a good solution.
Leo..

Telpelango

Internal pull up can also be enabled on analogue pins.
Better tell us the who/where/what/when/why.
Joining two processors is not always a good solution.
Oh yeah, sorry, saw that enabling pullup on them will change the read values, so I automatically decided that cant be used.

I might have worded my post in a confusing way.
So, I have a Mega running the main automation code, controlled via a TFT LCD touchscreen display (powered from a separate 3.3V buck).
Additionally I have a Nano with two light barriers on analog pins, the code is currently sending a SPI msg to the Mega via nRF24L01+ modules when a jam is detected.

That combination works fine, but as I said it was recently decided to remove the wireless modules and connect the Nano to the Mega directly.

Now, my question is:
If I leave my detection code on the Nano so it doesn't ruin my main code, can I power the Nano from the same 9V and connect 2 digital output pins to 2 digital input pins on the Mega? Or would it be safer to use another buck to get 9V for the Nano?

JCA79B

What kind of signal do the light barriers send to the Nano? Is it an analog voltage varying between 0 and 5 volts or a digital level that is either 0 or 5 volts?

Wawa

#4
Jun 14, 2019, 11:17 pm Last Edit: Jun 14, 2019, 11:31 pm by Wawa
powered from a separate 3.3V buck...
Why?
A Mega has a dedicated 3.3volt regulator that isn't used for anything else on the Mega, and it can provide up to 150mA.
You might not need a separate supply (you should know the current draw of that display).
Two supplies could result in phantom-powering through the I/O lines, which is bad.

can I power the Nano from the same 9V and connect 2 digital output pins to 2 digital input pins on the Mega? Or would it be safer to use another buck to get 9V for the Nano?
Just connect the 5volt pins (and ground) together, so the Mega powers the Nano. The Nano itself only draws 30mA.
Don't know what the LEDs in the light barriers use, because you didn't post a circuit diagram.
Merging the code and removing the Nano would be easier though.
Leo..

Telpelango

#5
Jun 17, 2019, 08:54 am Last Edit: Jun 17, 2019, 09:00 am by Telpelango
What kind of signal do the light barriers send to the Nano? Is it an analog voltage varying between 0 and 5 volts or a digital level that is either 0 or 5 volts?
Analog 0 to 5 depending on distance measured.

Why?
A Mega has a dedicated 3.3volt regulator that isn't used for anything else on the Mega, and it can provide up to 150mA.
You might not need a separate supply (you should know the current draw of that display).
Two supplies could result in phantom-powering through the I/O lines, which is bad.
I already tried that, it doesn't work, the screen draws too much current in combination with the other connected components.
It is not 2 supplies exactly. 12V from one PSU unit is connected to 9V and 3.3V buck converters, 9V goes to Vin, and 3.3V to screen power and backlight.

Just connect the 5volt pins (and ground) together, so the Mega powers the Nano. The Nano itself only draws 30mA.
Don't know what the LEDs in the light barriers use, because you didn't post a circuit diagram.
Merging the code and removing the Nano would be easier though.
I pulled 9V from the buck to a power plug for the Nano, so the Nano is powered from the same supply. I am just thinking about using a second 9V buck specifically for the Nano because they are 1A max.
I also added 1k resistors in series with the pins from Nano to Mega to be safe.

The reason I would like to avoid merging the code is that I want the detector module as a separate unit so it can just be connected when needed.

Go Up