Uploaded October 2012 | Updated September 2026, 2 weeks ago
The 8051 comes equipped with two timers, both of which may be controlled, set, read, and configured individually. The 8051 timers have three general functions: 1) Keeping time and/or calculating the amount of time between events, 2) Counting the events themselves, or 3) Generating baud rates for the serial port.
The three timer uses are distinct so we will talk about each of them separately. The first two uses will be discussed in this chapter while the use of timers for baud rate generation will be discussed in the chapter relating to serial ports.
How does a timer count?
How does a timer count? The answer to this question is very simple: A timer always counts up. It doesnt matter whether the timer is being used as a timer, a counter, or a baud rate generator: A timer is always incremented by the microcontroller.
Programming Tip: Some derivative chips actually allow the program to configure whether the timers count up or down. However, since this option only exists on some derivatives it is beyond the scope of this tutorial which is aimed at the standard 8051. It is only mentioned here in the event that you absolutely need a timer to count backwards, you will know that you may be able to find an 8051-compatible microcontroller that does it.
USING TIMERS TO MEASURE TIME
Obviously, one of the primary uses of timers is to measure time. We will discuss this use of timers first and will subsequently discuss the use of timers to count events. When a timer is used to measure time it is also called an "interval timer" since it is measuring the time of the interval between two events.
How long does a timer take to count?
First, its worth mentioning that when a timer is in interval timer mode (as opposed to event counter mode) and correctly configured, it will increment by 1 every machine cycle. As you will recall from the previous chapter, a single machine cycle consists of 12 crystal pulses. Thus a running timer will be incremented:
11,059,000 / 12 = 921,583
921,583 times per second. Unlike instructions--some of which require 1 machine cycle, others 2, and others 4--the timers are consistent: They will always be incremented once per machine cycle. Thus if a timer has counted from 0 to 50,000 you may calculate:
50,000 / 921,583 = .0542
.0542 seconds have passed. In plain English, about half of a tenth of a second, or one-twentieth of a second.
Obviously its not very useful to know .0542 seconds have passed. If you want to execute an event once per second youd have to wait for the timer to count from 0 to 50,000 18.45 times. How can you wait "half of a time?" You cant. So we come to another important calculation.
Thus, we now have a system with which to measure time. All we need to review is how to control the timers and initialize them to provide us with the information we need.
16-bit Time Mode (mode 1)
Timer mode "1" is a 16-bit timer. This is a very commonly used mode. It functions just like 13-bit mode except that all 16 bits are used.
TLx is incremented from 0 to 255. When TLx is incremented from 255, it resets to 0 and causes THx to be incremented by 1. Since this is a full 16-bit timer, the timer may contain up to 65536 distinct values. If you set a 16-bit timer to 0, it will overflow back to 0 after 65,536 machine cycles.
8-bit Time Mode (mode 2)
Timer mode "2" is an 8-bit auto-reload mode. What is that, you may ask? Simple. When a timer is in mode 2, THx holds the "reload value" and TLx is the timer itself. Thus, TLx starts counting up. When TLx reaches 255 and is subsequently incremented, instead of resetting to 0 (as in the case of modes 0 and 1), it will be reset to the value stored in THx.
For example, lets say TH0 holds the value FDh and TL0 holds the value FEh. If we were to watch the values of TH0 and TL0 for a few machine cycles this is what wed see:
Machine Cycle TH0 Value TL0 Value
1 FDh FEh
2 FDh FFh
3 FDh FDh
4 FDh FEh
5 FDh FFh
6 FDh FDh
7 FDh FEh
As you can see, the value of TH0 never changed. In fact, when you use mode 2 you almost always set THx to a known value and TLx is the SFR that is constantly incremented.
Whats the benefit of auto-reload mode? Perhaps you want the timer to always have a value from 200 to 255. If you use mode 0 or 1, youd have to check in code to see if the timer had overflowed and, if so, reset the timer to 200. This takes precious instructions of execution time to check the value and/or to reload it. When you use mode 2 the microcontroller takes care of this for you. Once youve configured a timer in mode 2 you dont have to worry about checking to see if the timer has overflowed nor do you have to worry about resetting the value--the microcontroller hardware will do it all for you.
The auto-reload mode is very commonly used for establishing a baud rate which we will talk more about in the Serial Communications chapter.
-~-~~-~~~-~~-~-
Please watch: "Sci Hub Not working 2018 August"
youtube.com/watch?v=uV3EntVBxTY
-~-~~-~~~-~~-~-
The 8051 comes equipped with two timers, both of which may be controlled, set, read, and configured individually. The 8051 timers have three general functions: 1) Keeping time and/or calculating the amount of time between events, 2) Counting the events themselves, or 3) Generating baud rates for the serial port.
The three timer uses are distinct so we will talk about each of them separately. The first two uses will be discussed in this chapter while the use of timers for baud rate generation will be discussed in the chapter relating to serial ports.
How does a timer count?
How does a timer count? The answer to this question is very simple: A timer always counts up. It doesnt matter whether the timer is being used as a timer, a counter, or a baud rate generator: A timer is always incremented by the microcontroller.
Programming Tip: Some derivative chips actually allow the program to configure whether the timers count up or down. However, since this option only exists on some derivatives it is beyond the scope of this tutorial which is aimed at the standard 8051. It is only mentioned here in the event that you absolutely need a timer to count backwards, you will know that you may be able to find an 8051-compatible microcontroller that does it.
USING TIMERS TO MEASURE TIME
Obviously, one of the primary uses of timers is to measure time. We will discuss this use of timers first and will subsequently discuss the use of timers to count events. When a timer is used to measure time it is also called an "interval timer" since it is measuring the time of the interval between two events.
How long does a timer take to count?
First, its worth mentioning that when a timer is in interval timer mode (as opposed to event counter mode) and correctly configured, it will increment by 1 every machine cycle. As you will recall from the previous chapter, a single machine cycle consists of 12 crystal pulses. Thus a running timer will be incremented:
11,059,000 / 12 = 921,583
921,583 times per second. Unlike instructions--some of which require 1 machine cycle, others 2, and others 4--the timers are consistent: They will always be incremented once per machine cycle. Thus if a timer has counted from 0 to 50,000 you may calculate:
50,000 / 921,583 = .0542
.0542 seconds have passed. In plain English, about half of a tenth of a second, or one-twentieth of a second.
Obviously its not very useful to know .0542 seconds have passed. If you want to execute an event once per second youd have to wait for the timer to count from 0 to 50,000 18.45 times. How can you wait "half of a time?" You cant. So we come to another important calculation.
Thus, we now have a system with which to measure time. All we need to review is how to control the timers and initialize them to provide us with the information we need.
16-bit Time Mode (mode 1)
Timer mode "1" is a 16-bit timer. This is a very commonly used mode. It functions just like 13-bit mode except that all 16 bits are used.
TLx is incremented from 0 to 255. When TLx is incremented from 255, it resets to 0 and causes THx to be incremented by 1. Since this is a full 16-bit timer, the timer may contain up to 65536 distinct values. If you set a 16-bit timer to 0, it will overflow back to 0 after 65,536 machine cycles.
8-bit Time Mode (mode 2)
Timer mode "2" is an 8-bit auto-reload mode. What is that, you may ask? Simple. When a timer is in mode 2, THx holds the "reload value" and TLx is the timer itself. Thus, TLx starts counting up. When TLx reaches 255 and is subsequently incremented, instead of resetting to 0 (as in the case of modes 0 and 1), it will be reset to the value stored in THx.
For example, lets say TH0 holds the value FDh and TL0 holds the value FEh. If we were to watch the values of TH0 and TL0 for a few machine cycles this is what wed see:
Machine Cycle TH0 Value TL0 Value
1 FDh FEh
2 FDh FFh
3 FDh FDh
4 FDh FEh
5 FDh FFh
6 FDh FDh
7 FDh FEh
As you can see, the value of TH0 never changed. In fact, when you use mode 2 you almost always set THx to a known value and TLx is the SFR that is constantly incremented.
Whats the benefit of auto-reload mode? Perhaps you want the timer to always have a value from 200 to 255. If you use mode 0 or 1, youd have to check in code to see if the timer had overflowed and, if so, reset the timer to 200. This takes precious instructions of execution time to check the value and/or to reload it. When you use mode 2 the microcontroller takes care of this for you. Once youve configured a timer in mode 2 you dont have to worry about checking to see if the timer has overflowed nor do you have to worry about resetting the value--the microcontroller hardware will do it all for you.
The auto-reload mode is very commonly used for establishing a baud rate which we will talk more about in the Serial Communications chapter.
-~-~~-~~~-~~-~-
Please watch: "Sci Hub Not working 2018 August"
youtube.com/watch?v=uV3EntVBxTY
-~-~~-~~~-~~-~-



![Transistor As an oscillator Multivibrator
Tishitu explains
An Astable multivibrator is a multivibrator that does not rest in an unstable state like other multivibrators,
but continuously switches between two states.
Astable multivibrators are free-running multivibrators which have no stable state i.e. they alter between two permissible states indefinitely to result in square wave output. However it is to be noted that, inorder to do this, they do not require any external trigger except the DC supply, due to which they fall under the
category of relaxation oscillators.
Astable Multivibrators can produce TWO very short square wave output waveforms from each transistor or a much longer rectangular shaped output either symmetrical or non-symmetrical depending upon the time constant of the RC network as shown below.
JJD - Adventure [NCS Release]
this music is provided by NCS, the link to the track is
https://www.youtube.com/watch?v=f2xGxd9xPYA
TISHITU
ISO: 9001-2008
RESEARCH AND CONSULTANCY CELL OF INDUSTRIAL APPLICATION
A Joint Accreditation System of Australia and New Zealand
Copyright © All Rights Reserved www.tishitu.org Reg No.08122629691/SSI
Accreditation No. M3111204IN
-~-~~-~~~-~~-~-
Please watch: Lifi Communication by Arduino UNO Download Project
https://www.youtube.com/watch?v=c4gC8dbaiZg
-~-~~-~~~-~~-~- Transistor As an oscillator Multivibrator](https://i.ytimg.com/vi/kX7ySmLi_AQ/mqdefault.jpg)
![TISHITU Part-2 LM 35 temperature control via RS 232 Protocol By Visual Basic 6.0 , Proteus & Keil
In 1963, IBM produced computers which were specialized for data acquisition. These include the IBM 7700 Data Acquisition System and its
successor, the IBM 1800 Data Acquisition and Control System. These expensive specialized systems were surpassed in 1974 by general
purpose S-100 computers and data acquisitions cards produced by Tecmar/Scientific Solutions Inc. In 1981 IBM introduced the IBM
Personal Computer and Scientific Solutions introduced the first PC data acquisition products.
Data acquisition is the process of sampling signals that measure real world physical conditions and converting the resulting samples
into digital numeric values that can be manipulated by a computer. Data acquisition systems (abbreviated with the acronym DAS or DAQ)
typically convert analog waveforms into digital values for processing. The components of data acquisition systems include:
Sensors that convert physical parameters to electrical signals.
Signal conditioning circuitry to convert sensor signals into a form that can be converted to digital values.
Analog-to-digital converters, which convert conditioned sensor signals to digital values.
Data acquisition applications are controlled by software programs developed using various general purpose programming languages such as
BASIC, C, Fortran, Java, Lisp, Pascal.
Specialized software tools used for building large-scale data acquisition systems include EPICS. Graphical programming environments
include ladder logic, Visual C++, Visual Basic, and LabVIEW.
ISIS Schematic Capture - a tool for entering designs.
PROSPICE Mixed mode SPICE simulation - industry standard SPICE3F5 simulator combined with a digital simulator.
ARES PCB Layout - PCB design system with automatic component placer, rip-up and retry auto-router and interactive design rule checking.
VSM - Virtual System Modelling lets cosimulate embedded software for popular micro-controllers alongside hardware design.
Data acquisition begins with the physical phenomenon or physical property to be measured. Examples of this include temperature, light
intensity, gas pressure, fluid flow, and force. Regardless of the type of physical property to be measured, the physical state that is
to be measured must first be transformed into a unified form that can be sampled by a data acquisition system. The task of performing
such transformations falls on devices called sensors.
A sensor, which is a type of transducer, is a device that converts a physical property into a corresponding electrical signal (e.g., a
acquisition system to measure differing properties depends on having sensors that are suited to detect the various properties to be
measured. Signal conditioning may be necessary if the signal from the transducer is not suitable for the DAQ hardware being used. The
signal may need to be filtered or amplified in most cases. Various other examples of signal conditioning might be bridge completion,
providing current or voltage excitation to the sensor, isolation, linearization. For transmission purposes, single ended analog
signals, which are more susceptible to noise can be converted to differential signals. Once digitized, the signal can be encoded to
reduce and correct transmission errors.
DAQ (Data acquisition )hardware is what usually interfaces between the signal and a PC[1]. It could be in the form of modules that can
be connected to the computers ports (parallel, serial, USB, etc.) or cards connected to slots (S-100 bus, AppleBus, ISA, MCA, PCI,
PCI-E, etc.) in the motherboard. Usually the space on the back of a PCI card is too small for all the connections needed, so an
external breakout box is required. The cable between this box and the PC can be expensive due to the many wires, and the required
shielding.
DAQ cards often contain multiple components (multiplexer, ADC, DAC, TTL-IO, high speed timers, RAM). These are accessible via a bus by
a microcontroller, which can run small programs. A controller is more flexible than a hard wired logic, yet cheaper than a CPU so that
it is permissible to block it with simple polling loops. For example: Waiting for a trigger, starting the ADC, looking up the time,
waiting for the ADC to finish, move value to RAM, switch multiplexer, get TTL input, let DAC proceed with voltage ramp.
-~-~~-~~~-~~-~-
Please watch: Lifi Communication by Arduino UNO Download Project
https://www.youtube.com/watch?v=c4gC8dbaiZg
-~-~~-~~~-~~-~- TISHITU Part-2 LM 35 temperature control via RS 232 Protocol By Visual Basic 6.0 , Proteus & Keil](https://i.ytimg.com/vi/kb_k-UueEhE/mqdefault.jpg)



![Tank Circuit & Tuned Circuit
Tank Circuit & Tuned Circuit
An LC circuit, also called a resonant circuit, tank circuit, or tuned circuit, is an electric circuit consisting of an inductor, represented by the letter L, and a capacitor, represented by the letter C, connected together.
In a circuit Capacitor and Inductor coupled in Parallel One end of both are grounded and another is with high current switch where battery is connected , whenever we switch on the circuit high current flow in one direction because of DC. so behavior of capacitance and Inductor is to Oscillate with lack in time of charging so one charge another discharge until total energy is not consumed
JJD - Adventure [NCS Release]
this music is provided by NCS, the link to the track is
https://www.youtube.com/watch?v=f2xGx...
Download Files From Link:-
For formula :-
http://www.mediafire.com/file/yy8yxtkqtha82n1/Formulae_for_inductance.docx
For Circuit:-
http://www.mediafire.com/file/vrigr9l0pa4eger/tuned_or_tank_circuit.zip
TISHITU
ISO: 9001-2008
RESEARCH AND CONSULTANCY CELL OF INDUSTRIAL APPLICATION
A Joint Accreditation System of Australia and New Zealand
Copyright © All Rights Reserved www.tishitu.org Reg No.08122629691/SSI
Accreditation No. M3111204IN
-~-~~-~~~-~~-~-
Please watch: Lifi Communication by Arduino UNO Download Project
https://www.youtube.com/watch?v=c4gC8dbaiZg
-~-~~-~~~-~~-~- Tank Circuit & Tuned Circuit](https://i.ytimg.com/vi/mLN4QEo-Wgk/mqdefault.jpg)

