ATmega328 random reset

Hello,

i made PCB for measuring temperature with some other components (fan, lcd and sd card module). I made two almost the same versions, one with Arduino Nano (for development) and one with ATmega328 stand alone (with arduino bootloader) for long-term use. All the components are basicly the same.

I finished program code and test it on PCB with Arduino Nano.. Everything is working like it should, without any problems. I burned bootloader in new ATmega328 and load exactly the same program on it. On this stand alone version i am getting random resets from time to time, totally without any logical iteration.

Any ideas? I can upload circuit scheme if it will help.

I would minimize the code as much as possible. In fact, run Blink on it for a while if you have an LED onboard. Try to separate hardware and software faults any way you can.

Is the BOD set on the mega? Check supply voltages. Can you post a pic of your PCB? Maybe we can see something obvious.

I uploaded the whole scheme..

What is BOD? I don't know what's that mean. I measured supply voltages and they are fine, stable 5V.

Brown-out detection. Google would tell you that!

My first guess is decoupling. But a photo and/or schematic are very illuminating usually.

I don't see anything obviously wrong from the schematics. An actual photo of the PCB itself might help though.

The schematic was very good well laid out and almost perfect but it can't possibly work as drawn or designed. The CD4050 or 74HC4050 or whatever is a 5V part and I assume that the device was intended as a level shifter for the 3V3 SD card? Most of the ones I've seen are 3V3 interface and your level shifter Vcc is connected to 5 V defeating the level shifting, were it so you could have used one of the remaining 3 buffers for the MISO connection from the card to the controller. In my opinion you need the .1 uF capacitors right at both the display Vcc and on the '4050 as well as the two 'obligatory' caps on the controller's analog and digital Vcc connections and I think that the best method for a multi-chip board as busy as yours (not a nano or pro..) really requires both caps right at the IC for best results.

Bob

Is the standalone version in a case? case properly grounded?

If not, you may get freezing, hangups, or random resets.

-74HC4050 is for SD card level shifting
-74HC595 is for LCD multiplexing
-TC670 is fan failure IC

I am using SD card module with voltage regulator (LC Studio)
http://www.ebay.com/itm/1pcs-ARM-MCU-NEW-SD-Card-Module-Slot-Socket-Reader-For-Arduino-/121048128832?pt=LH_DefaultDomain_0&hash=item1c2f07dd40

For now, the whole PCB is not in the case. How can version with Nano work ok without being put in case, although everything is basicly the same (or isn't?)

Docedison:
In my opinion you need the .1 uF capacitors right at both the display Vcc and on the '4050 as well as the two 'obligatory' caps on the controller's analog and digital Vcc connections and I think that the best method for a multi-chip board as busy as yours (not a nano or pro..) really requires both caps right at the IC for best results.

I put 16MHz crystal and 22pF as close as possible. Crystal is under the ATmega socket and two caps are as near as possible. Could you please draw it in my scheme picture, where and how exactly should i put those another caps? You say 0,1 uF (probably ceramic).

I uploaded 3 pictures of actual PCB.

Top

Bottom

Working

Scheme

Those caps go as close as possible across pins 1 and 16 of the -595, pins 1 and 8 of the 4050.
So it's just like the TC670 you put on that small pcb.
You should always use such cap directly at any logic IC.

I will try that and report.. Thanks!

Three possibilities come to mind:

  1. Lack of decoupling capacitors. See previous posts. The most important one is between Vcc and Gnd of the atmega328p. I suggest you solder one directly across the Vcc and ground pins of the chip, on the underside of the board, with really short leads.

  2. Power supply brownout, e.g. if the peak fan current is too much for either the 7805 or the supply that is providing 12V. Need to know more about the fan and the supply before we can discount this as a possibility.

  3. Software problem.

Somehow you missed this part...

The schematic was very good well laid out and almost perfect but it can't possibly work as drawn or designed. The CD4050 or 74HC4050 or whatever is a 5V part and I assume that the device was intended as a level shifter for the 3V3 SD card? Most of the ones I've seen are 3V3 interface and your level shifter Vcc is connected to 5 V defeating the level shifting, were it so you could have used one of the remaining 3 buffers for the MISO connection from the card to the controller.

Before that board is going to work you will have to fix the level shifter Vcc. If the CD4050 is seeing 5V as it's supply it will output 5V.. Not 3V3 as you need for proper operation.
{Edit}
Bob

Docedison:
Before that board is going to work you will have to fix the level shifter Vcc. If the CD4050 is seeing 5V as it's supply it will output 5V.. Not 3V3 as you need for proper operation.
{Edit}
Bob

Oh my.. Hmm.

I saw that sd card module have voltage regulator for 3,3V. It uses AMS1117 and it should provide up to 1A current. Is it possible to use this voltage regulator for supplying 74HC4050? I think in my case this would be the easiest solution, if it could work that way of course.

I think i solved my problem..

Like i said in my previous post, now i am powering 74HC4050 through 3.3V regulator. I also added 0,1uF ceramic caps between VCC and GND of ATmega328, 74HC4050, 74HC595 and LCD.

Up till now (after half an hour of testing) everything works fine, without problems.. And i hope it will stay that way :slight_smile:

Thank you for all guys! :smiley:

A Good Job, well Done.

Bob