CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Time over

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest
Guest







Time over
PostPosted: Wed Jun 08, 2005 10:07 am     Reply with quote

How to check if the time is over 24?
I want to register 2 hours over (26).

Code:


#INT_TIMER1       
void clock_isr()
{             
  if(--int_count==0)
  {   
   ++sec;
   int_count = INTS_PER_SECOND;
   
   if(sec==60)
   {
    sec=0;
    min++;
   }
 
   if(min==60)
   {
    min = 0;
    ++hour; 
   
   }
   if (hour==24)
   {
      //hour = 0;
   }
  }   
}
valemike
Guest







PostPosted: Wed Jun 08, 2005 10:17 am     Reply with quote

if (hour==24)
{
hour = 0;
day++;
}

I figure you could introduce a variable called "day". So if you want to see 2 hours past 24 hours, then you'll have day = 1 and hour = 2.
Guest
Guest







PostPosted: Wed Jun 08, 2005 11:07 am     Reply with quote

If i want to count days and if i still want to see over time, what then ?
I have problems with understending what will be after :

if (hour==24)
{
hour = 0;
day++;
}

if (day==60)
{
day = 0;
}

When i reach 24 hours, i set the hour=0; so that the timer can correctly count the days. Where can i now define 2 hours over time ?

This is now extended version of my last post.. Now im counting hours and days...
valemike
Guest







PostPosted: Wed Jun 08, 2005 11:29 am     Reply with quote

I think you want to see how much time has elapsed since a certain time-stamped event.

After an event, just save the seconds, minutes, hours, and days snapshot, and then you can do arithmetic to see how much time has elapsed.
Guest
Guest







PostPosted: Thu Jun 09, 2005 2:23 am     Reply with quote

So, if i get you right...

Code:

if (hour==24)
{
hour = 0;
day++;
time_stamp_hours=TRUE;
}

if (day==60)
{
day = 0;
}


...

if (time_stamp_hours && hour==2)
{
  do something
else
  do something else
}



this should work ?
Guest
Guest







PostPosted: Thu Jun 16, 2005 8:56 am     Reply with quote

Becuse the poster has already ask the "almost" same thing... this is my question...

How to count under hours ( 5 hours over ).

With other words when i reach 0 hours, how can i count hours that are "under" 0. Im making countdown and i must use hours as const and i can not change the value ( it must be 24 ).

Wenn i reach 0 i can not find the way how to corectly count negative hours...
valemike
Guest







PostPosted: Thu Jun 16, 2005 11:28 am     Reply with quote

Well then you'll need an identical set of variables, and use the prefix
"negative_" so you can meaningfully name those variables.

When your regular counter hits 00:00:00, then start counting up on your second set of of counters.
Guest
Guest







PostPosted: Fri Jun 17, 2005 1:37 am     Reply with quote

Quote:
When your regular counter hits 00:00:00, then start counting up on your second set of of counters.


That's the part that i dont understand...
Code:

if (hour==0)
{
hour = 24;
}


now what ?. The hour is 0 and now i must start the second counter. Ok, but how will the second counter knows how many times he must count to take one hour over..

Simpler language :-):
Code:

if(min==60)
  {
  min = 0;
  hour--;
  }

This will give me correct countdown till 0 but i can not define another counter inside the min part to count negative time ...
I hope you get what i want to say :-))
Guest
Guest







PostPosted: Fri Jun 17, 2005 1:40 am     Reply with quote

.... and then again, how will i get correct time?. Something like -2:15:20 ?
If i set time stamp in each part ( sec, min, hour ) i still dont get it...Must i define 3 different additional counters..
Guest_
Guest







PostPosted: Sat Jun 18, 2005 2:38 am     Reply with quote

On the behalf of those who dont know ( including me :-)) can some of you gurus give some code example / solution for solving problem in last post ?
Guest_
Guest







PostPosted: Sat Jun 18, 2005 2:39 am     Reply with quote

On the behalf of those who dont know ( including me :-)) can some of you gurus give some code example / solution for solving problem in last post ?
Guest_
Guest







PostPosted: Sun Jun 19, 2005 4:08 am     Reply with quote

What's up gurus, no one has answer to this ..... anyone?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group