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 ForumBugsSoftware Bugs › Controlling millis() function

Page Index Toggle Pages: 1
Controlling millis() function (Read 12753 times)
09/30/08 at 20:13:51

ponckk   Offline
YaBB Newbies
?

Posts: 4
*
 
hello
does anyone know how to fix the bug that millis() has?, hen it gets to 32000 it colapses, and hense, the program doesnt run well after this.

please help

if(soltar ==false ){
   Serial.print(millis(), DEC);       // prints the value read
  Serial.print("M");
   if(millis() - activar > palpito){
     antes = 0;
     soltar = true;
   }
 }


//contact at ponckk@yahoo.com
 
IP Logged
 
Reply #1 - 10/01/08 at 20:15:46

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
Could you please post Wiring version, OS, and complete code?
 
IP Logged
 
Reply #2 - 02/17/09 at 22:07:26

mga   Offline
YaBB Newbies

Posts: 41
*
 
i have a similar problem

firmware 1.15
wiring 0018

Code:
void setup () {
  Serial.begin(9600);
}

void loop () {
  if (millis()-last_refresh>picture_time) {
    last_refresh = millis();
    Serial.println(last_refresh);
  }
  drawMatrix();
} 



i removed irrelevant code. enough to say it all works well until the millisecond 32000. from that point on millis gives me negative values.
 
IP Logged
 
Reply #3 - 02/17/09 at 22:26:47

mga   Offline
YaBB Newbies

Posts: 41
*
 
okay so i FINALLY figured out the deal

since millis can go up to (in theory) infinity, the number you associate it to must accept large values. i am now using unsigned long (this should give me about 50 days of continous "play")

i would suggest mentioning this in the reference for us newbies... i have been struggling with this thing for two days now.

- mga
 
IP Logged
 
Reply #4 - 02/19/09 at 04:59:57

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
millis returns a long value, http://wiring.org.co/learning/reference/millis_.html
check also this: http://wiring.org.co/learning/examples/timer.html
for a full timer example.
 
IP Logged
 
Page Index Toggle Pages: 1