0
votes

I have below setup. I found that My arduino Getting restarted again. I have Arduino board , lCD Display, SENSOR. The Sensor and LCD Display SHARE common ground and 5v supply from 7805 IC and Arduino board get powered on using 7812 regulator IC . finally they are under common ground potential.Now i have Peice of code. Individually i tried each function are working fine without any error and Arduino Board will not get reseted.When i put together all my code block. getting restarted. Once it restart work fine for couple of minute and again reseted.

  1. How to resolve this issue?

    #include <LiquidCrystal.h>
    #include <avr/wdt.h>
    LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
    void setup()
    {
     Serial.begin(9600);
     wdt_enable(WDTO_8S);
     MODE=INIT;
     pinMode(beeper, OUTPUT);
     lcdClear();
    }
    
    void loop()
    {
    Track_loop();
    LCD_Display();
    CHK_Key();
    wdt_reset();
    Serial.println("..........................");
    }
    void Track_loop()
    {
      calcPos(); 
      calcTime();
      calcElevationAngle();
      callMode();
      actuate();
      // checkHWFaults();
      Wind_calc();
      Print_Result(); 
    
    }
    
    void Print_Result()
    {
      Print_Date();
      Print_Time();
    }
    

I have added these function in my Serial.println statement

void Print_Date(){
  Serial.print("Local Date:");
  Serial.print(local_day);
  Serial.print("/");
  Serial.print(local_month);
  Serial.print("/");
  Serial.println(local_year);
}
void Print_Time()
{ Serial.print("local_time is:");
  Serial.print(local_h);
  Serial.print("-");
  Serial.print(local_m);
  Serial.print("-");
  Serial.println(local_s);


}
1
Have you tried to figure out which piece it stalls at? - Ignacio Vazquez-Abrams
Is there any IDE availble for Arduino . Where i can use of break point. - RKNAYAK
@RKNAYAK if you do the Serial.println() at places you can then use a terminal program like Putty/Terraterm to connect over the Serial port and output those display commands - Wayne
@wayne i could not able to understand what ur telling . can you elobrate the answer with example - RKNAYAK
@RKNAYAK - Updated my answer - Wayne

1 Answers

0
votes

I suspect your use of the Watchdog is causing issues.

If we say that http://www.embedds.com/using-watchdog-timer-in-your-projects/ is an "authoritive" source of information, then maybe your call to wdt_reset() is not being called in time and therefore your system is being reset?

If you enabled watchdog timer, you have to take care and reset it before it fills up and resets MCU. Otherwise if your program hangs or sticks in some infinite loop without reset watchdog simply counts up and resets system

From http://www.nongnu.org/avr-libc/user-manual/group_avr_watchdog.html

#define wdt_reset() __asm__ __volatile__ ("wdr")

Reset the watchdog timer. When the watchdog timer is enabled, a call to this instruction is required before the timer expires, otherwise a watchdog-initiated device reset will occur.

If you disable the watchdog from your project, do you still get the same outcome?

Update 1

To debug your code you use the Serial.println("xxxx") function to output the required text to the serial port that you have setup.

See

NOTE: Should we update these instructions so that they contain the full instructions? Marking as Community Wiki so everyone can update as required.