Time delay without using delay() and millis()

I am designing an industrial control panel using arduino. I have to use time delays as long as 10 seconds and since using delay() makes a halt in the controller I tried using millis(). But it is complicated and it will work only for 50 days. I want the system to work continuously without any maintenance and I need to control as many as 6 relays. So, I need a better solution (hardware or software based) to tackle this problem. How can I do this?

VigneshSkp: I tried using millis(). But it is complicated and it will work only for 50 days.

It is not complex and it will work forever (or at least until your battery goes flat.)

See: http://www.gammon.com.au/millis for the real reason why it works for more than 50 days.

The demo Several Things at a Time illustrates the use of millis() to manage timing. It may help with understanding the technique and how it can be used indefinitely when you use subtraction to figure out if the interval has elapsed.

The only limitation is that you cannot have an interval longer than about 49 days (232 millisecs). But if you wanted an interval that long you would be using a Real Time Clock.

…R

Apart from what you believe about millis() being complicated and only going 50 days, does it matter to you if there's any drift in the time? Is actual time of day important? If so you would be wanting to look at Real Time Clocks.

ardy_guy: Apart from what you believe about millis() being complicated and only going 50 days, does it matter to you if there's any drift in the time? Is actual time of day important? If so you would be wanting to look at Real Time Clocks.

The actual time of day is not important for me. I just want to read the inputs even if the delay is currently active, without using millis(). This is what I want.

without using millis(). This is what I want.

Can you please explain your objection to using millis() ? It really is not complicated and will work beyond 50 days if used correctly.

Save the millis() value at the time that the start action happens. Then, each time through loop(), check whether the required wait period has elapsed by subtracting the start time from the millis() value now. If the period has elapsed then act accordingly and maybe save the start time for the next activity. If not, then go round loop() again, perhaps taking other actions and/or reading inputs, but don't block the free running of loop().

UKHeliBob: Can you please explain your objection to using millis() ? It really is not complicated and will work beyond 50 days if used correctly.

Save the millis() value at the time that the start action happens. Then, each time through loop(), check whether the required wait period has elapsed by subtracting the start time from the millis() value now. If the period has elapsed then act accordingly and maybe save the start time for the next activity. If not, then go round loop() again, perhaps taking other actions and/or reading inputs, but don't block the free running of loop().

I don't object using millis(). I was just curious about knowing if there are any easy alternatives to millis(). If there are no alternatives I will use millis().

VigneshSkp: I don't object using millis().

Well you originally objected on the grounds of complication and the 50 day thing.... so did we manage to arrest those fears?

There are alternatives but I would call non easier then using millis()…

ardy_guy: so did we manage to arrest those fears?

Of course! and thanks.