How To Interface Simple Tra C Controller Module With P89v51RD2?
How To Interface Simple Tra C Controller Module With P89v51RD2?
Introduction: When you decide to interface Traffic controller module with P89v51RD2 microcontroller, we have to understand two things, first you should know how
to burn code in P89v51RD2 microcontroller. This microcontroller is having serial programming facility. Normal ATMEL 8051 microcontroller which is cheaper in
market but you cannot program via serial cable or using Flashmagic Utility. You need EPROM programmer for that. Second, you should know how to create HEX file
code using Keil version 2 cross compiler.
Nowadays Intel stop manufacturing 8051 microcontroller. Some other companies are manufacturing 8051 microcontroller. This 8 bit microcontroller market is so
huge, you will find more than 100 different 8051 microcontroller. Recently I was moving in Lamgigton Road market of Mumbai for P89v51RD2FN or BN, someone
told me Philips (NXP) stopped manufacturing this IC.
If you google, you will find on many websites. What is distinguish difference between normal Atmel 8051 and P89v51RD2? P89v51rd2 is having boot loader, flashmagic is knowing
address of this boot loader. Due to this bootloader, flash memory is easily programmable using Serial cable. We do not require some special voltage. If you are modifying code
many times then it is always good to use P89v51rd2 microcontroller.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
requirements and Logic
Requirement of experiment: a) 8051 kit and 12 V power supply and serial cable or Dongale to convert USB to serial port b)Traffic controller module with 12-16 burg
wires for interfacing.
Logic of Traffic controller: We know traffic signals and its meaning. We have Red light, Green Light and Yellow light.
Traffic lights alternate the right of way of road users by displaying lights of a standard color (red, yellow/amber, and green), using a universal color code.
1)Illumination of the green light allows traffic to proceed in the direction denoted,
2)Illumination of the yellow/amber light denoting, if safe to do so, prepare to stop short of the intersection, and
3)Illumination of the red signal prohibits any traffic from proceeding. Usually, the red light contains some orange in its hue, and the green light contains
some blue, for the benefit of people with red-green color blindness, and “green” lights in many areas are in fact blue lenses on a yellow light (which together
appear green).
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Table 1: Pin Assignment with 8051 and traffic module. Please assume that we are using separate traffic module. If you are using customized module, then you have
to change some Io line here and there.
Direction3_yellow = P1^1;//D2
NORTH Listen (yellow LED)
Direction1_yellow = P0^1;//D11
Listen (yellow LED)
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Direction2_green = P0^7;//D6
GO(Green LED)
Direction2_red = P0^5;//D4
STOP (red LED)
Fig1 shows circuit diagram of interfacing of Traffic module with 8051 microcontroller.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Above figure shows total 12 LEDs interfaced with microcontrollers. Table 1 shows IO lines of 8051 port lines and directions.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Below Fig2 shows actual module of Traffic controller. Its 20 pins are available to interface with I/O lines of 8051 microcontroller. You have to take care that 5V
should be provided to the Traffic controller module and common ground with 8051 board is reuired. In the diagram you can noticed that 20pin header is shown. You
can find out conection from backside of PCB also
You can notice Direction symbol on the traffic module, this is like MAP direction. For example, I want to control NORTH direction of traffic. I Have 3 LEDs, Green,
Yellow and Red. So GREEN LED you have to interface to P1.2, and YELLOW LED to P1.1 and RED LED to P1.0 Io lines. Similarly you can do for other direction.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Program logic is for these direction only.
Please type following code as source file in the Keil IDE version 2 screen and Save it as main.c and take care of reg51.h header file which will provide SFR details to
compiler.
Source Code
Main.c source code,
#include <Reg51.h>
#define OFF 0
#define ON 1
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
sbit Direction1_yellow = P0^1;//D11
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
sbit Direction4_green = P1^7;//D9
for(i=0;i<dtime;i++)
for(j=0;j<1275;j++);
void all_off()
Direction1_red = OFF;
Direction1_yellow = OFF;
Direction1_green = OFF;
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Direction2_red = OFF;
Direction2_yellow = OFF;
Direction2_green = OFF;
Direction3_red = OFF;
Direction3_yellow = OFF;
Direction3_green = OFF;
Direction4_red = OFF;
Direction4_yellow = OFF;
Direction4_green = OFF;
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
void Direction1()
Direction2_red = ON;
Direction3_red = ON;
Direction4_red = ON;
Direction1_red = OFF;
Direction1_green = ON;
MSDelayL(green_delay);
Direction1_green = OFF;
Direction1_yellow = ON;
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
MSDelayL(yellow_delay);
Direction1_yellow = OFF;
void Direction2()
Direction1_red = ON;
Direction3_red = ON;
Direction4_red = ON;
Direction2_red = OFF;
Direction2_green = ON;
MSDelayL(green_delay);
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Direction2_green = OFF;
Direction2_yellow = ON;
MSDelayL(yellow_delay);
Direction2_yellow = OFF;
void Direction3()
Direction1_red = ON;
Direction2_red = ON;
Direction4_red = ON;
Direction3_red = OFF;
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Direction3_green = ON;
MSDelayL(green_delay);
Direction3_green = OFF;
Direction3_yellow = ON;
MSDelayL(yellow_delay);
Direction3_yellow = OFF;
void Direction4()
Direction1_red = ON;
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Direction2_red = ON;
Direction3_red = ON;
Direction4_red = OFF;
Direction4_green = ON;
MSDelayL(green_delay);
Direction4_green = OFF;
Direction4_yellow = ON;
MSDelayL(yellow_delay);
Direction4_yellow = OFF;
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
void main(void)
all_off();
while(1)
Direction1();
Direction2();
Direction3();
Direction4();
Create HEX file and download HEX file using FlashMagic software and do not forgot to do common grounding of 8051 kit and traffic controller module.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
We are giving assembly listing also. You will find this little bit cryptic because this is taken from lst file. But you avoid memory location from Assembly listing. You
should not type memory locations if you want to prepare traffic.asm kind from below code.
We have tested this code on normal P89v51RD2 board with simple traffic controller module. Our cross compiler is Keil version 2 (Eval)
0000 L?0019:
; SOURCE LINE # 27
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
; SOURCE LINE # 28
; SOURCE LINE # 30
0004 E4 CLR A
0007 ?C0001:
0007 C3 CLR C
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
; SOURCE LINE # 31
000E E4 CLR A
0011 ?C0004:
0011 0B INC R3
0015 0A INC R2
0016 ?C0016:
001C ?C0003:
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
001C 0D INC R5
0020 0C INC R4
0021 ?C0017:
; SOURCE LINE # 32
0023 ?C0007:
0023 22 RET
; SOURCE LINE # 34
; SOURCE LINE # 35
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
; SOURCE LINE # 36
; SOURCE LINE # 37
; SOURCE LINE # 38
; SOURCE LINE # 40
; SOURCE LINE # 41
; SOURCE LINE # 42
; SOURCE LINE # 44
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
; SOURCE LINE # 45
; SOURCE LINE # 46
; SOURCE LINE # 48
; SOURCE LINE # 49
; SOURCE LINE # 50
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
; SOURCE LINE # 51
0018 22 RET
; SOURCE LINE # 53
; SOURCE LINE # 54
; SOURCE LINE # 55
; SOURCE LINE # 56
; SOURCE LINE # 57
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
; SOURCE LINE # 58
; SOURCE LINE # 60
; SOURCE LINE # 61
; SOURCE LINE # 62
; SOURCE LINE # 64
; SOURCE LINE # 65
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
0015 120000 R LCALL _MSDelayL
; SOURCE LINE # 66
; SOURCE LINE # 67
001A 22 RET
; SOURCE LINE # 69
; SOURCE LINE # 70
; SOURCE LINE # 71
; SOURCE LINE # 72
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
0002 D290 SETB Direction3_red
; SOURCE LINE # 73
; SOURCE LINE # 74
; SOURCE LINE # 76
; SOURCE LINE # 77
; SOURCE LINE # 78
; SOURCE LINE # 8
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
000F D286 SETB Direction2_yellow
; SOURCE LINE # 81
; SOURCE LINE # 82
; SOURCE LINE # 83
001A 22 RET
; SOURCE LINE # 85
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
; SOURCE LINE # 86
; SOURCE LINE # 87
; SOURCE LINE # 88
; SOURCE LINE # 89
; SOURCE LINE # 90
; SOURCE LINE # 92
; SOURCE LINE # 93
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
; SOURCE LINE # 94
; SOURCE LINE # 96
; SOURCE LINE # 97
; SOURCE LINE # 98
; SOURCE LINE # 99
001A 22 RET
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
0008 D297 SETB Direction4_green
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
; SOURCE LINE # 114
001A 22 RET
0003 ?C0013:
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
; SOURCE LINE # 121
In above code various comment lines are there. To save time of typing or to increase readability of code, you can remove commented lines.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Filed Under: Recent Articles
HAVE A QUESTION?
Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and
Electro-Tech-Online.com where you can get those questions asked and answered by your peers!
EDA BOARD
ELECTRO-TECH-ONLINE
FEATURED TUTORIALS
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Designing Open Loop Non – Isolated Buck Converter (Part 5/12)
Designing Close Loop Non-Isolated Boost Converter With Adjustable Output (Part 4/12)
Designing Open Loop Non-Isolated Boost Converter With Adjustable Output Voltage (Part 3/12)
Designing Closed Loop Non – Isolated Boost Converter SMPS (Part 2/12)
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
STAY UP TO DATE
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
RECENT ARTICLES
MOST POPULAR
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
555 timer circuit 8051 alarm Arduino atmega16 avr circuit clock computer connector dc motor display Electronic Part Electronic
Parts Fujitsu gsm ic infineontechnologies Intel invention IoT ir lcd ldr led maximintegratedproducts microchip Microchip Technology microchiptechnology
EDABOARD.COM DISCUSSIONS
ELECTRO-TECH-ONLINE.COM DISCUSSIONS
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Connect with Engineers Garage
Copyright © 2021 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD