Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumWiring HardwareTroubleshooting › having a stabillity issue

Page Index Toggle Pages: 1
having a stabillity issue (Read 4933 times)
12/18/06 at 05:58:01

greyskale   Offline
YaBB Newbies
int my_mind = 0;
Chicago IL USA

Posts: 17
*
 
hello, i have been having some timing issues, so i wrote a simple flasher program to test it and it seems to crash the wiring board consistantly... can someone look at my code and tell me what i'm missing?

int ledPin = 48;
int value = LOW;
long previousMillis = 0;
long interval = 500;
int inc = 2;
int Max = 500;
int Min = 10;

void setup()
{
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  timer();
  limit();
}

void timer()
{
  if(millis() - previousMillis > interval){
    previousMillis = millis();
    if(value == LOW){
     value = HIGH;
    }
    else{
     value = LOW;
     interval = interval - inc;
    }
    digitalWrite(ledPin, value);
  }
}

void limit()
{
  if((interval <= Min) || (interval >= Max)){
    inc = -inc;
  }
}
 
IP Logged
 
Reply #1 - 12/19/06 at 08:09:12

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
I've tested your code and no crash happens at all, the amber led blinks forever, with a variable frequency which I guess is depending of the variable 'interval' in your code, that's all. What do you have connected to the board?

I've just added two lines so check the value of interval, things seem fine. What do you mean by crashing?

int ledPin = 48;
int value = LOW;
long previousMillis = 0;
long interval = 500;
int inc = 2;
int Max = 500;
int Min = 10;

void setup()
{
 Serial.begin(9600);
 pinMode(ledPin, OUTPUT);
}

void loop()
{
 timer();
 limit();
}

void timer()
{
 if(millis() - previousMillis > interval){
   previousMillis = millis();
   if(value == LOW){
    value = HIGH;
   }
   else{
    value = LOW;
    interval = interval - inc;
   }
   digitalWrite(ledPin, value);
   Serial.println(interval, DEC);
 }
}

void limit()
{
 if((interval <= Min) || (interval >= Max)){
   inc = -inc;  
 }
}
 
IP Logged
 
Reply #2 - 12/20/06 at 01:35:41

greyskale   Offline
YaBB Newbies
int my_mind = 0;
Chicago IL USA

Posts: 17
*
 
I really don't know what else to call it other than a crash... The board will freeze randomly (the led will stay on). I've tried to make sense of it, but sometimes it happens after 5-6 min... sometimes it'll go for an hour or more. Any thoughts?
 
IP Logged
 
Reply #3 - 12/20/06 at 04:23:20

Alan_Kilian   Offline
Full Member
Wiring? It looks like
Java to me.

Posts: 118
***
 
Are you powering it from USB or from a +5 Volt source or from a greater than +5 Volt source?

There's a proper amount of decoupling capacitors on the board, but I'm suspecting a power problem.

I'll get it on one of my board and see how long it lasts.
 
IP Logged
 
Reply #4 - 12/20/06 at 05:32:48

greyskale   Offline
YaBB Newbies
int my_mind = 0;
Chicago IL USA

Posts: 17
*
 
I've suspected this as well  Wink. I tested both the USB supply and a 9V wall wart (not sure of the current... I'm at work and don't have it on hand) and it seems to be indifferent to the power source.

btw Alan, send me a PM, I still have those displays for you... I moved three times this year and keep misplacing the package Embarrassed.
 
IP Logged
 
Reply #5 - 12/20/06 at 21:33:45

greyskale   Offline
YaBB Newbies
int my_mind = 0;
Chicago IL USA

Posts: 17
*
 
I think I may have narrowed it down to the power supply. After moving to another outlet, the board has been running for over 8 hours with no freezes. I live in an old building and there tends to be allot of stuff on all the circuits in the house... add dimmers fans and electric heaters and the outlets are probobly noisy as hell.

I'll let it run and see if anything turns up.

btw Alan, don't forget to shoot me a PM.
 
IP Logged
 
Page Index Toggle Pages: 1