T-n-T: Dealing with register overflows

The problem

It is required to count time intervals longer than 65535ms, i.e. greater than the maximum dimension of variables and constants accepted in CANNY controllers.

The solution

The solution (diagram 1).

The seconds counter counts the elapsed seconds (blocks No. 1 and 2) and when 60 seconds (block No. 3) has elapsed, it transmits a pulse to the minute counter.

The solution (diagram 2).

The seconds counter counts the elapsed seconds (blocks No. 1 and 2) and when 3600 seconds have elapsed (block No. 3), i.e. 1 hour, transmits an impulse to the hour counter.

Using the above approach, changing the period value of the “PWM Generator” block (block # 1) and the Y value of the “Greater” block, you can measure the required time intervals in a wide range of values (see example below).

The solution (diagram 3).

The solution can be used in other areas to count the number of different events.

By increasing the cascade of counters, you can get the ability to count almost unlimited values.