Traffic Light Control
Traffic Light Control
Traffic Light Control
TRAFFIC
LIGHT CONTROL
Made by :
Shailesh Mittal 100805063
Shikha Khattar 100805065
Suresh Malhotra 100805071
Samarth Gulati 100805086
EIC 3rd yr
Contents
1. Introduction
2. Aim
3. Components used
4. Working
5. PIC
6. Pin diagram
7. Pin description
8. Power supply
1.Introduction ;
2.Aim:
4.Working :
1. Red and green LED’s glow for an interval of 10 sec each.
2. When the red of one lane glows correspondingly green of the other
lane glows .
3. Yellow of both the lanes glow simultaneously for 2 sec .
4. If one of the push buttons is pressed ( only during the red light i.e. the
vehicle crossed the traffic signal ) the camera takes a picture of that
vehicle number plate .( here camera is represented by a led)
5 . PIC
( Peripheral interface controller)
PICs are popular with both industrial developers and hobbyists alike due to their
low cost, wide availability, large user base, extensive collection of application
notes, availability of low cost or free development tools, and serial programming
(and re-programming with flash memory) capability.
Microchip announced on February 2008 the shipment of its six billionth PIC
processor.
Core architecture
Separate code and data spaces (Harvard architecture) for devices other
than PIC32, which has a Von Neumann architecture.
A small number of fixed length instructions
Most instructions are single cycle execution (2 clock cycles, or 4 clock
cycles in 8bit models), with one delay cycle on branches and skips
One accumulator (W0), the use of which (as source operand) is implied
(i.e. is not encoded in the opcode)
All RAM locations function as registers as both source and/or destination
of math and other functions.
A hardware stack for storing return addresses
A fairly small amount of addressable data space (typically 256 bytes),
extended through banking
Data space mapped CPU, port, and peripheral registers
The program counter is also mapped into the data space and writable (this
is used to implement indirect jumps).
There is no distinction between memory space and register space because the
RAM serves the job of both memory and registers, and the RAM is usually just
referred to as the register file or simply as the registers.
External data memory is not directly addressable except in some high pin count
PIC18 devices.
Code space
The code space is generally implemented as ROM, EPROM or flash ROM. In
general, external code memory is not directly addressable due to the lack of an
external memory interface. The exceptions are PIC17 and select high pin count
PIC18 devices.[5]
Word size
All PICs handle (and address) data in 8-bit chunks. However, the unit of
addressability of the code space is not generally the same as the data space. For
example, PICs in the baseline and mid-range families have program memory
addressable in the same wordsize as the instruction width, i.e. 12 or 14 bits
respectively. In contrast, in the PIC18 series, the program memory is addressed
in 8-bit increments (bytes), which differs from the instruction width of 16 bits.
Stacks
PICs have a hardware call stack, which is used to save return addresses. The
hardware stack is not software accessible on earlier devices, but this changed
with the 18 series devices.
Hardware support for a general purpose parameter stack was lacking in early
series, but this greatly improved in the 18 series, making the 18 series
architecture more friendly to high level language compilers.
Instruction set
A PIC's instructions vary from about 35 instructions for the low-end PICs to over
80 instructions for the high-end PICs. The instruction set includes instructions to
perform a variety of operations on registers directly, the accumulator and a literal
constant or the accumulator and a register, as well as for conditional execution,
and program branching.
Some operations, such as bit setting and testing, can be performed on any
numbered register, but bi-operand arithmetic operations always involve W (the
accumulator), writing the result back to either W or the other operand register. To
load a constant, it is necessary to load it into W before it can be moved into
another register. On the older cores, all register moves needed to pass through
W, but this changed on the "high end" cores.
PIC cores have skip instructions which are used for conditional execution and
branching. The skip instructions are 'skip if bit set' and 'skip if bit not set'.
Because cores before PIC18 had only unconditional branch instructions,
conditional jumps are implemented by a conditional skip (with the opposite
condition) followed by an unconditional branch. Skips are also of utility for
conditional execution of any immediate single following instruction.
Performance
The architectural decisions are directed at the maximization of speed-to-cost
ratio. The PIC architecture was among the first scalar CPU designs, and is still
among the simplest and cheapest. The Harvard architecture—in which
instructions and data come from separate sources—simplifies timing and
microcircuit design greatly, and this benefits clock speed, price, and power
consumption.
The PIC instruction set is suited to implementation of fast lookup tables in the
program space. Such lookups take one instruction and two instruction cycles.
Many functions can be modeled in this way. Optimization is facilitated by the
relatively large program space of the PIC (e.g. 4096 x 14-bit words on the
16F690) and by the design of the instruction set, which allows for embedded
constants. For example, a branch instruction's target may be indexed by W, and
execute a "RETLW" which does as it is named - return with literal in W.
Advantages
The PIC architectures have these advantages:
Limitations
The PIC architectures have these limitations:
One accumulator
Register-bank switching is required to access the entire RAM of many
devices
Operations and registers are not orthogonal; some instructions can
address RAM and/or immediate constants, while others can only use the
accumulator
The following limitations have been addressed in the PIC18 series, but still apply
to earlier cores:
Stack:
With paged program memory, there are two page sizes to worry about: one for
CALL and GOTO and another for computed GOTO (typically used for table
lookups). For example, on PIC16, CALL and GOTO have 11 bits of addressing,
so the page size is 2048 instruction words. For computed GOTOs, where you
add to PCL, the page size is 256 instruction words. In both cases, the upper
address bits are provided by the PCLATH register. This register must be
changed every time control transfers between pages. PCLATH must also be
preserved by any interrupt handler.[7]
Compiler development
While several commercial compilers are available, in 2008, Microchip released
their own C compilers, C18 and C30, for the line of 18F 24F and 30/33F
processors. By contrast, Atmel's AVR microcontrollers—which are competitive
with PIC in terms of hardware capabilities and price, but feature a more
traditional instruction set—have long been supported by the GNU C Compiler.
The easy to learn RISC instruction set of the PIC assembly language code can
make the overall flow difficult to comprehend. Judicious use of
simple macros can increase the readability of PIC assembly language. For
example, the original Parallax PIC assembler ("SPASM") has macros which hide
W and make the PIC look like a two-address machine. It has macro instructions
like "mov b, a" (move the data from address a to address b) and "add b, a"
(add data from address a to data in address b). It also hides the skip instructions
by providing three operand branch macro instructions such as "cjne a, b,
dest" (compare a with b and jump to dest if they are not equal).
Programme
aextern sbit stline1;
extern sbit stline2;
extern sbit red1;
extern sbit red2;
void CAMERA0()
{
int i;
for(i=0;i<=2;i++)
{
PORTC=0xFF ;
Delay_ms(500); // 1/2 second delay
PORTC=0x00 ;
Delay_ms(500);
}
INTCON.B1 = 0x0;
}
void CAMERA1()
{
int i;
for(i=0;i<=4;i++)
{
PORTC=0xFF ;
Delay_ms(250); // 1/2 second delay
PORTC=0x00 ;
Delay_ms(250);
}
INTCON.B1 = 0;
}
void main(){
do {
INTCON = 0x90;
} while(1); // Endless loop
}
6. Pin diagram:
7.Pin description:
8. diagram of supply :
Here we are using 5V power supply with the help of 7805 regulator Ic.
LM 7805