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.
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.
The 8051 microcontroller has 40 pins that provide input/output capabilities. It has four 8-bit I/O ports (P0, P1, P2, P3) that allow connection to external devices. Unlike microprocessors, the 8051 has onboard I/O ports so no additional chips are needed. The I/O ports use circuits that allow pins to be individually configured as inputs or outputs using latches controlled by the microcontroller.
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.
Programming avr microcontroller digital iManas Mantri
This document provides information on programming digital I/O for AVR microcontrollers in C. It discusses how to configure the DDR, PORT, and PIN registers to set pins as inputs or outputs. It gives an example of a program that continuously reads the logic values on port B and writes them to port C. It also shows a schematic and code for blinking 8 LEDs connected to an ATMega8515 microcontroller.
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
This document discusses I/O ports, how to use them, and handling the bouncing problem with switches. It explains that I/O ports allow communication between a microcontroller and the outside world by reading and writing voltage levels on pins. The direction of pins is set by a TRIS register. Switches connected to pins can bounce, so software reads the pin multiple times with a delay to filter out false readings. LEDs are used as simple outputs, requiring current limiting resistors. Sample code is provided to output patterns on one port based on inputs to another, including a function to handle switch bouncing.
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.
Embedded Systems - IO Programming
In 8051, I/O operations are done using four ports and 40 pins. The following pin diagram shows the details
of the 40 pins. I/O operation operation port reserves reserves 32 pins where each port has 8 pins. The other 8 pins are
designated as V , GND, XTAL1, XTAL2, RST, EA (bar), ALE/PROG (bar), and PSEN (bar).
It is a 40 Pin PDIP (Plastic Dual Inline Package)
I/O Ports and their Functions
The four ports P0, P1, P2, and P3, each use 8 pins, making them 8-bit ports. Upon RESET, all the ports
are configured onfigured as inputs, inputs, ready to be used as input ports. When the first 0 is written written to a port, it becomes becomes
an output. To reconfigure it as an input, a 1 must be sent to a port.
Port 0 (Pin No 32 – Pin No 39)
Dual Role of Port 0 and Port 2
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.
The 8051 microcontroller has 40 pins that provide input/output capabilities. It has four 8-bit I/O ports (P0, P1, P2, P3) that allow connection to external devices. Unlike microprocessors, the 8051 has onboard I/O ports so no additional chips are needed. The I/O ports use circuits that allow pins to be individually configured as inputs or outputs using latches controlled by the microcontroller.
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.
Programming avr microcontroller digital iManas Mantri
This document provides information on programming digital I/O for AVR microcontrollers in C. It discusses how to configure the DDR, PORT, and PIN registers to set pins as inputs or outputs. It gives an example of a program that continuously reads the logic values on port B and writes them to port C. It also shows a schematic and code for blinking 8 LEDs connected to an ATMega8515 microcontroller.
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
This document discusses I/O ports, how to use them, and handling the bouncing problem with switches. It explains that I/O ports allow communication between a microcontroller and the outside world by reading and writing voltage levels on pins. The direction of pins is set by a TRIS register. Switches connected to pins can bounce, so software reads the pin multiple times with a delay to filter out false readings. LEDs are used as simple outputs, requiring current limiting resistors. Sample code is provided to output patterns on one port based on inputs to another, including a function to handle switch bouncing.
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.
Embedded Systems - IO Programming
In 8051, I/O operations are done using four ports and 40 pins. The following pin diagram shows the details
of the 40 pins. I/O operation operation port reserves reserves 32 pins where each port has 8 pins. The other 8 pins are
designated as V , GND, XTAL1, XTAL2, RST, EA (bar), ALE/PROG (bar), and PSEN (bar).
It is a 40 Pin PDIP (Plastic Dual Inline Package)
I/O Ports and their Functions
The four ports P0, P1, P2, and P3, each use 8 pins, making them 8-bit ports. Upon RESET, all the ports
are configured onfigured as inputs, inputs, ready to be used as input ports. When the first 0 is written written to a port, it becomes becomes
an output. To reconfigure it as an input, a 1 must be sent to a port.
Port 0 (Pin No 32 – Pin No 39)
Dual Role of Port 0 and Port 2
This document provides an introduction to programming PIC microcontrollers using assembly language. It explains the basic components of a PIC microcontroller like the PIC16F84 and shows a simple assembly language program that turns on an LED connected to port B0 as an example. The summary provides essential information about assembly language, the components of a PIC microcontroller program, and assembling and running a simple program on a PIC.
The document discusses various components of microprocessors and peripherals. It provides definitions and explanations of microprocessors, memory devices like ROM, registers like the accumulator, buses, instructions, and machine cycles. It also covers I/O devices like the 8255 PPI, 8279 keyboard interface, 8251 USART, and 8254 timer, describing their components, operating modes, and initialization procedures. The document is a set of questions and answers relating to microprocessor architecture and common peripherals.
This document contains information about Rahil Vyas, a 5th semester ECE student at Amiraj college with enroll number 131080111012. It describes the basic components, features, and specifications of the 8051 microcontroller including its internal ROM, RAM, I/O ports, timers, serial interface, and addressing modes. It provides block diagrams of the 8051 architecture and examples of different instruction types like data transfer, arithmetic, and stack operations.
The document discusses I/O ports and timers in the 8051 microcontroller. It describes the four 8-bit I/O ports (Port 0, Port 1, Port 2, Port 3) that can be configured as inputs or outputs. It also discusses the two 16-bit timer/counters (Timer 0 and Timer 1), their associated registers (TMOD and TCON), and operating modes. The ports and timers provide capabilities for interfacing with external devices and generating time delays or counting events.
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.
1. The document describes how an 8051 microcontroller controls the logic levels on its output and input pins.
2. It explains how writing a 1 or 0 to an output latch sets the corresponding pin high or low, and how reading the input latch indicates whether an external pin is high or low.
3. Pull-up resistors on port 0 pins are also described, as well as the alternate functions of some port 3 pins.
The document describes the input/output buffers and latches for port bits P0.X through P3.X of the 8051 microcontroller. Each port bit has a latch that is used to read from or write to that pin, with the latch being connected to the internal data bus. The latches can be read from or written to under control of address/control signals to interface each port bit with the internal microcontroller components and data bus.
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 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.
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 discusses serial communication using the 8051 microcontroller. It begins by introducing serial vs parallel data transfer, communication modes, and framing. It then describes the RS-232 protocol and pinout when using the 8051 UART. Setting the baud rate using Timer 1 is explained. The document provides details on the Serial Control Register and transmitting and receiving data with the serial port. It concludes by discussing using interrupts with the serial port and providing an example of transmitting data from Port 1 and receiving to Port 0 using interrupts.
The document discusses the instruction set of the 8051 microcontroller. It describes different types of instructions such as arithmetic, data transfer, logical, branching, and bitwise logical instructions. It provides examples of instructions like ADD, MOV, INC, ANL, CLR, and CPL. It also shows the effect of sample instructions on registers and flags before and after execution.
This document discusses various applications of embedded systems including temperature measurement using thermistors and linear temperature sensors like the LM35. It describes how to interface the LM35 temperature sensor with an 8-bit ADC0809 and microcontroller port for temperature readings. It also discusses controlling a stepper motor and interfacing it to port pins of a microcontroller. Finally, it explains interfacing a 2x16 LCD display and keyboard matrix to a microcontroller for input/output applications.
The document provides information about the 74HC/HCT4020 integrated circuit, which is a 14-stage binary ripple counter. It has 12 parallel outputs, a clock input, and an overriding asynchronous master reset input. The counter advances on the falling edge of the clock input and the master reset input asynchronously clears all counter stages and forces the outputs low. The document includes specifications, pin descriptions, logic diagrams, timing diagrams, and package information.
The document describes implementing a system-on-chip (SoC) using VHDL that includes a CPU, ROM, and parallel I/O port. The CPU is a 32-bit RISC architecture with 32 general purpose registers and instructions include MOV, ADD, SUB, LOAD, STORE. The ROM stores the program code. The parallel I/O port interfaces with external devices and responds to memory reads and writes. Implementation details are provided for each component in VHDL including register definitions, control signals, and finite state machines to describe operation.
The document discusses the internal architecture of the AT89C51 microcontroller, including its RAM, special function registers (SFRs), ports, timers/counters, serial interface, and interrupt system. It provides details on the pinouts and functions of the various pins, and describes the purpose and operation of the SFRs, timers, and interrupt handling mechanism.
This document contains information about microcontroller solutions from Ali Akbar Siddiqui of Sir Syed University of Engineering and Technology. It includes sections on 8-bit microcontrollers, programming, memory organization, I/O ports, bit manipulation, registers, and data transfer. The document provides code examples and explanations of microcontroller concepts such as register banks, stack pointers, bit addressing, and data transfer using direct memory access.
This document describes using a finite state machine (FSM) approach to handle asynchronous events in microcontroller units (MCUs). It provides an example of toggling LEDs in response to button presses without using busy-waiting. The example encodes the button states as states in a FSM with states like "CHECK FOR PRESS" and "CHECK FOR RELEASE". Transitioning between these states based on button input allows handling events asynchronously and without blocking other tasks. It also describes adding a software timer to flash an LED while still handling button presses.
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 the Microcontroller 8051. It provides a block diagram and pin description of the 8051. It describes the registers, memory mapping, stack, I/O ports, timers and interrupts of the 8051 microcontroller. It compares microprocessors and microcontrollers, discussing the differences in hardware structure and applications.
This document provides an overview of the 8051 microcontroller architecture. 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 timers/counters, one serial interface, and other features. It also discusses the different addressing modes for 8051 assembly language programming including immediate, register, direct, register indirect, and external direct addressing.
This document provides an introduction to programming PIC microcontrollers using assembly language. It explains the basic components of a PIC microcontroller like the PIC16F84 and shows a simple assembly language program that turns on an LED connected to port B0 as an example. The summary provides essential information about assembly language, the components of a PIC microcontroller program, and assembling and running a simple program on a PIC.
The document discusses various components of microprocessors and peripherals. It provides definitions and explanations of microprocessors, memory devices like ROM, registers like the accumulator, buses, instructions, and machine cycles. It also covers I/O devices like the 8255 PPI, 8279 keyboard interface, 8251 USART, and 8254 timer, describing their components, operating modes, and initialization procedures. The document is a set of questions and answers relating to microprocessor architecture and common peripherals.
This document contains information about Rahil Vyas, a 5th semester ECE student at Amiraj college with enroll number 131080111012. It describes the basic components, features, and specifications of the 8051 microcontroller including its internal ROM, RAM, I/O ports, timers, serial interface, and addressing modes. It provides block diagrams of the 8051 architecture and examples of different instruction types like data transfer, arithmetic, and stack operations.
The document discusses I/O ports and timers in the 8051 microcontroller. It describes the four 8-bit I/O ports (Port 0, Port 1, Port 2, Port 3) that can be configured as inputs or outputs. It also discusses the two 16-bit timer/counters (Timer 0 and Timer 1), their associated registers (TMOD and TCON), and operating modes. The ports and timers provide capabilities for interfacing with external devices and generating time delays or counting events.
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.
1. The document describes how an 8051 microcontroller controls the logic levels on its output and input pins.
2. It explains how writing a 1 or 0 to an output latch sets the corresponding pin high or low, and how reading the input latch indicates whether an external pin is high or low.
3. Pull-up resistors on port 0 pins are also described, as well as the alternate functions of some port 3 pins.
The document describes the input/output buffers and latches for port bits P0.X through P3.X of the 8051 microcontroller. Each port bit has a latch that is used to read from or write to that pin, with the latch being connected to the internal data bus. The latches can be read from or written to under control of address/control signals to interface each port bit with the internal microcontroller components and data bus.
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 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.
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 discusses serial communication using the 8051 microcontroller. It begins by introducing serial vs parallel data transfer, communication modes, and framing. It then describes the RS-232 protocol and pinout when using the 8051 UART. Setting the baud rate using Timer 1 is explained. The document provides details on the Serial Control Register and transmitting and receiving data with the serial port. It concludes by discussing using interrupts with the serial port and providing an example of transmitting data from Port 1 and receiving to Port 0 using interrupts.
The document discusses the instruction set of the 8051 microcontroller. It describes different types of instructions such as arithmetic, data transfer, logical, branching, and bitwise logical instructions. It provides examples of instructions like ADD, MOV, INC, ANL, CLR, and CPL. It also shows the effect of sample instructions on registers and flags before and after execution.
This document discusses various applications of embedded systems including temperature measurement using thermistors and linear temperature sensors like the LM35. It describes how to interface the LM35 temperature sensor with an 8-bit ADC0809 and microcontroller port for temperature readings. It also discusses controlling a stepper motor and interfacing it to port pins of a microcontroller. Finally, it explains interfacing a 2x16 LCD display and keyboard matrix to a microcontroller for input/output applications.
The document provides information about the 74HC/HCT4020 integrated circuit, which is a 14-stage binary ripple counter. It has 12 parallel outputs, a clock input, and an overriding asynchronous master reset input. The counter advances on the falling edge of the clock input and the master reset input asynchronously clears all counter stages and forces the outputs low. The document includes specifications, pin descriptions, logic diagrams, timing diagrams, and package information.
The document describes implementing a system-on-chip (SoC) using VHDL that includes a CPU, ROM, and parallel I/O port. The CPU is a 32-bit RISC architecture with 32 general purpose registers and instructions include MOV, ADD, SUB, LOAD, STORE. The ROM stores the program code. The parallel I/O port interfaces with external devices and responds to memory reads and writes. Implementation details are provided for each component in VHDL including register definitions, control signals, and finite state machines to describe operation.
The document discusses the internal architecture of the AT89C51 microcontroller, including its RAM, special function registers (SFRs), ports, timers/counters, serial interface, and interrupt system. It provides details on the pinouts and functions of the various pins, and describes the purpose and operation of the SFRs, timers, and interrupt handling mechanism.
This document contains information about microcontroller solutions from Ali Akbar Siddiqui of Sir Syed University of Engineering and Technology. It includes sections on 8-bit microcontrollers, programming, memory organization, I/O ports, bit manipulation, registers, and data transfer. The document provides code examples and explanations of microcontroller concepts such as register banks, stack pointers, bit addressing, and data transfer using direct memory access.
This document describes using a finite state machine (FSM) approach to handle asynchronous events in microcontroller units (MCUs). It provides an example of toggling LEDs in response to button presses without using busy-waiting. The example encodes the button states as states in a FSM with states like "CHECK FOR PRESS" and "CHECK FOR RELEASE". Transitioning between these states based on button input allows handling events asynchronously and without blocking other tasks. It also describes adding a software timer to flash an LED while still handling button presses.
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 the Microcontroller 8051. It provides a block diagram and pin description of the 8051. It describes the registers, memory mapping, stack, I/O ports, timers and interrupts of the 8051 microcontroller. It compares microprocessors and microcontrollers, discussing the differences in hardware structure and applications.
This document provides an overview of the 8051 microcontroller architecture. 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 timers/counters, one serial interface, and other features. It also discusses the different addressing modes for 8051 assembly language programming including immediate, register, direct, register indirect, and external direct addressing.
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 overview of the 8051 microcontroller, including its block diagram, pin descriptions, registers, memory mapping, stack, timers, and interrupts. It describes the CPU, RAM, ROM, I/O ports, timers, and interrupt control that are integrated into a single chip in the 8051 microcontroller. It also explains various registers related to timers and interrupts in the 8051.
The document provides an overview of the 8051 microcontroller, including its block diagram, pin descriptions, registers, memory mapping, stack, I/O port programming, timers, and interrupts. It explains the basic components and architecture of the 8051, how it maps memory and handles interrupts and timers. It also compares microprocessors to microcontrollers and discusses embedded systems.
The document provides information about the 8051 microcontroller. It describes the basic components of a microcontroller including the CPU, memory, I/O ports, and timers. It explains the pin layout and functions of the 8051 microcontroller. Key components like registers, memory mapping, stack, and interrupts of the 8051 are summarized. Programming I/O ports and timers is also covered at a high level.
Analog To Digital Conversion (ADC) Programming in LPC2148Omkar Rane
1) The document describes programming the on-chip 10-bit ADC of the LPC2148 microcontroller to implement a simple data acquisition system. It discusses the features of the ADC, the programming interface, control registers, and provides code to initialize the ADC and read conversion results.
2) The code configures the ADC ports and control registers, reads the conversion results when the ADC status indicates a conversion is complete, and prints the voltage levels to the UART.
3) The results show the ADC accurately converts analog voltages from 0-3.1V to their corresponding 10-bit digital values, which are printed to the UART terminal.
The document provides instructions for using an LCD display with a PIC microcontroller. It describes connecting the LCD to the microcontroller in 4-bit mode to save pins. It includes the LCD initialization routine, functions for sending data and commands to the LCD, and positioning the cursor. In the main program, it reads analog sensor values, controls fan speed with PWM, and displays the values and fan speed on the LCD at different lines and positions on the screen.
This document discusses the I/O ports on the 8051 microcontroller and how to interface it with an external 8255 parallel I/O chip. It describes the internal structure and functionality of the 8051's four 8-bit I/O ports P0-P3. It also covers how to configure the ports for input or output, read from and write to the ports, and how the port pins are multiplexed with other signals. The document then discusses using the 8255 chip to expand the number of available I/O ports and provides an example of simple interfacing between the 8051 and 8255 with code.
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.
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.
The document discusses the PIC16F877 microcontroller. It provides details about its memory, packaging options, I/O pins and their special functions. Examples are given to illustrate using the microcontroller for an LED flasher, lockout system, musical tone generator, stepper motor controller and PWM motor speed control using interrupts. The examples cover digital I/O, timers, interrupts, ADC and USART communication.
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 discusses the Intel 8051 microcontroller family. It provides a brief history of the 8051, noting it was introduced in 1980 and had 128 bytes of internal RAM and 4Kbytes of ROM. It then lists several manufacturers of 8051 variants and their key features. The rest of the document goes into more detail about the hardware architecture of the 8051, including the pin descriptions and functions of the ports, timers, and serial interface.
The document describes the AT89C51 microcontroller, including its features, pin descriptions, block diagram, and programming details. Key points:
- It has 4K bytes of flash memory, 128 bytes of RAM, 32 I/O lines, two timers, serial port, and low power modes.
- Pins described include ports 0-3, reset, clock, and power pins. Ports have pullups and alternate functions like serial I/O.
- Block diagram shows CPU, memory, I/O, and peripheral blocks.
- Programming interface supports low or high voltage modes for in-system or external programming of flash memory.
The document provides an introduction to the PIC microcontroller including its origins, architecture, and key features. It discusses the PIC16F877A microcontroller in detail including its register file map, pin configuration, status register, and difference compared to the 8051 microcontroller. Examples of writing assembly language code and C code for blinking an LED are also provided.
The document discusses the 8155 Programmable Peripheral Interface chip. It can be used as an interface between a microprocessor and I/O devices. The 8155 contains RAM, I/O ports, and a timer. It has ports A, B, and C that can be configured as input or output. The timer can operate in different modes. Programming the 8155 involves writing control words to its control register to configure the ports and timer. An example application shows how an 8155 can be used to interface an ADC and read temperature values using handshaking between the ADC and 8155 ports.
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.
3. What you need to start
MPLAB Programming IDE (need windows OS)
• http://www.microchip.com/stellent/idcplg?IdcService=S
S_GET_PAGE&nodeId=1406&dDocName=en019469
&part=SW007002
MPLAB C compiler for PIC18 MCUs
• http://www.microchip.com/stellent/idcplg?IdcService=S
S_GET_PAGE&nodeId=1406&dDocName=en534868
PIC18F2520 Data Sheet
• http://www.microchip.com/wwwproducts/Devices.aspx
?dDocName=en010277
6. Parts
4Mhz Crystal
H-Bridge / Motor Controller
The Base
(Chassis)- Each
group will bring its
own robot base.
Note1: When buying
the base, put in your
mind the maze size.
and the way the base
move.
Note2: a sample of the
maze is available in the
second floor of
Nethken Hall
7. Board Note: All the pins inside
the shaded areas are
connected together.
connectivity
8. Power Circuit
Main Voltage
Power Regulat 5 volt
source or
Capacito
Resistor LED
r
Ground
9. Power Circuit Note: The same like
the previous slide, just
another perspective.
11. PIC 18 pins map
Port A Port B
Analog Input Digital I/O
Port A
Port C Port C
Digital I/O Digital I/O
12. Connecting PIC 18
Resistor
Capacit
or
Capacit
Crystal
ors
Note: Sometimes you will need to add a resistor between the Pin
10 and the crystal. for more information look at the PIC18F2520
Data Sheet.
13. Start Reset
Note: You need the Start/Reset sercut to give the micro
controller the signal to start/restart the program. You can add
a push button if you want a restart button
21. What You Learned
Robot requirements (Softwares and Hardwares)
How to make the power circuit
How to connect your PIC18 chip
How to connect the H-Bridge
23. Hello World - LED ON
/** I N C L U D E S **************************************************/
#include "p18f2520.h"
/** D E C L A R A T I O N S ******************************************/
void main (void)
{
TRISC = 0b01111111; // PORTC bit 7 to output (0); bits 6:0 are inputs (1)
LATCbits.LATC7 = 1; // Set LAT register bit 7 to turn on LED
while (1) Note1: You need to
; include the specific
library of the PIC18 you
} are using.
Note2 : Use the Note3 : Use The
register TRIS to define function LAT to define
the output pins and the the output value of a
input pins in the Port. specific pin
24. Hello World - Blinking LED
/** I N C L U D E S **************************************************/
#include "p18f2520.h"
#include "delays.h"
/** D E C L A R A T I O N S ******************************************/
void main (void)
{
TRISC = 0b01111111; // PORTC bit 7 to output (0); bits 6:0 are inputs (1)
while (1){
LATCbits.LATC7 = 1;
K // Set LAT register bit 7 to turn on LED
Delay1KTCYx(50); // Delay 50 x 1000 (1k) = 50,000 cycles; 50ms @ 4MHz
LATCbits.LATC7 = 0; // Set LAT register bit 7 to turn on LED
Delay1KTCYx(20); // Delay 50 x 1000 (1k) = 50,000 cycles; 20ms @ 4MHz
}
Note: To use the delay
; function, you have to
include the delay
} libraryPut your
Note:
application inside the
While(1) loop to make
it run forever.
27. Running The Robot
/** I N C L U D E S **************************************************/
#include "p18f2520.h"
/** D E C L A R A T I O N S ******************************************/
void main (void)
{
int moveForward = 0b01010011;
int moveBack = 0b00110101;
int turnLeft = 0b01010010;
int turnRight = 0b01000011;
TRISC = 0b00000000; // All PORTC bits to output (0)
PORTC = moveForward ; // set PORTC bits to 0b10100011
while (1)
; Note : Use the register PORT to
give or read a value from/to all the
} pins in the specified Port.
Note : PORTA, PORTB, PORTC
28. Timing
/** I N C L U D E S **************************************************/
#include "p18f45k20.h"
#include "delays.h"
/** D E C L A R A T I O N S ******************************************/
void main (void)
{
int moveForward = 0b01010011;
int moveBack = 0b00110101;
int turnLeft = 0b01010010;
int turnRight = 0b01000011;
TRISC = 0; // All PORTC bits to output (0) (using the dismal system )
PORTC = moveForward ;
Delay1KTCYx(50); // Delay 50 x 1000 (1k) = 50,000 cycles; 50ms @ 4MHz
PORTC = turnLeft ;
Delay1KTCYx(50); // Delay 50 x 1000 (1k) = 50,000 cycles; 50ms @ 4MHz
PORTC = turnRight ;
Delay1KTCYx(50); // Delay 50 x 1000 (1k) = 50,000 cycles; 50ms @ 4MHz
PORTC = moveBack ;
Delay1KTCYx(50); // Delay 50 x 1000 (1k) = 50,000 cycles; 50ms @ 4MHz
while (1)
;
}
Note: Think about how
this robot will be
moving
29. What You Learned
How to start your first project
How to define the Input and the output ports
How to Time Control your output
30. Problem
Robot with Touch Sensor
Our Robot IR Sensor
Wall
31. IR Sensor
Operating Voltage 4.5v - 5.5v (red and black)
Distance 4cm - 30cm
Analog output (White Cable)
Note: The white cable
will go to the Micro
Controller. And the
Red to the Regulated
5v we created. and the
black to the ground.
Note2: The response
time for this IR Sensor
is 39ms. which is too
slow for a moving
robot.
32. IR Sensor
Note: if the distance is
less than 4cm the
Sensor gives back
wrong measuring.
Note2: Because the
response time for the
IR sensor is too
slow, you need to
detect the distance as
early as you can. and
put a safe fail back
technique
34. Connecting the IR Sensors
Center Sensor (AN0)
Left Sensor (AN1)
Right Sensor (AN2)
35. Using The AD Converter
void setSensor(sensorChannel)
{
switch (sensorChannel)
{
case 0:// channel AN0 for Central Sensor
ADCON0 = 1;
break;
case 1: // channel AN1 for Right Sensor
ADCON0 = 5; //101
break;
case 2: // channel AN2 for Left Sensor
ADCON0 = 9; //1001
break;
} Note2: We create the
}
Function SetSensor to
make it easer for us to
debug and understand
the code.
36. ADCON0
STATUS ON/OFF
CHANNEL NUMBER BITS
BIT BIT
Note2: if you need to understand more about the Analog to
Digital Converter’s registers read about it in the micro
controller Data Sheet.
37. void setupAD()
{
ADCON1 = 12; //This sets the chip so that AN0, AN1, AN2 are analog. Instructions for this can be found in
the chip documentation. p 230
ADCON0 = 0; //Make sure ADC settings are 0
ADCON2 = 164; //this sets Right justified. Bit 6 is NC (0), Bits 5-0 adjust time (Bits 5-0 are 100100)
}
void enableAD() // You don’t need this function, we already set our ADON to 1 in the function SetSensor() I put it
just to explain what you can do.
{
Note: Enable the AD
ADCON0bits.ADON = 1; //Enables the A/D converter buy changing the pit
} ADON value to 1 and
void listenToAD()
disable it by changing
{ the value to 0;
ADCON0bits.GO_DONE = 1; //Like the start button for the converter.
while(ADCON0bits.GO_DONE == 1) //Wait until the ADC is finished. GO_DONE will change to 0 and the
loop will end
{
//do nothing here
}
}
38. How to use it in the main
Note: The Values for FarRange and
int farRange = 70; CloseRange is just for explaining. You will
int closeRange = 150; need to figure out the best values for your
int centralSensor, rightSensor, leftSensor; robot.
own
setSensor(0);
Note: The values from the AD will
listenToAD(); be stored in the Register ADRES,
if you need to compare the
centralSensor = ADRES; distance from the sensors you
if (centralSensor < farRange) need to store the value to a
variable or your ADRES will be
PORTC = moveBack; overwritten.
if (centralSensor > farRange && SC < clsoeRange)
PORTC = turnLeft;
if (centralSensor > closeRange)
PORTC = moveBackward;
39. What You learned
The Usage of Sensors
How to use Analog IR sensor
Making The right diction
Note: The Code I provided is not
meant to be running 100%, it is
explanatory code ONLY.
You will need to define your
functions and variables correctly.
40. SPECIAL THANKS
Robotic Club Advisor
•Dr. Ben Choi
Robotic Club Vise President
•James Hurst
Our FaceBook Group : Louisiana Tech Robotic
Club