The document discusses programming PIC microcontrollers and interfacing with various devices. It begins with an introduction to PIC16F877A microcontrollers and MPLAB IDE. It then describes several labs for interfacing with LEDs, LCDs, keypads, analog to digital converters, pulse width modulation, relays, GSM modules, I2C protocols, and real-time clocks. The labs provide code examples for blinking LEDs, displaying messages on LCDs, reading analog sensor values, controlling relays, sending and receiving GSM messages, using I2C communication, and working with real-time clocks.
The document is about a book titled "PIC microcontrollers for beginners, too!" that introduces microcontrollers and programming for PIC microcontrollers. It provides an overview of the book's contents which include introductions to microcontrollers and assembly language programming, descriptions of the PIC16F84 microcontroller and its instruction set, examples of assembly language programs, and tutorials on using the MPLAB programming environment and code samples. The book is intended for beginners to help them learn microcontroller fundamentals and get started with PIC microcontroller programming.
This document contains code for initializing and controlling a LCD display module connected to a PIC16F887 microcontroller. It defines macros for the LCD pins and functions for initializing the LCD, writing data, clearing the display, moving the cursor, and printing strings. The main program initializes the LCD, prints two strings to different rows, and loops continuously displaying them.
This document discusses analog to digital conversion and pulse width modulation.
It explains that analog signals from peripherals must be converted to digital signals the microcontroller can understand using an analog to digital converter (ADC). It also describes how pulse width modulation varies the duty cycle of a signal to control motor speed or other analog systems. Common applications like temperature measurement and motor control are provided as examples.
- The document describes the Multipilot 32, a flight controller board developed by LASER NAVIGATION.
- It has an ARM Cortex-M3 processor, 512KB flash memory, 64KB RAM, and interfaces for sensors, radios, motors and more.
- The board runs ChibiOS or VROS and supports projects like OpenPilot, AutoPilot and Paparazzi. It is compatible with many sensors, radios and brushless ESC/servos.
- Developers can use IDEs like CooCox, Eclipse, or commercial options, with libraries for sensor control, radio control and more.
- The Multipilot 32 is available for pre-
This document provides an overview of microcontroller architecture and assembly language programming. It discusses the following key points in 3 sentences:
The document introduces PIC microcontrollers and assembly language, noting that assembly language uses mnemonic instructions that must be translated to machine code by an assembler. It explains the assembling and linking process used to convert assembly code to machine code that can be burned into the PIC's program memory. Various PIC assembly language instructions are also described, including MOVLW, MOVWF, logic instructions, and bit manipulation instructions to set and clear bits on I/O ports.
Programming the Digital I/O Interface of a PIC microcontrollerCorrado Santoro
The document discusses the digital I/O interface of Microchip PIC18F microcontrollers. It explains that each pin can be programmed as an input or output. As an input, the pin can read logic high or low voltages to detect button presses or sensor signals. As an output, it can generate voltages to control LEDs or other devices. The document provides examples of connecting buttons, sensors, and LEDs to digital pins and programming the pins as inputs and outputs using configuration registers to read button states and toggle an LED.
The document summarizes the Multipilot 32 board, which is a flight controller board developed by Laser Navigation for UAV systems. It has an ARM Cortex-M3 processor and supports various sensors, ESCs, servos, and communication protocols. It can be used with various open source autopilot projects and is supported by an online community and commercial partners. It is available for pre-order at a price of $99 or €70.
The document discusses the architecture and assembly language programming of PIC18 microcontrollers. It covers topics such as:
- PIC18 microcontrollers use a Harvard architecture with separate memory for instructions and data. They have a program memory, data memory, I/O ports, and support devices like timers.
- The PIC18 architecture is based on an advanced RISC design. Key components include registers like WREG for temporary data storage. Special function registers and general purpose registers are used to access I/O ports and timers.
- Assembly language instructions like MOVLW, ADDLW, and MOVWF are used to move data between program memory, registers and I/O ports. The
The document is about a book titled "PIC microcontrollers for beginners, too!" that introduces microcontrollers and programming for PIC microcontrollers. It provides an overview of the book's contents which include introductions to microcontrollers and assembly language programming, descriptions of the PIC16F84 microcontroller and its instruction set, examples of assembly language programs, and tutorials on using the MPLAB programming environment and code samples. The book is intended for beginners to help them learn microcontroller fundamentals and get started with PIC microcontroller programming.
This document contains code for initializing and controlling a LCD display module connected to a PIC16F887 microcontroller. It defines macros for the LCD pins and functions for initializing the LCD, writing data, clearing the display, moving the cursor, and printing strings. The main program initializes the LCD, prints two strings to different rows, and loops continuously displaying them.
This document discusses analog to digital conversion and pulse width modulation.
It explains that analog signals from peripherals must be converted to digital signals the microcontroller can understand using an analog to digital converter (ADC). It also describes how pulse width modulation varies the duty cycle of a signal to control motor speed or other analog systems. Common applications like temperature measurement and motor control are provided as examples.
- The document describes the Multipilot 32, a flight controller board developed by LASER NAVIGATION.
- It has an ARM Cortex-M3 processor, 512KB flash memory, 64KB RAM, and interfaces for sensors, radios, motors and more.
- The board runs ChibiOS or VROS and supports projects like OpenPilot, AutoPilot and Paparazzi. It is compatible with many sensors, radios and brushless ESC/servos.
- Developers can use IDEs like CooCox, Eclipse, or commercial options, with libraries for sensor control, radio control and more.
- The Multipilot 32 is available for pre-
This document provides an overview of microcontroller architecture and assembly language programming. It discusses the following key points in 3 sentences:
The document introduces PIC microcontrollers and assembly language, noting that assembly language uses mnemonic instructions that must be translated to machine code by an assembler. It explains the assembling and linking process used to convert assembly code to machine code that can be burned into the PIC's program memory. Various PIC assembly language instructions are also described, including MOVLW, MOVWF, logic instructions, and bit manipulation instructions to set and clear bits on I/O ports.
Programming the Digital I/O Interface of a PIC microcontrollerCorrado Santoro
The document discusses the digital I/O interface of Microchip PIC18F microcontrollers. It explains that each pin can be programmed as an input or output. As an input, the pin can read logic high or low voltages to detect button presses or sensor signals. As an output, it can generate voltages to control LEDs or other devices. The document provides examples of connecting buttons, sensors, and LEDs to digital pins and programming the pins as inputs and outputs using configuration registers to read button states and toggle an LED.
The document summarizes the Multipilot 32 board, which is a flight controller board developed by Laser Navigation for UAV systems. It has an ARM Cortex-M3 processor and supports various sensors, ESCs, servos, and communication protocols. It can be used with various open source autopilot projects and is supported by an online community and commercial partners. It is available for pre-order at a price of $99 or €70.
The document discusses the architecture and assembly language programming of PIC18 microcontrollers. It covers topics such as:
- PIC18 microcontrollers use a Harvard architecture with separate memory for instructions and data. They have a program memory, data memory, I/O ports, and support devices like timers.
- The PIC18 architecture is based on an advanced RISC design. Key components include registers like WREG for temporary data storage. Special function registers and general purpose registers are used to access I/O ports and timers.
- Assembly language instructions like MOVLW, ADDLW, and MOVWF are used to move data between program memory, registers and I/O ports. The
Embedded system (Chapter 3) io_port_programmingIkhwan_Fakrudin
The document discusses input/output (I/O) ports programming for the PIC18F4550 microcontroller. It describes the 5 ports - PORTA, PORTB, PORTC, PORTD, and PORTE, identifying the number of pins in each port. It explains that many pins have dual roles, serving as both general I/O pins and alternate functions. The document outlines how to configure ports as inputs or outputs using TRIS, PORT, and LAT registers. It provides examples of initializing ports and accessing registers by bit or byte to control individual pins.
This document provides information about Microchip Technology, a manufacturer of microcontrollers and analog semiconductors. It discusses Microchip's headquarters and wafer fabrication facilities. It also lists some of Microchip's main competitors in the semiconductor industry. Additionally, it gives an overview of Microchip's microcontroller architectures like PIC and some key variants. It then presents a problem about designing a circuit to turn on an LED based on voltage levels. It provides information about analog to digital converters and how they work. Finally, it discusses the PIC12F683 microcontroller and some of its analog to digital converter registers used to read voltage levels.
This document provides an industrial internship report for work completed at DRDO (Defense Research & Development Organization) in India. The internship focused on studying the AVR Atmega16 microcontroller architecture and applying it in a general purpose circuit. The report includes an acknowledgment, abstract, background on DRDO and the host lab SAG, and a detailed section-by-section summary of the work completed on microcontrollers, embedded systems, and a comparison of microcontrollers and microprocessors.
The document discusses microcontrollers and the PIC16F877 microcontroller in particular. It provides the following key points:
- A microcontroller is a single-chip computer containing a processor, memory, and input/output peripherals. Microcontrollers can store and run user-written programs.
- The main parts of a microcontroller include a CPU, RAM, ROM, I/O lines, timers, and analog-to-digital and digital-to-analog converters.
- The PIC16F877 is chosen for its low cost, reliability, ease of use, and ability to perform a wide range of tasks using C language software.
The document discusses C programming for PIC microcontrollers. It covers the standard structure of a C program, including comments, header files, configuration bits, functions, and function bodies. It also discusses various C data types like unsigned char, signed char, unsigned int, and signed int. Examples are provided to illustrate how to use these data types and write C programs that toggle ports on a PIC microcontroller. The outcomes are for students to understand C programming languages for PIC18, the structure of C programs for PIC18, and common C data types used for PIC microcontrollers.
This document provides information about a lab manual for a Microcontrollers course. It includes:
1) An index listing 12 experiments covering assembly programming of 8051 microcontrollers and interfacing programs, along with MSP430 programming.
2) Syllabus details for the course outlining topics like data transfer, arithmetic, logic instructions, counters and interfacing modules.
3) Instructions for students on lab protocols and expectations.
4) Table of contents organizing the experiments and programs by topic and page numbers.
5) An introduction section describing 8051 architecture features and Keil μVision tools for programming.
The TramelBlaze Chip Specification document describes a system-on-chip (SOC) featuring a 16-bit processor, universal asynchronous receiver/transmitter (UART), and 8 pulse-width modulation (PWM) blocks. The SOC is designed to provide simple embedded control and includes blocks for the processor, UART, PWM controller, and reset synchronization. Verification confirmed basic UART transmission and PWM functionality as specified.
The document summarizes the pin configuration of the LPC2148 microcontroller. It has 45 GPIO pins across two ports, with Port 0 having 29 visible I/O pins and Port 1 having 16 visible pins. The microcontroller contains 19 different peripherals including USB D+ and D- lines, oscillator pins, RTC pins, ground pins, power supply pins, analog ground, analog power supply reference, and RTC power supply pin.
The P89V51RD2 is an 80C51 microcontroller with 64kB of Flash memory and 1kB of RAM. It has features like In-System Programming, In-Application Programming, and a choice of running at the standard 80C51 clock rate or twice the throughput at the same clock frequency in X2 mode. It includes ports, timers, serial interfaces, and low power modes.
The document provides an overview of the LPC214x microcontroller family from NXP Semiconductors, which features an ARM7 processor, on-chip flash memory, RAM, analog and digital peripherals like USB, SPI, I2C, and GPIO. It describes the memory architecture and maps as well as the system control block and various peripherals included in the MCU, such as timers, serial interfaces, and an ADC. The document also outlines programming and debugging tools available for the LPC214x family like in-system programming, an embeddedICE logic for debugging, and a trace macrocell for instruction tracing.
Chp5 pic microcontroller instruction set copymkazree
The document provides an outline and descriptions of the instruction set for PIC microcontrollers, including common instructions like MOVLW, ADDWF, ANDLW, CALL, RETURN, and SLEEP. It describes the functionality of each instruction, their operands, and how they affect status register bits. Examples are given to illustrate how each instruction works and the resulting register values.
Blinking Of LEDs On LPC2148 ARM 7 TDMIS Based MicrocontrollerOmkar Rane
This document describes an experiment to program an LED to blink at regular intervals using an LPC2148 microcontroller. It discusses the objectives, equipment, theory of operation including the microcontroller's bus structure, PLL, and peripherals. It provides the algorithm, sample code to blink an LED, and shows the output of the compiled hex file and blinking LED. The goal is to learn to interface and program the microcontroller's GPIO pins to control an LED.
This document provides an introduction to robotics and instructions for building a basic robot. It discusses the necessary software and hardware, including an MPLAB programming IDE, MPLAB C compiler, PIC18F2520 microprocessor data sheet, programming tool, prototype board, wires, resistors, capacitors, voltage regulator, LEDs, battery, and motor controller. It explains how to connect the PIC18 microprocessor, power circuit, and H-bridge motor controller. The document demonstrates code for turning on an LED, blinking an LED, and controlling motor direction. It discusses using delays to control timing and introduces using an infrared sensor to detect obstacles. In closing, it thanks the robotic club advisor and vice president for their support.
This document provides information about the features and architecture of the 8051 microcontroller. It describes the 8-bit CPU, 64K program memory, 64K data memory, 4K on-chip program memory, 128 bytes of on-chip data RAM, 32 I/O lines, two timers, UART serial communication, interrupt structure, and on-chip oscillator. It also covers the pin descriptions, registers, memory mapping, stack, I/O port programming, timers, and interrupts of the 8051. Finally, it discusses the instruction set groups for arithmetic, logical, data transfer, boolean, and program branching operations.
This document describes how to interface an LCD display with an Atmega 32 microcontroller. It provides details on the pin descriptions of a 16x2 LCD, how to send commands and data to the LCD by selecting the appropriate registers, a code example in C to initialize and write text to the LCD, and screenshots of the code running in Proteus simulation software displaying "AVR 32" and "Atmega32" on the LCD. It also lists common LCD display commands.
This document discusses Microchip PIC microcontrollers and their use in an electrocardiogram (ECG) device. It covers the internal architecture of PIC microcontrollers including memory organization, registers, oscillators, and analog-to-digital converters. Diagrams and examples are provided to explain how PIC microcontrollers function and can be programmed to acquire, process, and transmit ECG signal data.
The document discusses the ATmega16 microcontroller. It begins by explaining the differences between microprocessors and microcontrollers, and introduces the ATmega16 as a low-power 8-bit microcontroller based on AVR architecture. It then details the features of the ATmega16 including its pinout, registers, memory, and I/O ports. The document also provides examples of coding and interfacing the ATmega16, such as blinking an LED and using delay functions.
The document discusses interfacing I/O ports on the PIC16F84 microcontroller. It describes how to configure the ports as inputs or outputs using the TRIS registers and how to read from and write to the pins. It also covers interrupts, timers, serial communication, analog to digital conversion, and provides an example of a water temperature alarm system using these concepts.
The document discusses the 8051 microcontroller. It describes the basic components of the 8051 including 4K bytes of internal ROM, 128 bytes of internal RAM, four 8-bit I/O ports, two 16-bit timers/counters, and one serial interface. It also provides details on the block diagram, important pins like ports and serial interface pins, and how to connect an external clock source to the 8051.
This document describes the design of a softcore microcontroller called UMASS-core that is implemented in an FPGA. The UMASS-core is based on the Microchip PIC16F84 8-bit microcontroller architecture but adds some additional features. It is written in VHDL and synthesized for a Spartan3 FPGA. The goal is to provide designers flexibility to customize the microcontroller configuration while maintaining compatibility with PIC16F84 assembly code.
1. The document discusses embedded systems and Microchip PIC microcontrollers. It describes what embedded systems are and provides examples of application areas.
2. It explains the differences between microprocessors and microcontrollers, and discusses the architecture and features of Microchip's PIC microcontrollers.
3. The document provides an overview of programming PIC microcontrollers, including the instruction set, device structure, and basic circuit requirements.
A microcontroller is a computer system on a single chip that contains a processor core, memory, and programmable input/output peripherals. Microcontrollers are commonly used to control objects, processes, or events. They are often embedded in devices to control their functions. A microcontroller contains a CPU, RAM, ROM, flash memory, I/O ports, an ADC, and timers. Common microcontrollers include the Intel 8051, Atmel ATmega 16, and PIC microcontrollers. The microcontroller reads programmed instructions from flash memory and executes them via the CPU to control its I/O pins based on inputs.
Embedded system (Chapter 3) io_port_programmingIkhwan_Fakrudin
The document discusses input/output (I/O) ports programming for the PIC18F4550 microcontroller. It describes the 5 ports - PORTA, PORTB, PORTC, PORTD, and PORTE, identifying the number of pins in each port. It explains that many pins have dual roles, serving as both general I/O pins and alternate functions. The document outlines how to configure ports as inputs or outputs using TRIS, PORT, and LAT registers. It provides examples of initializing ports and accessing registers by bit or byte to control individual pins.
This document provides information about Microchip Technology, a manufacturer of microcontrollers and analog semiconductors. It discusses Microchip's headquarters and wafer fabrication facilities. It also lists some of Microchip's main competitors in the semiconductor industry. Additionally, it gives an overview of Microchip's microcontroller architectures like PIC and some key variants. It then presents a problem about designing a circuit to turn on an LED based on voltage levels. It provides information about analog to digital converters and how they work. Finally, it discusses the PIC12F683 microcontroller and some of its analog to digital converter registers used to read voltage levels.
This document provides an industrial internship report for work completed at DRDO (Defense Research & Development Organization) in India. The internship focused on studying the AVR Atmega16 microcontroller architecture and applying it in a general purpose circuit. The report includes an acknowledgment, abstract, background on DRDO and the host lab SAG, and a detailed section-by-section summary of the work completed on microcontrollers, embedded systems, and a comparison of microcontrollers and microprocessors.
The document discusses microcontrollers and the PIC16F877 microcontroller in particular. It provides the following key points:
- A microcontroller is a single-chip computer containing a processor, memory, and input/output peripherals. Microcontrollers can store and run user-written programs.
- The main parts of a microcontroller include a CPU, RAM, ROM, I/O lines, timers, and analog-to-digital and digital-to-analog converters.
- The PIC16F877 is chosen for its low cost, reliability, ease of use, and ability to perform a wide range of tasks using C language software.
The document discusses C programming for PIC microcontrollers. It covers the standard structure of a C program, including comments, header files, configuration bits, functions, and function bodies. It also discusses various C data types like unsigned char, signed char, unsigned int, and signed int. Examples are provided to illustrate how to use these data types and write C programs that toggle ports on a PIC microcontroller. The outcomes are for students to understand C programming languages for PIC18, the structure of C programs for PIC18, and common C data types used for PIC microcontrollers.
This document provides information about a lab manual for a Microcontrollers course. It includes:
1) An index listing 12 experiments covering assembly programming of 8051 microcontrollers and interfacing programs, along with MSP430 programming.
2) Syllabus details for the course outlining topics like data transfer, arithmetic, logic instructions, counters and interfacing modules.
3) Instructions for students on lab protocols and expectations.
4) Table of contents organizing the experiments and programs by topic and page numbers.
5) An introduction section describing 8051 architecture features and Keil μVision tools for programming.
The TramelBlaze Chip Specification document describes a system-on-chip (SOC) featuring a 16-bit processor, universal asynchronous receiver/transmitter (UART), and 8 pulse-width modulation (PWM) blocks. The SOC is designed to provide simple embedded control and includes blocks for the processor, UART, PWM controller, and reset synchronization. Verification confirmed basic UART transmission and PWM functionality as specified.
The document summarizes the pin configuration of the LPC2148 microcontroller. It has 45 GPIO pins across two ports, with Port 0 having 29 visible I/O pins and Port 1 having 16 visible pins. The microcontroller contains 19 different peripherals including USB D+ and D- lines, oscillator pins, RTC pins, ground pins, power supply pins, analog ground, analog power supply reference, and RTC power supply pin.
The P89V51RD2 is an 80C51 microcontroller with 64kB of Flash memory and 1kB of RAM. It has features like In-System Programming, In-Application Programming, and a choice of running at the standard 80C51 clock rate or twice the throughput at the same clock frequency in X2 mode. It includes ports, timers, serial interfaces, and low power modes.
The document provides an overview of the LPC214x microcontroller family from NXP Semiconductors, which features an ARM7 processor, on-chip flash memory, RAM, analog and digital peripherals like USB, SPI, I2C, and GPIO. It describes the memory architecture and maps as well as the system control block and various peripherals included in the MCU, such as timers, serial interfaces, and an ADC. The document also outlines programming and debugging tools available for the LPC214x family like in-system programming, an embeddedICE logic for debugging, and a trace macrocell for instruction tracing.
Chp5 pic microcontroller instruction set copymkazree
The document provides an outline and descriptions of the instruction set for PIC microcontrollers, including common instructions like MOVLW, ADDWF, ANDLW, CALL, RETURN, and SLEEP. It describes the functionality of each instruction, their operands, and how they affect status register bits. Examples are given to illustrate how each instruction works and the resulting register values.
Blinking Of LEDs On LPC2148 ARM 7 TDMIS Based MicrocontrollerOmkar Rane
This document describes an experiment to program an LED to blink at regular intervals using an LPC2148 microcontroller. It discusses the objectives, equipment, theory of operation including the microcontroller's bus structure, PLL, and peripherals. It provides the algorithm, sample code to blink an LED, and shows the output of the compiled hex file and blinking LED. The goal is to learn to interface and program the microcontroller's GPIO pins to control an LED.
This document provides an introduction to robotics and instructions for building a basic robot. It discusses the necessary software and hardware, including an MPLAB programming IDE, MPLAB C compiler, PIC18F2520 microprocessor data sheet, programming tool, prototype board, wires, resistors, capacitors, voltage regulator, LEDs, battery, and motor controller. It explains how to connect the PIC18 microprocessor, power circuit, and H-bridge motor controller. The document demonstrates code for turning on an LED, blinking an LED, and controlling motor direction. It discusses using delays to control timing and introduces using an infrared sensor to detect obstacles. In closing, it thanks the robotic club advisor and vice president for their support.
This document provides information about the features and architecture of the 8051 microcontroller. It describes the 8-bit CPU, 64K program memory, 64K data memory, 4K on-chip program memory, 128 bytes of on-chip data RAM, 32 I/O lines, two timers, UART serial communication, interrupt structure, and on-chip oscillator. It also covers the pin descriptions, registers, memory mapping, stack, I/O port programming, timers, and interrupts of the 8051. Finally, it discusses the instruction set groups for arithmetic, logical, data transfer, boolean, and program branching operations.
This document describes how to interface an LCD display with an Atmega 32 microcontroller. It provides details on the pin descriptions of a 16x2 LCD, how to send commands and data to the LCD by selecting the appropriate registers, a code example in C to initialize and write text to the LCD, and screenshots of the code running in Proteus simulation software displaying "AVR 32" and "Atmega32" on the LCD. It also lists common LCD display commands.
This document discusses Microchip PIC microcontrollers and their use in an electrocardiogram (ECG) device. It covers the internal architecture of PIC microcontrollers including memory organization, registers, oscillators, and analog-to-digital converters. Diagrams and examples are provided to explain how PIC microcontrollers function and can be programmed to acquire, process, and transmit ECG signal data.
The document discusses the ATmega16 microcontroller. It begins by explaining the differences between microprocessors and microcontrollers, and introduces the ATmega16 as a low-power 8-bit microcontroller based on AVR architecture. It then details the features of the ATmega16 including its pinout, registers, memory, and I/O ports. The document also provides examples of coding and interfacing the ATmega16, such as blinking an LED and using delay functions.
The document discusses interfacing I/O ports on the PIC16F84 microcontroller. It describes how to configure the ports as inputs or outputs using the TRIS registers and how to read from and write to the pins. It also covers interrupts, timers, serial communication, analog to digital conversion, and provides an example of a water temperature alarm system using these concepts.
The document discusses the 8051 microcontroller. It describes the basic components of the 8051 including 4K bytes of internal ROM, 128 bytes of internal RAM, four 8-bit I/O ports, two 16-bit timers/counters, and one serial interface. It also provides details on the block diagram, important pins like ports and serial interface pins, and how to connect an external clock source to the 8051.
This document describes the design of a softcore microcontroller called UMASS-core that is implemented in an FPGA. The UMASS-core is based on the Microchip PIC16F84 8-bit microcontroller architecture but adds some additional features. It is written in VHDL and synthesized for a Spartan3 FPGA. The goal is to provide designers flexibility to customize the microcontroller configuration while maintaining compatibility with PIC16F84 assembly code.
1. The document discusses embedded systems and Microchip PIC microcontrollers. It describes what embedded systems are and provides examples of application areas.
2. It explains the differences between microprocessors and microcontrollers, and discusses the architecture and features of Microchip's PIC microcontrollers.
3. The document provides an overview of programming PIC microcontrollers, including the instruction set, device structure, and basic circuit requirements.
A microcontroller is a computer system on a single chip that contains a processor core, memory, and programmable input/output peripherals. Microcontrollers are commonly used to control objects, processes, or events. They are often embedded in devices to control their functions. A microcontroller contains a CPU, RAM, ROM, flash memory, I/O ports, an ADC, and timers. Common microcontrollers include the Intel 8051, Atmel ATmega 16, and PIC microcontrollers. The microcontroller reads programmed instructions from flash memory and executes them via the CPU to control its I/O pins based on inputs.
The document provides information about PIC microcontrollers including their history, architecture, features, and programming. It discusses that PIC was developed in 1975 to improve I/O performance. Key points include:
- PIC uses Harvard architecture with separate memory for program and data.
- Features include baseline, mid-range, enhanced mid-range, and PIC18 models with varying complexity and peripherals.
- Programming involves setting I/O ports and individual pins as input or output using SFR registers like PORT, TRIS, and LAT.
- Timers can generate delays or count external events using internal or external clocks. Serial communication transfers data one bit at a time through a single pin.
The document provides an introduction to PIC microcontrollers. It discusses that PIC stands for Programmable Intelligent Computer and is a microcontroller with built-in memory, RAM, and modules like EEPROM and timers. PICs are popular due to their low cost, availability of development tools, small instruction set, and small size. The document outlines the different PIC architectures, families, speeds, and memory sizes. It provides details on the registers, peripherals like flash memory, RAM, EEPROM, I/O ports, and USART serial communication.
An embedded system is a combination of hardware and software designed for a specific task. It contains a microcontroller or microprocessor that executes programmed instructions. A microcontroller contains a CPU, memory, and programmable input/output peripherals on a single chip. The Atmega8 is an 8-bit AVR microcontroller developed by Atmel with 8KB of flash memory. It has ports that can be configured as inputs or outputs using data direction registers to interface with external devices like LEDs for blinking. Programming the microcontroller involves writing code, compiling it, and flashing the hex file onto the chip.
This document provides an introduction to PIC microcontrollers, including:
- An overview of PIC architecture and why they are popular
- Differences between Harvard and Von Neumann architectures used in PICs
- Variations in core architectures, memory sizes, and instruction sets across the PIC family
- Details on the features, memory, peripherals, and instruction set of the PIC16F877A microcontroller
- Examples of common PIC applications like an LED flasher and button reader
The document introduces how to create a basic "Hello World" project in MPLAB IDE using a PIC32 microcontroller. It describes setting up a new project, creating a source code file, adding code for digital output pins on ports A and B, compiling and running the code in the simulator. The code turns on LEDs connected to the ports by setting the pins as outputs and writing a 1 to the ports.
Overview of Microcontroller and ATMega32 microcontrollerRup Chowdhury
This presentation provides an overview of microcontrollers and the ATMega32 microcontroller. It defines a microcontroller as a small computer on a single chip that contains a CPU, memory, and programmable I/O. It describes the typical elements of a microcontroller including the processor, memory, I/O peripherals, ADC, DAC, and system bus. It then discusses features of the ATMega32 like its architecture, pins, applications, and special features. In closing, it thanks the audience for their time.
The document discusses using the Ready-for-PIC board and SDR libraries to interact with the board's peripherals. It covers initializing and using digital I/O lines, timers, and the analog-to-digital converter. The SDR library provides functions to easily initialize and control these components without needing in-depth knowledge of the microcontroller's registers. Interrupts from timers and other peripherals can also be handled using the library functions. Example code is provided to illustrate flashing LEDs using timers and reading pushbuttons.
1 PageAlarm Clock Design Using PIC18F45E.docxmercysuttle
1 | Page
Alarm Clock Design Using PIC18F45
ELEC 310
Submitted by: Maria AlKadhem
Contents
Detailed Specification: 2
Input: 2
LCD display: 2
Microcontroller: 4
Clocking Choice 5
Working theory: 5
Pin out of the device: 6
LCD interfacing: 6
Final comments: 7
Introduction:
The major purpose of the project is to get familiar with the PIC18FXX series microcontrollers. We are ought to design an alarm clock which will be able to display the time on an LCD as well as we can give input through the dip switches. The dip switches will be able to increment the hours and minutes. We will go through the detailed design a bit later in the document.
In order to implement the alarm clock we had to make external circuitry as well which was necessary for the following functions.
· Input
· Buzzer
· Display at LCD.
The pith of the alarm clock is to run the clock of MCU in counter mode. When the counter is set the MCU starts counting till the number and then when the threshold is generated the output signal is used to start a buzzer. At the same time there is an LCD used in the circuit which will be responsible for displaying the three things.
· Current time.
· Alarm time
· Remaining time.
For setting the alarm there are two DIP switches. One for adjusting the hours and other is used for adjusting the minutes. For clearing the alarm we simply will be pressing both at a time. The corresponding ports of the MCU will be used in the INPUT mode.Detailed Specification:
Let’s discuss the detailed specifications of this device.Input:
The input of the alarm clock consists of two DIP switches. One switch will be used for adjusting the hours. The second switch will be used for the adjustment of the minutes.
Each time a button is at high logic there will be an increase in the corresponding variable of alarm.
When both of the buttons are pressed there will be a reset of clock making the value to 0.0. It will be the off state of the clock as well.LCD display:
We are using a 16x 2 display screen which is of 16 pin. The device is TRULY LCD MODULE MTC-C162DPRN-2N. It is capable of displaying 16 characters in 2 lines at a time. Making overall 32 characters.
The pin Details are given below for the LCD module.
Pin NO. Symbol Level Description
1 VSS 0V Ground
2 VDD 5.0V Supply voltage for logic
3 VO --- Input voltage for LCD
4 RS H/L H : Data, L : Instruction code
5 R/W H/L H : Read mode, L : Write mode
6 E H, H →L Chip enable signal
7 DB0 H/L Data bit 0
8 DB1 H/L Data bit 1
9 DB2 H/L Data bit 2
10 DB3 H/L Data bit 3
11 DB4 H/L Data bit 4
12 DB5 H/L Data bit 5
13 DB6 H/L Data bit 6
14 DB7 H/L Data bit 7
15 NC --- No Connection
16 NC --- No Connection
The VSS is kept at ground.
Last 2 pins are not included in the design they are not used at all.
Microcontroller:
The selected microcontroller is PIC18F452 because of the following reasons.
This powerful 10 MIPS (100 nanosecond instruction execution) yet easy-to-program (only 77 single word instructio ...
The document introduces Microchip's 8-bit PIC microcontrollers and describes their families and features. It discusses the PIC10F/12F, PIC16F and PIC18F families and their applications. It also describes starter kits, development tools and additional resources for working with 8-bit PIC MCUs. Microchip offers low-cost hardware and software solutions to meet various application needs such as automating garden watering.
This document provides an overview of embedded systems and the AVR microcontroller. It discusses how embedded systems combine hardware and software to perform tasks like processing and storing data. Examples of embedded systems include those used in biotechnology, telecom, military, automotive, and consumer electronics. It then describes the AVR microcontroller, its features, memory segments, pin descriptions, and how to interface it with hardware using Embedded C. Code examples are provided to blink LEDs and interface with 7-segment displays and LCDs.
This presentation discusses an embedded system project to control a fan based on temperature. It includes:
- An overview of Skyphi Technologies, an organization that provides training in embedded systems and other domains.
- A definition of embedded systems and examples like ATMs, aircraft systems, and more.
- An introduction to the AVR microcontroller and its features like the ATmega8, programming tools, and pin diagram.
- Explanations of embedded C programming structure, I/O ports, registers, and programming the AVR microcontroller.
- Details of the temperature controlled fan project including components, working principle, circuit diagram, and code overview.
- Applications of the temperature controlled fan
STONE Tech is a manufacturer of HMI display modules (Intelligent TFT LCD). We provide LCD modules/LCD Displays, Graphic LCM, smart Display LCD, TFT LCM, Custom LCD Module Display, and LCD panels. china LCD Manufacturers.
This document provides an introduction to PIC microcontrollers. It discusses that PIC stands for "Programmable Intelligent Computer" and that a PIC microcontroller is a processor with built-in memory and RAM that can be used to control projects. It then lists some of the useful built-in modules of PIC microcontrollers like EEPROM, timers, and analog comparators. The document also discusses why PIC microcontrollers are popular, which includes their low cost, wide availability, and small size. It then provides details on the pins of the common PIC 16F84 microcontroller and describes its registers and peripherals. Finally, it gives a simple code example using ports on the PIC 16F84
This document provides an overview of using Python for embedded systems development on the Raspberry Pi and ESP32 microcontrollers. It discusses why Python is suitable, how to set up the Raspberry Pi and install an operating system. It also covers GPIO pin layout and functions, pulse width modulation (PWM), and installing MicroPython on the ESP32. The document recommends books and online courses for further learning about Python for embedded systems and microcontrollers.
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080Vivek Venugopal
This document proposes a novel four-port DC/DC converter topology for renewable energy applications. The proposed topology adds two switches and two diodes to a traditional half-bridge topology to interface two power sources, one bidirectional storage port, and one isolated load port. Zero-voltage switching is achieved for all four main switches. Three ports can be tightly regulated through independent duty cycles while the fourth is unregulated to maintain power balance. Experimental results confirm independent control over three processing paths with low component count and losses.
Pic16f877a microcontroller based projects list _ PIC Microcontroller.pdfIsmailkhan77481
This document provides a list of 38 PIC16F877A microcontroller-based projects, with brief descriptions of each. The projects include interfacing MATLAB with a PIC16F877 microcontroller via serial communication, creating a PIC development/testing board, generating PWM waves, emulating a PLC using the CI16F877A, communicating a PIC MCU with Python via serial, blinking LEDs using assembly language, creating a keyless car alarm, interfacing an LCD with the PIC16F877A, creating a 7-segment clock with temperature display using a DS18B20 sensor, designing a multimeter with the PIC16F877, setting up the CloudX microcontroller, creating
Este manual describe diferentes métodos para el diseño de sistemas electroneumáticos avanzados, incluyendo métodos directos, de bandera, cascada, paso a paso mínimo y máximo. Incluye secciones sobre secuencias, controles lógicos programables y diagnóstico de fallas. El documento proporciona ejemplos y ejercicios para aplicar estos métodos.
Este documento trata sobre controladores lógicos programables (PLC). Presenta una introducción a los PLC, incluyendo su concepto, ventajas, campos de aplicación, estructura y equipos de programación. También clasifica los diferentes tipos de PLC y describe su uso en tableros de control industrial.
El documento consiste en una lista repetida de la dirección web www.FreeLibros.com en más de 200 líneas consecutivas. Proporciona poca información sobre el contenido del sitio web, pero indica que la dirección www.FreeLibros.com es el tema principal del documento.
Este documento presenta una introducción a los controladores lógicos programables (PLCs). Explica que un PLC es un equipo que puede tomar información del mundo exterior, procesarla realizando operaciones lógicas y matemáticas, y ejecutar acciones programadas como respuesta. Describe los elementos básicos de un sistema PLC, incluyendo la unidad central de procesamiento, memoria, módulos de entrada y salida, y dispositivos de entrada y salida. También explica conceptos como el cableado de dispositivos de entrada como interruptores, sens
Este documento presenta una introducción a los autómatas programables (PLC), incluyendo su historia, ventajas e inconvenientes. Explica la estructura interna y externa de los PLC, sus áreas de memoria y modos de funcionamiento. Finalmente, resume las instrucciones básicas de programación para PLC como operadores lógicos, temporizadores, contadores y saltos.
The document is a system manual that provides information about installing, programming, and configuring S7-200 SMART CPUs and expansion modules, including an overview of the products, new features, communication options, and instructions for connecting to a CPU and creating a sample program.
Siemens' SIMATIC S7-200 SMART PLC offers an affordable and flexible automation solution for developing markets. It provides a range of CPU modules with integrated I/O and communication ports. Additional I/O and communication can be added via cost-effective signal boards. The PLC uses a high-speed processor and user-friendly software to provide powerful motion control, networking, and programming capabilities despite its low cost. It can be integrated with other Siemens products to create complete automation solutions for applications like packaging machines.
El documento describe diferentes métodos para variar la velocidad de motores eléctricos de corriente alterna de dos o tres velocidades, incluyendo el uso de dos bobinados independientes, la conexión Dahlander y variadores de frecuencia electrónicos. Se explican circuitos de potencia y mando para cada método y se proporcionan ejemplos de relaciones de velocidad que se pueden lograr.
PLC: Buses industriales y de campo practicas de laboratorio por Jose Miguel R...SANTIAGO PABLO ALBERTO
El documento trata sobre buses industriales y de campo. Contiene 16 prácticas sobre diferentes buses como Profibus, Interbus, DeviceNet, ControlNet, DH+ y RIO, Ethernet, MPI y AS-i utilizando equipos Siemens y Rockwell Automation. El autor es José Miguel Rubio Calin, ingeniero técnico industrial que ha desarrollado las prácticas para su uso en centros de formación.
PLC y Electroneumática: Electricidad y Automatismo eléctrico por Luis Miguel...SANTIAGO PABLO ALBERTO
Este documento trata sobre electricidad y automatismos eléctricos. Explica conceptos básicos como la generación, transporte y medición de la corriente eléctrica, así como los componentes pasivos como resistencias, bobinas y condensadores. También analiza circuitos eléctricos en corriente continua y alterna monofásica, incluyendo cálculos, leyes y métodos de resolución. Por último, introduce conceptos de electromagnetismo.
Electrónica: Diseño y desarrollo de circuitos impresos con Kicad por Miguel P...SANTIAGO PABLO ALBERTO
Este documento presenta un manual sobre el diseño y desarrollo de circuitos impresos utilizando el software libre Kicad. Explica conceptos básicos como footprints, pads, pistas, capas y librerías. Incluye instrucciones para la instalación de Kicad en Windows y Linux, y guías detalladas sobre la edición de esquemas, la creación de la placa de circuito impreso y el diseño de pistas.
PLC: Diseño, construcción y control de un motor doble Dahlander(cuatro veloci...SANTIAGO PABLO ALBERTO
Este documento describe las condiciones de uso de una tesis protegida por derechos de autor. Se requiere reconocer los derechos del autor y citarlo correctamente. No se puede usar la tesis con fines comerciales ni distribuirla sin permiso.
Este documento presenta información sobre la documentación técnica necesaria para proyectos de automatización. Explica que la documentación debe incluir planos de instalación, diagramas de bloques, esquemas de circuitos, diagramas y tablas, y planos de conexiones. Además, detalla normas para la documentación como IEC 61082 e IEC 60617 y proporciona detalles sobre la identificación de componentes a través de códigos normalizados.
Electrónica digital: Introducción a la Lógica Digital - Teoría, Problemas y ...SANTIAGO PABLO ALBERTO
Este documento presenta un libro sobre electrónica digital que introduce conceptos básicos de lógica digital como sistemas de numeración, representación de números, codificación de información, álgebra de conmutación y funciones lógicas básicas. El libro fue desarrollado por un equipo de 11 profesores e ingenieros de la Universidad Nacional de Educación a Distancia y está destinado a estudiantes de ingeniería eléctrica y electrónica.
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Sinan KOZAK
Sinan from the Delivery Hero mobile infrastructure engineering team shares a deep dive into performance acceleration with Gradle build cache optimizations. Sinan shares their journey into solving complex build-cache problems that affect Gradle builds. By understanding the challenges and solutions found in our journey, we aim to demonstrate the possibilities for faster builds. The case study reveals how overlapping outputs and cache misconfigurations led to significant increases in build times, especially as the project scaled up with numerous modules using Paparazzi tests. The journey from diagnosing to defeating cache issues offers invaluable lessons on maintaining cache integrity without sacrificing functionality.
Batteries -Introduction – Types of Batteries – discharging and charging of battery - characteristics of battery –battery rating- various tests on battery- – Primary battery: silver button cell- Secondary battery :Ni-Cd battery-modern battery: lithium ion battery-maintenance of batteries-choices of batteries for electric vehicle applications.
Fuel Cells: Introduction- importance and classification of fuel cells - description, principle, components, applications of fuel cells: H2-O2 fuel cell, alkaline fuel cell, molten carbonate fuel cell and direct methanol fuel cells.
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...IJECEIAES
Medical image analysis has witnessed significant advancements with deep learning techniques. In the domain of brain tumor segmentation, the ability to
precisely delineate tumor boundaries from magnetic resonance imaging (MRI)
scans holds profound implications for diagnosis. This study presents an ensemble convolutional neural network (CNN) with transfer learning, integrating
the state-of-the-art Deeplabv3+ architecture with the ResNet18 backbone. The
model is rigorously trained and evaluated, exhibiting remarkable performance
metrics, including an impressive global accuracy of 99.286%, a high-class accuracy of 82.191%, a mean intersection over union (IoU) of 79.900%, a weighted
IoU of 98.620%, and a Boundary F1 (BF) score of 83.303%. Notably, a detailed comparative analysis with existing methods showcases the superiority of
our proposed model. These findings underscore the model’s competence in precise brain tumor localization, underscoring its potential to revolutionize medical
image analysis and enhance healthcare outcomes. This research paves the way
for future exploration and optimization of advanced CNN models in medical
imaging, emphasizing addressing false positives and resource efficiency.
Advanced control scheme of doubly fed induction generator for wind turbine us...IJECEIAES
This paper describes a speed control device for generating electrical energy on an electricity network based on the doubly fed induction generator (DFIG) used for wind power conversion systems. At first, a double-fed induction generator model was constructed. A control law is formulated to govern the flow of energy between the stator of a DFIG and the energy network using three types of controllers: proportional integral (PI), sliding mode controller (SMC) and second order sliding mode controller (SOSMC). Their different results in terms of power reference tracking, reaction to unexpected speed fluctuations, sensitivity to perturbations, and resilience against machine parameter alterations are compared. MATLAB/Simulink was used to conduct the simulations for the preceding study. Multiple simulations have shown very satisfying results, and the investigations demonstrate the efficacy and power-enhancing capabilities of the suggested control system.
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...shadow0702a
This document serves as a comprehensive step-by-step guide on how to effectively use PyCharm for remote debugging of the Windows Subsystem for Linux (WSL) on a local Windows machine. It meticulously outlines several critical steps in the process, starting with the crucial task of enabling permissions, followed by the installation and configuration of WSL.
The guide then proceeds to explain how to set up the SSH service within the WSL environment, an integral part of the process. Alongside this, it also provides detailed instructions on how to modify the inbound rules of the Windows firewall to facilitate the process, ensuring that there are no connectivity issues that could potentially hinder the debugging process.
The document further emphasizes on the importance of checking the connection between the Windows and WSL environments, providing instructions on how to ensure that the connection is optimal and ready for remote debugging.
It also offers an in-depth guide on how to configure the WSL interpreter and files within the PyCharm environment. This is essential for ensuring that the debugging process is set up correctly and that the program can be run effectively within the WSL terminal.
Additionally, the document provides guidance on how to set up breakpoints for debugging, a fundamental aspect of the debugging process which allows the developer to stop the execution of their code at certain points and inspect their program at those stages.
Finally, the document concludes by providing a link to a reference blog. This blog offers additional information and guidance on configuring the remote Python interpreter in PyCharm, providing the reader with a well-rounded understanding of the process.
Comparative analysis between traditional aquaponics and reconstructed aquapon...bijceesjournal
The aquaponic system of planting is a method that does not require soil usage. It is a method that only needs water, fish, lava rocks (a substitute for soil), and plants. Aquaponic systems are sustainable and environmentally friendly. Its use not only helps to plant in small spaces but also helps reduce artificial chemical use and minimizes excess water use, as aquaponics consumes 90% less water than soil-based gardening. The study applied a descriptive and experimental design to assess and compare conventional and reconstructed aquaponic methods for reproducing tomatoes. The researchers created an observation checklist to determine the significant factors of the study. The study aims to determine the significant difference between traditional aquaponics and reconstructed aquaponics systems propagating tomatoes in terms of height, weight, girth, and number of fruits. The reconstructed aquaponics system’s higher growth yield results in a much more nourished crop than the traditional aquaponics system. It is superior in its number of fruits, height, weight, and girth measurement. Moreover, the reconstructed aquaponics system is proven to eliminate all the hindrances present in the traditional aquaponics system, which are overcrowding of fish, algae growth, pest problems, contaminated water, and dead fish.
2. Programming with PIC Microcontroller
www.researchdesignlab.com Page 1
PIC
CONTROLLER
3. Programming with PIC Microcontroller
www.researchdesignlab.com Page 2
Table of Contents
INTRODUCTION .......................................................................................................................... 3
EMBEDDED SYSTEMS ........................................................................................................... 3
PIC16F877A ............................................................................................................................... 3
Overview:.................................................................................................................................... 3
MPLAB IDE:.............................................................................................................................. 5
GETTING STARTED WITH EMBED C PROGRAMMING:.................................................... 24
Lab 1 . LED Blinking using PIC controller (16F877A) with MPLAB: .................................. 24
Lab2.To display a message on LCD using pic controller........................................................ 26
Lab3.Interfacing ADC to display analog to digital conversion values on LCD...................... 30
Lab 6. Interfacing KEYPAD to display value on LCD when a key is pressed. ....................... 39
Lab7. Interfacing 7segment ..................................................................................................... 45
Lab 8. Interfacing GSM modem to send and receive the message........................................... 48
Lab 9. Interfacing RELAY to turn the relays ON and OFF...................................................... 52
Lab 10. Display a message using I2c Protocol ........................................................................ 57
Lab 11. Working with RTC and controller............................................................................... 65
4. Programming with PIC Microcontroller
www.researchdesignlab.com Page 3
INTRODUCTION
EMBEDDED SYSTEMS
PIC16F877A
Overview:
The PIC 16F877A PIC microcontroller is one of the most popular general purpose
microcontrollers. It is of 8-bit which means the most available operations are limited to 8-bits.It
is a 40-pin IC.
5. Programming with PIC Microcontroller
www.researchdesignlab.com Page 4
Ports:
There is one 6-bit ports: A , 3 8-bit ports: B ,C,D and one 3 bit port:E.
PORTA (Pin 2 to 7)and TRISA register :PORTA is a 6-bit wide, bidirectional port. The
corresponding data direction register is TRISA. Setting a TRISA bit ( = 1)
will make the corresponding. PORTA pin an input (i.e., put the corresponding output driver in a
High-Impedance mode).Clearing a TRISAbit (= 0) will make the corresponding PORTA pin an
output (i.e., put the contents of the output latch on the selected pin).Reading the PORTA regiter
reads the status of the pins,whereas writing to it will write to the port latch.All write operations
are read-modify write operations.Therefore, a write to a port implies that the port pins are read,
the value is modified and then written to the port data latch.
PORTB(Pin 33 to 40)and TRISB register: PORTB is an 8-bit wide, bidirectional port. The
corresponding data direction register is TRISB. Setting aTRISB bit (= 1)will make the
corresponding PORTB pin an input(i.e., put the corresponding output driver in a High-
Impedance mode). Clearing a TRISB bit (= 0)will make the corresponding PORTB pin an
output (i.e.,put the contents of the output latch on the selected pin).Three pins of PORTB are
multiplexed with the In-Circuit.Debugger and Low-Voltage Programming
function:RB3/PGM,RB6/PGC and RB7/PGD.
PORTC(pin 15 to 18 and pin 24 to 26)and TRISC register:PORTC is an 8-bit wide,
bidirectional port. The corresponding data direction register is TRISC. Setting a TRISC bit (= 1)
will make the corresponding PORTC pin an input (i.e., put the corresponding output driver in a
High-Impedance mode). Clearing a TRISC bit (= 0)will make the corresponding PORTC pin an
output (i.e.put the contents of the output latch on the selected pin).PORTC is multiplexed with
several peripheral functions PORTC pins have Schmitt Trigger input buffers. When the I2C
module is enabled, the PORTC<4:3>pins can be configured with normal I2C levels, or with
SMBus levels, by using the CKE bit (SSPSTAT<6>).When enabling peripheral functions, care
should be taken in defining TRIS bits for each PORTC pin. Some peripherals override the TRIS
6. Programming with PIC Microcontroller
www.researchdesignlab.com Page 5
bit to make a pin an output, while other peripherals override the TRIS bit to make a pin an input.
Since the TRIS bit override is in effect while the peripheral is enabled, read-modify write
instructions (BSF, BCF, XORWF) with TRISC as the destination, should be avoided. The user
should refer to corresponding peripheral section for the correct TRIS bit settings.
PORTD(Pin 19to22 and pin 27to30)and TRISD register: PORTD is an 8-bit port
with Schmitt Trigger input buffers. Each pin is individually configurable as an input or output.
PORTD can be configured as an 8-bit wide microprocessor port (Parallel Slave Port) by setting
control bit, PSPMODE (TRISE<4>). In this mode, the input buffers are TTL.
PORTE(Pin8 to 10)and TRISE register: PORTE has three pins (RE0/RD/AN5,
RE1/WR/AN6 and RE2/CS/AN7) which are individually configurable as inputs or outputs.
These pins have Schmitt Trigger input buffers.The PORTE pins become the I/O control inputs
for the microprocessor port when bit PSPMODE (TRISE<4>) is set. In this mode, the user must
make certain that the TRISE<2:0> bits are set and that the pins are configured as digital inputs.
Also, ensure that ADCON1 is configured for digital I/O. In this mode, the input buffers are TTL.
PORTE pins are multiplexed with analog inputs. When selected for analog input, these pins will
read as ‘0’s.
MPLAB IDE:
MPLAB IDE is a free integrated toolset for the development of embedded application on
microchip IC and dsPIC microcontroller.
Install MPLAB by following the instructions sets provided in your software.
Creating a new project:
1) Open MPLAB
2) Create a folder in any drive.
3) Select project->project wizard
7. Programming with PIC Microcontroller
www.researchdesignlab.com Page 6
4) Click on next
8. Programming with PIC Microcontroller
www.researchdesignlab.com Page 7
5) Select PIC16F7877A then click on next.
9. Programming with PIC Microcontroller
www.researchdesignlab.com Page 8
6) Select HI-TECH Universal Tool Suite and click next
7) Click on browse and select the folder you saved on the drive and write a filename ex: lcd12.
10. Programming with PIC Microcontroller
www.researchdesignlab.com Page 9
8) Click on save
11. Programming with PIC Microcontroller
www.researchdesignlab.com Page 10
9)Click on next->next->next->finish
12. Programming with PIC Microcontroller
www.researchdesignlab.com Page 11
10) You will get the following window.
11) Click on file->new->type a program
13. Programming with PIC Microcontroller
www.researchdesignlab.com Page 12
12) Click on save->save it in the same folder with .c extension and click on save.
14. Programming with PIC Microcontroller
www.researchdesignlab.com Page 13
13) Right click on source file ->add files->select your .c file->click on open.
17. Programming with PIC Microcontroller
www.researchdesignlab.com Page 16
14)click on programmer->select programmer->9PICkit 2
18. Programming with PIC Microcontroller
www.researchdesignlab.com Page 17
15) Click on configure ->configuration bits->unclick the configuration bits set in code->click ok-
select low voltage programming->then click the configuration set in code
25. Programming with PIC Microcontroller
www.researchdesignlab.com Page 24
GETTING STARTED WITH EMBED C PROGRAMMING:
Lab 1 . LED Blinking using PIC controller (16F877A) with MPLAB:
26. Programming with PIC Microcontroller
www.researchdesignlab.com Page 25
I/O Connections :
PORT B4LED1
PORTB5LED2
PORTB6Switch1
PORTB7Switch2
#include <htc.h>
#define _XTAL_FREQ 20000000 //crystal frequency of 20MHZ
#define Input1 RB7 //set port RB7 as input port
#define Input2 RB1 //set port RB1 as input port
#define Output1 RB4 //set port RB4 as output port
#define Output2 RB5 //set port RB5 as output port
void main()
{
TRISB=0X82; //use portB register as input as well as output port
while(1) //infinite loop
{
if(Input1==0) //if switch1 is pressed ie connect port RB7 to sw1
{
Output1=1; //blink both the LED’S
Output2=1;
}
else if(Input2==0) //If switch2 is pressed ie connect port RB1 to sw2
{
Output1=0; //both the LED’S are turned off
Output2=0;
}
}
}
27. Programming with PIC Microcontroller
www.researchdesignlab.com Page 26
Lab2.To display a message on LCD using pic controller
28. Programming with PIC Microcontroller
www.researchdesignlab.com Page 27
I/O connection:
PORT B0 tO B7DO to D7 of LCD
ENABLED7
R/WGROUND
R/SD6
#include <htc.h>
#include<string.h>
#define _XTAL_FREQ 20000000 //crystal frequency of 20MHZ
#define EN RD7 //connect enable pin of LCD to port D7
#define RS RD6 //connect Register select pin of LCD
to port D6
void LCD_Delay() //delay routine
{
__delay_ms(1);
}
void LCD_Cmd(unsigned char cmd) //this function is to write command to
the LCD
{
PORTB=cmd;
RS=0; //Set RS pin to low in order to send a
command to the LCD
EN=1; //set EN pin to high in order to send
high pulse
LCD_Delay(); //give a small delay
EN=0; //set EN pin to low in order to make
pulse low
LCD_Delay(); //give a small delay
29. Programming with PIC Microcontroller
www.researchdesignlab.com Page 28
}
void LCD_Init() //Initializing LCD
{
unsigned char cmd[5]={0X38,0X06,0X0F,0X01,0X80},Count;
//0x38 represents 5x7 matrix ,0x06 represent entry mode,0x0f represent display on cursor
blinking,0x01 represents clearing the LCD,0x80 represents 1st
row
for(Count=0;Count<5;Count++)
LCD_Cmd(cmd[Count]);
}
void LCD_SendDataByte(unsigned char data) //this function is to write a byte on LCD
{
PORTB=data;
RS=1; //make RS pin high inorder to send a
data
EN=1; //set enable pin to high in order to
sendhigh to low pulse
LCD_Delay(); //provide a small delay
EN=0;
LCD_Delay();
}
void LCD_Display( char *addr) //this function is to display a string on
LCD
{
while(*addr)
{
LCD_SendDataByte(*addr);
addr++;
}
30. Programming with PIC Microcontroller
www.researchdesignlab.com Page 29
}
void main()
{
TRISB=0x00; //make the registerB as ouput
TRISD=0x00; //make the registerD as ouput
LCD_Init(); //Initialize the LCD
__delay_ms(1000);
while(1) //infinite loop
{
LCD_Cmd(0X01); //clearing the LCD
LCD_Cmd(0X84); //1st
row 4th
position
LCD_Display("123"); //display 123 on LCD
LCD_Cmd(0xc0); //2nd
row
LCD_Display(" RDL"); //display RDL on LCD
__delay_ms(1000); //delay by 1s
LCD_Cmd(0x01); //clear the LCD
LCD_Cmd(0x80); //1st
row
LCD_Display(" LCD"); //display LCD
LCD_Cmd(0xc0); //2nd
row
LCD_Display(" Display"); //display on LCD
__delay_ms(1000); //delay by 1s
}
31. Programming with PIC Microcontroller
www.researchdesignlab.com Page 30
}
Lab3.Interfacing ADC to display analog to digital conversion values on LCD.
I/O connection:
PORT B0 to B7DO to D7 of LCD
ENABLED7
R/WGROUND
R/SD6
A0PORTC0
#include <htc.h>
#include<string.h>
#define _XTAL_FREQ 20000000 //crystal frequency of 20MHZ
#define EN RD7 //connect enable pin of LCD to port D7
#define RS RD6 //connect Register select pin of LCD to port
D6
/*LCD code */
void LCD_Delay() //delay routine
{
__delay_ms(1);
}
void LCD_Cmd(unsigned char cmd) //this function is to write command to the LCD
{
32. Programming with PIC Microcontroller
www.researchdesignlab.com Page 31
PORTB=cmd;
RS=0; //Set RS pin to low in order to send a
command to the LCD
EN=1; //set EN pin to high in order to send
high pulse
LCD_Delay(); //give a small delay
EN=0; //set EN pin to low in order to make
pulse low
LCD_Delay(); //give a small delay
}
void LCD_Init() //Initializing LCD
{
unsigned char cmd[5]={0X38,0X06,0X0F,0X01,0X80},Count;
//0x38 represents 5x7 matrix ,0x06 represent entry mode,0x0f represent display on cursor
blinking,0x01 represents clearing the LCD,0x80 represents 1st
row
for(Count=0;Count<5;Count++)
LCD_Cmd(cmd[Count]);
}
void LCD_SendDataByte(unsigned char data) //this function is to write a byte on LCD
{
PORTB=data;
RS=1; //make RS pin high inorder to send a data
EN=1; //set enable pin to high in order to send
high to low pulse
LCD_Delay(); //provide a small delay
EN=0;
LCD_Delay();
}
void LCD_Display( char *addr) //this function is to display a string on LCD
{
while(*addr)
{
LCD_SendDataByte(*addr);
addr++;
}
}
void ADC_Init()
{
ADCON0 = 0x41; //set A/D control register0 to 0x41
ADCON1 = 0xC0; //set A/D control register1 0xc0
33. Programming with PIC Microcontroller
www.researchdesignlab.com Page 32
}
unsigned int ADC_Read(unsigned char channel)
{
if(channel > 7)
return 0;
ADCON0 &= 0xC5;
ADCON0 |= channel<<3;
__delay_ms(2);
GO_nDONE = 1;
while(GO_nDONE);
return ((ADRESH<<8)+ADRESL); //left shift the higherorder bits and add the lower order
bits
}
void display(unsigned int number) //this function is for (0-1024)A/D conversion
{
unsigned char digit1,digit2,digit3,digit4,digit[4];
unsigned char x;
unsigned char temp;
digit1 = number / 1000u ; // extract thousands digit
digit2 = (number / 100u) % 10u; // extract hundreds digit
digit3 = (number / 10u) % 10u; // extract tens digit
digit4 = number % 10u; // extract ones digit
digit[3]=digit4;
digit[2]=digit3;
digit[1]=digit2;
digit[0]=digit1;
for(x=0;x<4;x++) //loop for upto 4 digits
{
temp=digit[x]|0x30; //convert to ACII
LCD_SendDataByte(temp); //display the value on LCD
}
}
void main()
{
34. Programming with PIC Microcontroller
www.researchdesignlab.com Page 33
unsigned int value;
unsigned int a;
TRISB = 0x00; //Set registerB as output
TRISC = 0x00; //Set registerC as output
TRISD=0x00; //set registerD as output
LCD_Init(); //initialize the LCD
__delay_ms(1000); //provide delay for 1s
ADC_Init(); //ADC initialisation
do
{
a = ADC_Read(0); //read port (A0)
__delay_ms(2000); //provide delay for 2s
LCD_Cmd(0x80); //1st
row
LCD_ display(a); //display the value on LCD
__delay_ms(1000); //provide delay
} while(1);
}
35. Programming with PIC Microcontroller
www.researchdesignlab.com Page 34
Lab 4.Interfacing UART toTransmit and Receive the message
I/O connection:
TX and RXUART RX and TX
Ground of Ic UART ground
#include<htc.h>
#define _XTAL_FREQ 20000000 //crystal frequency of 20MHZ
#include "uart.h" //header file
#include "string.h" //header file
char val;
void main()
{
__delay_ms(1000); //provide delay for 1s
UART_Init(9600); //calling initialization function with 9600 baud
rate
__delay_ms(1000); //provide delay for 1s
UART_Write_Text("RDL"); //Display RDL on hyper terminal
do
{
if(UART_Data_Ready()) //check whether it is ready to receive a data
{
recieve = UART_Read(); //read a data and store in variable
UART_Write(recieve); //display on terminal
UART_Write(10); //enter
UART_Write(13); //carriage return
36. Programming with PIC Microcontroller
www.researchdesignlab.com Page 35
__delay_ms(1000); //provide delay of 1s
}
}while(1);
}
char UART_Init(const long int baudrate)
{
unsigned int x;
x = (_XTAL_FREQ - baudrate*64)/(baudrate*64);
if(x>255)
{
x = (_XTAL_FREQ - baudrate*16)/(baudrate*16);
BRGH = 1; //High Baud Rate Select bit set to high
}
if(x<256)
{
SPBRG = x; //Writing SPBRG register
SYNC = 0; //Selecting Asynchronous Mode
SPEN = 1; //enables serial port
TRISC7 = 1;
TRISC6 = 1;
CREN = 1; //enables continuous reception
TXEN = 1; //enables continuous transmission
return 1;
}
return 0;
}
char UART_TX_Empty()
{
return TRMT; //Returns Transmit Shift Status bit
37. Programming with PIC Microcontroller
www.researchdesignlab.com Page 36
}
char UART_Data_Ready()
{
return RCIF; //Flag bit
}
char UART_Read() //this function is used to read a byte
{
while(!RCIF); //Waits for Reception to complete
return RCREG; //Returns the 8 bit data
}
void UART_Read_Text(char *Output, unsigned int length)//this function is used to read a text
{
int i;
for(int i=0;i<length;i++)
Output[i] = UART_Read();
}
void UART_Write(char data) //this function is used to write a byte
{
while(!TRMT);
TXREG = data; //transmit register
}
void UART_Write_Text(char *text) //this function is used to write a string
{
int i;
for(i=0;text[i]!='0';i++)
UART_Write(text[i]);
}
38. Programming with PIC Microcontroller
www.researchdesignlab.com Page 37
Lab 5.Interfacing PWM to vary the brightness of LED
I/O connection:
PORT C1LED1.
PORTC2LED2
#include<htc.h>
#define XTAL 20000 //20Mhz=20000Khz
#define PWM_Freq 1 //1Khz PWM frequency
#define TMR2_PRE 16 //Timer2 Prescale
#define PR2_Val ((char)((XTAL/(4*TMR2_PRE*PWM_Freq))-1))
//Calculation for Period register PR2 (2Khz)
#define Duty_Cyc PR2_Val*2
unsigned int i;
void PWM_init(void); // This function is to initialize the PWM
void PWM_change(unsigned int); //This function is to change theDuty cycle
routine
void DelayMs(unsigned int); //this function is to provide a delay
void main(void)
{
PWM_init();
while(1)
{
i=0;
PWM_change(i);
DelayMs(10);
while(i<PR2_Val)
{
i=i+1;
PWM_change(i);
39. Programming with PIC Microcontroller
www.researchdesignlab.com Page 38
DelayMs(200);
}
}
}
void PWM_init(void)
{
TRISC2=0; //PWM channel 1 and 2 configured as output
TRISC1=0;
PORTC = 0x00;
CCP1CON=0x0c; //CCP1 and CCP2 are configured for PWM
CCP2CON=0x0c;
PR2=PR2_Val; //Move the PR2 value
T2CON=0x03; //Timer2 Prescale is 16
TMR2=0x00;
TMR2ON=1; //Turn ON timer2
}
void PWM_change(unsigned int DTY) //Duty cycle change routine
{
CCPR1L=DTY; //Value is between 0 to 255
CCPR2L=DTY;
}
void DelayMs(unsigned int Ms) //Delay Routine
{
int delay_cnst;
while(Ms>0)
40. Programming with PIC Microcontroller
www.researchdesignlab.com Page 39
{
Ms--;
for(delay_cnst = 0;delay_cnst <220;delay_cnst++); //delay constant for 1Ms @20Mhz
}
}
Lab 6. Interfacing KEYPAD to display value on LCD when a key is pressed.
I/O connection:
PORT D0 tO D7DO to D7 of LCD
ENABLEC0
R/WGROUND
R/SC1
R1,R2,R3,R4PORT B0 to B3
C1,C2,C3,C4PORT4 to B7
#include <htc.h>
#include <stdio.h> // Define I/O functions
#define XTAL 20000000
#define BAUD_RATE 9.6 //9600 Baudrate
41. Programming with PIC Microcontroller
www.researchdesignlab.com Page 40
#define BAUD_VAL (char)(XTAL/ (16 * BAUD_RATE )) - 1;
//Calculation For9600 Baudrate @20Mhz
#define EN RC0
#define RS RC1
void ScanCol(void); //Column Scan Function
void ScanRow(void); //Row Scan Function
void DelayMs(unsigned int);
void LCD_Cmd(unsigned char);
void LCD_Init(void);
void LCD_Display( char *addr);
void LCD_SendDataByte(unsigned char);
unsigned char KeyArray[4][4]= { '1','2','3','4',
'5','6','7','8',
'9','A','B','C',
'D','E','F','0'};
//Keypad value Initialization Function
unsigned char Count[4][4]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int Col=0,Row=0,count=0,i,j;
void main()
{
TRISD=0x00; //set registerD as output
TRISC=0x00; //set register C as output
LCD_Init(); //initialize LCD
DelayMs(1000);
42. Programming with PIC Microcontroller
www.researchdesignlab.com Page 41
nRBPU=0; //Enable PORTB Pullup values
while(1)
{
TRISB=0X0f; // Enable the 4 LSB as I/P & 4 MSB as
O/P
PORTB=0X00;
while(PORTB==0x0f); // Get the ROW value
ScanRow();
TRISB=0Xf0; // Enable the 4 LSB as O/P & 4 MSB as
I/P
PORTB=0X00;
while(PORTB==0xf0); // Get the Column value
ScanCol();
DelayMs(1000); //provide a delay of 1s
Count[Row][Col]++; // Count the Pressed key
LCD_Cmd(0X01); //clear the LCD
LCD_Cmd(0X80); //1st
row of the LCD
LCD_SendDataByte(KeyArray[Row][Col]); //send keypad value and display on LCD
DelayMs(1000); //provide delay of 1s
}
}
void ScanRow() // Row Scan Function
{
switch(PORTB)
{
43. Programming with PIC Microcontroller
www.researchdesignlab.com Page 42
case 0x07:
Row=3; // 4th Row
break;
case 0x0b:
Row=2; // 3rd Row
break;
case 0x0d:
Row=1; // 2nd Row
break;
case 0x0e:
Row=0; // 1st Row
break;
}
}
void ScanCol() // Column Scan Function
{
switch(PORTB)
{
case 0x70:
Col=3; // 4th Column
break;
case 0xb0:
Col=2; // 3rd Column
break;
case 0xd0:
Col=1; // 2nd Column
break;
case 0xe0:
44. Programming with PIC Microcontroller
www.researchdesignlab.com Page 43
Col=0; // 1st Column
break;
}
}
/*LCD CODE*/
void LCD_Delay() //delay routine
{
__delay_ms(1);
}
void LCD_Cmd(unsigned char cmd) //this function is to write command to the LCD
{
PORTB=cmd;
RS=0; //Set RS pin to low in order to send a
command to the LCD
EN=1; //set EN pin to high in order to send high pulse
LCD_Delay(); //give a small delay
EN=0; //set EN pin to low in order to make pulse low
LCD_Delay(); //give a small delay
}
void LCD_Init() //Initializing LCD
{
unsigned char cmd[5]={0X38,0X06,0X0F,0X01,0X80},Count;
45. Programming with PIC Microcontroller
www.researchdesignlab.com Page 44
//0x38 represents 5x7 matrix ,0x06 represent entry mode,0x0f represent display on cursor
blinking,0x01 represents clearing the LCD,0x80 represents 1st
row
for(Count=0;Count<5;Count++)
LCD_Cmd(cmd[Count]);
}
void LCD_SendDataByte(unsigned char data) //this function is to write a byte on LCD
{
PORTB=data;
RS=1; //make RS pin high inorder to send a data
EN=1; //set enable pin to high in order to send high
to low pulse
LCD_Delay(); //provide a small delay
EN=0;
LCD_Delay();
}
void LCD_Display( char *addr) //this function is to display a string on LCD
{
while(*addr)
{
LCD_SendDataByte(*addr);
addr++;
}
}
46. Programming with PIC Microcontroller
www.researchdesignlab.com Page 45
Lab7. Interfacing 7segment
I/O connection:
A,B,C,D,E,F,G,DPB0 to B7
DIG1,DIG2,DIG3,DIG4 A0 to A3
#include<htc.h>
#define CNTRL_PORT PORTA
#define DATA_PORT PORTB
void hex2dec(unsigned char); //function to convert hex value to decimal
void send_seg(unsigned char,unsigned char,unsigned char,unsigned char); //Function to display
count on 7seg
void DelayMs(unsigned int); //function to provide delay
unsigned char x;
unsigned char thou=0,hun=0,ten=0,single=0;
unsignedcharCA[10] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsignedchar CC[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char CA_CNTRL[4] = {0x07,0x0b,0x0d,0x0e};
unsigned char CC_CNTRL[4] = {0x08,0x04,0x02,0x01};
unsigned char n=1;
void main()
{
unsigned char number;
nRBPU =0;
TRISB=0x00; //PORTB configured as O/P
ADCON1=0x07; //Configure PORTA & PORTE as Digital
port
47. Programming with PIC Microcontroller
www.researchdesignlab.com Page 46
TRISA=0x00; //PORTA Configured as O/P
while(1)
{
if(x == 200)
{
x=0;
single++; //Increment up to 9 in unit place
if(single>9)
{
single=0;
ten++; //Increment up to 9 in Tenth place
if(ten>9)
{
ten=0;
hun++; //Increment up to 9 in Hundredth place
if(hun>9)
{
hun=0;
thou++; //Increment up to 9 in Thousandth place
if(thou>9)
thou=0;
}
}
}
}
x++;
send_seg(thou,hun,ten,single);
}
}
void send_seg(unsigned char thou,unsigned char hun,unsigned char ten,unsigned char single)
{
if(n==1)
{
CNTRL_PORT=CA_CNTRL[0]; //Eanble Unit place 7-Segment
DATA_PORT=CA[single]; //Display Unit Place Number
n=2;
DelayMs(5);
}
else if(n==2)
{
CNTRL_PORT=CA_CNTRL[1]; //Eanble Tenth place 7-Segment
DATA_PORT=CA[ten]; //Display Tenth Place Number
n=3;
DelayMs(5);
48. Programming with PIC Microcontroller
www.researchdesignlab.com Page 47
}
else if(n==3)
{
CNTRL_PORT=CA_CNTRL[2]; //Enable Hundredth place 7-Segment
DATA_PORT=CA[hun]; //Display Hundredth Place Number
n=4;
DelayMs(5);
}
else if(n==4)
{
CNTRL_PORT=CA_CNTRL[3]; //Eanble Thousandth place 7-Segment
DATA_PORT=CA[thou]; //Display Thousandth Place Number
n=1;
DelayMs(5);
}
}
void DelayMs(unsigned int Ms)
{
int delay_cnst;
while(Ms>0)
{
Ms--;
for(delay_cnst = 0;delay_cnst <220;delay_cnst++);
}
}
49. Programming with PIC Microcontroller
www.researchdesignlab.com Page 48
Lab 8. Interfacing GSM modem to send and receive the message
I/Oconnection:
Vin of GSM12v
Ground of GSMGround
D0,D1 of GSMTX,RX
#define <htc.h>
#define _XTAL_FREQ 20000000 //crystal frequency of 20MHZ
#include "uart.h" //header file
#include "string.h" //header file
char UART_Init(const long int baudrate)
{
unsigned int x;
x = (_XTAL_FREQ - baudrate*64)/(baudrate*64);
if(x>255)
{
x = (_XTAL_FREQ - baudrate*16)/(baudrate*16);
50. Programming with PIC Microcontroller
www.researchdesignlab.com Page 49
BRGH = 1; //High Baud Rate Select bit set to high
}
if(x<256)
{
SPBRG = x; //Writing SPBRG register
SYNC = 0; //Selecting Asynchronous Mode
SPEN = 1; //enables serial port
TRISC7 = 1;
TRISC6 = 1;
CREN = 1; //enables continuous reception
TXEN = 1; //enables continuous transmission
return 1;
}
return 0;
}
char UART_TX_Empty()
{
return TRMT; //Returns Transmit Shift Status bit
}
char UART_Data_Ready()
{
return RCIF; //Flag bit
}
char UART_Read() //this function is used to read a byte
{
while(!RCIF); //Waits for Reception to complete
return RCREG; //Returns the 8 bit data
51. Programming with PIC Microcontroller
www.researchdesignlab.com Page 50
}
void UART_Read_Text(char *Output, unsigned int length)
//this function is used to read a text
{
int i;
for(int i=0;i<length;i++)
Output[i] = UART_Read();
}
void UART_Write(char data) //this function is used to write a byte
{
while(!TRMT);
TXREG = data; //transmit register
}
void UART_Write_Text(char *text) //this function is used to write a string
{
int i;
for(i=0;text[i]!='0';i++)
UART_Write(text[i]);
}
void main()
{
UART_Init(9600); //initialize the UART function
__delay_ms(1000); //provide the delay of 1s
while(1) //infinite loop
{
__delay_ms(1000); //provide a delay of 1s
UART_Write_Text("AT"); //attention command
52. Programming with PIC Microcontroller
www.researchdesignlab.com Page 51
UART_Write(13); //enter
UART_Write(10); //carriage return
__delay_ms(1000); //provide delay of 1s
UART_Write_Text("AT+CMGF=1"); //initialize the modem
UART_Write(13); //enter
UART_Write(10); //carriage return
__delay_ms(1000); //provide delay of 1s
UART_Write_Text("AT+CMGS="1234567890""); //send a message
UART_Write(13); //enter
UART_Write(10); //carriage return
__delay_ms(1000); //provide delay of 1s
UART_Write_Text("GSM"); //display on hyper terminal
UART_Write(13); //enter
UART_Write(10); //carriage return
__delay_ms(1000); //provide delay of 1s
UART_Write(26); //Ctr +Z
}
}
53. Programming with PIC Microcontroller
www.researchdesignlab.com Page 52
Lab 9. Interfacing RELAY to turn the relays ON and OFF.
I/O connection:
B0,B1,B2,B3 to relay shield.
#define _XTAL_FREQ 20000000 //crystal frequency of 20MHZ
#include "uart.h" //header file
#include "string.h" //header file
#define relay1 RB1
#define relay2 RB2
#define relay3 RB3
#define relay4 RB4
char UART_Init(const long int baudrate)
{
unsigned int x;
x = (_XTAL_FREQ - baudrate*64)/(baudrate*64);
54. Programming with PIC Microcontroller
www.researchdesignlab.com Page 53
if(x>255)
{
x = (_XTAL_FREQ - baudrate*16)/(baudrate*16);
BRGH = 1; //High Baud Rate Select bit set to high
}
if(x<256)
{
SPBRG = x; //Writing SPBRG register
SYNC = 0; //Selecting Asynchronous Mode
SPEN = 1; //enables serial port
TRISC7 = 1;
TRISC6 = 1;
CREN = 1; //enables continuous reception
TXEN = 1; //enables continuous transmission
return 1;
}
return 0;
}
char UART_TX_Empty()
{
return TRMT; //Returns Transmit Shift Status bit
}
char UART_Data_Ready()
{
return RCIF; //Flag bit
}
char UART_Read() //this function is used to read a byte
55. Programming with PIC Microcontroller
www.researchdesignlab.com Page 54
{
while(!RCIF); //Waits for Reception to complete
return RCREG; //Returns the 8 bit data
}
void UART_Read_Text(char *Output, unsigned int length)//this function is used to read a text
{
int i;
for(int i=0;i<length;i++)
Output[i] = UART_Read();
}
void UART_Write(char data) //this function is used to write a byte
{
while(!TRMT);
TXREG = data; //transmit register
}
void UART_Write_Text(char *text) //this function is used to write a string
{
int i;
for(i=0;text[i]!='0';i++)
UART_Write(text[i]);
}
void main()
{
unsigned char ReceivChar;
TRISB=0X00; //make register as the output
PORTB=0X00; //make the PORTB as the output port
56. Programming with PIC Microcontroller
www.researchdesignlab.com Page 55
UART_Init(9600); //inititalise the UART
DelayMs(1000); //provide delay of 1s
while(1)
{
if(UART_Data_Ready()) //check if the data is ready
{
ReceivChar = UART_Read(); //store the data in a variable
UART_Write(ReceivChar); //display on hyperterminal
__delay_ms(1000); //provide delay of 1s
if(ReceivChar=='1') //check if the received char is 1if 1
{
ReceivChar = UART_Read(); //store the data in a variable
UART_Write(ReceivChar); //display on hyperterminal
if(ReceivChar=='N') //if received character is N
relay1=1; //turn ON the 1st
relay
else if(ReceivChar=='F') //if received character is F
relay1=0; //turn OFF the 1st
relay
}
else if(ReceivChar=='2') //check if the received char is 2if 2
{
ReceivChar = UART_Read(); //store the data in a variable
UART_Write(ReceivChar); //display on hyperterminal
if(ReceivChar=='N') //if received character is N
relay2=1; //turn ON the 2nd relay
57. Programming with PIC Microcontroller
www.researchdesignlab.com Page 56
else if(ReceivChar=='F') //if received character is F
relay2=0; //turn OFF the 2nd relay
}
else if(ReceivChar=='3') //check if the received char is 3if 3
{
ReceivChar = UART_Read(); //store the data in a variable
UART_Write(ReceivChar); //display on hyperterminal
if(ReceivChar=='N') //if received character is N
relay3=1; //turn ON the 3rd relay
else if(ReceivChar=='F') //if received character is N
relay3=0; //turn OFF the 3rd relay
}
else if(ReceivChar=='4') //check if the received char is 4if 4
{
ReceivChar = UART_Read(); //store the data in a variable
UART_Write(ReceivChar); //display on hyperterminal
if(ReceivChar=='N') //if received character is N
relay4=1; //turn ON the 4th relay
else if(ReceivChar=='F') //if received character is N
relay4=0; //turn OFF the 4th relay
}
58. Programming with PIC Microcontroller
www.researchdesignlab.com Page 57
Lab 10. Display a message using I2c Protocol
I/O connection:
SCL of EEPROMC3
SDA of EEPROMC4
#include<htc.h>
#include"string.h"
#include<stdio.h>
#define _XTAL_FREQ 20000000
#define I2C_FREQ 100 // 100khz at 4Mhz
#define FOSC 20000 // 20Mhz==>20000Khz
void WaitMSSP(void); //function to wait for a operation to complete
void i2c_init(void); //Initialize the UART
void I2C_Start(void); //function to send a start bit
59. Programming with PIC Microcontroller
www.researchdesignlab.com Page 58
void I2C_Stop(void); //function to send a stop bit
char I2C_Read_Data(void); //function to read a data
char I2C_Write_Data(unsigned char); //function to write the data
void I2C_Reset(void); //function to reset the bit
void DelayMs(unsigned int); //function to provide a delay
char UART_Init(const long int); // function to initialize UART
void UART_Write_Text(char *); //function to write the string
void UART_Write(char ); //function to write the byte
char UART_Data_Ready(void); //function to check if data ready
char UART_Read(void); //function to read the data
void main()
{
char a;
UART_Init(9600); //initialize the UART
DelayMs(1000); //Provide a delay of 1s
i2c_init(); //initialize the I2C
DelayMs(1000); //Provide a delay of 1s
while(1)
60. Programming with PIC Microcontroller
www.researchdesignlab.com Page 59
{
I2C_Start(); //start bit is set in this function
DelayMs(100); //Provide a delay
I2C_Write_Data(0xa0); //write the data on to the location 0xa0(device address)
DelayMs(100); //Provide a delay
I2C_Write_Data(0x20); //write the data on to location 0x20
DelayMs(100); //Provide a delay
I2C_Write_Data('a'); //send character ‘a’
DelayMs(100); //Provide a delay
I2C_Stop(); //stop bit is set in this function
DelayMs(100); //Provide a delay
I2C_Start(); //start bit is set in this function
DelayMs(100); //Provide a delay
I2C_Write_Data(0xa0); //write the data on to the location 0xa0(device address)
DelayMs(100); //Provide a delay
I2C_Write_Data(0x20); //write the data on to location 0x20
DelayMs(100); //Provide a delay
I2C_Reset(); //this function is used to reset
DelayMs(100); //Provide a delay
I2C_Write_Data(0xa1); //write the data on to the location 0xa0(device address)
DelayMs(100); //Provide a delay
a=I2C_Read_Data(); //this function reads the data stored in EEPROM
UART_Write(a); //display the character on hyper terminal
DelayMs(100); //Provide a delay
I2C_Stop(); //stop bit is set in this function
DelayMs(100); //Provide a delay
}
}
char I2C_Write_Data(unsigned char data)
61. Programming with PIC Microcontroller
www.researchdesignlab.com Page 60
//This function is used to write the data onto EEPROM
{
//WaitMSSP(); // wait for the operation to be finished
SSPBUF=data; //Send Slave address write command
WaitMSSP(); //wait for operation to complete
}
void I2C_Start() //this function is used to set start bit
{
SEN=1; //start bit is set
WaitMSSP(); //wait for operation to complete
}
void I2C_Stop() //this function is used to set start bit
{
PEN=1; //stop bit is set
WaitMSSP(); //wait for operation to complete
}
void I2C_Reset() //this function is used to reset start bit
{
RSEN=1; // Send re-start bit
62. Programming with PIC Microcontroller
www.researchdesignlab.com Page 61
WaitMSSP(); //wait for operation to complete
}
char I2C_Read_Data() //this function is used to read data from EEPROM
{
RCEN=1; // Enable receive
WaitMSSP(); //wait for operation to complete
ACKDT=1; // Acknowledge data 1: NACK, 0: ACK
ACKEN=1; // Enable ACK to send
WaitMSSP(); //wait for operation to complete
return SSPBUF; // Send the received data to PC
DelayMs(30);
}
void WaitMSSP() // function for wait for operation to complete
{
while(!SSPIF); // while SSPIF=0 stay here else exit the loop
63. Programming with PIC Microcontroller
www.researchdesignlab.com Page 62
SSPIF=0; // operation completed clear the flag
}
void i2c_init() //function to initialize I2C
{
TRISC3=1; // Set up I2C lines by setting as input
TRISC4=1;
SSPCON=0x28; // SSP port, Master mode, clock = FOSC / (4 * (SSPADD+1))
SSPADD=(FOSC / (4 * I2C_FREQ)) - 1; //clock 100khz
SSPSTAT=80; // Slew rate control disabled
}
void DelayMs(unsigned int Ms) //function to provide a delay
{
int delay_cnst;
while(Ms>0)
64. Programming with PIC Microcontroller
www.researchdesignlab.com Page 63
{
Ms--;
for(delay_cnst = 0;delay_cnst <220;delay_cnst++);
}
}
char UART_Init(const long int baudrate)
{
unsigned int x;
x = (_XTAL_FREQ - baudrate*64)/(baudrate*64);
if(x>255)
{
x = (_XTAL_FREQ - baudrate*16)/(baudrate*16);
BRGH = 1; //High Baud Rate Select bit set to high
}
if(x<256)
{
SPBRG = x; //Writing SPBRG register
SYNC = 0; //Selecting Asynchronous Mode
SPEN = 1; //enables serial port
TRISC7 = 1;
TRISC6 = 1;
CREN = 1; //enables continuous reception
TXEN = 1; //enables continuous transmission
65. Programming with PIC Microcontroller
www.researchdesignlab.com Page 64
return 1;
}
return 0;
}
char UART_TX_Empty()
{
return TRMT; //Returns Transmit Shift Status bit
}
char UART_Data_Ready()
{
return RCIF; //Flag bit
}
char UART_Read() //this function is used to read a byte
{
while(!RCIF); //Waits for Reception to complete
return RCREG; //Returns the 8 bit data
}
void UART_Read_Text(char *Output, unsigned int length)//this function is used to read a text
{
int i;
for(int i=0;i<length;i++)
Output[i] = UART_Read();
}
void UART_Write(char data) //this function is used to write a byte
{
while(!TRMT);
66. Programming with PIC Microcontroller
www.researchdesignlab.com Page 65
TXREG = data; //transmit register
}
void UART_Write_Text(char *text) //this function is used to write a string
{
int i;
for(i=0;text[i]!='0';i++)
UART_Write(text[i]);
}
Lab 11. Working with RTC and controller
Pinconnection:
SCL of RTCC3
SDA of RTCC4
68. Programming with PIC Microcontroller
www.researchdesignlab.com Page 67
void ds1307_init(void);
void DelayMs(unsigned int);
void main()
{
int count=0;
DelayMs(20); //provide a delay
ds1307_init(); //initialize ds1307
UART_Init(9600); //initialize the UART
for(i=0;i<7;i++)
DS1307Write(i,data[i]);
DelayMs(20); //provide a delay
while(1)
{
sec=DS1307Read(0); // Read second
min=DS1307Read(1); // Read minute
69. Programming with PIC Microcontroller
www.researchdesignlab.com Page 68
hour=DS1307Read(2); // Read hour
day=DS1307Read(3); // Read day
date=DS1307Read(4); // Read date
month=DS1307Read(5); // Read month
year=DS1307Read(6); // Read year
printf("Time: %x : %x : %x ",(hour&0x1f),min,sec); //Display the Hours, Minutes,
Seconds(hours is taken from 5 LSB bits )
printf("Date: %x / %x / %x r",date,month,year); //Display the Date, Month, Year
DelayMs(150); //provide a delay
}
}
void DS1307Write(unsigned char addr, unsigned char data)
{
SEN=1; //Initiate Start condition on SDA & SCL pins
WaitMSSP();
SSPBUF=LC01CTRLIN; // Slave address + Write command
70. Programming with PIC Microcontroller
www.researchdesignlab.com Page 69
WaitMSSP();
SSPBUF=addr; // Write the location
WaitMSSP();
SSPBUF=data; // Write the Data
WaitMSSP();
PEN=1; // Enable the Stop bit
WaitMSSP();
}
unsigned char DS1307Read(unsigned char addr)
{
unsigned char x;
RSEN=1; // Enable the repeated Start Condition
WaitMSSP ();
71. Programming with PIC Microcontroller
www.researchdesignlab.com Page 70
SSPBUF=LC01CTRLIN; // Slave address + Write command
WaitMSSP ();
SSPBUF=addr; //Write the location (memory address of Hour, minute, etc...)
WaitMSSP ();
RSEN=1; // Enable the repeated Start Condition
WaitMSSP ();
SSPBUF=LC01CTRLOUT; // Slave address + Read command
WaitMSSP ();
RCEN=1; // Enable to receive data
WaitMSSP ();
ACKDT=1; // Acknowledge the operation (Send NACK)
ACKEN=1; // Acknowledge sequence on SDA & SCL pins
PEN=1; // Enable the Stop bit
WaitMSSP ();
x=SSPBUF; // Store the Receive value in a variable
72. Programming with PIC Microcontroller
www.researchdesignlab.com Page 71
return (x);
}
void WaitMSSP()
{
while(!SSPIF); // SSPIF is zero while TXion is progress
SSPIF=0;
}
void ds1307_init()
{
TRISC3=1; // RC3,RC4 set to I2C Mode(Input)
TRISC4=1;
SSPCON=0x28; // Enable the SDA,SCL & I2C Master Mode
SSPADD=(FOSC / (4 * I2C_FREG)) – 1;// SSP baud rate 100Khz
SSPSTAT=0x80; // Disable slew Rate control
PORTC=0x18;
73. Programming with PIC Microcontroller
www.researchdesignlab.com Page 72
DS1307Write(0,0x00);
}
void putch(unsigned char byte) //Required for printf statement
{
while(!TXIF); // Wait for the Transmit Buffer to be empty
TXREG = byte; // Transmit the Data
}
void DelayMs(unsigned int Ms) //Function to provide a delay
{
int delay_cnst;
while(Ms>0)
{
74. Programming with PIC Microcontroller
www.researchdesignlab.com Page 73
Ms--;
for(delay_cnst = 0;delay_cnst <220;delay_cnst++);
}
}
char UART_Init(const long int baudrate) //function to initialize the UART
{
unsigned int x;
x = (_XTAL_FREQ - baudrate*64)/(baudrate*64);
if(x>255)
{
x = (_XTAL_FREQ - baudrate*16)/(baudrate*16);
BRGH = 1; //High Baud Rate Select bit set to high
}
if(x<256)
{
SPBRG = x; //Writing SPBRG register
SYNC = 0; //Selecting Asynchronous Mode
SPEN = 1; //enables serial port
TRISC7 = 1;
TRISC6 = 1;
CREN = 1; //enables continuous reception
TXEN = 1; //enables continuous transmission
return 1;
}
return 0;
}
76. RESEARCH DESIGN LABS | VOLUME 1, ISSUE 1 WWW.RESEARCHDESIGNLAB.COM
All digital circuits require regulated power
supply. Here is a simple power supply circuit
diagram used on this board.
You can use AC or DC source (12V) which
converts into regulated 5V which is required for
driving the development board circuit.
Power supply, 5V-12V
Select the IC's from the given list and mount on the ZIF socket. ZIF socket pin maps out PORT1
PORT2 PORT3 PORT4 for easy making connections for the rest of the circuit. Port 1 is enabled with
pull up circuit and also connected ISP for easy on board Programming.
1. 40 pin ZIF socket for IC mount & ISP connector*
77. RESEARCH DESIGN LABS | VOLUME 1, ISSUE 1 WWW.RESEARCHDESIGNLAB.COM
2. Reset
One seven segment digit consist of 7+1 LEDs which are arranged in a specific formation which
can be used to represent digits from 0 to 9 and even some letters. One additional LED is used for
marking the decimal dot, in case you want to write a decimal point in the desired segment.
3. Node connector
Resets your microcontroller by pressing s23 Node connector is an additional on board
connection extender or 1 connection IN
and 1 connection out
4. 4 digit 7 segment display
78. RESEARCH DESIGN LABS | VOLUME 1, ISSUE 1 WWW.RESEARCHDESIGNLAB.COM
26 Pin raspberry connector is an easy way for
making connections with raspberry pi with
this development board.
Arduino Shield footprint is provided in the
board to mount different types of Arduino
compatible shields on this development
board.
5. 26 pin raspberry connector 6. Arduino Shield footprint
IC ULN2803 consists of octal high voltage, high current darlington transistor arrays. The eight NPN
Darlington connected transistors in this family of arrays are ideally suited for interfacing between
low logic level digital circuitry (such as TTL, CMOS or PMOS/NMOS) and the higher
current/voltage requirements of lamps, relays, printer hammers or other similar loads for a
broad range of computer, industrial, and consumer applications.
7. ULN 2803 driver
79. RESEARCH DESIGN LABS | VOLUME 1, ISSUE 1 WWW.RESEARCHDESIGNLAB.COM
Features
The ULN 2803 IC consists of eight NPN Darlington
connected transistors (often called a Darlington
pair). Darlington pair consists of two bipolar
transistors such that the current amplified by
the first is amplified further by the second to
get a high current gain β or hFE. The figure
shown below is one of the eight Darlington pairs
of ULN 2803 IC.
Now 2 cases arise:-
Case 1: When IN is 0 volts.
Q1 and Q2 both will not conduct as there is no
base current provided to them. Thus, nothing
will appear at the output (OUT).
Case 2: When IN is 5 volts.
Input current will increase and both transistors Q1 and Q2 will begin to conduct. Now, input
current of Q2 is combination of input current and emitter current of Q1, so Q2 will conduct more
than Q1 resulting in higher current gain which is very much required to meet the higher current
requirements of devices like motors, relays etc. Output current flows through Q2 providing a path
(sink) to ground for the external circuit that the output is applied to. Thus, when a 5V input is
applied to any of the input pins (1 to 8), output voltage at corresponding output pin (11 to 18)
drops down to zero providing GND for the external circuit. Thus, the external circuit gets
grounded at one end while it is provided +Vcc at its other end. So, the circuit gets completed and
starts operating.
Working
• Eight Darlingtons with Common Emitter.
• Open–collector outputs.
• Free wheeling clamp diodes for
transient suppression.
• Output Current to 500 mA.
• Output Voltage to 50 V.
• Inputs pinned opposite outputs
to simplify board layout.
80. RESEARCH DESIGN LABS | VOLUME 1, ISSUE 1 WWW.RESEARCHDESIGNLAB.COM
One IC that wants to talk to another must: (Protocol)
1) Wait until it sees no activity on the I2C bus. SDAand SCLare both high. The bus is 'free'.
2) Put a message on the bus that says 'its mine' - I have STARTED to use the bus. All other ICs then
LISTEN to the bus data to see whether they might be the one who will be called up
(addressed).
3) Provide on the CLOCK (SCL) wire a clock signal. It will be used by all the ICs as the reference
time at which each bit of DATA on the data (SDA) wire will be correct (valid) and can be used.
The data on the data wire (SDA) must be valid at the time the clock wire (SCL) switches from
'low' to 'high' voltage.
4) Put out in serial form the unique binary 'address'(name) of the IC that it wants to
communicate with.
5) Put a message (one bit) on the bus telling whether it wants to SEND or RECEIVE data from the
other chip. (The read/write wire is gone!)
6) Ask the other IC toACKNOWLEDGE (using one bit) that it recognized its address and is ready to
communicate.
7) After the other IC acknowledges all is OK, data can be transferred.
8) The first IC sends or receives as many 8-bit words of data as it wants. After every 8-bit data
word the sending IC expects the receiving IC to acknowledge the transfer is going OK.
9) When all the data is finished the first chip must free up the bus and it does that by a special
message called 'STOP'. It is just one bit of information transferred by a special 'wiggling' of the
SDA/SCLwires of the bus.
8. I2C bus
81. RESEARCH DESIGN LABS | VOLUME 1, ISSUE 1 WWW.RESEARCHDESIGNLAB.COM
Serial to Peripheral Interface (SPI) is a hardware/firmware communications protocol developed
by Motorola and later adopted by others in the industry. Microwire of National Semiconductor is
same as SPI. Sometimes SPI is also called a "four wire" serial bus.
The Serial Peripheral Interface or SPI-bus is a simple 4-wire serial communications interface used
by many microprocessor/microcontroller peripheral chips that enables the controllers and
peripheral devices to communicate each other. Even though it is developed primarily for the
communication between host processor and peripherals, a connection of two processors via SPI is
just as well possible.
The SPI bus, which operates at full duplex (means, signals carrying data can go in both directions
simultaneously), is a synchronous type data link setup with a Master / Slave interface and can
support up to 1 megabaud or 10Mbps of speed. Both single-master and multi-master protocols are
possible in SPI. But the multi-master bus is rarely used and look awkward, and are usually limited
to a single slave.
The SPI Bus is usually used only on the PCB. There are many facts, which prevent us from using it
outside the PCB area. The SPI Bus was designed to transfer data between various IC chips, at very
high speeds. Due to this high-speed aspect, the bus lines cannot be too long, because their
reactance increases too much, and the Bus becomes unusable. However, its possible to use the SPI
Bus outside the PCB at low speeds, but this is not quite practical.
The peripherals can be a Real Time Clocks, converters like ADC and DAC, memory modules like
EEPROM and FLASH, sensors like temperature sensors and pressure sensors, or some other devices
like signal-mixer, potentiometer, LCD controller, UART, CAN controller, USB controller and
amplifier.
9. SPI bus
82. RESEARCH DESIGN LABS | VOLUME 1, ISSUE 1 WWW.RESEARCHDESIGNLAB.COM
All XBeeZNet 2.5 modules can be identified by their unique 64-bit addresses or a user-
configurableASCII string identifier The 64-bit address of a module can be read using the SH and SL
commands. TheASCII string identifier is configured using the NI command.
To transmit using device addressing, only the destination address must be configured. The
destination address can be specified using either the destination device's 64-bit address or its NI-
string. The XBee modules also support coordinator and broadcast addressing modes. Device
addressing in the AT firmware is configured using the DL, DH, or DN commands. In the API
firmware, the ZigBee Transmit Request API frame (0x10) can be used to specify destination
addresses.
To address a node by its 64-bit address, the destination address must be set to match the 64-bit
address of the remote. In the AT firmware, the DH and DL commands set the destination 64-bit
address. In the API firmware, the destination 64-bit address is set in the ZigBee Transmit Request
frame. ZigBee end devices rely on a parent (router or coordinator) to remain awake and receive
any data packets destined for the end device. When the end device wakes from sleep, it sends a
transmission (poll request) to its parent asking if the parent has received any RF data destined for
the end device. The parent, upon receipt of the poll request, will send an RF response and the
buffered data (if present). If the parent has no data for the end device, the end device may
return to sleep, depending on its sleep mode configuration settings. The following figure
demonstrates how the end device uses polling to receive RF data through its parent.
10. XBEE footprint/ XBEE Adaptor module
83. RESEARCH DESIGN LABS | VOLUME 1, ISSUE 1 WWW.RESEARCHDESIGNLAB.COM
A standard FT232 breakout board from
researchdesignlab.com could be used
to interface on these connectors,
whose other end is connected to a USB.
These connectors provide on board
3.3V DC connections.
RS-232 is a standard communication protocol for linking computer and its peripheral devices to
allow serial data exchange. In simple terms RS232 defines the voltage for the path used for data
exchange between the devices. It specifies common voltage and signal level, common pin wire
configuration and minimum, amount of control signals.
11. FT232 breakout
board connector
12. DC 3.3V connectors
13. DB-9 female connector
84. RESEARCH DESIGN LABS | VOLUME 1, ISSUE 1 WWW.RESEARCHDESIGNLAB.COM
LED's are used to indicate something,
whether any pin is high or indicating
the output for many purposes like
indicating I/O status or program
debugging running state. We have
four led outputs on board which can
be used by the programmer as per the
requirement for testing and
development.
DIP switches are an alternative to jumper blocks. Their main advantages are that they are quicker
to change and there are no parts to lose.
The DS1307 Serial Real Time Clock is a low power, full BCD clock/calendar plus 56 bytes of
nonvolatile SRAM. Address and data are transferred serially via a 2-wire bi-directional bus. The
clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The
end of the month date is automatically adjusted for months with less than 31 days, including
corrections for leap year. The clock operates in either the 24-hour or 12-hour format withAM/PM
indicator. The DS1307 has a built-in power sense circuit which detects power failures and
automatically switches to the battery supply.
14. 8x1 LED's
15. 8 way DIP switch
16. RTC Module
85. RESEARCH DESIGN LABS | VOLUME 1, ISSUE 1 WWW.RESEARCHDESIGNLAB.COM
The DS1307 operates as a slave device on the serial bus. Access is obtained by implementing a
START condition and providing a device identification code followed by a register address.
Subsequent registers can be accessed sequentially until a STOP condition is executed. When VCC
falls below 1.25 x VBAT the device terminates an access in progress and resets the device address
counter. Inputs to the device will not be recognized at this time to prevent erroneous data from
being written to the device from an out of tolerance system. When VCC falls below VBAT the
device switches into a low current battery backup mode. Upon power up, the device switches
from battery to VCC when VCC is greater than VBAT +0.2V and recognizes inputs.
Features:
1. 56 byte nonvolatile RAM for data storage
2. 2-wire serial interface
3. Programmable square wave output signal
4. Automatic power-fail detect and switch circuitry
5. Consumes less than 500 nA in battery backup mode with oscillator running
6. Optional industrial temperature range -40°C to +85°C
7. Available in 8-pin DIP or SOIC
8. Recognized by Underwriters Laboratory
Operation
PIN DESCRIPTION
1. VCC - Primary Power Supply
2. X1, X2 - 32.768 kHz Crystal Connection
3. VBAT - +3V Battery Input
4. GND - Ground
5. SDA - Serial Data
6. SCL - Serial Clock
7. SQW/OUT - Square wave/Output Driver
86. RESEARCH DESIGN LABS | VOLUME 1, ISSUE 1 WWW.RESEARCHDESIGNLAB.COM
IC, EEPROM I2C 4K, 24C04, DIP8
Memory Size: 4Kbit
Memory Configuration: 512 x 8
Interface Type: I2C, Serial
Clock Frequency: 400kHz
Supply Voltage Range: 2.5V to 5.5V
Memory Case Style: DIP
No. of Pins: 8
Operating Temperature Range: -40°C to +85°C
SVHC: No SVHC (19-Dec-2011)
Base Number: 24
Device Marking: M24C04
IC Generic Number: 24C04
Interface: I2C
Interface Type: Serial, I2C
Logic Function Number: 24C04
Memory Configuration: 512 x 8
Memory Size: 4Kbit
Memory Type: EEPROM
Memory Voltage Vcc: 2.5V
Operating Temperature Max: +85°C
Operating Temperature Min: -40°C
Package / Case: DIP
Supply Voltage Max: 5.5V
Supply Voltage Min: 2.5V
Termination Type: Through Hole
Voltage Vcc: 2.5V
17. EEPROM
Node connector is an additional on board connection extender
or 1 connection IN and 1 connection OUT
18. 2x5x2 jumper node
87. RESEARCH DESIGN LABS | VOLUME 1, ISSUE 1 WWW.RESEARCHDESIGNLAB.COM
19. DC 5V connectors
These connectors provide
on board 5V DC connections.
The Potentiometer Option allows the user to adjust the frequency reference by rotating a
potentiometers dial. Turning the potentiometer changes the frequency reference making it
easier to adjust the motor speed and also to set the duty cycle for PWM values.
Switches are mainly used to
switch the controls of a
module. We have four switches
on board which can be used by
the programmer as per the
requirement for testing and
development
20. Potentiometer
21. 4x1 keypad
88. RESEARCH DESIGN LABS | VOLUME 1, ISSUE 1 WWW.RESEARCHDESIGNLAB.COM
LCD screen consists of two lines with 16 characters each. Each character consists of 5x7 dot
matrix. Contrast on display depends on the power supply voltage and whether messages are
displayed in one or two lines. For that reason, variable voltage 0-Vdd is applied on pin marked as
Vee. Trimmer potentiometer is usually used for that purpose. Some versions of displays have built
in backlight (blue or green diodes). When used during operating, a resistor for current limitation
should be used (like with any LE diode). LCD Connection Depending on how many lines are used
for connection to the microcontroller, there are 8-bit and 4-bit LCD modes. The appropriate mode
is determined at the beginning of the process in a phase called “initialization”. In the first case,
the data are transferred through outputs D0-D7 as it has been already explained. In case of 4-bit
LED mode, for the sake of saving valuable I/O pins of the microcontroller, there are only 4 higher
bits (D4-D7) used for communication, while other may be left unconnected.
Consequently, each data is sent to LCD in two steps: four higher bits are sent first (that normally
would be sent through lines D4-D7), four lower bits are sent afterwards. With the help of
initialization, LCD will correctly connect and interpret each data received. Besides, with regards
to the fact that data are rarely read from LCD (data mainly are transferred from microcontroller
to LCD) one more I/O pin may be saved by simple connecting R/W pin to the Ground. Such saving
has its price. Even though message displaying will be normally performed, it will not be possible
to read from busy flag since it is not possible to read from display.
Features:
1. Can display 224 different symbols.
2. Low power consumption.
3. 5x7 dot matrix format.
4. Powerful command set and user produced characters.
Fig: Circuit connections of LCD
22. 16x2 LCD connectors
10k
89. RESEARCH DESIGN LABS | VOLUME 1, ISSUE 1 WWW.RESEARCHDESIGNLAB.COM
1. Gnd:- Power supply ground
2. VCC:-+5v Power supply input
3. RS:- Reset pin
Node connector is an additional on board connection extender or 1 connection IN and 1
connection out
4. R/W:- Read/Write pin
5. En:-Enable pin
6. D0-D7:- Data lines
Pin Description
23. Node connector
90. RESEARCH DESIGN LABS | VOLUME 1, ISSUE 1 WWW.RESEARCHDESIGNLAB.COM
In a 4x4 matrix keypad eight Input/Output ports are used for interfacing with any
microcontrollers. Rows are connected to Peripheral Input/Output (PIO) pins configured as
output. Columns are connected to PIO pins configured as input with interrupts. In this
configuration, four pull-up resistors must be added in order to apply a high level on the
corresponding input pins as shown in below Figure. The corresponding hexadecimal value of the
pressed key is sent on four LEDs.
This Application Note describes programming techniques implemented on the AT91 ARM-based
microcontroller for scanning a 4x4 Keyboard matrix usually found in both consumer and industrial
applications for numeric data entry.AT91 Keyboard interface In this application, a 4x4 matrix
keypad requiring eight Input/Output ports for interfacing is used as an example. Rows are
connected to Peripheral Input/Output (PIO) pins configured as output. Columns are connected to
PIO pins configured as input with interrupts. In this configuration, four pull-up resistors must be
added in order to apply a high level on the corresponding input pins as shown in Figure 1. The
corresponding hexadecimal value of the pressed key is sent on four LEDs.
FEATURES
1. Contact debouncing.
2. Easy to interface.
3. Interfaces to any microcontroller or microprocessor.
4. Data valid output signal for interrupt activation.
PIN DETAILS
pin 1-4: R0-R3:- Rows
pin 5-8: C0-C3:- Columns
24. 4x4 Matrix Keypad
Working
25. DC 12V connectors
These connectors provide on board
12V DC connections.