Moe's Techblog

Arduino reset with external power supply

When you wan't to reset your Arduino, you can use the watchdog timer to do this. Just by enableing the watch dog

wdt_enable(WDTO_1S);
while(1){}

you restart your system. After restart, you have to disable the watchdog timer to avoid a unfinite loop of restarts. So first command in the setup()-function should be something like

wdt_disable();

For me, this works fine as long as my board is powered over USB (5V).

With an external power supply of 12V on the other hand, my device could not do a proper restart process. The watchdog timer was to fast after boot up, so I got to the cycle of reboots. I think the watchdog timer depends on the Vin voltage and gets faster with increasing Vin. In this case it was too fast. Symbolic constants for the watchdog timeout. Since the watchdog timer is based on a free-running RC oscillator, the times are approximate only and apply to a supply voltage of 5 V. At lower supply voltages, the times will increase. For older devices, the times will be as large as three times when operating at Vcc = 3 V, while the newer devices (e. g. ATmega128, ATmega8) only experience a negligible change.


The solution for me was to use a power supply with only 7V , so Vin is just a little over 6V and the behaviour of the arduino board is like with USB power.

Hexgonales Wabenmuster als SVG-Grafik

Um nicht nur ein hexagonales Gitter (trivial) von Punkten, aber auch die dazugehörigen Verbindungslinien zu erzeugen, kann dieser Algorithmus benutzt werden.

 

#include 
#include 
#include 

double vx[100][100];
double vy[100][100];




double posX(int x,int y)
{
  return x-(y%2)*0.5+vx[x][y]*0.7;
}

double posY(int x,int y)
{
  return y*0.866+vy[x][y]*0.7;
}

int setKnod(int x,int y, double a)
{  printf("\n",posX(x,y)*a,posY(x,y)*a);
}


int setCon(int x1,int y1, int x2, int y2,double a)
{
 printf (" \n",x2,y2);
}

main()
{
int x,y;

double a= 20;
double da= a*0.866;

int Ny=10;
int Nx=10;

srand(time(NULL));

for (y=0;y<=Ny;y=y+1)
   {
   for (x=0;x<=Nx;x=x+1)
     {
	 if (((x%3==0) && (y%2==0)) || ((x%3==2) && (y%2==1))  )
       {
	      //printf ("%.3f\t%.3f\n",x-(y%2)*a/2,y*da);
	      
		  vx[x][y]= (float)rand()/RAND_MAX;
		  vy[x][y]= (float)rand()/RAND_MAX;
		  setKnod(x,y,a);

		  vx[x+1][y]= (float)rand()/RAND_MAX;
		  vy[x+1][y]= (float)rand()/RAND_MAX;
	      setKnod(x+1,y,a);
		  printf ("\n");
	   }


	 }
   }

printf("\n");

for (y=0;y<=Ny;y=y+1)
   {
   for (x=0;x<=Nx;x=x+1)
     {
	 if (((x%3==0) && (y%2==0)) || ((x%3==2) && (y%2==1))  )
       {
		  setCon(x,y,x+1,y,a);
		  
	      if (y0)
		    {
   	        setCon(x+1,y,x+1+((y+1)%2),y-1,a);
		    }
		  printf ("\n");
	   }


	 }
   }

printf("\n");
}
Neuere Posts → Home