Professional Documents
Culture Documents
Existing system:
In existing system we use eye blink sensor in this we have to wear a glass and it has IR
sensor is fixed in that glass to sense drowsiness. By using this eye will get affected while passing
IR sensor.
Proposed System:
The purpose of this project is to investigate the development of a system for detecting the
likelihood that a driver is about to fall asleep in control of the vehicle, and to sound an alarm or
carry out some other function if this occurs. In this system the drivers fatigue is going to detect
with the help of MATLAB based eye monitoring and steering wheel grip sensors.
In MATLAB process we use webcam to monitor the iris of the driver after image
acquisition; face detection is the first stage of processing. Then symptoms of hypo-vigilance are
extracted from the eyes. If eyes are blinking normally no warning is issued but when the eyes are
closed for more than half second this system issues warning to the driver in form of alarm.
In steering sensor part, the sensors are placed in the steering wheel. The output of the
sensor is given to the ADC0808.The ADC output is given to the microcontroller; here we are
going to check the grip values. If the pressure of the driver is reduced in the steering than the
normal value for a while microcontroller gives the indication by means of alarm and stop the
vehicle after quite bit time.
BLOCK DIAGRAM:
Power Supply
Driver
Circuit
Vehicle motor
Recognition
Authentication
AT89C51
Microcontroller
MAX 232
LCD Display
Processing
Alarm
ADC 0808
Hardware Requirements:
ADC 0808.
Relay unit
Web camera
PC
Alarm.
Software Requirements:
Embedded C.
Keil Compiler.
MATLAB
List of Modules:
Module 5: LCD
Module 1:
Power Supply for 8051 Microcontroller
This section describes how to generate +5V DC power supply
The power supply section is the important one. It should deliver constant
output regulated power supply for successful working of the project. A 0-12V/1 mA
transformer is used for this purpose. The primary of this transformer is connected in
to main supply through on/off switch& fuse for protecting from overload and short
circuit protection. The secondary is connected to the diodes to convert 12V AC to
12V DC voltage. And filtered by the capacitors, which is further regulated to +5v, by
using IC 7805
8051 Microcontroller:
Microcontroller manufacturers have been competing for a long time for attracting choosy
customers and every couple of days a new chip with a higher operating frequency, more memory
and upgraded A/D converters appeared on the market.
However, most of them had the same or at least very similar architecture known in the world of
microcontrollers as 8051 compatible. What is all this about?
The whole story has its beginnings in the far 80s when Intel launched the first series of
microcontrollers called the MCS 051. Even though these microcontrollers had quite modest
features in comparison to the new ones, they conquered the world very soon and became a
standard for what nowadays is called the microcontroller.
The main reason for their great success and popularity is a skillfully chosen configuration which
satisfies different needs of a large number of users allowing at the same time constant expansions
(refers to the new types of microcontrollers). Besides, the software has been developed in great
extend in the meantime, and it simply was not profitable to change anything in the
microcontrollers basic core. This is the reason for having a great number of various
microcontrollers which basically are solely upgraded versions of the 8051 family.
As seen in figure above, the 8051 microcontroller has nothing impressive in appearance:
The whole configuration is obviously thought of as to satisfy the needs of most programmers
working on development of automation devices. One of its advantages is that nothing is missing
and nothing is too much. In other words, it is created exactly in accordance to the average users
taste and needs. Another advantages are RAM organization, the operation of Central Processor
Unit (CPU) and ports which completely use all recourses and enable further upgrade.
Pinout Description
Pins 1-8: Port 1 Each of these pins can be configured as an input or an output.
Pin 9: RS A logic one on this pin disables the microcontroller and clears the contents of most
registers. In other words, the positive voltage on this pin resets the microcontroller. By applying
logic zero to this pin, the program starts execution from the beginning.
Pins10-17: Port 3 Similar to port 1, each of these pins can serve as general input or output.
Besides, all of them have alternative functions:
Pin 10: RXD Serial asynchronous communication input or Serial synchronous communication
output.
Pin 11: TXD Serial asynchronous communication output or Serial synchronous communication
clock output.
Pin 12: INT0 Interrupt 0 input.
Pin 13: INT1 Interrupt 1 input.
Pin 14: T0 Counter 0 clock input.
Pin 15: T1 Counter 1 clock input.
Pin 16: WR Write to external (additional) RAM.
Pin 17: RD Read from external RAM.
Pin 18, 19: X2, X1 Internal oscillator input and output. A quartz crystal which specifies
operating frequency is usually connected to these pins. Instead of it, miniature ceramics
resonators can also be used for frequency stability. Later versions of microcontrollers operate at a
frequency of 0 Hz up to over 50 Hz.
Pin 20: GND Ground.
Pin 21-28: Port 2 If there is no intention to use external memory then these port pins are
configured as general inputs/outputs. In case external memory is used, the higher address byte,
i.e. addresses A8-A15 will appear on this port. Even though memory with capacity of 64Kb is
not used, which means that not all eight port bits are used for its addressing, the rest of them are
not available as inputs/outputs.
Pin 29: PSEN If external ROM is used for storing program then a logic zero (0) appears on it
every time the microcontroller reads a byte from memory.
Pin 30: ALE Prior to reading from external memory, the microcontroller puts the lower address
byte (A0-A7) on P0 and activates the ALE output. After receiving signal from the ALE pin, the
external register (usually 74HCT373 or 74HCT375 add-on chip) memorizes the state of P0 and
uses it as a memory chip address. Immediately after that, the ALU pin is returned its previous
logic state and P0 is now used as a Data Bus. As seen, port data multiplexing is performed by
means of only one additional (and cheap) integrated circuit. In other words, this port is used for
both data and address transmission.
Pin 31: EA By applying logic zero to this pin, P2 and P3 are used for data and address
transmission with no regard to whether there is internal memory or not. It means that even there
is a program written to the microcontroller, it will not be executed. Instead, the program written
to external ROM will be executed. By applying logic one to the EA pin, the microcontroller will
use both memories, first internal then external (if exists).
Pin 32-39: Port 0 Similar to P2, if external memory is not used, these pins can be used as
general inputs/outputs. Otherwise, P0 is configured as address output (A0-A7) when the ALE pin
is driven high (1) or as data output (Data Bus) when the ALE pin is driven low (0).
Pin 40: VCC +5V power supply.
Pin configuration, i.e. whether it is to be configured as an input (1) or an output (0), depends on
its logic state. In order to configure a microcontroller pin as an input, it is necessary to apply a
logic zero (0) to appropriate I/O port bit. In this case, voltage level on appropriate pin will be 0.
Similarly, in order to configure a microcontroller pin as an input, it is necessary to apply a logic
one (1) to appropriate port. In this case, voltage level on appropriate pin will be 5V (as is the case
with any TTL input). This may seem confusing but don't loose your patience. It all becomes clear
after studying simple electronic circuits connected to an I/O pin.
Figure above illustrates a simplified schematic of all circuits within the microcontroler connected
to one of its pins. It refers to all the pins except those of the P0 port which do not have pull-up
resistors built-in.
Output pin
A logic zero (0) is applied to a bit of the P register. The output FE transistor is turned on, thus
connecting the appropriate pin to ground.
Input
pin
A logic one (1) is applied to a bit of the P register. The output FE transistor is turned off and the
appropriate pin remains connected to the power supply voltage over a pull-up resistor of high
resistance.
Logic state (voltage) of any pin can be changed or read at any moment. A logic zero (0) and logic
one (1) are not equal. A logic one (0) represents a short circuit to ground. Such a pin acts as an
output.
A logic one (1) is loosely connected to the power supply voltage over a resistor of high
resistance. Since this voltage can be easily reduced by an external signal, such a pin acts as an
input.
Port 0
The P0 port is characterized by two functions. If external memory is used then the lower address
byte (addresses A0-A7) is applied on it. Otherwise, all bits of this port are configured as
inputs/outputs.
The other function is expressed when it is configured as an output. Unlike other ports consisting
of pins with built-in pull-up resistor connected by its end to 5 V power supply, pins of this port
have this resistor left out. This apparently small difference has its consequences:
If any pin of this port is configured as an input then it acts as if it floats. Such an input has
unlimited input resistance and indetermined potential.
When the pin is configured as an output, it acts as an open drain. By applying logic 0 to a port
bit, the appropriate pin will be connected to ground (0V). By applying logic 1, the external
output will keep on floating. In order to apply logic 1 (5V) on this output pin, it is necessary to
built in an external pull-up resistor.
Only in case P0 is used for addressing external memory, the microcontroller will
provide internal power supply source in order to supply its pins with logic one. There
is no need to add external pull-up resistors.
Port 1
P1 is a true I/O port, because it doesn't have any alternative functions as is the case with P0, but
can be cofigured as general I/O only. It has a pull-up resistor built-in and is completely
compatible with TTL circuits.
Port 2
P2 acts similarly to P0 when external memory is used. Pins of this port occupy addresses
intended for external memory chip. This time it is about the higher address byte with addresses
A8-A15. When no memory is added, this port can be used as a general input/output port showing
features similar to P1.
Port 3
All port pins can be used as general I/O, but they also have an alternative function. In order to
use these alternative functions, a logic one (1) must be applied to appropriate bit of the P3
register. In terms of hardware, this port is similar to P0, with the difference that its pins have a
pull-up resistor built-in.
Pin's Current limitations
When configured as outputs (logic zero (0)), single port pins can receive a current of 10mA. If
all 8 bits of a port are active, a total current must be limited to 15mA (port P0: 26mA). If all ports
(32 bits) are active, total maximum current must be limited to 71mA. When these pins are
configured as inputs (logic 1), built-in pull-up resistors provide very weak current, but strong
enough to activate up to 4 TTL inputs of LS series.
As seen from description of some ports, even though all of them have more or less similar
architecture, it is necessary to pay attention to which of them is to be used for what and how.
For example, if they shall be used as outputs with high voltage level (5V), then P0 should be
avoided because its pins do not have pull-up resistors, thus giving low logic level only. When
using other ports, one should have in mind that pull-up resistors have a relatively high resistance,
so that their pins can give a current of several hundreds microamperes only.
Memory Organization
The 8051 has two types of memory and these are Program Memory and Data Memory. Program
Memory (ROM) is used to permanently save the program being executed, while Data Memory
(RAM) is used for temporarily storing data and intermediate results created and used during the
operation of the microcontroller. Depending on the model in use (we are still talking about the
8051 microcontroller family in general) at most a few Kb of ROM and 128 or 256 bytes of RAM
is used. However
All 8051 microcontrollers have a 16-bit addressing bus and are capable of addressing 64 kb
memory. It is neither a mistake nor a big ambition of engineers who were working on basic core
development. It is a matter of smart memory organization which makes these microcontrollers a
real programmers goody.
Program Memory
The first models of the 8051 microcontroller family did not have internal program memory. It
was added as an external separate chip. These models are recognizable by their label beginning
with 803 (for example 8031 or 8032). All later models have a few Kbyte ROM embedded. Even
though such an amount of memory is sufficient for writing most of the programs, there are
situations when it is necessary to use additional memory as well. A typical example are so called
lookup tables. They are used in cases when equations describing some processes are too
complicated or when there is no time for solving them. In such cases all necessary estimates and
approximates are executed in advance and the final results are put in the tables (similar to
logarithmic tables).
How does the microcontroller handle external memory depend on the EA pin logic state:
EA=0 In this case, the microcontroller completely ignores internal program memory and
executes only the program stored in external memory.
EA=1 In this case, the microcontroller executes first the program from built-in ROM, then the
program stored in external memory.
In both cases, P0 and P2 are not available for use since being used for data and address
transmission. Besides, the ALE and PSEN pins are also used.
Data Memory
As already mentioned, Data Memory is used for temporarily storing data and intermediate results
created and used during the operation of the microcontroller. Besides, RAM memory built in the
8051 family includes many registers such as hardware counters and timers, input/output ports,
serial data buffers etc. The previous models had 256 RAM locations, while for the later models
this number was incremented by additional 128 registers. However, the first 256 memory
locations (addresses 0-FFh) are the heart of memory common to all the models belonging to the
8051 family. Locations available to the user occupy memory space with addresses 0-7Fh, i.e.
first 128 registers. This part of RAM is divided in several blocks.
The first block consists of 4 banks each including 8 registers denoted by R0-R7. Prior to
accessing any of these registers, it is necessary to select the bank containing it. The next memory
block (address 20h-2Fh) is bit- addressable, which means that each bit has its own address (07Fh). Since there are 16 such registers, this block contains in total of 128 bits with separate
addresses (address of bit 0 of the 20h byte is 0, while address of bit 7 of the 2Fh byte is 7Fh).
The third group of registers occupy addresses 2Fh-7Fh, i.e. 80 locations, and does not have any
special functions or features.
Additional RAM
In order to satisfy the programmers constant hunger for Data Memory, the manufacturers
decided to embed an additional memory block of 128 locations into the latest versions of the
8051 microcontrollers. However, its not as simple as it seems to be The problem is that
electronics performing addressing has 1 byte (8 bits) on disposal and is capable of reaching only
the first 256 locations, therefore. In order to keep already existing 8-bit architecture and
compatibility with other existing models a small trick was done.
What does it mean? It means that additional memory block shares the same addresses with
locations intended for the SFRs (80h- FFh). In order to differentiate between these two
physically separated memory spaces, different ways of addressing are used. The SFRs memory
locations are accessed by direct addressing, while additional RAM memory locations are
accessed by indirect addressing.
Memory expansion
In case memory (RAM or ROM) built in the microcontroller is not sufficient, it is possible to add
two external memory chips with capacity of 64Kb each. P2 and P3 I/O ports are used for their
addressing and data transmission.
From the users point of view, everything works quite simply when properly connected because
most operations are performed by the microcontroller itself. The 8051 microcontroller has two
pins for data read RD#(P3.7) and PSEN#. The first one is used for reading data from external
data memory (RAM), while the other is used for reading data from external program memory
(ROM). Both pins are active low. A typical example of memory expansion by adding RAM and
ROM chips (Hardward architecture), is shown in figure above.
Even though additional memory is rarely used with the latest versions of the microcontrollers,
we will describe in short what happens when memory chips are connected according to the
previous schematic. The whole process described below is performed automatically.
A signal on the ALE pin latches the IC circuit 74HCT573 and immediately
afterwards 8 higher bits of address (A8-A15) appear on the port. In this way, a
desired location of additional program memory is addressed. It is left over to
read its content.
Port P0 pins are configured as inputs, the PSEN pin is activated and the
microcontroller reads from memory chip.
Similar occurs when it is necessary to read location from external RAM. Addressing is
performed in the same way, while read and write are performed via signals appearing on the
control outputs RD (is short for read) or WR (is short for write).
Addressing
While operating, the processor processes data as per program instructions. Each instruction
consists of two parts. One part describes WHAT should be done, while the other explains HOW
to do it. The latter part can be a data (binary number) or the address at which the data is stored.
Two ways of addressing are used for all 8051 microcontrollers depending on which part of
memory should be accessed:
Direct Addressing
On direct addressing, the address of memory location containing data to be read is specified in
instruction. The address may contain a number being changed during operation (variable). For
example:
Since the address is only one byte in size (the largest number is 255), only the first 255 locations
of RAM can be accessed this way. The first half of RAM is available for use, while another half
is reserved for SFRs.
MOV A,33h; Means: move a number from address 33 hex. to accumulator
Indirect Addressing
On indirect addressing, registers R0, R1 or Stack Pointer are used for specifying 8-bit addresses.
Since only 8 bits are avilable, it is possible to access only registers of internal RAM this way
(128 locations when speaking of previous models or 256 locations when speaking of latest
models of microcontrollers). If an extra memory chip is added then the 16-bit DPTR Register
(consisting of the registers DPTRL and DPTRH) is used for specifying address. In this way it is
possible to access any location in the range of 64K.
Special Function Registers (SFRs) are a sort of control table used for running and monitoring the
operation of the microcontroller. Each of these registers as well as each bit they include, has its
name, address in the scope of RAM and precisely defined purpose such as timer control,
interrupt control, serial communication control etc. Even though there are 128 memory locations
intended to be occupied by them, the basic core, shared by all types of 8051 microcontrollers,
has only 21 such registers. Rest of locations are intensionally left unoccupied in order to enable
the manufacturers to further develop microcontrollers keeping them compatible with the
previous versions. It also enables programs written a long time ago for microcontrollers which
are out of production now to be used today.
A
Register (Accumulator)
A register is a general-purpose register used for storing intermediate results obtained during
operation. Prior to executing an instruction upon any number or operand it is necessary to store it
in the accumulator first. All results obtained from arithmetical operations performed by the ALU
are stored in the accumulator. Data to be moved from one register to another must go through the
accumulator. In other words, the A register is the most commonly used register and it is
impossible to imagine a microcontroller without it. More than half instructions used by the 8051
microcontroller use somehow the accumulator.
B Register
Multiplication and division can be performed only upon numbers stored in the A and B registers.
All other instructions in the program can use this register as a spare accumulator (A).
During the process of writing a program, each register is called by its name so that
their exact addresses are not of importance for the user. During compilation, their
names will be automatically replaced by appropriate addresses.
R Registers (R0-R7)
This is a common name for 8 general-purpose registers (R0, R1, R2 ...R7). Even though they are
not true SFRs, they deserve to be discussed here because of their purpose. They occupy 4 banks
within RAM. Similar to the accumulator, they are used for temporary storing variables and
intermediate results during operation. Which one of these banks is to be active depends on two
bits of the PSW Register. Active bank is a bank the registers of which are currently used.
The following example best illustrates the purpose of these registers. Suppose it is necessary to
perform some arithmetical operations upon numbers previously stored in the R registers:
(R1+R2) - (R3+R4). Obviously, a register for temporary storing results of addition is needed.
This is how it looks in the program:
MOV A,R3; Means: move number from R3 into accumulator
ADD
A,R4;
Means:
add
number
from
R4
to
accumulator
(result
remains
in
accumulator)
MOV R5,A; Means: temporarily move the result from accumulator into R5
MOV A,R1; Means: move number from R1 to accumulator
ADD A,R2; Means: add number from R2 to accumulator
SUBB A,R5; Means: subtract number from R5 (there are R3+R4)
PSW register is one of the most important SFRs. It contains several status bits that reflect the
current state of the CPU. Besides, this register contains Carry bit, Auxiliary Carry, two register
bank select bits, Overflow flag, parity bit and user-definable status flag.
P - Parity bit. If a number stored in the accumulator is even then this bit will be automatically
set (1), otherwise it will be cleared (0). It is mainly used during data transmit and receive via
serial communication.
- Bit 1. This bit is intended to be used in the future versions of microcontrollers.
OV Overflow occurs when the result of an arithmetical operation is larger than 255 and cannot
be stored in one register. Overflow condition causes the OV bit to be set (1). Otherwise, it will be
cleared (0).
RS0, RS1 - Register bank select bits. These two bits are used to select one of four register
banks of RAM. By setting and clearing these bits, registers R0-R7 are stored in one of four banks
of RAM.
RS1
RS2
Space
in
RAM
Bank0 00h07h
Bank1 08h0Fh
Bank2 10h17h
Bank3 18h1Fh
DPTR register is not a true one because it doesn't physically exist. It consists of two separate
registers: DPH (Data Pointer High) and (Data Pointer Low). For this reason it may be treated as a
16-bit register or as two independent 8-bit registers. Their 16 bits are primarly used for external
memory addressing. Besides, the DPTR Register is usually used for storing data and
intermediate results.
Sta
ck Pointer (SP) Register
A value stored in the Stack Pointer points to the first free stack address and permits stack
availability. Stack pushes increment the value in the Stack Pointer by 1. Likewise, stack pops
decrement its value by 1. Upon any reset and power-on, the value 7 is stored in the Stack Pointer,
which means that the space of RAM reserved for the stack starts at this location. If another value
is written to this register, the entire Stack is moved to the new memory location.
P0, P1, P2, P3 - Input/Output Registers
If neither external memory nor serial communication system are used then 4 ports with in total of
32 input/output pins are available for connection to peripheral environment. Each bit within these
ports affects the state and performance of appropriate pin of the microcontroller. Thus, bit logic
state is reflected on appropriate pin as a voltage (0 or 5 V) and vice versa, voltage on a pin
reflects the state of appropriate port bit.
As mentioned, port bit state affects performance of port pins, i.e. whether they will be configured
as inputs or outputs. If a bit is cleared (0), the appropriate pin will be configured as an output,
while if it is set (1), the appropriate pin will be configured as an input. Upon reset and power-on,
all port bits are set (1), which means that all appropriate pins will be configured as inputs.
I/O ports are directly connected to the microcontroller pins. Accordingly, logic state of these
registers can be checked by voltmeter and vice versa, voltage on the pins can be checked by
inspecting their bits!
Timer T0
As seen in figure below, the timer T0 consists of two registers TH0 and TL0 representing a low
and a high byte of one 16-digit binary number.
Accordingly, if the content of the timer T0 is equal to 0 (T0=0) then both registers it consists of
will contain 0. If the timer contains for example number 1000 (decimal), then the TH0 register
(high byte) will contain the number 3, while the TL0 register (low byte) will contain decimal
number 232.
Formula
TH0
Matching
used
to
the
calculate
values
in
256
previous
these
+
example
two
registers
TL0
it
would
be
is
very
simple:
as
follows:
Since the timer T0 is virtually 16-bit register, the largest value it can store is 65 535. In case of
exceeding this value, the timer will be automatically cleared and counting starts from 0. This
condition is called an overflow. Two registers TMOD and TCON are closely connected to this
timer and control its operation.
TMOD Register (Timer Mode)
The TMOD register selects the operational mode of the timers T0 and T1. As seen in figure
below, the low 4 bits (bit0 - bit3) refer to the timer 0, while the high 4 bits (bit4 - bit7) refer to
the timer 1. There are 4 operational modes and each of them is described herein.
T1M1,T1M0 These two bits select the operational mode of the Timer 1.
Descriptio
T1M1
T1M0
Mode
13-bit timer
16-bit timer
8-bit
auto-
reload
Split mode
GATE0 enables and disables Timer 1 using a signal brought to the INT0 pin
(P3.2):
T0M1,T0M0 These two bits select the operational mode of the Timer 0.
Descriptio
T0M1
T0M0
Mode
13-bit timer
16-bit timer
8-bit
auto-
reload
Split mode
This is one of the rarities being kept only for the purpose of compatibility with the previous
versions of microcontrollers. This mode configures timer 0 as a 13-bit timer which consists of all
8 bits of TH0 and the lower 5 bits of TL0. As a result, the Timer 0 uses only 13 of 16 bits. How
does it operate? Each coming pulse causes the lower register bits to change their states. After
receiving 32 pulses, this register is loaded and automatically cleared, while the higher byte (TH0)
is incremented by 1. This process is repeated until registers count up 8192 pulses. After that, both
registers are cleared and counting starts from 0.
Mode 1 configures timer 0 as a 16-bit timer comprising all the bits of both registers TH0 and
TL0. That's why this is one of the most commonly used modes. Timer operates in the same way
as in mode 0, with difference that the registers count up to 65 536 as allowable by the 16 bits.
Mode 2 configures timer 0 as an 8-bit timer. Actually, timer 0 uses only one 8-bit register for
counting and never counts from 0, but from an arbitrary value (0-255) stored in another (TH0)
register.
The following example shows the advantages of this mode. Suppose it is necessary to constantly
count up 55 pulses generated by the clock.
If mode 1 or mode 0 is used, It is necessary to write the number 200 to the timer registers and
constantly check whether an overflow has occured, i.e. whether they reached the value 255.
When it happens, it is necessary to rewrite the number 200 and repeat the whole procedure. The
same procedure is automatically performed by the microcontroller if set in mode 2. In fact, only
the TL0 register operates as a timer, while another (TH0) register stores the value from which the
counting starts. When the TL0 register is loaded, instead of being cleared, the contents of TH0
will be reloaded to it. Referring to the previous example, in order to register each 55th pulse, the
best solution is to write the number 200 to the TH0 register and configure the timer to operate in
mode 2.
Timer
0 in Mode 3 (Split Timer)
Mode 3 configures timer 0 so that registers TL0 and TH0 operate as separate 8-bit timers. In
other words, the 16-bit timer consisting of two registers TH0 and TL0 is split into two
independent 8-bit timers. This mode is provided for applications requiring an additional 8-bit
timer or counter. The TL0 timer turns into timer 0, while the TH0 timer turns into timer 1. In
addition, all the control bits of 16-bit Timer 1 (consisting of the TH1 and TL1 register), now
control the 8-bit Timer 1. Even though the 16-bit Timer 1 can still be configured to operate in
any of modes (mode 1, 2 or 3), it is no longer possible to disable it as there is no control bit to do
it. Thus, its operation is restricted when timer 0 is in mode 3.
The only application of this mode is when two timers are used and the 16-bit Timer 1 the
operation of which is out of control is used as a baud rate generator.
Timer Control (TCON) Register
TCON register is also one of the registers whose bits are directly in control of timer operation.
Only 4 bits of this register are used for this purpose, while rest of them is used for interrupt
control to be discussed later.
1 - Timer 1 is enabled.
0 - Timer 1 is disabled.
1 - Timer 0 is enabled.
0 - Timer 0 is disabled.
In order to use timer 0, it is first necessary to select it and configure the mode of its operation.
Bits of the TMOD register are in control of it:
Referring to figure above, the timer 0 operates in mode 1 and counts pulses generated by internal
clock
the
frequency
of
which
is
equal
to
1/12
the
quartz
frequency.
The TR0 bit is set and the timer starts operation. If the quartz crystal with frequency of 12MHz is
embedded then its contents will be incremented every microsecond. After 65.536 microseconds,
the both registers the timer consists of will be loaded. The microcontroller automatically clears
them and the timer keeps on repeating procedure from the beginning until the TR0 bit value is
logic zero (0).
Depending on application, it is necessary either to read a number stored in the timer registers or
to register the moment they have been cleared.
- It is extremely simple to read a timer by using only one register configured in mode 2 or 3. It is
sufficient to read its state at any moment. That's all!
- It is somehow complicated to read a timer configured to operate in mode 2. Suppose the lower
byte is read first (TL0), then the higher byte (TH0). The result is:
TH0 = 15 TL0 = 255
Everything seems to be ok, but the current state of the register at the moment of reading was:
TH0 = 14 TL0 = 255
In case of negligence, such an error in counting (255 pulses) may occur for not so obvious but
quite logical reason. The lower byte is correctly read (255), but at the moment the program
counter was about to read the higher byte TH0, an overflow occurred and the contents of both
registers have been changed (TH0: 1415, TL0: 2550). This problem has a simple solution.
The higher byte should be read first, then the lower byte and once again the higher byte. If the
number stored in the higher byte is different then this sequence should be repeated. It's about a
short loop consisting of only 3 instructions in the program.
There is another solution as well. It is sufficient to simply turn the timer off while reading is
going on (the TR0 bit of the TCON register should be cleared), and turn it on again after reading
is finished.
Timer 0 Overflow Detection
Usually, there is no need to constantly read timer registers. It is sufficient to register the moment
they are cleared, i.e. when counting starts from 0. This condition is called an overflow. When it
occurrs, the TF0 bit of the TCON register will be automatically set. The state of this bit can be
constantly checked from within the program or by enabling an interrupt which will stop the main
program execution when this bit is set. Suppose it is necessary to provide a program delay of
0.05 seconds (50 000 machine cycles), i.e. time when the program seems to be stopped:
First a number to be written to the timer registers should be calculated:
When enabled, the timer will resume counting from this number. The state of the TF0 bit, i.e.
whether it is set, is checked from within the program. It happens at the moment of overflow, i.e.
after exactly 50.000 machine cycles or 0.05 seconds.
How to measure pulse duration?
Suppose it is necessary to measure the duration of an operation, for example how long a device
has been turned on? Look again at the figure illustrating the timer and pay attention to the
function of the GATE0 bit of the TMOD register. If it is cleared then the state of the P3.2 pin
doesn't affect timer operation. If GATE0 = 1 the timer will operate until the pin P3.2 is cleared.
Accordingly, if this pin is supplied with 5V through some external switch at the moment the
device is being turned on, the timer will measure duration of its operation, which actually was
the objective.
How to count up pulses?
Similarly to the previous example, the answer to this question again lies in the TCON register.
This time it's about the C/T0 bit. If the bit is cleared the timer counts pulses generated by the
internal oscillator, i.e. measures the time passed. If the bit is set, the timer input is provided with
pulses from the P3.4 pin (T0). Since these pulses are not always of the same width, the timer
cannot be used for time measurement and is turned into a counter, therefore. The highest
frequency that could be measured by such a counter is 1/24 frequency of used quartz-crystal.
Timer 1
Timer 1 is identical to timer 0, except for mode 3 which is a hold-count mode. It means that they
have the same function, their operation is controlled by the same registers TMOD and TCON
and both of them can operate in one out of 4 different modes.
Serial port must be configured prior to being used. In other words, it is necessary to determine
how many bits is contained in one serial word, baud rate and synchronization clock source.
The whole process is in control of the bits of the SCON register (Serial Control).
SM0 - Serial port mode bit 0 is used for serial port mode selection.
REN - Reception Enable bit enables serial reception when set. When cleared,
serial reception is disabled.
TB8 - Transmitter bit 8. Since all registers are 8-bit wide, this bit solves the
problem of transmiting the 9th bit in modes 2 and 3. It is set to transmit a
logic 1 in the 9th bit.
RB8 - Receiver bit 8 or the 9th bit received in modes 2 and 3. Cleared by
hardware if 9th bit received is a logic 0. Set by hardware if 9th bit received is
a logic 1.
TI - Transmit Interrupt flag is automatically set at the moment the last bit of
one byte is sent. It's a signal to the processor that the line is available for a
new byte transmite. It must be cleared from within the software.
As seen, serial port mode is selected by combining the SM0 and SM2 bits:
SM0
SM1
Mode
Description
Baud Rate
8-bit UART
9-bit UART
(1/64
the
quartz
frequency)
1
9-bit UART
In mode 0, serial data are transmitted and received through the RXD pin, while the TXD pin
output clocks. The bout rate is fixed at 1/12 the oscillator frequency. On transmit, the least
significant bit (LSB bit) is sent/received first.
TRANSMIT - Data transmit is initiated by writing data to the SBUF register. In fact, this
process starts after any instruction being performed upon this register. When all 8 bits have been
sent, the TI bit of the SCON register is automatically set.
RECEIVE - Data receive through the RXD pin starts upon the two following conditions are
met: bit REN=1 and RI=0 (both of them are stored in the SCON register). When all 8 bits have
been received, the RI bit of the SCON register is automatically set indicating that one byte
receive is complete.
Since there are no START and STOP bits or any other bit except data sent from the SBUF
register in the pulse sequence, this mode is mainly used when the distance between devices is
short, noise is minimized and operating speed is of importance. A typical example is I/O port
expansion by adding a cheap IC (shift registers 74HC595, 74HC597 and similar).
Mode 1
In mode 1, 10 bits are transmitted through the TXD pin or received through the RXD pin in the
following manner: a START bit (always 0), 8 data bits (LSB first) and a STOP bit (always 1).
The START bit is only used to initiate data receive, while the STOP bit is automatically written
to the RB8 bit of the SCON register.
TRANSMIT - Data transmit is initiated by writing data to the SBUF register. End of data
transmission is indicated by setting the TI bit of the SCON register.
RECEIVE - The START bit (logic zero (0)) on the RXD pin initiates data receive. The
following two conditions must be met: bit REN=1 and bit RI=0. Both of them are stored in the
SCON register. The RI bit is automatically set upon data reception is complete.
In mode 2, 11 bits are transmitted through the TXD pin or received through the RXD pin: a
START bit (always 0), 8 data bits (LSB first), a programmable 9th data bit and a STOP bit
(always 1). On transmit, the 9th data bit is actually the TB8 bit of the SCON register. This bit
usually has a function of parity bit. On receive, the 9th data bit goes into the RB8 bit of the same
register (SCON).The baud rate is either 1/32 or 1/64 the oscillator frequency.
TRANSMIT - Data transmit is initiated by writing data to the SBUF register. End of data
transmission is indicated by setting the TI bit of the SCON register.
RECEIVE - The START bit (logic zero (0)) on the RXD pin initiates data receive. The
following two conditions must be met: bit REN=1 and bit RI=0. Both of them are stored in the
SCON register. The RI bit is automatically set upon data reception is complete.
Mode 3
Mode 3 is the same as Mode 2 in all respects except the baud rate. The baud rate in Mode 3 is
variable.
The parity bit is the P bit of the PSW register. The simplest way to check correctness of the
received byte is to add a parity bit to it. Simply, before initiating data transmit, the byte to
transmit is stored in the accumulator and the P bit goes into the TB8 bit in order to be a part of
the message. The procedure is opposite on receive, received byte is stored in the accumulator
and the P bit is compared with the RB8 bit. If they are the same- everything is OK!
Baud Rate
Baud Rate is a number of sent/received bits per second. In case the UART is used, baud rate
depends on: selected mode, oscillator frequency and in some cases on the state of the SMOD bit
of the SCON register. All the necessary formulas are specified in the table:
Baud Rate
Mode 0
Fosc. / 12
1
Mode 1
Bit SMOD
Fosc.
Mode 2
Fosc.
32 1
Fosc. / 64
1
Mode 3
Fosc.
16 12 (256TH1)
Timer 1 is usually used as a clock generator as it enables various baud rates to be easily set. The
whole procedure is simple and is as follows:
Depending on needs, select one of the standard values from the table and
write it to the TH1 register. That's all.
Fosc. (MHz)
Bit SMOD
Baud Rate
11.0592
12
14.7456
150
40 h
30 h
00 h
300
A0 h
98 h
80 h
75 h
52 h
600
D0 h
CC h
C0 h
BB h
A9 h
1200
E8 h
E6 h
E0 h
DE h
D5 h
2400
F4 h
F3 h
F0 h
EF h
EA h
F3 h
EF h
EF h
4800
4800
FA h
F8 h
9600
FD h
FC h
9600
19200
16
20
0
1
F5 h
0
F5 h
FD h
FC h
38400
FE h
76800
FF h
Multiprocessor Communication
As you may know, additional 9th data bit is a part of message in mode 2 and 3. It can be used for
checking data via parity bit. Another useful application of this bit is in communication between
two or more microcontrollers, i.e. multiprocessor communication. This feature is enabled by
setting the SM2 bit of the SCON register. As a result, after receiving the STOP bit, indicating end
of the message, the serial port interrupt will be generated only if the bit RB8 = 1 (the 9th bit).
Of course, only one of them will match the address and immediately clear the SM2 bit of the
SCON register and prepare to receive the data byte to come. Other slaves not being addressed
leave their SM2 bit set ignoring the coming data bytes.
IE
Register (Interrupt Enable)
Interrupt Priorities
It is not possible to forseen when an interrupt request will arrive. If several interrupts are
enabled, it may happen that while one of them is in progress, another one is requested. In order
that the microcontroller knows whether to continue operation or meet a new interrupt request,
there is a priority list instructing it what to do.
The priority list offers 3 levels of interrupt priority:
1. Reset! The apsolute master. When a reset request arrives, everything is
stopped and the microcontroller restarts.
2. Interrupt priority 1 can be disabled by Reset only.
3. Interrupt priority 0 can be disabled by both Reset and interrupt priority 1.
The IP Register (Interrupt Priority Register) specifies which one of existing interrupt sources
have higher and which one has lower priority. Interrupt priority is usually specified at the
beginning of the program. According to that, there are several possibilities:
If two interrupt requests, at different priority levels, arrive at the same time
then the higher priority interrupt is serviced first.
If the both interrupt requests, at the same priority level, occur one after
another, the one which came later has to wait until routine being in progress
ends.
If two interrupt requests of equal priority arrive at the same time then the
interrupt to be serviced is selected according to the following priority list:
The IP register bits specify the priority level of each interrupt (high or low priority).
Priority 0
Priority 1
Priority 0
Priority 1
Priority 0
Priority 1
Priority 0
Priority 1
Priority 0
Priority 1
Handling Interrupt
Vector (address)
IE0
3h
TF0
Bh
TF1
1B h
RI, TI
23 h
From the moment an interrupt is enabled, the microcontroller is on alert all the time. When an
interrupt request arrives, the program execution is stopped, electronics recognizes the source and
the program jumps to the appropriate address (see the table above). This address usually stores
a jump instruction specifying the start of appropriate subroutine. Upon its execution, the program
resumes operation from where it left off.
Reset
Reset occurs when the RS pin is supplied with a positive pulse in duration of at least 2 machine
cycles (24 clock cycles of crystal oscillator). After that, the microcontroller generates an internal
reset signal which clears all SFRs, except SBUF registers, Stack Pointer and ports (the state of
the first two ports is not defined, while FF value is written to the ports configuring all their pins
as inputs). Depending on surrounding and purpose of device, the RS pin is usually connected to a
power-on reset push button or circuit or to both of them. Figure below illustrates one of the
simplest circuit providing safe power-on reset.
Basically, everything is very simple: after turning the power on, electrical capacitor is being
charged for several milliseconds through a resistor connected to the ground. The pin is driven
high during this process. When the capacitor is charged, power supply voltage is already stable
and the pin remains connected to the ground, thus providing normal operation of the
microcontroller. Pressing the reset button causes the capacitor to be temporarily discharged and
the microcontroller is reset. When released, the whole process is repeated
Through the program- step by step...
Microcontrollers normally operate at very high speed. The use of 12 MHz quartz crystal enables
1.000.000 instructions to be executed per second. Basically, there is no need for higher operating
rate. In case it is needed, it is easy to built in a crystal for high frequency. The problem arises
when it is necessary to slow down the operation of the microcontroller. For example during
testing in real environment when it is necessary to execute several instructions step by step in
order to check I/O pins' logic state.
Interrupt system of the 8051 microcontroller practically stops operation of the microcontroller
and enables instructions to be executed one after another by pressing the button. Two interrupt
features enable that:
address
What is going on? As soon as the P3.2 pin is cleared (for example, by pressing the button), the
microcontroller will stop program execution and jump to the 03hex address will be executed.
This address stores a short interrupt routine consisting of 3 instructions.
The first instruction is executed until the push button is realised (logic one (1) on the P3.2 pin).
The second instruction is executed until the push button is pressed again. Immediately after that,
the RETI instruction is executed and the processor resumes operation of the main program. Upon
execution of any program instruction, the interrupt INT0 is generated and the whole procedure is
repeated (push button is still pressed).
Idle mode
Upon the IDL bit of the PCON register is set, the microcontroller turns off the greatest power
consumer- CPU unit while peripheral units such as serial port, timers and interrupt system
continue operating normally consuming 6.5mA. In Idle mode, the state of all registers and I/O
ports remains unchanged.
In order to exit the idle mode and make the microcontroller operate normally, it is necessary to
enable and execute any interrupt or reset. It will cause the IDL bit to be automatically cleared and
the program resumes operation from instruction having set the IDL bit. It is recommended that
first three instructions to execute now are NOP instructions. They don't perform any operation
but provide some time for the microcontroller to stabilize and prevents undesired changes on the
I/O ports.
Power Down mode
By setting the PD bit of the PCON register from within the program, the microcontroller is set to
Power down mode, thus turning off its internal oscillator and reduces power consumption
enormously. The microcontroller can operate using only 2V power supply in power- down mode,
while a total power consumption is less than 40uA. The only way to get the microcontroller back
to normal mode is by reset.
While the microcontroller is in Power Down mode, the state of all SFR registers and I/O ports
remains unchanged. By setting it back into the normal mode, the contents of the SFR register is
lost, but the content of internal RAM is saved. Reset signal must be long enough, approximately
10mS, to enable stable operation of the quartz oscillator.
PCON
register
PD By setting this bit the microcontroller enters the Power Down mode.
IDL By setting this bit the microcontroller enters the idle mode.
Module 2:
Module 3:
Grip sensor
Sensing
Electrode
Oscillator
Detector
Output
Unit
Linear output
Switch
output
Power supply
-12v dc
O/p current
-100ma
-10ma
Switching
-0 or 12v
Analog
Hysteris
-10%
No Load Current
-10ma
A dynamic grip sensor is formed from a unitary block having upper and lower covers. The
sensor, being of a size so that it can be gripped by a human hand, comprises two sets of parallel
flexure beams connected between outer end blocks and a center block and are loaded by a base
plate connected to the outer end block and extending between the end blocks. The flexure beams
deflect to respond to hand grip strength.
Module 4:
Relay:
Relay is an electrical switch that opens and closes under the control of another electrical circuit.
In the original form, the switch is operated by an electromagnet to open or close one or many sets of
contacts. It was invented by Joseph Henry in 1835. Because a relay is able to control an output circuit of
higher power than the input circuit, it can be considered to be, in a broad sense, a form of an electrical
amplifier.
A simple electromagnetic relay, such as the one taken from a car in the first picture, is an
adaptation of an electromagnet. It consists of a coil of wire surrounding a soft iron core, an iron yoke,
which provides a low reluctance path for magnetic flux, a moveable iron armature, and a set, or sets, of
contacts; two in the relay pictured. The armature is hinged to the yoke and mechanically linked to a
moving contact or contacts. It is held in place by a spring so that when the relay is de-energized there is
an air gap in the magnetic circuit. In this condition, one of the two sets of contacts in the relay pictured is
closed, and the other set is open. Other relays may have more or fewer sets of contacts depending on their
function. The relay in the picture also has a wire connecting the armature to the yoke. This ensures
continuity of the circuit between the moving contacts on the armature, and the circuit track on the Printed
Circuit Board (PCB) via the yoke, which is soldered to the PCB.
When an electric current is passed through the coil, the resulting magnetic field attracts the
armature and the consequent movement of the movable contact or contacts either makes or breaks a
connection with a fixed contact. If the set of contacts was closed when the relay was de-energized, then
the movement opens the contacts and breaks the connection, and vice versa if the contacts were open.
When the current to the coil is switched off, the armature is returned by a force, approximately half as
strong as the magnetic force, to its relaxed position. Usually this force is provided by a spring, but gravity
is also used commonly in industrial motor starters. Most relays are manufactured to operate quickly. In a
low voltage application, this is to reduce noise. In a high voltage or high current application, this is to
reduce arcing.
If the coil is energized with DC, a diode is frequently installed across the coil, to dissipate the
energy from the collapsing magnetic field at deactivation, which would otherwise generate a voltage
spike dangerous to circuit components. Some automotive relays already include that diode inside the relay
case. Alternatively a contact protection network, consisting of a capacitor and resistor in series, may
absorb the surge. If the coil is designed to be energized with AC, a small copper ring can be crimped to
the end of the solenoid. This "shading ring" creates a small out-of-phase current, which increases the
minimum pull on the armature during the AC cycle.
By analogy with the functions of the original electromagnetic device, a solid-state relay is made with a
thyristor or other solid-state switching device. To achieve electrical isolation an optocoupler can be used
which is a light-emitting diode (LED) coupled with a photo transistor.
Types of relay
Latching relay
A latching relay has two relaxed states (bistable). These are also called 'keep' or 'stay' relays.
When the current is switched off, the relay remains in its last state. This is achieved with a solenoid
operating a ratchet and cam mechanism, or by having two opposing coils with an over-center spring or
permanent magnet to hold the armature and contacts in position while the coil is relaxed, or with a
remnant core. In the ratchet and cam example, the first pulse to the coil turns the relay on and the second
pulse turns it off. In the two coil example, a pulse to one coil turns the relay on and a pulse to the opposite
coil turns the relay off. This type of relay has the advantage that it consumes power only for an instant,
while it is being switched, and it retains its last setting across a power outage.
Reed relay
A reed relay has a set of contacts inside a vacuum or inert gas filled glass tube, which protects the
contacts against atmospheric corrosion. The contacts are closed by a magnetic field generated when
current passes through a coil around the glass tube. Reed relays are capable of faster switching speeds
than larger types of relays, but have low switch current and voltage ratings. See also reed switch.
Mercury-wetted relay
A mercury-wetted reed relay is a form of reed relay in which the contacts are wetted with
mercury. Such relays are used to switch low-voltage signals (one volt or less) because of their low contact
resistance, or for high-speed counting and timing applications where the mercury eliminates contact
bounce. Mercury wetted relays are position-sensitive and must be mounted vertically to work properly.
Because of the toxicity and expense of liquid mercury, these relays are rarely specified for new
equipment. See also mercury switch.
Polarized relay
A Polarized Relay placed the armature between the poles of a permanent magnet to increase
sensitivity. Polarized relays were used in middle 20th Century telephone exchanges to detect faint pulses
and correct telegraphic distortion. The poles were on screws, so a technician could first adjust them for
maximum sensitivity and then apply a bias spring to set the critical current that would operate the relay.
Machine tool relay
A machine tool relay is a type standardized for industrial control of machine tools, transfer
machines, and other sequential control. They are characterized by a large number of contacts (sometimes
extendable in the field) which are easily converted from normally-open to normally-closed status, easily
replaceable coils, and a form factor that allows compactly installing many relays in a control panel.
Although such relays once were the backbone of automation in such industries as automobile assembly,
the programmable logic controller (PLC) mostly displaced the machine tool relay from sequential control
applications.
Contactor relay
A contactor is a very heavy-duty relay used for switching electric motors and lighting loads.
High-current contacts are made with alloys containing silver. The unavoidable arcing causes the contacts
to oxidize and silver oxide is still a good conductor. Such devices are often used for motor starters. A
motor starter is a contactor with overload protection devices attached. The overload sensing devices are a
form of heat operated relay where a coil heats a bi-metal strip, or where a solder pot melts, releasing a
spring to operate auxiliary contacts. These auxiliary contacts are in series with the coil. If the overload
senses excess current in the load, the coil is de-energized. Contactor relays can be extremely loud to
operate, making them unfit for use where noise is a chief concern.
Solid-state relay
Solid state relay, which has no moving parts
25 amp or 40 amp solid state contactors
A solid state relay (SSR) is a solid state electronic component that provides a similar function to an
electromechanical relay but does not have any moving components, increasing long-term reliability. With
early SSR's, the tradeoff came from the fact that every transistor has a small voltage drop across it. This
voltage drop limited the amount of current a given SSR could handle. As transistors improved, higher
current SSR's, able to handle 100 to 1,200 amps, have become commercially available. Compared to
electromagnetic relays, they may be falsely triggered by transients.
Solid state contactor relay
A solid state contactor is a very heavy-duty solid state relay, including the necessary heat sink, used for
switching electric heaters, small electric motors and lighting loads; where frequent on/off cycles are
required. There are no moving parts to wear out and there is no contact bounce due to vibration. They are
activated by AC control signals or DC control signals from Programmable logic controller (PLCs), PCs,
Transistor-transistor logic (TTL) sources, or other microprocessor controls.
Buchholz relay
A Buchholz relay is a safety device sensing the accumulation of gas in large oil-filled transformers, which
will alarm on slow accumulation of gas or shut down the transformer if gas is produced rapidly in the
transformer oil.
forced-guided contacts is to enable the safety circuit to check the status of the relay. Forced-guided
contacts are also known as "positive-guided contacts", "captive contacts", "locked contacts", or "safety
relays".
SPDT - Single Pole Double Throw. A common terminal connects to either of two others. Including two
for the coil, such a relay has five terminals in total.
DPST - Double Pole Single Throw. These have two pairs of terminals. Equivalent to two SPST
switches or relays actuated by a single coil. Including two for the coil, such a relay has six terminals in
total. The poles may be Form A or Form B (or one of each).
DPDT - Double Pole Double Throw. These have two rows of change-over terminals. Equivalent to two
SPDT switches or relays actuated by a single coil. Such a relay has eight terminals, including the coil.
The "S" or "D" may be replaced with a number, indicating multiple switches connected to a single
actuator. For example 4PDT indicates a four pole double throw relay (with 14 terminals).
Applications
Relays are used to and for:
Control a high-voltage circuit with a low-voltage signal, as in some types of modems or audio amplifiers,
Control a high-current circuit with a low-current signal, as in the starter solenoid of an automobile,
Detect and isolate faults on transmission and distribution lines by opening and closing circuit breakers
(protection relays),
Safety-critical logic. Because relays are much more resistant than semiconductors to nuclear radiation,
they are widely used in safety-critical logic, such as the control panels of radioactive waste-handling
machinery.
Time delay functions. Relays can be modified to delay opening or delay closing a set of contacts. A very
short (a fraction of a second) delay would use a copper disk between the armature and moving blade
assembly. Current flowing in the disk maintains magnetic field for a short time, lengthening release time.
For a slightly longer (up to a minute) delay, a dashpot is used. A dashpot is a piston filled with fluid that is
allowed to escape slowly. The time period can be varied by increasing or decreasing the flow rate. For
longer time periods, a mechanical clockwork timer is installed.
"Dry" contacts - when switching very low level signals, special contact materials may be needed such as
gold-plated contacts
Contact protection - suppress arcing in very inductive circuits
Coil protection - suppress the surge voltage produced when switching the coil current
Isolation between coil circuit and contacts
Aerospace or radiation-resistant testing, special quality assurance
Expected mechanical loads due to acceleration - some relays used in aerospace applications are
designed to function in shock loads of 50 g or more
Accessories such as timers, auxiliary contacts, pilot lamps, test buttons
Regulatory approvals
Stray magnetic linkage between coils of adjacent relays on a printed circuit board.
Protective relay
A protective relay is a complex electromechanical apparatus, often with more than one coil, designed to
calculate operating conditions on an electrical circuit and trip circuit breakers when a fault was found.
Unlike switching type relays with fixed and usually ill-defined operating voltage thresholds and operating
times, protective relays had well-established, selectable, time/current (or other operating parameter)
curves. Such relays were very elaborate, using arrays of induction disks, shaded-pole magnets, operating
and restraint coils, solenoid-type operators, telephone-relay style contacts, and phase-shifting networks to
allow the relay to respond to such conditions as over-current, over-voltage, reverse power flow, over- and
under- frequency, and even distance relays that would trip for faults up to a certain distance away from a
substation but not beyond that point. An important transmission line or generator unit would have had
cubicles dedicated to protection, with a score of individual electromechanical devices. The various
protective functions available on a given relay are denoted by standard ANSI Device Numbers. For
example, a relay including function 51 would be a timed overcurrent protective relay.
These protective relays provide various types of electrical protection by detecting abnormal conditions
and isolating them from the rest of the electrical system by circuit breaker operation. Such relays may be
located at the service entrance or at major load centers.
Design and theory of these protective devices is an important part of the education of an electrical
engineer who specializes in power systems. Today these devices are nearly entirely replaced (in new
designs) with microprocessor-based instruments (numerical relays) that emulate their electromechanical
ancestors with great precision and convenience in application. By combining several functions in one
case, numerical relays also save capital cost and maintenance cost over electromechanical relays.
However, due to their very long life span, tens of thousands of these "silent sentinels" are still protecting
transmission lines and electrical apparatus all over the world.
Overcurrent relay
An "Overcurrent Relay" is a type of protective relay which operates when the load current exceeds a
preset value. The ANSI Device Designation Number is 50 for an Instantaneous OverCurrent (IOC), 51 for
a Time OverCurrent (TOC). In a typical application the overcurrent relay is used for overcurrent
protection, connected to a current transformer and calibrated to operate at or above a specific current
level. When the relay operates, one or more contacts will operate and energize a trip coil in a Circuit
Breaker and trip (open) the Circuit Breaker.
T = K x 1 x 2 Sin
Where
K is a constant
1 and 2 are the two fluxes
is the phase angle between the fluxes
The relay's primary winding is supplied from the power systems current transformer via a plug bridge,
which is also commonly known as the plug setting multiplier (psm). The variations in the current setting
are usually seven equally spaced tappings or operating bands that determine the relays sensitivity. The
primary winding is located on the upper electromagnet. The secondary winding has connections on the
upper electromagnet that are energized from the primary winding and connected to the lower
electromagnet. Once the upper and lower electromagnets are energized they produce eddy currents that
are induced onto the metal disc and flow through the flux paths. This relationship of eddy currents and
fluxes creates rotational torque proportional to the input current of the primary winding, due to the two
flux paths been out of phase by 90.
Therefore in an overcurrent condition a value of current will be reached that overcomes the control spring
pressure on the spindle and the breaking magnet causing the metal disc to rotate moving towards the fixed
contact. This initial movement of the disc is also held off to a critical positive value of current by small
slots that are often cut into the side of the disc. The time taken for rotation to make the contacts is not
only dependent on current but also the spindle backstop position, known as the time multiplier (tm). The
time multiplier is divided into 10 linear divisions of the full rotation time.
Providing the relay is free from dirt, the metal disc and the spindle with its contact will reach the fixed
contact, thus sending a signal to trip and isolate the circuit, within its designed time and current
specifications. Drop off current of the relay is much lower than its operating value, and once reached the
relay will be reset in a reverse motion by the pressure of the control spring governed by the braking
magnet.
Distance relay
The most common form of feeder protection on high voltage transmission systems is distance relay
protection. Power lines have set impedance per killometre and using this value and comparing voltage
and current the distance to a fault can be determined. The ANSI standard device number for a distance
relay is 21. The main types of distance relay protection schemes are:Three step distance protection
Switched distance protection
Accelerated or permissive intertrip protection
Blocked distance protection
In three step distance protection, the relays are separated into three separate zones of impedance
measurement to accommodate for over reach and under reach conditions. Zone 1 is instantaneous in
operation and has a purposely set under reach of 80% of the total line length to avoid operation for the
next line. This is due to measurements of impedance of lines not being entirely accurate, errors in voltage
and current transformers and relay tolerances. These errors can be up to 20% of the line impedance,
hence the zones 80% reach. Zone 2 covers the last 20% of the feeder line length and provides backup to
the next line by having a slight over reach. To prevent mal-operation the zone has a 0.5 second time delay.
Zone 3 provides backup for the next line and has a time delay of 1 second to grade with zone 2 protection
of the next line.
Double switching
In railway signalling, relays energize to give a green light, so that if the power fails or a wire breaks, the
signal goes to red. This is called "fail-safe". To protect against false feeds relay circuits are often cut on
both the positive and negative side, so that two false feeds are needed to cause a false green.
The first relay was invented by Joseph Henry in 1835. The name relay derives from the French
noun relays that indicate the horse exchange place of the postman. Generally a relay is an electrical
hardware device having an input and output gate. The output gate consists in one or more electrical
contacts that switch when the input gate is electrically excited. It can implement a decouple, a router or
barker for the electrical power, a negation, and, on the base of the wiring, complicated logical functions
containing and, or, and flip-flop. In the past relays had a wide use, for instance the telephone switching or
the railway routing and crossing systems. In spite of electronic progresses (as programmable devices),
relays are still used in applications where ruggedness, simplicity, long life and high reliability are
important factors (for instance in safety applications).
Operation
When a current flows through the coil, the resulting magnetic field attracts an armature that is
mechanically linked to a moving contact. The movement either makes or breaks a connection
with a fixed contact. When the current to the coil is switched off, the armature is returned by a
force approximately half as strong as the magnetic force to its relaxed position. Usually this is a
spring, but gravity is also used commonly in industrial motor starters. Most relays are
manufactured to operate quickly. In a low voltage application, this is to reduce noise. In a high
voltage or high current application, this is to reduce arcing.
If the coil is energized with DC, a diode is frequently installed across the coil, to dissipate the
energy from the collapsing magnetic field at deactivation, which would otherwise generate a
spike of voltage and might cause damage to circuit components. If the coil is designed to be
energizedwith AC, a small copper ring can be crimped to the end of the solenoid. This "shading
ring" creates a small out-of-phase current, which increases the minimum pull on the armature
during the AC cycle.
Electromechanical relay:
It consists in a fixed coil (a) and a moving armature (b) mechanically linked (c) to a moving contact (d).
Feeding the coil by means of electrical current a magnetic field rises. Then the moving armature is
attracted to the coil and, consequentially, the contact can be moved. The movement of the contact either
makes or breaks an electrical connection with a fixed contact (e). When the feeding current of the coil is
removed, the armature and the feed contact return to their relaxed position by means of a spring or of the
elasticity of the contact. An electromechanical relay has galvanic insulation between the input and output
gate and between the terminals of the contacts when they are in break position.
To detect and isolate faults on transmission and distribution lines by opening and closing circuit
breakers (protection relays),
To isolate the controlling circuit from the controlled circuit when the two are at different
potentials, for example when controlling a mains-powered device from a low-voltage switch. The
latter is often applied to control office lighting as the low voltage wires are easily installed in
partitions, which may be often moved as needs change. They may also be controlled by room
occupancy detectors in an effort to conserve energy,
To perform logic functions. For example, the Boolean AND function is realised by connecting
NO relay contacts in series, the OR function by connecting NO contacts in parallel. The changeover or Form C contacts perform the XOR (exclusive or) function. Similar functions for NAND
and NOR are accomplished using NC contacts. Due to the failure modes of a relay compared with
a semiconductor, they are widely used in safety critical logic, such as the control panels of
radioactive waste handling machinery.
To perform time delay functions. Relays can be modified to delay opening or delay closing a set of
contacts. A very short (a fraction of a second) delay would use a copper disk between the armature and
moving blade assembly. Current flowing in the disk maintains magnetic field for a short time, lengthening
release time. For a slightly longer (up to a minute) delay, a dashpot is used. A dashpot is a piston filled
with fluid that is allowed to escape slowly. The time period can be varied by increasing or decreasing the
flow rate. For longer time periods, a mechanical clockwork timer is installed.
MODULE-2
DRIVER CIRCUIT
The ULN2003 is a monolithic high voltage and high current Darlington transistor arrays. It
consists of seven NPN darlington pairs that features high-voltage outputs with common-cathode clamp
diode for switching inductive loads. The collector-current rating of a single Darlington pair is 500mA.
The darlington pairs may be paralleled for higher current capability. Applications include relay drivers,
hammer drivers, lamp drivers, display drivers (LED gas discharge), line drivers, and logic buffers.
The ULN2003 has a 2.7kW series base resistor for each Darlington pair for operation directly
with TTL or 5V CMOS devices.
FEATURES
* 500mA rated collector current (Single output)
* High-voltage outputs: 50V
* Inputs compatible with various types of logic.
* Relay driver application
The ULN2003 series input resistors selected for operation directly with 5 V TTL or CMOS. These devices
will handle numerous interface needs particularly those beyond the capabilities of standard logic buffers.
The ULN2003 have series input resistors for operation directly from 6 V to 15 VCMOS or PMOS logic
outputs. The ULN 2003 is the standard Darlington arrays.
The outputs are capable of sinking 500mA and will withstand at least 50 V in the OFF state. Outputs may
be paralleled for higher load current capability. The ULx2823A/LW and ULx2824A/
LW will withstand 95 V in the OFF state.
These Darlington arrays are furnished in 18-pin dual in-line plastic packages (suffix A) or 18lead small-outline plastic packages (suffix LW). All devices are pinned with outputs opposite inputs to
facilitate ease of circuit board layout. Prefix ULN devices are rated for operation over the temperature
range of -20C to +85C; prefix ULQ devices are rated for operation to -40 C.
Module 5:
Introduction
The most commonly used Character based LCDs are based on Hitachi's HD44780
controller or other which are compatible with HD44580. In this tutorial, we will discuss about
character based LCDs, their interfacing with various microcontrollers, various interfaces (8-bit/4bit), programming, special stuff and tricks you can do with these simple looking LCDs which can
give a new look to your application.
Pin Description
The most commonly used LCDs found in the market today are 1 Line, 2 Line or 4 Line
LCDs which have only 1 controller and support at most of 80 charachers, whereas LCDs
supporting more than 80 characters make use of 2 HD44780 controllers.
Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two pins are
extra in both for back-light LED connections). Pin description is shown in the table below.
Pin No.
Pin no. 1
Pin no. 2
Pin no. 3
Pin no. 4
Pin no. 5
Pin no. 6
Name
D7
D6
D5
D4
D3
D2
Description
Data bus line 7 (MSB)
Data bus line 6
Data bus line 5
Data bus line 4
Data bus line 3
Data bus line 2
Pin no. 7
Pin no. 8
Pin no. 9
D1
D0
EN1
Usually these days you will find single controller LCD modules are used more in the market. So
in the tutorial we will discuss more about the single controller LCD, the operation and everything
else is same for the double controller too. Lets take a look at the basic information which is there
in every LCD.
BF - Busy Flag:
Busy Flag is an status indicator flag for LCD. When we send a command or data to the
LCD for processing, this flag is set (i.e BF =1) and as soon as the instruction is executed
successfully this flag is cleared (BF = 0). This is helpful in producing and exact amount of delay.
for the LCD processing. To read Busy Flag, the condition RS = 0 and R/W = 1 must be met and
The MSB of the LCD data bus (D7) act as busy flag. When BF = 1 means LCD is busy and will
not accept next command or data and BF = 0 means LCD is ready for the next command or data
to process.
CGRAM, the address where you want to send the data, is decided by the instruction you send to
LCD. We will discuss more on LCD instruction set further in this tutorial.
Although looking at the table you can make your own commands and test them. Below is a brief
list of useful commands which are used frequently while working on the LCD.
No.
1
2
3
4
5
6
7
8
9
10
12
13
14
15
16
17
Instruction
Hex
Decimal
Function Set: 8-bit, 1 Line, 5x7 Dots
0x30
48
Function Set: 8-bit, 2 Line, 5x7 Dots
0x38
56
Function Set: 4-bit, 1 Line, 5x7 Dots
0x20
32
Function Set: 4-bit, 2 Line, 5x7 Dots
0x28
40
Entry Mode
0x06
6
Display off Cursor off
(clearing display without clearing DDRAM 0x08
8
content)
Display on Cursor on
0x0E
14
Display on Cursor off
0x0C
12
Display on Cursor blinking
0x0F
15
Shift entire display left
0x18
24
Shift entire display right
0x1C
30
Move cursor left by one character
0x10
16
Move cursor right by one character
0x14
20
Clear Display (also clear DDRAM content) 0x01
1
Set DDRAM address or coursor position on
0x80+add* 128+add*
display
Set CGRAM address or set pointer to
0x40+add** 64+add**
CGRAM location
Table 4: Frequently used commands and instructions for LCD
MODULE 6:
MAX 232
Introduction
MAX-232 is primary used for people building electronics with an RS-232 interface.
Serial RS-232 communication works with voltages (-15V ... -3V for high) and +3V ...
+15V for low) which are not compatible with normal computer logic voltages. To
receive serial data from an RS-232 interface the voltage has to be reduced, and the
low and high voltage level inverted. In the other direction (sending data from some
logic over RS-232) the low logic voltage has to be "bumped up", and a negative
voltage has to be generated, too.
RS232 COMMUNICATION
Introduction
Electrical signal characteristics such as voltage levels, signaling rate, timing and
slew-rate of signals, voltage withstand level, short-circuit behavior, maximum stray
capacitance and cable length
The standard does not define such elements as character encoding (for example,
ASCII, Baudot or EBCDIC), or the framing of characters in the data stream (bits per
character, start/stop bits, parity). The standard does not define protocols for error
detection or algorithms for data compression.
The standard does not define bit rates for transmission, although the standard says
it is intended for bit rates lower than 20,000 bits per second. Many modern devices
can exceed this speed (38,400 and 57,600 bit/s being common, and 115,200 and
230,400 bit/s making occasional appearances) while still using RS-232 compatible
signal levels.
Details of character format and transmission bit rate are controlled by the serial
port hardware, often a single integrated circuit called a UART that converts data
from parallel to serial form. A typical serial port includes specialized driver and
receiver integrated circuits to convert between internal logic levels and RS-232
compatible signal levels.
In this circuit the microcontroller transmitter pin is connected in the MAX232 T2IN
pin which converts input 5v TTL/CMOS level to RS232 level. Then T2OUT pin is
connected to reviver pin of 9 pin D type serial connector which is directly connected
to PC.
KEIL SOFTWARE
Keil Software is the leading vendor for 8/16-bit development tools (ranked at first position
in the 2004 Embedded Market Study of the Embedded Systems and EE Times magazine). Keil
Software is represented world-wide in more than 40 countries. Since the market introduction in
1988, the Keil C51 Compiler is the de facto industry standard and supports more than 500
current 8051 device variants. Now, Keil Software offers development tools for ARM.
Keil Software makes C compilers, macro assemblers, real-time kernels, debuggers, simulators,
integrated environments, and evaluation boards for the 8051, 251, ARM, and XC16x/C16x/ST10
microcontroller families.
Keil Software is pleased to announce simulation support for the Atmel AT91 ARM family of
microcontrollers. The Keil Vision Debugger simulates the complete ARM instruction-set as well
as the on-chip peripherals for each device in the AT91 ARM/Thumb microcontroller family. The
integrated simulator provides complete peripheral simulation. Other new features in the Vision
Debugger include:
An integrated Software Logic Analyzer that measures I/O signals as well as program
variables and helps developers create complex signal processing algorithms.
An Execution Profiler that measures time spent in each function, source line, and assembler
instruction. Now developers can find exactly where programs spend the most time.
"Using nothing more than the provided simulation support and debug scripts, developers can
create a high-fidelity simulation of their actual target hardware and environment. No extra
hardware or test equipment is required. The Logic Analyzer and Execution Profiler will help
developers when it comes time to develop and tune signaling algorithms." said Jon Ward,
President of Keil Software USA, Inc.
Vision3 Overview
The Vision3 IDE is a Windows-based software development platform that combines a robust editor,
project manager, and make facility. Vision3 integrates all tools including the C compiler, macro
assembler, linker/locator, and HEX file generator. Vision3 helps expedite the development process of
your embedded applications by providing the following:
Integrated make facility for assembling, compiling, and linking your embedded applications,
True integrated source-level Debugger with high-speed CPU and peripheral simulator,
Advanced GDI interface for software debugging in the target hardware and for connection to
Keil ULINK,
Flash programming utility for downloading the application program into Flash ROM,
The Vision3 IDE offers numerous features and advantages that help you quickly and successfully
develop embedded applications. They are easy to use and are guaranteed to help you achieve your
design goals.
The Vision3 IDE and Debugger is the central part of the Keil development toolchain. Vision3
offers a Build Mode and a Debug Mode.
In the Vision3 Build Mode you maintain the project files and generate the application.
In the Vision3 Debug Mode you verify your program either with a powerful CPU and peripheral
simulator or with the Keil ULINK USB-JTAG Adapter (or other AGDI drivers) that connect the
debugger to the target system. The ULINK allows you also to download your application into Flash
ROM of your target system.
The
Vision3
Device
Database
automatically configures the development
tools for the target microcontroller.
Build Mode: Allows you to translate all the application files and to generate executable
programs. The features of the Build Mode are described under Creating Applications.
Debug Mode: Provides you with a powerful debugger for testing your application. The Debug
Mode is described in Testing Programs.
In both operating modes you may use the source editor of Vision3 to modify your source code. The
Debug mode adds additional windows and stores an own screen layout. The following picture shows a
typical configuration of Vision3 in the Debug Mode.
The tabs of the Output Window provides: Build messages and fast error access; Debug
Command input/output console; Find in Files results with quick file access.
The Memory Window gives access to the memory areas in display various formats.
The Watch & Call Stack Window allows you to review and modify program variables and
displays the current function call tree.
The Workspace is used for the file editing, disassembly output, and other debug information.
The Peripheral Dialogs help you to review the status of the on-chip peripherals in the
microcontroller.
Create a project, select the target chip from the device database, and configure the tool
settings.
2.
3.
4.
5.
The following block diagram illustrates the complete Vision3 software development cycle. Each
component is described below.
Vision3 IDE
The Vision3 IDE combines project management, a rich-featured editor with interactive error
correction, option setup, make facility, and on-line help. Use Vision3 to create your source files and
organize them into a project that defines your target application. Vision3 automatically compiles,
assembles, and links your embedded application and provides a single focal point for your
development efforts.
Library Manager
The library manager allows you to create object library from the object files created by the compiler
and assembler. Libraries are specially formatted, ordered program collections of object modules that
may be used by the linker at a later time. When the linker processes a library, only those object
modules in the library that are necessary to create the program are used.
Linker/Locator
The Linker/Locator creates an executable program file using the object modules extracted from
libraries and those created by the compiler and assembler. An executable program file (also called
absolute object module) contains no relocatable code or data. All code and data reside at fixed
memory locations.
This executable program file may be used:
Vision3 Debugger
The Vision3 symbolic, source-level debugger is ideally suited for fast, reliable program debugging.
The debugger includes a high-speed simulator that let you simulate an microcontroller system
including on-chip peripherals and external hardware. The attributes of the chip you use are
automatically configured when you select the device from the Device Database.
The Vision3 Debugger provides several ways for you to test your programs on real target hardware.
Use the Keil ULINK USB-JTAG adapter for Flash downloading and software test of your
program via on-chip debugging system like the Embedded ICE macro cell that is integrated in
many ARM devices.
Use the AGDI interface to attach use the Vision3 Debugger front end with your target system
using other debuggers like Monitor, In-System Debugger, or Emulator.
Shortcu
t
New
Ctrl+N
Open
Ctrl+O
Close
Closes the active file.
Save
Ctrl+S
Save
as...
Save
All
Saves all open source and text files including the project.
Device Database
Opens the Device Database Dialog where you may maintain the Vision3 Device Database.
License Management
Opens the License Management Dialog where you may maintain and review the installed
software components.
Setup...
Ctrl+P
Preview
Exit
Exits Vision3 and prompts to save any files that are open.
Flash Menu
The Flash menu allows you to configure and run Flash Programming Utilities. With Configure Flash
Tools the programming tool is selected and configured. For details refer to Configure Flash Menu.
Menu Item
Download
Downloads program to Flash using the programming utility configured under Options for
Target Utilities.
Erase
Erases the Flash ROM (only available for some devices).
Shortcu
t
Configure
Flash
Tools...
Opens the Options for Target Utilities dialog where you may configure the Flash
Utilities.
Status Bar
The Status Bar shown at button of the screen (when enabled in the View Menu) displays messages
and information about the current Vision command and other status information as explained below:
Debug Channel shows the active debug tool and displays the name of the Advanced GDI Driver or
Simulation when the program is tested with build-in Vision Simulator.
Execution Time displays time information during simulation. Right click on execution time to set
marks for timing analysis.
Cursor Position shows the position in the current editor file (L: line number, C: column number).
Editor and Keyboard Status Information displays:
OVR: indicates the overtype editor mode that replaces characters as you type. By default
characters are inserted when you type. The Insert key toggles between overtype and
standard mode.
R/W or R/O: the current editor file attribute. R/W full read/write access. R/O read-only
access which prevents from text modifications.
Using Debugger
The Vision3 Debugger simulates up to 4GB (Giga Bytes) of memory from which areas can be
mapped for read, write, or code execution access. The Vision3 simulator traps and reports
illegal memory accesses.
In addition to memory mapping, the simulator also provides support for the integrated
peripherals of the various ARM based microcontroller devices. The on-chip peripherals of the
CPU you have selected are configured from the Device Database selection you have made
when you create your project target. Refer to Start Vision3 and Create a Project File for more
information about selecting a device.
You may select and display the on-chip peripheral components using the Debug menu. You
can also change the aspects of each peripheral using the controls in the dialog boxes.
Breakpoints
Vision3 lets you define breakpoints in several different ways. You may already set Execution Breaks
during editing of your source text, even before the program code is translated. Breakpoints can be
defined and modified in the following ways:
With the File Toolbar buttons. Just select the code line in the Editor or Disassembly window
and click on the breakpoint buttons.
With the breakpoint commands in the local menu. The local menu opens with a right mouse
click on the code line in the Editor or Disassembly window.
The Debug Breakpoints dialog lets you review, define and modify breakpoint settings.
This dialog allows you to define also access breakpoints with different attributes. Refer to the
examples below.
In the Output Window Command page you can use the BreakSet, BreakKill, BreakList,
BreakEnable, and BreakDisable commands.
The Breakpoint dialog lets you view and modify breakpoints. You can quickly disable or enable the
breakpoints with a mouse click on the check box in the Current Breakpoints list. A double click in
the Current Breakpoints list allows you to modify the selected break definition.
You define a breakpoint by entering an Expression in the Breakpoint dialog. Depending on the
expression one of the following breakpoint types is defined:
When the expression is a code address, an Execution Break (E) is defined that becomes
active when the specified code address is reached. The code address must refer to the first
byte of a CPU instruction.
When a memory Access (Read, Write or both) is selected an Access Break (A) is defined that
becomes active when the specified memory access occurs. You can specify the size of the
memory access window in bytes or object size of the expression. Expressions for an Access
Break must reduce to a memory address and memory type. The operators (&, &&, <. <=. >,
>=, = =, and !=) can be used to compare the variable values before the Access Break halts
program execution or executes the Command.
When the expression cannot be reduced to an address a Conditional Break (C) is defined
that becomes active when the specified conditional expression becomes true. The conditional
expression is recalculated after each CPU instruction, therefore the program execution speed
may slow down considerably.
When you specify a Command for a breakpoint, Vision3 executes the command and resumes
executing your target program. The command you specify here may be a Vision3 debug or signal
function. To halt program execution in a Vision3 function, set the _break_ system variable. For more
information refer to System Variables.
The Count value specifies the number of times the breakpoint expression is true before the breakpoint
is triggered.
CPU Registers
The CPU registers are displayed and Project Workspace - Regs page. To modify a register value,
select the value with a mouse click and wait a second. Another mouse click or the F2 key starts the
edit mode.
Disassembly Window
The Disassembly window shows your target program as mixed
source and assembly program or just assembly code. A trace history of previously executed
instructions may be displayed with Debug View Trace Records. To enable the trace history, set
Debug Enable/Disable Trace Recording.
If you select the Disassembly Window as the active window all program step commands work on CPU
instruction level rather than program source lines. You can select a text line and set or modify code
breakpoints using toolbar buttons or the context menu commands.
You may use the dialog Debug Inline Assembly... to modify the CPU instructions. That allows you
to correct mistakes or to make temporary changes to the target program you are debugging.
Logic Analyzer
The Vision3 Logic Analyzer provides a graphical display for value changes of variables or VTREGs that
you specify.
The Logic Analyzer window contains in the top border several buttons and display fields.
The Setup... dialog defines variables for signal recording and configures the display output. Some
configuration settings may be also changed from the context menu that opens with a right click on the
signal name.
Export... writes the current recorded signals to a tab-delimited file for analysis with external tools.
The time fields show:
Max Time: End time of the signal recording buffer content (typically identical with the current
CPU time).
The Zoom buttons define the time range of the display. Zoom All shows the complete content of the
signal recording buffer. Zoom Sel changes the display to a selection that you have previously marked
with a mouse drag while holding down the Shift key.
Code Show opens the source or disassembly window at the code position that causes the signal
transition.
Setup Min/Max configures the display range of a signal. Auto configures the max. / min. values
based based on the values from the current recording. Undo restores the previous settings before
Auto.
To Logic Analyzer allows you to review change information using the following mouse and cursor
commands:
Set cursor line with a mouse click. The cursor line displays all variable values at the selected
time stamp.
Move cursor line to previous or next signal change with Left or Right cursor key. The signal
is selected with a mouse click in the left border.
Show detailed information by placing the mouse cursor near a signal change (the Logic
Analyzer snaps to the closes signal change). The information box shows the signal delta values
based on the current cursor line position.
Memory Window
The Memory window displays the contents of the various memory areas. Up to four different
areas can be review in the different pages. The context menu allows you to select the output
format.
In the Address field of the Memory Window, you can enter any expression that evaluates to a
start address of the area you want to display. To change the memory contents, double click on
a value. This opens an edit box that allows you to enter new memory values. To update the
memory window while a target program is running enable View Periodic Window Update.
Watch Window
The Watch Window lets you view and modify program variables and lists the current function call
nesting. The contents of the Watch Window are automatically updated whenever program execution
stops. You can enable View Periodic Window Update to update variable values while a target
program is running.
Variable Values
The Locals page shows all local function variables of the current function. The Watch pages display
user-specify program variables.
You can add variables in three different ways:
Select the text <type F2 to edit> with a mouse click and wait a second. Another mouse click
or the F2 key starts the edit mode that allows you to add variables. In the same way you can
modify existing variables.
In an editor window open the context menu with a right mouse click and use Add to Watch
Window. Vision3 automatically selects the variable name under the cursor position,
alternatively you may mark an expression before using that command.
In the Output Window Command page you can use the WatchSet command to enter
variable names.
To modify a variable value, select the value with a mouse click and wait a second. Another mouse click
or the F2 key starts the edit mode.
To remove a variable, click on the line and press the Delete key or use the WatchKill command.
Function Call Nesting
The Call Stack page shows that current function call nesting. In the Call Stack page you can double
click on a line to show the invocation an editor window.
Advantages:
using this new algorithm we can detect symptoms of driver fatigue early enough to avoid an
accident
Low cost.
Highly secure.
Applications: