Hi all,
A while ago I created a script to run a timer to control up to 28 relays in an infinite loop. I made the script with menus and to use a keypad to change the delays between each relay, as well as the time the individual relays will stay on. There is also a screen in the system to show what you're doing.
To start with I had the delays in seconds, but since the timings need to be more accurate I changed it to milliseconds.
I have just discovered that for some reason if I input a delay time of larger than 36767 it changes the output to a negative number and it makes the timer inoperative. (I might have that number incorrect by a few digits, forgot my paperwork at work, but it's close to that number. The first negative number I think is -36768)
The code for the Default delay (offTime) and onTime is
int onTime = 10 ; // seconds on
int offTime = 3000 ; // milliseconds off
And the part where it uses these times for the relays is, (The relays control blower motors, which is why I called it Blower)
void ManageBlowers() {
if (millis() - BlowerStartTime > offTime * 1UL)
{
StartBlower(CurrentBlower);
CurrentBlower++;
if (CurrentBlower >= BlowerCount)
CurrentBlower=0;
}
for (int i = 0; i < BlowerCount;i++)
{
if(millis()-Blowers[i].StartedTime > onTime * 1000UL)
{
StopBlower(i);
}
}
}
Can anyone help me with a reason why this is happening? My apologies if I use the incorrect terminology, but I'm very new to the Arduino coding world, and this was my first script.
Hope someone can help