Signaling from one AVR to another - Hardware Question (I think)

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have been struggling with this problem for a couple of days now and I have had no luck finding an explanation for what I am doing wrong.  I seem to be missing a very key and, probably simple, piece of information.  Here is my situation:

 

I have 2 ATMega328 MCUs on a bread board.  They are both using the same power supply circuit.  Unit One is outputting a signal on one of it's pins just by setting the pin high and low.  This signal changes state every 5 seconds.  Unit Two is suppose to receive the signal and display a message on an LCD display telling me the state of the output pin on Unit One.  All the code is working correctly.  Unit One is sending the signal and I can see it on my oscilloscope just as I would expect.  Unit Two tells me that the pin is high when I connect it's input pin to the voltage rail and it tells me the pin is low when I disconnect it.  The problem is that when I connect the output from Unit One to the Input of Unit Two, the signal on the oscilloscope goes flat at 0 volts.  What am I missing?

 

Here is a list of things I have tried:

  1. Adding and removing a pull down resistor to the line - No effect (my design includes the use of the pull down resistor)
  2. Removing the pull down resistor and enabling the pull up resistor on unit 2's input pin - Effect: the voltage on the line is always high connecting Unit Two's input to ground works to send the signal low and disconnecting it sends the signal high.  The signal from Unit one is still not visible on the oscilloscope.
  3. Adding a diode - The signal does not exist on the output of the diode a very small signal exists on the input side (I think this is due to forward biasing but I am not sure if that is the correct term).
  4. Adding an NPN transistor, connecting the output of Unit One to the base, VCC to the collector, and the input of unit 2 to the emitter.  Effect - The signal is very small (less than 100 mV) and very noisy.  Removing the connection from the emitter to Unit Two shows me the full signal.
  5. Massive amounts of Googling.

 

It is as if when I send the signal to Unit Two, the MCU sends the signal to ground and doesn't read it at all.  However, this can't be the case as when I connect the same pin to VCC, the pin is read as high and there is a 5V constant signal on my oscilloscope.  There is something flawed in the way I am looking at this.  Please educate me.

 

Thanks in advance,
Joe

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yungoe wrote:
What am I missing?

Common Ground ?

 

(the high-low output has to be relative to some common ground level they both agree on).

 

BTW why two small AVRs? Life is much simpler with one big one.

(as I think this thread just ably demonstrated!)

Last Edited: Thu. Mar 17, 2016 - 02:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the quick reply.  I don't think common ground is not the issue.  Both MCUs are on the same power supply circuit including VCC and Ground.  I just did a continuity test with my volt meter to make sure and there is no resistance between the ground pins of both MCUs.  Let me know if I am doing this wrong as well.

This is a proof of concept for sending a signal between 2 MCUs.  It would be easier with one as what I am trying to prove would be unnecessary.wink

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Unit One is outputting a signal on one of it's pins just by setting the pin high and low

Put an LED (with a 330 ohm or 470 ohm resistor in series) from the Unit #1's output pin to ground.

This LED should light up for 5 Sec, be off for 5 Sec, etc.

Do this without Unit #2 connected.

 

This will confirm that the Unit #1 I/O pin is truly in digital output mode and that the pin is good.

 

If the pin is not correctly set up in digital output mode, is in input mode, or is damaged, the LED won't flash.

 

Next, check that the wire connecting the two uC's is good.

Perhaps you have a bad wire, which can be difficult to determine, and is very frustrating.

 

Next, try different holes in the breadboard, perhaps it is an old, worn out breadboard, with a loose / poor connection at one end.

 

Next, attach a schematic if your project, (jpg); and a photo of your breadboard setup, (jpg).

Use the "mountain" icon two to the left of the smilie face icon to attach images.

 

JC 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

It seems as though the One's output is configured to input with pull up, and Two's input is configured to output driving the pin to low.

BR,

M

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks DocJC and Menahem.  Menahem's observation is 100% correct.  I was setting the DDRs incorrectly on both MCUs.  I guess I have to think harder about my Boolean logic.  DocJC, your suggestion to send the pin to an LED was what led me to find the error in the Unit One's Code.  I was about to post that I had fixed the error on Unit one but still had a similar problem with the signal.   Then I saw Menahem's response.  I should have known that I inverted the error for Unit Two.  Once I corrected the errors the systems works as I want it to.  So I guess the answer is that this isn't really a hardware problem but coding error.  Thanks again to you both.

 

BTW, Menahem, I would love to know how you knew what the problem was from my description.  If you don't feel like explaining, that's fine.  I'm just ecstatic that the issue is resolved.

 

Joe

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Actually it was the Doc who hinted at your problem first:

DocJC wrote:
If the pin is not correctly set up in digital output mode, is in input mode, or is damaged, the LED won't flash.

What probably misled us from a more definite, earlier diagnosis was when you said:

yungoe wrote:
Unit One is sending the signal and I can see it on my oscilloscope just as I would expect

The fact is that if you leave the DDR bit of a pin as 0 then it will be a floating input that might show any level on the scope (though the scope itself may influence it). If you then write to the PORT register mistakenly thinking you are driving it to a solid 1 or 0 what you actually do by writing 1 to the PORT register when the DDR register bit is holding 0 is to turn on the internal pull up resistor. (It's about 30..50K Ohms so is pretty weak). When nothing else is connected to the pin this will be enough to make it look like a definite 1. I assume that when you had the PORT register bit set to 0 (pull up not enabled) that the pin was floating down near 0. So this looked as if it was being driven between 1 and 0.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

It was just a lucky guess. The first clue was that even a weak pull-up can act as an output when you measure it with a scope; the second one was "the pin is high when I connect it's input pin to the voltage rail". The rail always wins. :)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your diagnosis is correct.  Also, I did give due credit to DocJC in my last post.  His post is what led me to find the error in unit one's code.

 

Please understand, my intent is never to mislead.  Since I was seeing what I was expecting on the scope, I didn't think that the software was wrong.  My apologies for this and my thanks again to DocJC and Meneham.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I don't worry much about "credit" for answers.

I tend to learn a lot reading the Forum, and receive more help than I provide.

 

The bottom line is that it is nice hear you have your problem solved!

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

+1

+1

Best wishes,

M