I have the following requirement;
While the arduino process a chunk of code, i need to monitor the progress time and display it on LCD.
for example - I control the heater element with arduino via solid state relay. While the heater is turned on, i need to be able to monitor the 'uptime' of the heater via LCD. If it is a few seconds off, it is not the end of the world (I'm interested in range from somewhat half an hour to at least two hours)
for basic time monitoring can use the following code
void bake_process_handle()
{
//##time count##//
second = millis()/1000;
if(second%60==1)
{
if(minute%60==1)
{
hour++;
minute=0;
}
else
{
minute++;
second=0;
}
}
delayMiliseconds(1000); // wait a second so as not to send massive amounts of data
}
Note that variables are already defined in my program before.
But as soon as i include any other code inside that space between first line and delay such as
lcd print, delay, serial print, if's, etc.
, it causes additional delays in between first and last lines, thus it means that this method is now not precise enough.
Does there exist any "underground" timer that dont have any impact from other code in progress? That i would be able to pull out the information of the time? I have in mind kind of two threads, one just for timer purpose and another one for all of other code.
Does anyone have some other ideas how to do it?
thanks to you all