Go Down

Topic: I2C - Atmega328 Standalone vs Arduino Uno (Read 252 times) previous topic - next topic

tdoc23

I am working on a project using an Adafruit 7-segment display with I2C backpack controlled by an Arduino Uno.  I have played around with the example libraries and have no problem controlling the display with an Arduino Uno board. 

The next step in my project is to remove the Atmega328P chip from the Uno board and build a small circuit with some input from relays to pass information to the Atmega that will then be displayed on the 7-segment display. To test this I moved the Atmega to a breadboard and followed a tutorial to "Build an arduino on a breadboard."

https://www.instructables.com/id/How-to-Build-an-Arduino-Uno-on-a-BreadBoard/

I confirmed the build was working by flashing some example programs and testing the inputs/outputs.

My problem is, the breadboard version of the uno does not seem to work with the 7-segment display.
I have tried disabling internal pull-up resistors and adding different values of external pull-up resistors but nothing seems to work.  Unfortunately I don't have access to a scope or logic analyser.

Are there any extra components on an uno board in the I2C circuit that I might be missing? I have checked schematics but everything shows that the SDA and SCL pins on the board are connected directly to pins 27 and 28 on the Atmega. 

I appreciate any feedback or advice

GolamMostafa

Upload your sketch into the UNO Board. Leave the ATmega328P chip on the socket of the UNO Board. Remove the USB connector from the UNO Board. Power the UNO Board from a 9VDC adapter via the Power-pin connector. Press the RST Button. Check that the display unit is showing your desired message. Does it show the message?

pert

The instructables neglects to add decoupling capacitors on the power lines. This could lead to problems. I recommend the breadboard circuit shown in this tutorial instead:
http://www.gammon.com.au/breadboard

In this picture (before the crystal is added to the circuit), notice how the capacitors are placed as close as possible to the chip:


The instructables also skips the pull-up resistor on the reset pin. You can get away without it because there is an internal pull-up resistor on that pin, but the internal resistor is fairly weak pull-up so in a noisy electrical environment you could get spurious resets randomly, which would be very confusing to debug. It's worth being safe and throwing an extra resistor on the board (as shown in the picture above).

GolamMostafa

#3
Mar 23, 2019, 11:40 am Last Edit: Mar 23, 2019, 11:41 am by GolamMostafa
The instructables neglects to add decoupling capacitors on the power lines. This could lead to problems. [...].
Few queries:
1.  Do you suggest to put an external manual RESET Button (as per Arduino's official schematic) between Pin-1 (RESET Pin) and GND as there is no guarantee that the MCU will always come up to running state after power up reset?

2.  Do you suggest to put a diode (as per Arduino's official schematic) between Pin-1 (RESET Pin) and 5V? This is to suppress the transient that could possibly be generated when the RESET Button is pressed/released.

3.  As per Arduino's official schematic, there is one 0.1 uF capacitor between Pin-7/20 and GND. Your arrangement has shown 0.2 uF capacitors. Will the increase in capacitance do better?

4.  Pin-7 (VCC) and Pin-20 (AVCC) be shorted using a smaller jumper (avoiding the rail arrangement) which may go over the chip.

5.  Pin-8 (GND) and Pin-22 (GND) be shorted using a smaller jumper (avoiding the rail arrangement) which may go over the chip.
     

tdoc23

Upload your sketch into the UNO Board. Leave the ATmega328P chip on the socket of the UNO Board. Remove the USB connector from the UNO Board. Power the UNO Board from a 9VDC adapter via the Power-pin connector. Press the RST Button. Check that the display unit is showing your desired message. Does it show the message?
Yes this works, I have tried using different power supply methods (USB, External, 7805 circuit) it always works on the board but not on the breadboard version.  

I have also added decoupling capacitors across PINS 7 & 8 to no avail.

I also added a blinking LED as a "heartbeat" to ensure the code is actually running.  

GolamMostafa

#5
Mar 23, 2019, 05:43 pm Last Edit: Mar 23, 2019, 06:12 pm by GolamMostafa
Yes this works,
Now follow these steps:

1.  Upload a sketch to blink built-in LED (L) at 2-sec interval. Check that the L is correctly blinking.

2.  Remove USB connector.
3.  Gently remove the ATmega328P chip from the socket of the UNO Board and place it on Breadboard.

4.  Place a 16 MHz crystal between Pin-9 and Pin-10.
5.  Install 2.2k + LED circuit between Pin-19 (DPin-13) of MCU and Pin-8 (GND).
6.  Connect 5V from UNO to Pin-7 of MCU. Connect GND from UNO to Pin-8 of MCU. Connect RESET from UNO to Pin-1 of MCU.

7.  Connect the USB connector with the UNO Board.
8.  Press/release the RST button of UNO.
9.  Check that the LED of the Breadboard is blinking at 2-sec interval.

Note:  I have not told you to place the 0.1 uF decoupling capacitors for simplification purposes. We will do so sometimes later!

BTW:  Please, don't say that the LED is not blinking; mine is blinking just in front if me!  

Now, you have a working ATmega328P on the Breadboard.

10.  Connect RX-pin (DPin-0) of UNO with Pin-2 of MCU. Connect TX-pin (DPin-1) of UNO with Pin-3 of MCU.

11.  Upload new sketch to blink LED with 5-sec interval. Check that sketch has been uploaded and the LED starts blinking at 5-sec interval. (Mine one blinks!)

12.  Connect I2C LCD (0x27, 16, 2) with the MCU of the Breadboard. Upload the following sketch and check that the message Arduino has appeared on the LCD. 

tdoc23

...
Now, you have a working ATmega328P on the Breadboard.

I have already confirmed that I have a working Atmega on a breadboard, I have a flashing LED on my breadboard setup.  If this is working I can assume my 5V and GND connections are correct and the crystal is wired correctly (as it is providing me with the timing for the flash)

My issue now is that the I2C circuit still does not work.  The sketch I am using flashes 2 values on the display on a 1/2 second interval and toggles my test LED.  When using the board everything works as expected.  When I move the chip to my breadboard setup the LED still flashes but I see nothing on the display.

GolamMostafa

#7
Mar 23, 2019, 06:15 pm Last Edit: Mar 23, 2019, 06:18 pm by GolamMostafa
OK! Connect an I2C LCD (0x27/0x3F, 16, 2) with the MCU of the Breadboard. Upload the following sketch and check that the message Arduino has appeared on the Top line of the LCD. You have to move forward by adding one piece at a time with the MCU. This approach is known as SSS Strategy.
Code: [Select]
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup()
{
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0); //DP0 of Top Line
  lcd.print("Arduino");
}

void loop()
{

}

tdoc23

I don't actually have a a LCD display.  The unit I have is this one

https://www.adafruit.com/product/879


Regardless, when I use the example programs provided with the adafruit library it works fine on the board but not on the breadboard.  Leads me to believe the problem is Hardware related

GolamMostafa

#9
Mar 23, 2019, 06:55 pm Last Edit: Mar 23, 2019, 06:56 pm by GolamMostafa
These are very big display devices and when they are ON, they make a lot of electronic noises that might disturb the MCU. Under this situation, you need to use decoupling capacitors for the 5V line of the MCU and also for the crystal. You are also advised to short the unused IO lines (be sure they are in input modes) of the MCU to GND potentials especially the interrupt lines.

srnet

#10
Mar 23, 2019, 07:47 pm Last Edit: Mar 23, 2019, 08:14 pm by srnet
When you ran the I2C  scanner what I2C address did it return for the display ?

$50SAT is now Silent (but probably still running)
http://www.50dollarsat.info/
http://www.loratracker.uk/

tdoc23

When you ran the I2C  scanner what I2C address did it return for the display ?


I2C device found at address 0x70  !
done

Go Up