program resetting automatically??

Hi guys,

So I just unwrapped my brand new Decimilia and I'm having this one problem with it (mind you I tested my other new Decimilia board with the exact same code - no problems with that one)

the program is resetting automatically and starting over after it runs the loop once or twice....

whats going on here?

(I've tried placing a 10k resistor between RX and TX to see if that would help but to no avail)

Weird. What program do you have installed? What happens when it resets? Are you opening a serial connection to it from the computer (that can reset the board)?

ok heres the jist of the code (not the whole but you get the idea)

// nb 090307 b
//----------------------------------------------------------------o


int SERVOa = 12;
int SERVOb = 11;
int SERVOc = 10;
int SERVOd = 9;
int SERVOe = 8;
int SERVOf = 7;
int SERVOg = 6;
int SERVOh = 5;
int SERVOi = 4;

int MIN_PULSE = 500;
int MAX_PULSE = 2000;
int DELTA = 1800;

//int pulse_width = 0;
int lastPulse;
//int refreshTime = 20;

long randNumber;


//----------------------------------------------------------------o


void setup()
{
  int i;
  pinMode(SERVOa, OUTPUT);
  pinMode(SERVOb, OUTPUT);
  pinMode(SERVOc, OUTPUT);
  pinMode(SERVOd, OUTPUT);
  pinMode(SERVOe, OUTPUT);
  pinMode(SERVOf, OUTPUT);
  pinMode(SERVOg, OUTPUT);
  pinMode(SERVOh, OUTPUT);
  pinMode(SERVOi, OUTPUT);
  

  Serial.begin(9600);
  
  for (i=0; i<10; i++)
  {
    digitalWrite(SERVOa, HIGH);
    delayMicroseconds((MIN_PULSE + MAX_PULSE)/2);
    digitalWrite(SERVOa, LOW);
    delay(20);
  }

 Serial.println("servo's at midpoints");

  delay(2000);
}


//----------------------------------------------------------------oooo 1

void servo1()

{
  int i;
  int pulse_width;
//  int lastPulse;

  
  randNumber = random(500, 2000);
//  delay(5000);
  
  pulse_width = randNumber;
  Serial.print(lastPulse, DEC);
  Serial.print("servo1_");
  Serial.println(pulse_width, DEC);
  
  
  for (i=0; i<100; i++)
 {
      digitalWrite(SERVOa, HIGH);
      delayMicroseconds(pulse_width);
      digitalWrite(SERVOa, LOW);
      delay(20);

        lastPulse = pulse_width;
  }
}

//----------------------------------------------------------------oooo first three


void threeservos1()

{
  int i;
  int pulse_width;
//  int lastPulse;
 
  
  randNumber = random(500, 2000);
//  delay(5000);
  
  pulse_width = randNumber;
//  Serial.print(lastPulse, DEC);
  Serial.print("a c f_");
  Serial.println(pulse_width, DEC);
  
  
  for (i=0; i<60; i++)
 {
      digitalWrite(SERVOa, HIGH);
      digitalWrite(SERVOc, HIGH);
      digitalWrite(SERVOf, HIGH);


      delayMicroseconds(pulse_width);


      digitalWrite(SERVOa, LOW);
      digitalWrite(SERVOc, LOW);
      digitalWrite(SERVOf, LOW);


      delay(20);

        lastPulse = pulse_width;
  }
}
 
 //----------------------------------------------------------------oooo all up 
 
void allup()
{
 
  int i;
  
  for (i=0; i<10; i++)
  {
    digitalWrite(SERVOa, HIGH);
    digitalWrite(SERVOb, HIGH);
    digitalWrite(SERVOc, HIGH);
    
    delayMicroseconds(MIN_PULSE);
    
    digitalWrite(SERVOa, LOW);
    digitalWrite(SERVOb, LOW);
    digitalWrite(SERVOc, LOW);
 
    delay(20);
  }
  Serial.println("line one up");
  delay(2000);
  
   for (i=0; i<10; i++)
  {
    digitalWrite(SERVOd, HIGH);
    digitalWrite(SERVOe, HIGH);
    digitalWrite(SERVOf, HIGH);
    
    delayMicroseconds(MAX_PULSE);
    
    digitalWrite(SERVOd, LOW);
    digitalWrite(SERVOe, LOW);
    digitalWrite(SERVOf, LOW);
 
    delay(20);
  }
  Serial.println("line two up");
  delay(2000);
  
  
   for (i=0; i<10; i++)
  {
    digitalWrite(SERVOg, HIGH);
    digitalWrite(SERVOh, HIGH);
    digitalWrite(SERVOi, HIGH);
    
    delayMicroseconds(MIN_PULSE);
    
    digitalWrite(SERVOg, LOW);
    digitalWrite(SERVOh, LOW);
    digitalWrite(SERVOi, LOW);
 
    delay(20);
  }
  Serial.println("line three up");
  delay(2000);


}
  
 
 //----------------------------------------------------------------o
 
 void loop()
 {
   int i, c;
   
   if (Serial.available())
   {
     c = Serial.read();
     if ((c == 'a'))
     {
       allup();
       delay(10000);
     }
   }
     
   threeservos1();
   threeservos2();
   threeservos3();
   threeservos2();
   threeservos3();
   threeservos1();
   threeservos3();
   
   
   
}

ok so what it will do is run through the loop , and stop for a few seconds (about 7 sec. / enough time for the board to reload) and then go back to void setup.....

:-?

ok theres a good possibility the problem has been solved ....

I've been powering the motors with a wall wart connected through the board (alos powering the board itself)...

I went out and picked up a more powerful power supply (more amperage)
this seems to have worked - I've been watching it run for about 15 minutes now and it hasnt yet reset....

given the problem at hand, does this solution seem to be a viable one, or is this a strange occurrence?

That sounds reasonable. If you're drawing too much power from your power supply to your motors, you can limit the amount available for the Arduino, which will cause it to reset. Those "servos" in the code were making me suspicious. :slight_smile:

yes, those motors should most likely have their own power supply

the funny thing is I was running this machine the exact same way with one of the older Arduino's and it ran fine - the new ten thousand must be a bit different somehow.

anyways, thanks for the reply - prob seems to be solved

cheers