Improved control and monitor two different PLC using LabVIEW and NI-OPC server IJECEIAES
This paper proposes an improved control and monitors between two different PLCs, the Mitsubishi, and Omron. The main advantage is interoperability and communication between both PLC. The use of NI OPC server as the software interface reached interoperability and communication. There were developed two field applications to test interoperability. Laboratory virtual instrument engineering workbench (LabVIEW) uses as the software application for creating the user interface to control and monitor. This improvement show OPC server technology solves data compatibility issue between different driver controller’s and reducing development cost. Regardless of whether there are more than two different PLCs, it's enough to use the NI OPC server. So the benefit of the NI OPC server is not limited to two types of PLC used right now but can also use the other manufacturers. Besides, the improvement of the previous study is the use of the LabVIEW makes data from the OPC server displayed more realistic. The use of LabVIEW allows additional monitoring functions, one of which is LabVIEW vision. Data utilization becomes more flexible, and so it can use for more complex purposes. It is envisaged that this is very useful for Integrator engineer to implement this method in industrial automation.
Improved control and monitor two different PLC using LabVIEW and NI-OPC server IJECEIAES
This paper proposes an improved control and monitors between two different PLCs, the Mitsubishi, and Omron. The main advantage is interoperability and communication between both PLC. The use of NI OPC server as the software interface reached interoperability and communication. There were developed two field applications to test interoperability. Laboratory virtual instrument engineering workbench (LabVIEW) uses as the software application for creating the user interface to control and monitor. This improvement show OPC server technology solves data compatibility issue between different driver controller’s and reducing development cost. Regardless of whether there are more than two different PLCs, it's enough to use the NI OPC server. So the benefit of the NI OPC server is not limited to two types of PLC used right now but can also use the other manufacturers. Besides, the improvement of the previous study is the use of the LabVIEW makes data from the OPC server displayed more realistic. The use of LabVIEW allows additional monitoring functions, one of which is LabVIEW vision. Data utilization becomes more flexible, and so it can use for more complex purposes. It is envisaged that this is very useful for Integrator engineer to implement this method in industrial automation.
Universal Serial Bus (USB) is an industry standard developed in the mid-1990s that defines the cables, connectors and communications protocols used in a bus for connection, communication, and power supply between computers and electronic devices.
This PDF serves as a practical guide to microprocessors and controllers for electrical engineering students at Sarvajanik College of Engineering and Technology (SCET GTU). It goes beyond theory, offering practical solutions and applications tailored to the SCET GTU curriculum.
This resource aims to equip students with the skills to implement and utilize microprocessors and controllers effectively in real-world electrical engineering projects.
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docxfelicidaddinwoodie
15LLP108_Demo4_LedBlinking.pdf
1. Introduction
In Demo3, we have learned how to read sensor values of light, temperature and humidity of a node
and output these values to the console. In this demonstration, we will use the code from Demo3 and
learn how to turn on/off the LEDs and make them blinking regularly on the sensor node XM1000,
meanwhile to count how many times the LED has blinked and output the count to the console.
2. Timer
In order to make the blue LED on the XM1000 sensor node to blink in every half second (i.e. On 0.5S
and Off 0.5S), we also need a timer. Follow the instructions in Demo3 for configure and reset a timer.
We aslo need to create an infinite while() loop so that it runs our functions repeatedly, such as
counting the times the LED has blinked, output the counter’s value and actually turn on or off the
LEDs to make it blinking.
Please follow timer and while() loop structure in Demo3.
3. LED Blinking
To get access to the LED functionalities in Contiki, we need to include the LED header file in the
source code:
#include "leds.h" // file is in directory /home/user/contiki/core/dev
After the process begin, we have to initialise the LEDs on the sensor node by calling the following
function:
leds_init(); // Initialise the LEDs
And finally we can turn on, off, or blink the LEDs by the following functions:
void leds_on(unsigned char leds);
void leds_off(unsigned char leds);
void leds_toggle(unsigned char leds);
void leds_invert(unsigned char leds);
For example, if you want to blink the Blue LED, yon need to call the toggle function as:
void leds_toggle(LEDS_BLUE); // Toggle the blue LED
4. Exercise
Modify the program from Demo3 with periodic timer to make the BLUE led blinking in every half
second, also to count the blinking times and output the counted number to the console.
Can your change the code so that the BLUE LED is lighted for 1 second and off for 0.5 second
periodically?
15LLP108 – Internet of Things and Applications
Lab Session 2: Demo 4 – LED Blinking
Prepared by Xiyu Shi
5. Source code
Here is the source code for reference
#include "contiki.h"
#include "leds.h"
#include <stdio.h> /* for printf() */
static struct etimer timer;
/*____________________________________________________*/
PROCESS(led_blinking_process, "LED Blinking Process");
PROCESS(LED_process, "LED process");
AUTOSTART_PROCESSES(&LED_process);
/*____________________________________________________*/
PROCESS_THREAD(LED_process, ev, data)
{
static int count = 0;
PROCESS_BEGIN();
etimer_set(&timer, CLOCK_CONF_SECOND/2); // 0.5S timer
leds_init(); // intialise the LEDs
while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev==PROCESS_EVENT_TIMER); // wait for timer event
count++; // count the blinking times
process_start(&led_blinking_process, NULL); // to blink the BLUE Led
printf("Count: %d\n", count); // output the counte ...
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docxketurahhazelhurst
CASE STUDY
Internet/Excel Exercises, page 434, text
Record your findings in a Word document and submit it online
IBM has substantial operations in many countries, including the United States, Canada, and Germany. Go to finance.yahoo.com/q?s=ibm.
1. Click on Historical Prices. (Or apply this exercise to a different MNC.) Set the date range so that you can obtain quarterly values of the U.S. stock index for the last 20 quarters. Insert the quarterly data on a spreadsheet. Compute the percentage change in IBM’s stock price for each quarter. Next go to finance.yahoo.com/stock-center/ and click (under U.S.) on S&P Composite 1500 Index, which represents the U.S. stock market index, so that you can derive the quarterly percentage change in the U.S. stock index over the last 20 quarters. Then run a regression analysis with IBM’s quarterly return (percentage change in stock price) as the dependent variable and the quarterly percentage change in the U.S. stock market’s value as the independent variable. (Appendix C explains how Excel can be used to run regression analysis.) The slope coefficient serves as an estimate of the sensitivity of IBM’s value to the U.S. market returns. Also, check the fit of the relationship based on the R-squared statistic.
2. Go to finance.yahoo.com/stock-center/ and click (under “Europe”) on DAX, which represents the German stock market index. Repeat the process described in exercise 1 so that you can assess IBM’s sensitivity to the German stock market. Compare the slope coefficient between the two analyses. Is IBM’s value more sensitive to the U.S. market or the German market? Does the U.S. market or the German market explain a higher proportion of the variation in IBM’s returns (check the R-squared statistic)? Offer an explanation of your results.
Lab 5 Database Security
Use the script from week 1 for the week 5 lab.
1. Create four new users
a. The first user will have full rights to the database
b. The second user grant access to the Client’s table and allow them the rights to INSERT data into the clients table
c. The third user grant rights to create user logins and reset passwords
d. The fourth user grant column rights to the Course_Activity table allow access to the Course Code and Grade column. Allow user to UPDATE a maximum of 5 times per hour.
2. Login with each user to demonstrate the rights you have given them
a. User 1 login and create a VIEW for user 2 that just displays the Client table
b. User 2 login and add 3 more clients to the Clients table
c. User 3 login create two new users
d. User 4 login and UPDATE two new entries for Course Code and Grade Column for Client 1 and 2
e. For each user run the Show Privileges command to show correct rights and permissions have been applied
3. Show Log Files: For each user show log files (since we do not have MySQL Enterprise we cannot use the Audit function but as a substitute we can use the built-in log file function)
4. Create a Stored Procedure with User ...
Universal Serial Bus (USB) is an industry standard developed in the mid-1990s that defines the cables, connectors and communications protocols used in a bus for connection, communication, and power supply between computers and electronic devices.
This PDF serves as a practical guide to microprocessors and controllers for electrical engineering students at Sarvajanik College of Engineering and Technology (SCET GTU). It goes beyond theory, offering practical solutions and applications tailored to the SCET GTU curriculum.
This resource aims to equip students with the skills to implement and utilize microprocessors and controllers effectively in real-world electrical engineering projects.
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docxfelicidaddinwoodie
15LLP108_Demo4_LedBlinking.pdf
1. Introduction
In Demo3, we have learned how to read sensor values of light, temperature and humidity of a node
and output these values to the console. In this demonstration, we will use the code from Demo3 and
learn how to turn on/off the LEDs and make them blinking regularly on the sensor node XM1000,
meanwhile to count how many times the LED has blinked and output the count to the console.
2. Timer
In order to make the blue LED on the XM1000 sensor node to blink in every half second (i.e. On 0.5S
and Off 0.5S), we also need a timer. Follow the instructions in Demo3 for configure and reset a timer.
We aslo need to create an infinite while() loop so that it runs our functions repeatedly, such as
counting the times the LED has blinked, output the counter’s value and actually turn on or off the
LEDs to make it blinking.
Please follow timer and while() loop structure in Demo3.
3. LED Blinking
To get access to the LED functionalities in Contiki, we need to include the LED header file in the
source code:
#include "leds.h" // file is in directory /home/user/contiki/core/dev
After the process begin, we have to initialise the LEDs on the sensor node by calling the following
function:
leds_init(); // Initialise the LEDs
And finally we can turn on, off, or blink the LEDs by the following functions:
void leds_on(unsigned char leds);
void leds_off(unsigned char leds);
void leds_toggle(unsigned char leds);
void leds_invert(unsigned char leds);
For example, if you want to blink the Blue LED, yon need to call the toggle function as:
void leds_toggle(LEDS_BLUE); // Toggle the blue LED
4. Exercise
Modify the program from Demo3 with periodic timer to make the BLUE led blinking in every half
second, also to count the blinking times and output the counted number to the console.
Can your change the code so that the BLUE LED is lighted for 1 second and off for 0.5 second
periodically?
15LLP108 – Internet of Things and Applications
Lab Session 2: Demo 4 – LED Blinking
Prepared by Xiyu Shi
5. Source code
Here is the source code for reference
#include "contiki.h"
#include "leds.h"
#include <stdio.h> /* for printf() */
static struct etimer timer;
/*____________________________________________________*/
PROCESS(led_blinking_process, "LED Blinking Process");
PROCESS(LED_process, "LED process");
AUTOSTART_PROCESSES(&LED_process);
/*____________________________________________________*/
PROCESS_THREAD(LED_process, ev, data)
{
static int count = 0;
PROCESS_BEGIN();
etimer_set(&timer, CLOCK_CONF_SECOND/2); // 0.5S timer
leds_init(); // intialise the LEDs
while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev==PROCESS_EVENT_TIMER); // wait for timer event
count++; // count the blinking times
process_start(&led_blinking_process, NULL); // to blink the BLUE Led
printf("Count: %d\n", count); // output the counte ...
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docxketurahhazelhurst
CASE STUDY
Internet/Excel Exercises, page 434, text
Record your findings in a Word document and submit it online
IBM has substantial operations in many countries, including the United States, Canada, and Germany. Go to finance.yahoo.com/q?s=ibm.
1. Click on Historical Prices. (Or apply this exercise to a different MNC.) Set the date range so that you can obtain quarterly values of the U.S. stock index for the last 20 quarters. Insert the quarterly data on a spreadsheet. Compute the percentage change in IBM’s stock price for each quarter. Next go to finance.yahoo.com/stock-center/ and click (under U.S.) on S&P Composite 1500 Index, which represents the U.S. stock market index, so that you can derive the quarterly percentage change in the U.S. stock index over the last 20 quarters. Then run a regression analysis with IBM’s quarterly return (percentage change in stock price) as the dependent variable and the quarterly percentage change in the U.S. stock market’s value as the independent variable. (Appendix C explains how Excel can be used to run regression analysis.) The slope coefficient serves as an estimate of the sensitivity of IBM’s value to the U.S. market returns. Also, check the fit of the relationship based on the R-squared statistic.
2. Go to finance.yahoo.com/stock-center/ and click (under “Europe”) on DAX, which represents the German stock market index. Repeat the process described in exercise 1 so that you can assess IBM’s sensitivity to the German stock market. Compare the slope coefficient between the two analyses. Is IBM’s value more sensitive to the U.S. market or the German market? Does the U.S. market or the German market explain a higher proportion of the variation in IBM’s returns (check the R-squared statistic)? Offer an explanation of your results.
Lab 5 Database Security
Use the script from week 1 for the week 5 lab.
1. Create four new users
a. The first user will have full rights to the database
b. The second user grant access to the Client’s table and allow them the rights to INSERT data into the clients table
c. The third user grant rights to create user logins and reset passwords
d. The fourth user grant column rights to the Course_Activity table allow access to the Course Code and Grade column. Allow user to UPDATE a maximum of 5 times per hour.
2. Login with each user to demonstrate the rights you have given them
a. User 1 login and create a VIEW for user 2 that just displays the Client table
b. User 2 login and add 3 more clients to the Clients table
c. User 3 login create two new users
d. User 4 login and UPDATE two new entries for Course Code and Grade Column for Client 1 and 2
e. For each user run the Show Privileges command to show correct rights and permissions have been applied
3. Show Log Files: For each user show log files (since we do not have MySQL Enterprise we cannot use the Audit function but as a substitute we can use the built-in log file function)
4. Create a Stored Procedure with User ...
Innoslate, a model-based systems engineering solution, was developed in 2013 and is used by thousands of engineers, analysts, and program managers today. We’re now making another major feature release with Innoslate 4.5. Innoslate users can now utilize project management features such as Kanban boards, branching and forking, calendar, and timeline diagrams!
Did we mention, this fall we’re also releasing a brand new MBSE tool specifically designed for Standard Operating Procedures? That’s right, Sopatra, uses Natural Language Processing to turn SOP text into executable models. Learn how you can reduce cost and risk, while increasing the success of your operations by using Sopatra’s unique algorithms.
Watch the presentation here: https://www.youtube.com/watch?v=lw-ge_ZHo6s
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
Saudi Arabia stands as a titan in the global energy landscape, renowned for its abundant oil and gas resources. It's the largest exporter of petroleum and holds some of the world's most significant reserves. Let's delve into the top 10 oil and gas projects shaping Saudi Arabia's energy future in 2024.
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
Student information management system project report ii.pdf
15EE51 - Microcontrollers Laboratory
1. MICROCONTROLLERS LABORATORY (15EE51) REPORT
JABEZ WINSTON C 15MU01
Microcontroller Laboratory report submitted in partial fulfilment of the requirements for the degree
of
MASTER OF ENGINEERING
Branch: ELECTRICAL AND ELECTRONICS ENGINEERING
EMBEDDED AND REAL TIME SYSTEMS
Of Anna University, Chennai.
December 2015
DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING
PSG COLLEGE OF TECHNOLOGY
(Autonomous Institution)
COIMBATORE – 641 004
2. TABLE OF CONTENTS
Ex.No Date Title of the Experiment
Page
No.
Signature of Staff
1 7-9-2015
INTRODUCTION TO KEIL µVISION IDE 1
Debug Windows and Dialogs 1
Working with Keil µVision IDE 3
Sample program for blinking LEDs 11
2 10-10-2015
ASSEMBLY LANGAGE PROGRAMMING IN 8051 14
Timers/Counters 14
Serial Communication 17
Interrupts 19
3 12-11-2015
C LANGUAGE PROGRAMMING IN 8051 22
Timers/Counters 22
Serial Communication 26
Interrupts 28
4 16-11-2015
INTERFACED HARDWARE WITH 8051 30
LED interfacing with Zkit-51 30
Buzzer interfacing with Zkit-51 31
LCD interfacing with Zkit-51 32
Matrix keypad interfacing with Zkit-51 35
3. TABLE OF FIGURES
Fig.No. Title of the Figure Page No.
1.1 Keil IDE showing the various Windows available 2
1.2 Creation of new project 3
1.3 ‘Create New Project’ Window 3
1.4 ‘Select Device for Target’ Window 4
1.5 Drop down Menu in Project Window 4
1.6 ‘Add New Item ‘ Dialog Box 5
1.7 Keil IDE with sample program 5
1.8 ‘View’ Drop down menu in Keil IDE 6
1.9 Logic Analyzer Setup 6
1.10 Logic Analyzer Window 7
1.11 Setup Performance Analyzer 7
1.12 Performance Analyzer Window 7
1.13 Register Window 8
1.14 Memory Window showing Code Memory 8
1.15 Memory Window showing Data Memory 8
1.16 Disassembly Window 9
1.17 Serial Window 9
1.18 Program having breakpoints at Line 4,11,13 10
1.19 ‘Flash’ Drop Down Menu in Keil IDE 10
1.20 ‘Options for Target’ Window 10
1.21 HEX file in Objects Folder 11
1.22 Contents of HEX file 11
1.23 LED Window 12
1.24 LED Setup 13
1.25 LED Window showing LEDs 13
2.1 Waveform at P1.5 14
2.2 Timer 1 registers 15
2.3 Waveform at P1.2 16
2.4 Counter output 16
2.5 Serial Communication 18
4. 2.6 Windows showing Interrupts and Serial Communication 20
3.1 Waveform at P1.5 22
3.2 Timer registers 23
3.3 Counter output 25
3.4 Serial Communication 27
3.5 External ,Timer and Serial Communication Interrupt 29
4.1 RED LED glowing when KEY1 is pressed 31
4.2 GREEN LED glowing when KEY2 is pressed 31
4.3 Two strings printed on LCD 35
4.4 Matrix keypad and 16 x 2 LCD display 38
5. 15EE51 – Microcontrollers Laboratory Page 1
1.INTRODUCTION TO KEIL µVISION IDE
Keil µVision IDE is a window-based software development platform for 8051 and ARM
microcontrollers that combines a robust and modern editor with a project manager and make facility
tool. It integrates all the tools needed to develop embedded applications including a C/C++ compiler,
macro assembler, linker/locator, and a HEX file generator.
µVision GUI
The µVision GUI provides menus for selecting commands and toolbars with command buttons. The
Status Bar, at the bottom of the window, displays information and messages about the current
µVision command. Windows can be relocated and docked to another physical screen. The window
layout is saved for each project automatically and restored the next time the project is used. You can
restore the default layout using the menu Window – Reset View to Defaults.
µVision has two operating modes, the Build Mode for creating applications and the Debug Mode for
analyzing applications, which offers additional Windows and Dialogs.
Debug Windows and Dialogs
µVision provides many debugging windows and dialogs. Some of them are
Breakpoints- Define stop conditions for program execution.
Code Coverage- Examine statistics about code execution, including branch testing.
Command Window- Enter and view executed commands.
Disassembly Window- Test programs at the level of assembly instructions.
Logic Analyzer - Investigate value changes of peripherals, registers, and variables on a time
graph.
Memory Map- Evaluate memory areas and their access rights.
Memory Window - Analyze and modify memory content.
Performance Analyzer - Evaluate time and call statistics on module or function level.
Registers Window- view and modify register content.
Serial Window is a communication interface between the application and the PC.
Status Bar - View debugging status information.
Symbols Window- Find debug symbol information used in program.
System Viewer Find peripheral register information and change property values at runtime.
Toolbox Use and define configurable buttons for executing debugging commands
interactively.
Ex. No. 1
07-09-2015
6. Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 2
Fig1.1:KeilIDEshowingthevariousWindowsavailable
7. Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 3
Working with Keil µVision IDE
Getting started…
1.OpenKeil µVision ,Click Project New µVision Project.
2.Type a name and save the project file
Fig.1.3
Fig.1.2:Creation of new project
8. Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 4
3.Select Device for target as AT89S51as shown in Fig. 1.4
Fig.1.4
4.Right click Source Group 1 and select Add new Item to Source Group 1
Fig.1.5
9. Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 5
Choose file type as ASM ,name the file and click Add
Fig. 1.6
5.Type the code ,press F7/Bulid icon and Ctrl+F5 / Debug icon
Fig.1. 7
In Debug mode various simulations can be done with variety of tools like Logic Analyzer, Performance
Analyzer,etc.,Register and Memory status can be viewed during execution.
Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 5
Choose file type as ASM ,name the file and click Add
Fig. 1.6
5.Type the code ,press F7/Bulid icon and Ctrl+F5 / Debug icon
Fig.1. 7
In Debug mode various simulations can be done with variety of tools like Logic Analyzer, Performance
Analyzer,etc.,Register and Memory status can be viewed during execution.
Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 5
Choose file type as ASM ,name the file and click Add
Fig. 1.6
5.Type the code ,press F7/Bulid icon and Ctrl+F5 / Debug icon
Fig.1. 7
In Debug mode various simulations can be done with variety of tools like Logic Analyzer, Performance
Analyzer,etc.,Register and Memory status can be viewed during execution.
10. Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 6
Logic Analyzer
To perform Logic Analysis,Click View Analysis WindowLogic Analyzer as shown in Fig 1.8
Fig. 1.8
The Logic Analyzer Window opens up.Click Setup and configure as shown below to observe waveform at P1.0
Fig. 9: Logic Analyzer Setup
11. Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 7
Output waveform will be displayed as
Fig. 1.10: Logic Analyzer
Performance Analyzer
To perform analysis of various parts of the program,Click View Analysis Window Performance
Analyzer
Click Setup and configure as follows
Fig. 1.11: Setup Performance Analyzer
Output of performance is shown. Average execution time of a function and various other parameters
are shown to pave way for optimization
Fig. 1.12: Performance Analyzer
Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 7
Output waveform will be displayed as
Fig. 1.10: Logic Analyzer
Performance Analyzer
To perform analysis of various parts of the program,Click View Analysis Window Performance
Analyzer
Click Setup and configure as follows
Fig. 1.11: Setup Performance Analyzer
Output of performance is shown. Average execution time of a function and various other parameters
are shown to pave way for optimization
Fig. 1.12: Performance Analyzer
Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 7
Output waveform will be displayed as
Fig. 1.10: Logic Analyzer
Performance Analyzer
To perform analysis of various parts of the program,Click View Analysis Window Performance
Analyzer
Click Setup and configure as follows
Fig. 1.11: Setup Performance Analyzer
Output of performance is shown. Average execution time of a function and various other parameters
are shown to pave way for optimization
Fig. 1.12: Performance Analyzer
12. Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 8
Register Window
Memory Window
To access Memory Window,Click View Memory Window Memory 1
We can view both code memory as well as data memory.
Code memory contains the opcodes.Data memory contains the contents of RAM.
To access code memory or data memory,use C: or D: followed by address.
Eg: C:0x00 D:0x00
Fig. 1.14 : Memory Window showing Code Memory
To access Register Window ,Click View
Register Window .
Register window displays the contents of
Accumulator A ,register B,registers from R0
to R7,Program Status Word(PSW),Data
Pointer(DPTR),Stack Pointer(SP),Program
counter(PC),etc.,This makes program
debugging easier
Fig. 1.13 : Register Window
Fig. 1.15 : Memory Window showing Data Memory
Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 8
Register Window
Memory Window
To access Memory Window,Click View Memory Window Memory 1
We can view both code memory as well as data memory.
Code memory contains the opcodes.Data memory contains the contents of RAM.
To access code memory or data memory,use C: or D: followed by address.
Eg: C:0x00 D:0x00
Fig. 1.14 : Memory Window showing Code Memory
To access Register Window ,Click View
Register Window .
Register window displays the contents of
Accumulator A ,register B,registers from R0
to R7,Program Status Word(PSW),Data
Pointer(DPTR),Stack Pointer(SP),Program
counter(PC),etc.,This makes program
debugging easier
Fig. 1.13 : Register Window
Fig. 1.15 : Memory Window showing Data Memory
Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 8
Register Window
Memory Window
To access Memory Window,Click View Memory Window Memory 1
We can view both code memory as well as data memory.
Code memory contains the opcodes.Data memory contains the contents of RAM.
To access code memory or data memory,use C: or D: followed by address.
Eg: C:0x00 D:0x00
Fig. 1.14 : Memory Window showing Code Memory
To access Register Window ,Click View
Register Window .
Register window displays the contents of
Accumulator A ,register B,registers from R0
to R7,Program Status Word(PSW),Data
Pointer(DPTR),Stack Pointer(SP),Program
counter(PC),etc.,This makes program
debugging easier
Fig. 1.13 : Register Window
Fig. 1.15 : Memory Window showing Data Memory
13. Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 9
Disassembly Window
Click View Disassembly Window.
Disassembly Window shows the opcodes for each instruction.
Fig. 1.16: Disassembly Window
Serial Window
Click View Serial Windows UART #1
This is useful for simulating Serial communication before downloading it to microcontroller.
Fig. 1.17 : Serial Window
Breakpoints
Program can be made to stop at a particular instruction so as to know the status of memory and
registers at that point.
To insert a breakpoint place on a particular line or instruction and press F9.Pressing F9 again will
remove the breakpoint.
Multiple breakpoints can be inserted and program will stop at breakpoints when run.
Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 9
Disassembly Window
Click View Disassembly Window.
Disassembly Window shows the opcodes for each instruction.
Fig. 1.16: Disassembly Window
Serial Window
Click View Serial Windows UART #1
This is useful for simulating Serial communication before downloading it to microcontroller.
Fig. 1.17 : Serial Window
Breakpoints
Program can be made to stop at a particular instruction so as to know the status of memory and
registers at that point.
To insert a breakpoint place on a particular line or instruction and press F9.Pressing F9 again will
remove the breakpoint.
Multiple breakpoints can be inserted and program will stop at breakpoints when run.
Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 9
Disassembly Window
Click View Disassembly Window.
Disassembly Window shows the opcodes for each instruction.
Fig. 1.16: Disassembly Window
Serial Window
Click View Serial Windows UART #1
This is useful for simulating Serial communication before downloading it to microcontroller.
Fig. 1.17 : Serial Window
Breakpoints
Program can be made to stop at a particular instruction so as to know the status of memory and
registers at that point.
To insert a breakpoint place on a particular line or instruction and press F9.Pressing F9 again will
remove the breakpoint.
Multiple breakpoints can be inserted and program will stop at breakpoints when run.
14. Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 10
Fig. 1.18 Program having breakpoints at Line 4,11 and 13
Generating HEX file
To download the compiled program into the 8051 ,HEX file needs to be generated.To generate HEX
file ,click Flash Configure Flash Tools
Fig. 1.19
A dialog box opens up.Click the Output tab and check in Create HEX fileoption.ClickOK.
Fig.1.20
15. Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 11
Press F7/Bulid icon . Generated HEX file can be found in the Objects folder
Fig. 1.21 : HEX file in Objects folder
Fig.1. 22:Contents of the HEX file
Writing a sample program for blinking 8 LEDs connected to PORT 1 of 8051 periodically in Keil µVision IDE….
Additional software required: DLL files for LED simulation ( LED_CONTROL.DLL and LED_DATABASE.CDB )
ALGORITHM:
1. Start
2. Load 0xFF to Port 1.
3. Call Delay routine.
4. Load 0x00 to Port 0.
5. Call Delay routine.
6. Goto Start
Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 11
Press F7/Bulid icon . Generated HEX file can be found in the Objects folder
Fig. 1.21 : HEX file in Objects folder
Fig.1. 22:Contents of the HEX file
Writing a sample program for blinking 8 LEDs connected to PORT 1 of 8051 periodically in Keil µVision IDE….
Additional software required: DLL files for LED simulation ( LED_CONTROL.DLL and LED_DATABASE.CDB )
ALGORITHM:
1. Start
2. Load 0xFF to Port 1.
3. Call Delay routine.
4. Load 0x00 to Port 0.
5. Call Delay routine.
6. Goto Start
Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 11
Press F7/Bulid icon . Generated HEX file can be found in the Objects folder
Fig. 1.21 : HEX file in Objects folder
Fig.1. 22:Contents of the HEX file
Writing a sample program for blinking 8 LEDs connected to PORT 1 of 8051 periodically in Keil µVision IDE….
Additional software required: DLL files for LED simulation ( LED_CONTROL.DLL and LED_DATABASE.CDB )
ALGORITHM:
1. Start
2. Load 0xFF to Port 1.
3. Call Delay routine.
4. Load 0x00 to Port 0.
5. Call Delay routine.
6. Goto Start
16. Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 12
PROGRAM:
ORG 0x0000
START:MOV P1,#0xFF
ACALL DELAY
MOV P1,#0x00
ACALL DELAY
AJMP START
DELAY:MOV R0,#0xFF
L2:MOV R1,#0xFF
L1:DJNZ R1,L1
DJNZ R0,L2
RET
SIMULATION:
Create a new project , add a new assembly file, type the above code and save it.
To simulate the blink LED program, we have to download DLL for LED control from Keil website.
Copy the LED_CONTROL.DLL and LED_DATABASE.CDB file to KeilC51BIN directory.
Add this line to [C51] section of Tools.ini in Keil directory.
AGSI2=LED_CONTROL.DLL ("LED simulation")
Restart Keil µVision IDE.
With the project open, press Ctrl+F5 to Enter debug mode.
Click Peripherals LED. The LED Window opens up.
Right Click and select add LED.New LED window opens up as shown in Fig. 1.23
Fig. 1.23
17. Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 13
Setup the pins for LED as shown in Fig 1.24
Fig. 1.24
Similarly do the same for P1.1 ,P1.2,….P1.7
Fig. 1.25
Press F5 to run the program.
RESULT:
Thus the development, debugging features of Keil µVision IDE were studied and a sample program for blinking
LED was executed.
Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 13
Setup the pins for LED as shown in Fig 1.24
Fig. 1.24
Similarly do the same for P1.1 ,P1.2,….P1.7
Fig. 1.25
Press F5 to run the program.
RESULT:
Thus the development, debugging features of Keil µVision IDE were studied and a sample program for blinking
LED was executed.
Introduction to Keil µVision IDE
15EE51 – Microcontrollers Laboratory Page 13
Setup the pins for LED as shown in Fig 1.24
Fig. 1.24
Similarly do the same for P1.1 ,P1.2,….P1.7
Fig. 1.25
Press F5 to run the program.
RESULT:
Thus the development, debugging features of Keil µVision IDE were studied and a sample program for blinking
LED was executed.
18. 15EE51 – Microcontrollers Laboratory Page 14
ASSEMBLY LANGUAGE PROGRAMMING IN 8051
A.Timers /Counters
AIM:
i. To operate the timer0 in mode 0 and generate square wave of 66 % duty cycle.
ii. To operate the timer1 in mode 2 and generate a delay of 100 µs.
iii. Count clock pulses on P3.4 (T0 pin) and put it on Port 2
PROGRAM:
i. For generating square wave of 66 % duty cyle using timer 0 in mode 0
L1:
SETB P1.5
ACALL DELAY1
CLR P1.5
ACALL DELAY2
SJMP L1
DELAY1:
MOV TH0,#0x00 ;8 bit TH0 value
MOV TL0,#0x00 ;5 bit TL0 value
SETB TR0 ;Start timer
L2: JNB TF0,L2 ;Poll TF0 flag
CLR TR0
CLR TF0
RET
DELAY2:
MOV TH0,#0x80 ;8 bit TH0 value
MOV TL0,#0x00 ;5 bit TL0 value
SETB TR0 ;Start timer
L3: JNB TF0,L3 ;Poll TF0 flag
CLR TR0
CLR TF0
RET
OUTPUT:
Figure 2.1 Waveform at P1.5
Ex No.2
10-10-2015
19. ASSEMBLY LANGUAGE PROGRAMMING IN 8051
15EE51 –Microcontrollers Laboratory Page 15
ii. To operate the timer1 in mode 2 and generate a delay of 100 µs.
PROGRAM:
MOV TMOD,#0x20 ;Timer 1 in 8 bit autoreload mode (mode 2)
MOV TH1,#-92 ;100 µs /1.085 µs = 92 , 11.0592MHz ==> 1.085 µs
LOOP:SETB P1.2
ACALL DELAY
CLR P1.2
ACALL DELAY
SJMP LOOP
DELAY:SETB TR1 ;Start timer 1
L1:JNB TF1,L1 ; Poll TF1 flag
CLR TF1
CLR TR1
RET
OUTPUT:
Figure 2.2 Timer 1 registers
20. ASSEMBLY LANGUAGE PROGRAMMING IN 8051
15EE51 –Microcontrollers Laboratory Page 16
Figure 2.3 Waveform at P1.2
iii. Count clock pulses on P3.5 (T0 pin) and put it on Port 2
PROGRAM:
MOV TMOD,#0x50 ; Counter 1 ,8 bit mode
MOV TH1,#0x00 ; Autoreload value
SETB P3.5
AGAIN:SETB TR1
BACK:MOV A,TL1
MOV P2,A
JNB TF1,BACK
CLR TR1
CLR TF1
SJMP AGAIN
OUTPUT:
Figure 2.4
21. ASSEMBLY LANGUAGE PROGRAMMING IN 8051
15EE51 –Microcontrollers Laboratory Page 17
B.Serial Communication
AIM:
To turn on and turn off LEDs connected at PORT 1 by using serial communication. If ‘y’ is sent LEDs are turned on
and if ‘n’ is sent LEDs are turned off.Acknowledgment messages are also end.
PROGRAM:
ORG 0x00
MOV TMOD,#0x20 ; Timer 1, 8 bit autoreload
MOV SCON,#0x50 ; 8 bit,1 stop bit,Receive enabled
MOV TH1,#-3 ; 9600 baud rate for 11.0592 MHz
SETB TR1
WAIT:JNB RI,WAIT ;Poll RI flag bit
MOV R0,SBUF
CLR RI
CJNE R0,#'y',C1 ;If ‘y’ turn on LED
MOV P1,#0x00
SJMP DISPLAY_ON
C1:CJNE R0,#'n',C2 ;If ‘n’ turn off LED
MOV P1,#0xFF
SJMP DISPLAY_OFF
C2:SJMP WAIT
STRING1:DB "LEDs ON",10,0
STRING2:DB "LEDs OFF",10,0
DISPLAY_ON:MOV DPTR,#STRING1
SJMP SEND
DISPLAY_OFF:MOV DPTR,#STRING2
SJMP SEND
SEND:CLR A
MOVC A,@A+DPTR
JZ WAIT
MOV SBUF,A ;Place character to be transmitted in SBUF
WT:JNB TI,WT ;Poll TI flag bit
CLR TI
INC DPTR
SJMP SEND
22. ASSEMBLY LANGUAGE PROGRAMMING IN 8051
15EE51 –Microcontrollers Laboratory Page 18
OUTPUT:
Figure 2.5 (a) Serial Communication
Figure 2.5 (b) Serial Communication
23. ASSEMBLY LANGUAGE PROGRAMMING IN 8051
15EE51 –Microcontrollers Laboratory Page 19
C.Interrupts
AIM:
To write a program for demonstrating external interrupt (edge triggered at P3.2) , timer overflow interrupt(Timer 0)
and serial communication interrupt.
PROGRAM:
ORG 0x0000 ;RESET INTERRUPT
LJMP MAIN
ORG 0x0003 ;EXTERNAL INTERRUPT 0
CPL P1.0
RETI
ORG 0x000B ;TIMER 0 OVERFLOW INTERRUPT
CPL P1.1
RETI
ORG 0x0023 ;SERIAL COMMUNICATION INTERRUPT
LJMP SERIAL_ISR
ORG 0x0030
MAIN:
MOV SCON,#0x50
MOV IE,#0x93 ;ENABLE EXT ,TIMER 0 , SERIAL INTERRUPT
MOV TMOD,#0x22
MOV TH0,#0x00
MOV TH1,#-3
SETB TR0
SETB TR1
SETB IT0 ;EDGE TRIGERRED EXT. INTERRUPT
HERE:SJMP HERE
SERIAL_ISR:
CLR RI
MOV R0,SBUF
CJNE R0,#'y',C1
MOV P2,#0x00
C1:CJNE R0,#'n',C2
MOV P2,#0xFF
C2:RETI
24. ASSEMBLY LANGUAGE PROGRAMMING IN 8051
15EE51 –Microcontrollers Laboratory Page 20
External interrupt toggles the LED connected with P1.0 , timer overflow interrupt will generate square wave P1.1
and serial interrupt for turning ON and OFF LEDs at Port 2
OUTPUT:
Figure 2.6(a) Windows showing Interrupts,Serial Communication
Figure 2.6(b) Windows showing Interrupts,Serial Communication
25. ASSEMBLY LANGUAGE PROGRAMMING IN 8051
15EE51 –Microcontrollers Laboratory Page 21
RESULT:
Thus programs for Timers/Counters, Serial Communication and Interrupts were written in assembly and
simulated using Keil µVision IDE.
26. 15EE51 – Microcontrollers Laboratory Page 22
A. Timers /Counters
AIM:
i. To operate the timer0 in mode 0 and generate square wave of 66 % duty cycle.
ii. To operate the timer1 in mode 2 and generate a delay of 100 µs.
iii. Count clock pulses on P3.4 (T0 pin) and put it on Port 2
PROGRAM:
i. For generating square wave of 66 % duty cycle using timer 0 in mode 0
C CODE:
#include<reg51.h>
void delay1();
void delay2();
void main()
{
while(1)
{
P1|=(1<<5); //Set bit P1.5
delay1();
P1&=~(1<<5); //Clear bit P1.5
delay2();
}
}
void delay1()
{
TH0=0x00;
TL0=0x00;
TR0=1; //Start Timer 0
while(!TF0); //Poll TF0 flag
TR0=0;
TF0=0;
}
void delay2()
{
TH0=0x80;
TL0=0x00;
TR0=1; //Start Timer 0
while(!TF0); //Poll TF0 flag
TR0=0;
TF0=0;
}
C LANGUAGE PROGRAMMING IN 8051Ex No.3
12-11-2015
27. C PROGRAMMING IN 8051
15EE51 – Microcontrollers Laboratory Page 23
OUTPUT:
Figure 3.1 Waveform at P1.5
ii. To operate the timer1 in mode 2 and generate a delay of 100 µs.
C CODE:
#include<reg51.h>
void delay();
void main()
{
TH1=-92; // 100 µs/1.085 µs = 92 for 11.592 MHz
TMOD=0x20;
while(1)
{
P1|=(1<<2); //Set bit P1.2
delay();
P1&=~(1<<2); //Clear bit P1.3
delay();
}
}
void delay()
{
TR1=1;
while(!TF1); //Poll TF1 flag
TF1=0;
TR1=0;
}
28. C PROGRAMMING IN 8051
15EE51 – Microcontrollers Laboratory Page 24
OUTPUT:
Figure 3.2 (a) Timer registers
Figure 3.2 (b) Timer registers
iii. Count clock pulses on P3.5 (T0 pin) and put it on Port 2
C CODE:
#include<reg51.h>
void main()
{
TMOD=0x50; //Counter 1 ,Mode 1
TH1=0x00;
T0=1;
while(1)
{
TR1=1;
while(!TF1)
P2=TL1;
TR1=0;
TF1=0;
}
}
29. C PROGRAMMING IN 8051
15EE51 – Microcontrollers Laboratory Page 25
OUTPUT:
Figure 3.3 Counter output
30. C PROGRAMMING IN 8051
15EE51 – Microcontrollers Laboratory Page 26
B. Serial Communication
AIM:
To turn on and turn off LEDs connected at PORT 1 by using serial communication. If ‘y’ is sent LEDs are turned on
and if ‘n’ is sent LEDs are turned off.Acknowledgment messages ”LEDs ON” and “LEDs OFF” are also sent.
C CODE:
#include<reg51.h>
void Serial_Init();
void Serial_Str_Transmit(char *);
char Serial_Char_Receive();
void main()
{
char ch;
Serial_Init();
while(1)
{
ch=Serial_Char_Receive();
switch(ch)
{
case 'y':
P1=0x00;
Serial_Str_Transmit("LEDs ONn");
break;
case 'n':
P1=0xFF;
Serial_Str_Transmit("LEDs OFFn");
break;
}
}
}
void Serial_Init()
{
TMOD=0x20;
SCON=0x50;
TH1=-3; // 9600 baud rate for 11.0592 MHz
TR1=1;
}
char Serial_Char_Receive()
{
while(!RI); //Poll RI flag
RI=0; //Clear RI flag
return(SBUF);
}
31. C PROGRAMMING IN 8051
15EE51 – Microcontrollers Laboratory Page 27
void Serial_Str_Transmit(char *p)
{
while(*p!='0')
{
SBUF=*p;
while(!TI); //Poll TI flag
TI=0;
p++;
}
}
OUTPUT:
Figure 3.4 Serial Communication
32. C PROGRAMMING IN 8051
15EE51 – Microcontrollers Laboratory Page 28
C. Interrupts
AIM:
To write a program for demonstrating external interrupt (edge triggered at P3.2) , timer overflow interrupt(Timer 0)
and serial communication interrupt.
C CODE:
#include<reg51.h>
void Serial_Init();
void Interrupt_Init();
void Timer0_Init();
void main()
{
Serial_Init();
Interrupt_Init();
Timer0_Init();
while(1); // Wait forever
}
void Serial_Init()
{
TMOD=0x20;
SCON=0x50;
TH1=-3;
TR1=1;
}
void Interrupt_Init()
{
IE=0x93;
IT0=1;
}
void Timer0_Init()
{
TMOD|=0x02;
TR0=1;
}
void ext_int0(void) interrupt 0 //Ext.Interrupt 0
{
P1^=(1<<0);
}
void timer_int0(void) interrupt 1 //Timer interrupt 0
{
P1^=(1<<1);
}
33. C PROGRAMMING IN 8051
15EE51 – Microcontrollers Laboratory Page 29
void serial_int(void) interrupt 4 //Serial Interrupt
{
RI=0;
if(SBUF=='y')
P2=0x00;
if(SBUF=='n')
P2=0xFF;
}
External interrupt toggles the LED connected with P1.0 , timer overflow interrupt will generate square wave P1.1
and serial interrupt for turning ON and OFF LEDs at Port 2
OUTPUT:
Figure 3.5 External ,Timer and Serial Communication interrupt
RESULT:
Thus assembly and C programs for Timers/Counters, Serial Communication and Interrupts in 8051
microcontroller were written and simulated using Keil µVision IDE.
34. 15EE51 – Microcontrollers Laboratory Page 30
AIM:
i. To turn on only RED LED (P1.4) when key 1(P2.0) is pressed and turn only GREEN LED(P1.5)
when key 2(P2.1) is pressed
ii. To produce a single beep sound when key 1 is pressed and a double beep sound when key 2 is
pressed.
iii. To interface HD44780 compatible 16 × 2 LCD display in 8 bit mode.
iv. To interface a 4 × 4 Matrix keypad.
PROGRAM:
i. To write a program to turn on only RED LED (P1.4) when key 1(P2.0) is pressed and turn only
GREEN LED(P1.5) when key 2(P2.1) is pressed.
#include<reg51.h>
sbit RED =P1^4;
sbit GREEN =P1^5;
sbit KEY1=P2^0;
sbit KEY2=P2^1;
void main()
{
while(1)
{
if(!KEY1)
{
RED=0;
GREEN=1;
}
if(!KEY2)
{
RED=1;
GREEN=0;
}
}
4. INTERFACING HARDWARE WITH 8051
Ex No : 4
16-11-15
35. INTERFACING HARDWARE WITH 8051
15EE51 – Microcontrollers Laboratory Page 31
OUTPUT:
ii. To produce a beep sound when key 1 is pressed and a beep sound twice when key 2 is
pressed.
#include <reg51.h>
void beep();
void delay_ms(int d);
sbit BUZZER = P3^4;
void main()
{
while(1)
{
if(!KEY1)
{
beep();
}
if(!KEY2)
{
beep();
delay_ms(200);
beep();
}
}
Fig 4.1 RED LED glowing when Key1 is pressed Fig 4.2 GREEN LED glowing when Key2 is pressed