Skip to main content
Precise Timing in a Microcontroller and in the Universe
Apr 1, 1994

The 80C196KC is a 16-bit micro controller of the MCS-96 family produced by INTEL. It operates at 16 MHz with high performance. It has the capability of registering architecture, so no accumulator is needed, and most operations can be quickly performed from or to any of the 256 registers. It has many peripherals like a serial port, A/D converter, three PWM outputs, input output lines and a high speed I/O subsystem which can be controlled by any one of two 16-bit timers/counters. It can be used mid-range of control and in signal-processing applications like modems, motor controls, printers, engine controls, photocopiers, anti-lock brakes, AC motor control, disk drives, and medical instrumentation (INTEL 80C196KC user’s guide).

Synchronization is a problem in many areas of science, notably in electrical and electronics engineering. In synchronization, there must be at least two events, one of which serves as the reference for the other. Synchronized events always follow each other in a regular manner. In electrical engineering at the instant of synchronization of two busbar voltages, both voltages must be equal in magnitude and period and they must be in phase so that they can be switched in parallel if desired.

In my research I was synchronizing output voltage with line voltage; more recently I was trying to add certain further features into my program like time delay. At this stage while trying to generate synchronized outputs with a delay I failed to allow a few microseconds to the related registers (necessary because of some time delay caused by a few instructions) and also (as I later realized) I was putting some instructions in the wrong sequence. Maybe the beauty of the micro controller design is that it does not allow you to generate (actually you command the microcontroller to generate at the related outputs what you want it to generate) just anything you may happen to have in mind. The input has to be correctly ordered. If you give the right instructions in the right order, it generates (of course, within its limitations) the correct result, otherwise it generates the wrong result or just rubbish.

I spent a whole week looking for the reason for the problem which I have very roughly described. The program ought to have worked correctly because every instruction looked to be all right. But I didn’t see far enough into just how important a few microseconds and the sequences of instructions are. So, I got very frustrated and annoyed at not being able to find the reason for the failure of what ought to have been a simple program.

At night, while thinking about the problem, I realized some of the reasons for the problem, with the help of God. It was only a matter of a few microseconds in every cycle. I did not think that the program could be affected that much by that little. The outputs appeared quite stable for a time but then, after a while, the program would suddenly crash.

Ordinarily we might think: What can a few microseconds matter or the sequence of instructions? When we ask such questions, actually we are starting to think about the complexity of the universe.

The cause of the problem I was having was a few microseconds in every cycle (one cycle is 20,000 microsecond). A few microseconds in one cycle may seem nothing, but in fact the few microseconds are out in a continuous system, every cycle is affected. As a result, the program was causing the wrong outputs to be generated.

If, at this juncture, we think about the magnificence and/or complexity of the universe or for that matter of human beings, we begin to appreciate the greatness of God. In reality, it seems to me, it is impossible to imagine fully or to realize exactly the greatness of God since we cannot even grasp fully how complex the organization of the universe is. Take my problem as an example: it was a simple system with single input and single output, and yet neglecting to compensate a few microsecond of delays caused my output to crash. In the universe, every action and event in every bodily process in every plant and animal, must take place with the most minute exactness in real time, and not in the microsecond range but maybe in many times more or less than that range. Any oversight, be it ever so small, any error of sequence, any delay however small in any event in the universe, will affect all the other events in a chain of effects causing the system to crash suddenly, locally or, maybe, entirely. In short, the existence of the universe depends upon the correct instructions being minutely programmed in the correct sequence.

When we look at either the universe or at an individual creature in it, a human.being or plant or animal, we see that each operates as a large, separate system. We cannot even imagine how many inputs and outputs these systems have, we cannot imagine the complexity of the innumerable problems that are solved in such a way that life has been going on for millions of years. Whenever we look with open mind at any living organism within the universe or at the universe as a single, whole system, our sight returns to us, dazzled and overwhelmed-exactly as is described in the beautiful words of sura al-Mulk:

Then look again and yet again, your sight will return to you weakened and made dim. (67.4)

We see in the sky billions of stars turning in synchronization with each other according to some extraordinary law of harmony. And this harmony has been operative for millions of years, so effectively that its continuance is not in doubt. The same extraordinary miracle of harmony can be studied at the microscopic level: Within a single atom huge numbers of particles whizz past each other around the nucleous at unimaginable speeds in a continually renewed and vital process of creation.

Our understanding cannot fathom, nor our researches exhaust, the wonder in which we live and which we behold. And when we realize the complexity of the innumerable systems which compose the universe and whose inter-related functions have been managed not for seconds or hours, but for hundreds of millions of years, can we do otherwise than humbly acknowledge the wisdom and power of God? Equally, when we accept, as logically we must, that in the universe as a whole, everything is organized in the right way for its continued operation, are we not bound to conclude that every event, seemingly good or bad, has occurred at its own time and place, precisely, as pre-ordained (or ‘programmed’ we might say) by God? Thus, we are led to acknowledge the Creator, to marvel in humility at His grandeur, and His greatness.