2

Assume that we have two light bulbs in the room. Each bulb turns ON at fixed periodic intervals and stays ON for fix time period before turning OFF. The ON time is part of the periodic interval; ON time + OFF time = 1 cycle. Let's call them Bulb A and Bulb B with periodic times as 'Ca' and 'Cb'. The time the bulb stays ON is 'Ta' and 'Tb' respectively. Is there a mathematical expression to determine the next time instance when both the bulbs are in the "ON" state at the same time? Not necessarily turning on at the same time.

We can assume both periodic cycles start at the same time and the periodic times (Ca, Cb) are not multiples of each other.

To be more explanatory, I provided some numbers below

Bulb A peroidic time : Ca = 470ms.

Bulb B periodic time : Cb = 1280ms.

Bulb A stays on for Ta = 10ms.

Bulb B stays on for Tb = 20ms.

Assuming that both cycles start at exactly the same instance (time t = 0),

Bulb A ON time : (-5 to 5), (465 - 475), (935 - 945), ....

Bulb B ON time : (-10 to 10), (1270 - 1290), (2550 - 2570), ...

I am interested in knowing when will be the earliest time instance when both bulbs will be in "ON" state at the same time.

A simplified version of the problem is to assume Ta = Tb = impulse/Dirac delta function, meaning we treat it as overlap only at the exact instance. In that case, the solution is just the Least Common Multiplier of the cycle time of A and B (For numbers provided earlier solution is 60160ms ~ 60 secs)

I am interested in knowing if there is a mathematical way to solve if Ta and Tb are not zero and not equal.

niil87
  • 29
  • 1
    You should ask such a question on this site https://networkengineering.stackexchange.com/ because, even if you describe it as a "math question", the environment of your question necessitates a contextual technical knowledge that most people here don't have. – Jean Marie Sep 09 '22 at 18:18
  • There is no contextual technical knowledge required, it can be treated as a pure math problem. As a matter of fact, the audience from the math community will be better suited to solve this problem. The problem can be described in purely mathematical form but I am not an expert in writing in pure math format. Think of it as any problem in a math text book that you get in school – niil87 Sep 09 '22 at 19:08
  • 1
    Sorry but expressions like "two protocol stacks each with their own paging cycle"," SW/FW code in a modem" aren't understandable for people like me... – Jean Marie Sep 09 '22 at 19:14
  • 1
    I edited the question to express the problem in a simpler format. Please do let me know if something needs further simplification or explanation – niil87 Sep 09 '22 at 19:50

1 Answers1

2

Defining variables:

Let the $2$ bulbs be $B_1$ and $B_2$.
Let the $1^{st}$ bulb be ON for $x$ units of time and OFF for $y$ units of time.
Let the $2^{nd}$ bulb be ON for $i$ units of time and OFF for $j$ units of time.
So, Periodic cycle for $B_1=x+y$ and that for $B_2=i+j$.

Let $a\in[0,x+y)$ and $b\in[0,i+j)$.
Here, $a$ and $b$ respectively are the times taken by $B_1$ and $B_2$ to complete the incomplete cycle. (Which would be $a=5+460=465$ and $b=10+1260=1270$ in your case).
Note: A cycle is completed after the bulb is OFF again (and completes the OFF period too which is $y$ and $j$ respectively). The next cycle starts the moment bulb switches ON again.

Finding the time, $T$:

Now we want to find the earliest time, $T$ when both bulbs will be ON at the same time. That is:
$T=a+(x+y)m=b+(i+j)n\qquad$ where $m,n\in\Bbb Z$
Note: Essentially $m$ and $n$ are $2$ instances (consider them $T_1 \ \& \ T_2$ respectively for your ease) after which both the bulbs will be ON again.

Let $(x+y)\leq(i+j)$, then,
$$m=\frac{b-a+(i+j)n}{x+y}$$ For the above expression we want integer solution(s) for $m,n$.

Your First Case:

In your case, putting in all the values, we have:
$$\begin{align} m &= \frac{1270-465+1280n}{470} \\ &= 1+2n+\frac{67+68n}{94}\end{align}$$ But for any $n\in\Bbb Z$ we don't have $(67+68n)\mod94 = 0$.
Thus, the $2$ won't ever be ON again at the same time.
Note: To clear any confusions, the above statement may be better put as: The $2$ bulbs will never Switch ON together at the same time.


Your Second Case:

In the case where $a=b=0$, we have: $$\begin{align} m &= \frac{0+1280n}{470} \\ &= 2n+\frac{34n}{47}\end{align}$$ For $n=0$ obviously we'll get $m\in\Bbb Z$, so $T=0+1280(0)=0$.
Note: In general, $n=47k$ and we want $n$ to be the smallest integer to get smallest $T$ so that'd be at $k=0$.
Surprised that why we didn't get $60160$? Follow up to know.

In the case where $a=470 \text{ and } b=1280$, we have: $$\begin{align} m &= \frac{1280-470+1280n}{470} \\ &= 1+2n+\frac{34(n+1)}{47}\end{align}$$ For $n=46$ obviously we'll get $m\in\Bbb Z$, so $T=1280+1280(46)=60160$.
Note: In general, $n=46+47k$ and for smallest $n$, $k=0$ (always $k$ need to be put $0$ since we are interested in smallest time).
Note 2: Kindly see why now we get $60160$ unlike in case $a=b=0$. So be careful while taking the values of $a$ and $b$.


Final note: I took different variables than what you suggested so as to arrive at a more general and "neat" answer/solution.

And also, it may not always be easy to find/check whether we'll get integer solution(s) for $(m,n)$ for which you may instead check here and that's how I confirmed my result too.

  • I think you are missing a fact that overlap is not a single point in time but anywhere in the window when the bulb is on. Meaning we need to replace (i + j) by a window of possible values that goes from (i - j/2) to (i + j/2), same with (x + y). Of course, this is only for the cycle where we need to check the overlap as all previous cycles should be full cycles.

    Logically speaking, there should always be an overlap less than 60160 for any case, (except two cycles are exact multiples)

    Using simulation code : Overlap time B1=23030 and B2= 23040 for start time 470 and 1280 respectively.

    – niil87 Sep 19 '22 at 23:14
  • @niil87 when I write: "the above statement may be better put as: The 2 bulbs will never Switch ON together at the same time" - that is to clear the exactly same point as you have raised. Also, you are contradicting your own example where you find 60160ms as your answer since you are finding exactly what I did. For a simple (positive) overlap, the time would have come out much less than 60160ms. – InanimateBeing Sep 20 '22 at 04:01
  • Sorry, my bad, I see the cause of confusion. I am not contradicting my statement, the value of 60160 is when the ON duration is an impulse or Dirac type which is not realistic but gives an upper bound on the nearest overlap time. I added "state" to the question to avoid the confusion between "turning on" and "ON state". Hope the edit clarifies the question. – niil87 Sep 20 '22 at 14:55
  • @niil87 though that's a small change but it makes a considerable difference (making the answer post near irrelevant) so it would be better instead to post it as a different variant of this question. It would gain fresh light too and get more views than making edits here itself. Also, simply rephrase it as "when the 2 bulbs will be on together even if it's for half-a-second?". Such things are common and wouldn't be received badly (main problem earlier was just the technical jargons your post had which you handled quite well). – InanimateBeing Sep 20 '22 at 16:19
  • @niil87 I asked a follow-up question related to this post as I wasn't able to understand a simple thing. There are innumerous such (and much better) examples but hope you get the point. – InanimateBeing Sep 20 '22 at 16:31