Sie sind auf Seite 1von 80

GSM BASED INDUSTRIAL CONTROL AND AUTOMATION USING ARM7

ABSTRACT AIM: The main objective of this project is to develop an embedded system, which is used for intruder detection at Industry using GSM. IMPLEMENTATION: This project is implemented ARM based LPC2148 developed board interfaced with , relay, bulb and fan GSM modem, Buzzer and LCD for display purpose.

BLOCK DIAGRAM:

MOBILE AT REMOTE AREA

LCD 162
GSM

MAX 232

Lpc2148

RPS BUZZER Cryst al Dc fan light

relay relay

POWER SUPPLY:

STEP DOWN TRANSFORMER

BRIDGE RECTIFIER

FILTER CIRCUIT

REGULATOR SECTION

DESCRIPTION: There is a lot of requirement to automate the security systems to ensure the security of the industry at low cost. In our project we are going to develop an embedded security system which will detect the others not to intrude in industry. The security system will use GSM interface to inform the authorized person. How our project will works is on our embedded designed board there was a , relay to control fan and light through GSM Technology. The system can work standalone and can also be integrated to a computer using rs-232 port. The complete code for the embedded system is going to be developed using c-language.

SOFTWARE: Embedded C KEIL Uc Flash Version

HARDWARE:

LPC2148 ARM BOARD Power Supply RELAY LIGHT FAN GSM modem Buzzer LCD

ADVANTAGES: Low cost, automated operation, Low Power consumption.

CHAPTER 1 Embedded Systems INTRODUCTION TO EMBEDDED SYSTEMS Definition of an Embedded System An embedded system is a computer system designed for specific control functions within a larger system, often with real-time computing constraints. It is embedded as part of a complete device often including hardware and mechanical parts. By contrast, a general-purpose computer, such as a personal computer (PC), is designed to be flexible and to meet a wide range of end-user needs. Embedded systems control many devices in common use today. Embedded systems contain processing cores that are either microcontrollers or digital signal processors (DSP).The key characteristic, however, is being dedicated to handle a particular task. Since the embedded system is dedicated to specific tasks, design engineers can optimize it to reduce the size and cost of the product and increase the reliability and performance. Some embedded systems are mass-produced, benefiting from economies of scale. Physically, embedded systems range from portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers. Complexity varies from low, with a single microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or enclosure. Embedded systems are designed to do some specific task, rather than be a generalpurpose computer for multiple tasks. Some also have real-time performance constraints that must be met, for reasons such as safety and usability; others may have low or no performance requirements, allowing the system hardware to be simplified to reduce costs.

Embedded systems are not always standalone devices. Many embedded systems consist of small, computerized parts within a larger device that serves a more general purpose. For example, the Gibson Robot Guitar features an embedded system for tuning the strings, but the overall purpose of the Robot Guitar is, of course, to play music. Similarly, an embedded system in an automobile provides a specific function as a subsystem of the car itself.

The program instructions written for embedded systems are referred to as firmware, and are stored in read-only memory or Flash memory chips. They run with limited computer hardware resources: little memory, small or non-existent keyboard or screen.

Embedded system text user interfaceusing MicroVGA Embedded systems range from no user interface at all dedicated only to one task to complex graphical user interfaces that resemble modern computer desktop operating systems. Simple embedded devices use buttons, LEDs, graphic or character LCDs (for example popular HD44780 LCD) with a simple menu system. More sophisticated devices which use a graphical screen with touch sensing or screenedge buttons provide flexibility while minimizing space used: the meaning of the buttons can change with the screen, and selection involves the natural behavior of pointing at what's desired. Handheld systems often have a screen with a "joystick button" for a pointing device.

Some systems provide user interface remotely with the help of a serial (e.g. RS232, USB, IC, etc.) or network (e.g. Ethernet) connection. This approach gives several advantages: extends the capabilities of embedded system, avoids the cost of a display, simplifies BSP, allows us to build rich user interface on the PC. A good example of this is the combination of an embedded web serverrunning on an embedded device (such as an IP camera) or a network routers. The user interface is displayed in a web browser on a PC connected to the device, therefore needing no bespoke software to be installed. Processors in embedded systems Embedded processors can be broken into two broad categories. Ordinary microprocessors (P) use separate integrated circuits for memory and peripherals. Microcontrollers (C) have many more peripherals on chip, reducing power consumption, size and cost. In contrast to the personal computer market, many different basic CPU architectures are used, since software is custom-developed for an application and is not a commodity product installed by the end user. Both Von Neumann as well as various degrees of Harvard architectures are used. RISC as well as non-RISC processors are found. Word lengths vary from 4-bit to 64-bits and beyond, although the most typical remain 8/16-bit. Most architectures come in a large number of different variants and shapes, many of which are also manufactured by several different companies. An embedded system is some combination of computer hardware and software, either fixed in capability or programmable, that is specifically designed for a particular function. Industrial machines, automobiles, medical equipment, cameras, household appliances, airplanes, vending machines and toys (as well as the more obvious cellular phone and PDA) are among the myriad possible hosts of an embedded system. Embedded systems that are programmable are provided with programming interfaces, and embedded systems programming is a specialized occupation. Certain operating systems or language platforms are tailored for the embedded market, such as EmbeddedJava and Windows XP Embedded. However, some low-end consumer products use very inexpensive microprocessors and limited storage, with the application and operating system both part of a single program. The program is written permanently

into the system's memory in this case, rather than being loaded into RAM (random access memory) like programs on a personal computer. An embedded system is a single-purpose computer built into a larger system for the purposes of controlling and monitoring the system. A general purpose computer (e.g. a personal computer) is defined not to be an embedded system. Examples: cell phones, DSTV decoders, MP3 players, ABS breaking systems, and satellite guidance avionics. COMPONENTS OF EMBEDDED SYSTEM It has Hardware Processor, Timers, Interrupt controller, I/O Devices, Memories, Ports, etc. It has main Application Software Which may perform concurrently the series of tasks or multiple tasks. It has Real Time Operating System (RTOS) RTOS defines the way the system work. Which supervise the application software. It sets the rules during the execution of the application program. A small scale embedded system may not need an RTOS. Features of Embedded Systems The versatility of the embedded computer system lends itself to utility in all kinds of enterprises, from the simplification of deliverable products to a reduction in costs in their development and manufacture. Complex systems with rich functionality employ special operating systems that take into account major characteristics of embedded systems. Embedded operating systems have minimized footprint and may follow real-time operating system specifics. The special computers system is usually less powerful than general-purpose systems, although some expectations do exist where embedded systems are very powerful and complicated. Usually a low power consumption CPU with a limited amount of memory is used in embedded systems. Many embedded systems use very small operating systems; most of these provide very limited operating system capabilities.

Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost of the product, or increasing the reliability and performance. Some embedded systems are mass-produced, benefiting from economies of scale. Some embedded systems have to operate in extreme environment conditions such as very high temperature & humidity. For high volume systems such as portable music players or mobile phones, minimizing cost is usually the primary design consideration. Engineers typically select hardware that is just good enough to implement the necessary functions. For low volume or prototype embedded systems, general purpose computers may be adapted by limiting the programs or by replacing the operating system with a real-time operating system. Characteristics of Embedded Systems Embedded computing systems generally exhibit rich functionalitycomplex

functionality is usually the reason for introducing CPUs into the design. However, they also exhibit many non-functional requirements that make the task especially challenging: Real-time deadlines that will cause system failure if not met; Multi-rate operation; In many cases, low power consumption; Low manufacturing cost, which often means limited code size. Workstation programmers often concentrate on functionality. They may consider the performance characteristics of a few computational kernels of their software, but rarely analyze the total application. They almost never consider power consumption and manufacturing cost. The need to juggle all these requirements makes embedded system programming very challenging and is the reason why embedded system designers need to understand computer architecture.

Applications of Embedded Systems Some of the most common embedded systems used in everyday life are Small embedded controllers: 8-bit CPUs dominate, simple or no operating system (e.g., thermostats) Control systems: Often use DSP chip for control computations (e.g., automotive engine control) Distributed embedded control: Mixture of large and small nodes on a real-time Embedded networks (e.g., cars, elevators, factory automation) System on chip: ASIC design tailored to application area (e.g., consumer electronics, set-top boxes) Network equipment: Emphasis on data movement/packet flow (e.g., network switches; telephone switches) Critical systems: Safety and mission critical computing (e.g., pacemakers, automatic trains) Signal processing: Often use DSP chips for vision, audio, or other signal Processing (e.g., face recognition) Robotics: Uses various types of embedded computing (especially Vision and control) (e.g., autonomous vehicles) Computer peripherals: Wireless systems: Disk drives, keyboards, laser printers, etc. Wireless network-connected sensor networks and Motes to gather and report information Embedded PCs: Palmtop and small form factor PCs embedded into Equipment

Command and control:

Often huge military systems and systems of systems (e.g., a fleet of warships with interconnected Computers)

Home Appliances, intercom, telephones, security systems, garage door openers, answering machines, fax machines, home computers, TVs, cable TV tuner, VCR, camcorder, remote controls, video games, cellular phones, musical instruments, sewing machines, lighting control, paging, camera, pinball machines, toys, exercise equipment Office Telephones, computers, security systems, fax machines, microwave, copier, laser printer, color printer, paging Auto Trip computer, engine control, air bag, ABS, instrumentation, security system, transmission control, entertainment, climate control, cellular phone, keyless entry

TYPES OF EMBEDDED SYSTEMS Based on functionality and performance embedded systems categorized as 4 types 1. Stand alone embedded systems 2. Real time embedded systems 3. Networked information appliances 4. Mobile devices

1. Stand alone embedded systems:As the name implies, stand alone systems work in stand alone mode. They take i/p, process them and produce the desire o/p. The i/p can be an electrical signal from transducer or temperature signal or commands from human being. The o/p can be electrical signal to drive another system an led or LCD display ex digital camera, microwave oven, CD player, Air conditioner etc .

2. Real time embedded systems:In this type of an embedded system a specific work has to be complete in a particular period of time. Hard Real time systems: - embedded real time used in missiles Soft Real time systems: - DVD players 3. Networked information appliances:Embedded systems that are provided with n/w interfaces and accessed by n/w such as local area n/w or internet are called Network Information Appliances Ex A web camera is connected to the internet. Camera can send pictures in real time to any computers connected to the internet

4. Mobile devices:Actually it is a combination of both VLSI and Embedded System Mobile devices such as Mobile phone, Personal digital assistants, smart phones etc are special category of embedded systems

CHAPTER-2 LPC2148-ARM-7 2.1 Introduction to ARM Processor ARM Advanced RISC machines Founded in November 1990 Spun out of Acorn Computers Designs the ARM range of RISC processor cores Licenses ARM core designs to semiconductor partners who fabricate and sell to their customers. ARM does not fabricate silicon itself Software tools, boards, debug hardware, application software, bus architectures, peripherals etc One of the most licensed and thus widespread processor cores in the world Used in PDA, cell phones, multimedia players, handheld game console, digital TV and cameras ARM7: GBA, iPod ARM9: NDS, PSP, Sony Ericsson, BenQ ARM11: Apple iPhone, Nokia N93, N800 75% of 32-bit embedded processors Also develop technologies to assist with the design-in of the ARM architecture

Used especially in portable devices due to its low power consumption and reasonable performance On 22nd Jan, 2008, ARM announced that the total number of processors shipped by its Partners has exceeded ten billion RISC architecture (Reduced Instruction set computer) Fixed instruction size (e.g., 32bit)

Load-store architecture Operands must be located in registers The operation result is put into register

Large register file Simple addressing modes Hard-wired instruction decoding logic Pipelined execution Single-cycle execution Simple hardware Small die size Low power consumption

RISC organization

Advantage

Simple decoding Higher performance Easy to implement an effective pipelined structure

Disadvantage Performance depends on compiler Poor code density RISC has a fixed size of instruction format Small number of instructions

2.2 ARM LPC2148

This chapter introduces LPC2148 microcontroller board based on a 16-bit/32-bit ARM7TDMI-S CPU with real-time emulation and embedded trace support, that combine microcontrollers with embedded high-speed flash memory ranging from 32 kB to 512 kB. A 128-bit wide memory interface and unique accelerator architecture enable 32-bit code execution at the maximum clock rate. For critical code size applications, the alternative 16-bit Thumb mode reduces code by more than 30% with minimal

performance penalty. The meaning of LPC is Low Power Low Cost microcontroller. This is 32 bit microcontroller manufactured by Philips semiconductors (NXP). Due to their tiny size and low power consumption, LPC2148 is ideal for applications where miniaturization is a key requirement, such as access control and pointof-sale.

Features of ARM Microcontroller 16-bit/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package. 8 kB to 40 kB of on-chip static RAM and 32 kB to 512 kB of on-chip flash memory;128-bit wide interface/accelerator enables high-speed 60 MHz operation. In-System Programming/In-Application Programming (ISP/IAP) via on-chip boot loader software, single flash sector or full chip erase in 400 ms and programming of 256 B in 1 ms EmbeddedICE RT and Embedded Trace interfaces offer realtime debugging with the on-chip RealMonitor software and high-speed tracing of instruction execution. USB 2.0 Full-speed compliant device controller with 2 kB of endpoint RAM. In addition, the LPC2148 provides 8 kB of on-chip RAM accessible to USB by DMA. One or two (LPC2141/42 vs, LPC2144/46/48) 10-bit ADCs provide a total of 6/14 analog inputs, with conversion times as low as 2.44 ms per channel. Single 10-bit DAC provides variable analog output (LPC2148 only) Two 32-bit timers/external event counters (with four capture and four compare channels each), PWM unit (six outputs) and watchdog. Low power Real-Time Clock (RTC) with independent power and 32 kHz clock input Multiple serial interfaces including two UARTs (16C550), two Fast I2C-bus (400 kbit/s),SPI and SSP with buffering and variable data length capabilities.

Vectored Interrupt Controller (VIC) with configurable priorities and vector addresses Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64 package. Up to 21 external interrupt pins available. 60 MHz maximum CPU clock available from programmable on-chip PLL with settling time of 100 ms. On-chip integrated oscillator operates with an external crystal from 1 MHz to 25 MHz Power saving modes include Idle and Power-down Individual enable/disable of peripheral functions as well as peripheral clock scaling for additional power optimization. Processor wake-up from Power-down mode via external interrupt or BOD. Single power supply chip with POR and BOD circuits: CPU operating voltage range of 3.0 V to 3.6 V (3.3 V 10 %) with 5 V tolerant I/O.

Brief overview of ARM7 Architecture ARM7TDMI ARM 32-bit RISC core at 16-bit system costs. The ARM7TDMI core is a 32-bit embedded RISC processor delivered as a hard macrocell optimized to provide the best combination of performance, power and area characteristics. The ARM7TDMI core enables system designers to build embedded devices requiring small size, low power and high performance.

The ARM7 family also includes the ARM7TDMI processor, the ARM7TDMIS processor, the ARM720T processor and the ARM7EJ-S processors, each of which has been developed to address different market requirements.

The market for microprocessors continues to diversify, based on the evolving demands of applications including wireless, home entertainment, automotive and microcontrollers. ARM core families sharing the ARMv7 architecture will cover the widening spectrum of embedded processing. The ARM architecture is based on Reduced Instruction Set Computer (RISC) principles. The RISC instruction set and related decode mechanism are much simpler than those of Complex Instruction Set Computer (CISC) design. This simplicity gives: A high instruction throughput An excellence real-time interrupts response A small, cost-effective, processor macrocell The ARM7TDMI core is the industrys cost widely used 32-bit embedded RISC microprocessor solution. Optimized for cost and power-sensitive application, the ARM7TDMI solution provides low power consumption, small size, and high performance needed in portable, embedded application. The ARM7DMI-S is synthesizable version of ARM7TDMI core. The ARM720T hard macrocell contain the ARM7DMI core, 8KB unified cache and MMU (Memory Management Unit) that allows the use of protected execution space and virtual memory. The ARM7EJ-S processor is synthesizable core that provides all the benefit of ARM7DMI, while also incorporating ARMs latest DSP extensions and jazelle technology, enabling acceleration of Java-based applications.

2.3 Architecture: The ARM7 core is based on the von Neumann architecture with 32-bit data bus that carries both instruction and data. Data can be of 8 bits, 16 bits, 32 bits. It has following features:

Instruction pipeline Memory format Operation modes Coprocessor Debugging feature Instruction pipeline:

The ARMv7 core uses a three stager pipeline to increase the flow of instructions to the processor. This allows multiple simultaneous operations to take place and continuous operations and memory systems. The instructions are executed in three stages: Fetch Decode Execute During normal operation, while one instruction is being executed, its successor is being decoded, and third instruction is being fetched from the memory. The program counter (PC) value used in an executing instruction is always two instructions ahead of the address. Fetch (add) Decode Execute The STR instruction takes more than one cycles to execute, due to which any following instruction is stalled. To avoid this problem we can break decode stage in some more stages. ARM9 core has 5 stages in its pipeline.

2.4 Memory Format: The ARM7 memory interface is design to allow optimum performance potential and minimize memory usage. Speed critical control signals are pipelined to allow system control function to exploit the fast burst access modes supported by many memory technologies. ARM7 has four basics types of cycle: Internal Non sequential Sequential Coprocessor transfer The ARM7 can be configured to store the words as either in little-endian or big-endian format. The ARM7 processor supports the following data types: Word, 32-bit Half word, 16-bit Byte, 8-bit You must align this as follow: Word quantities must be aligned to four-byte boundaries. Half word quantities must be aligned to two-byte oundaries. Byte quantities can be placed on any boundary. The ARM core supports two operating states and instruction sets

- ARM state for 32 bit word aligned instruction - Thumb state for 16-bit half word aligned instruction 2.5 Operating modes: The ARMv7 core has seven modes of operation: User mode normal ARM program execution mode and used for executing most application programs. Fast Interrupt (FIQ) mode supports data transfer or channel processes to allow very fast interrupt Interrupt (IRQ) mode is used for general purpose interrupt handling. Supervisor (SVC) is protected mode for operating system. Abort (ABT) mode is entered after a data or instruction fetch is aborted. Undefined (UND) mode is entered when an undefined instruction is executed. System (SYS) is a privileged user mode for the operating system. Modes other than user mode are collectively known as privileged modes. Privileged modes are used to service interrupts or exceptions, or to access protected resources. The ARMv7 has 37 register all are 32bit wide, not all the registers are available for a given modes. R15 is program counter. R14 is link register. R13 stack pointer. CPSR current program status register. SPSR saved program status register. Coprocessor:

Up to 16 coprocessors can be connected to an ARMv7 system. Coprocessors are separate processing unit that tightly coupled to the ARM processor. Typical coprocessor contains: An instruction pipeline Instruction decode logic Handshake logic A register bank Special processing logic with its own data path Debugging Feature: Internal state of the ARM core can be examined using a JTAG interface to allow the insertion of instructions into core pipeline and avoid using external data bus. ARM7TDMI core includes an internal functional unit known as the Embedded ICE logic. The embedded ICE logic is configured to monitor the ARM7TDMI core actively for specific instruction fetches and data accesses.

2.5 Applications: Using the ARMv7 architecture, ARM can strengthen its position as a lowpower/performance leader while conquering new markets to carry its cores up in high performance and down in the low-cost high-volume domain of the microcontroller ARM designs the technology that lies at the heart of advanced digital products, from wireless, networking and consumer entertainment solutions to imaging, automotive, security and storage devices. ARM's comprehensive product offering includes 16/32-bit RISC microprocessors, data engines, 3D processors, digital libraries, embedded memories, peripherals, software and

development tools, as well as analog functions and high-speed connectivity products.

2.6 Arm Board description

Specifications of MiniARM-2148 board:


1. LPC2148@14.7456 MHz.

2. Operating speed up to 58.9824 MHz using on-chip PLL. 3. LCD interface circuit with 16 pins connector for connecting text LCD module. 4. One serial port with a serial communication cable to connect to PC. 5. Regulators to supply 5V, 3.3V, 1.8V to the board. 6. DC adaptor (230 VAC input, 9 VDC output, 50mA), which can be directly connected to the board. 7. Unused/optionally used port pins are available on convenient connectors. 8. Push button to reset the microcontroller. 9. Jumper to select between Program (ISP) mode and RUN mode. 10. MiniARM-2148 board include Real Time Clock(RTC) with battery. Please note, it can maintain date and time even when power is switched off; only if the RTC is initialized to correct mode of operation by software. 11. LCD is supplied along with the board and is to be connected to LCD interface circuit connector. 12. LED module is supplied along with the board and is to be connected to optional port pins.

2.7 Pin Configuration:

Pin description

Pin Connect Block The pin connect block allows selected pins of the microcontroller to have more than one function. Configuration registers control the multiplexers to allow connection between the pin and the on chip peripherals. Peripherals should be connected to the appropriate pins prior to being activated, and prior to any related interrupt(s) being enabled. Activity of any enabled peripheral function that is not mapped to a related pin should be considered undefined. Selection of a single function on a port pin completely excludes all other functions otherwise available on the same pin.

Register description:

Pin Function Select Register 0 (PINSEL0 - 0xE002 C000):

The PINSEL0 register controls the functions of the pins as per the settings listed below. The direction control bit in the IO0DIR register is effective only when the GPIO function is selected for a pin. For other functions, direction is controlled automatically.

Pin function Select register 1 (PINSEL1 - 0xE002 C004) The PINSEL1 register controls the functions of the pins as per the settings listed in following tables. The direction control bit in the IO0DIR register is effective only when

the GPIO function is selected for a pin. For other functions direction is controlled automatically.

Pin function Select register 2 (PINSEL2 - 0xE002 C014) The PINSEL2 register controls the functions of the pins as per the settings listed in Table. The direction control bit in the IO1DIR register is effective only when the GPIO function is selected for a pin. For other functions direction is controlled automatically. NOTE : use read-modify-write operation when accessing PINSEL2 register. Accidental write of 0 to bit 2 and/or bit 3 results in loss of debug and/or trace functionality! Changing of either bit 4 or bit 5 from 1 to 0 may cause an incorrect code execution!

2.8 General Purpose Input/Output ports (GPIO):

Every physical GPIO port is accessible via either the group of registers providing enhanced features and accelerated port access or the legacy group of registers Accelerated GPIO functions: GPIO registers are relocated to the ARM local bus so that the fastest possible I/O timing can be achieved Mask registers allow treating sets of port bits as a group, leaving other bits unchanged All registers are byte and half-word addressable Entire port value can be written in one instruction Bit-level set and clear registers allow a single instruction set or clear of any number of bits in one port Direction control of individual bits All I/O default to inputs after reset

Backward compatibility with other earlier devices is maintained with legacy registers appearing at the original addresses on the VPB bus GPIO pin description

Register description LPC2141/2/4/6/8 has two 32-bit General Purpose I/O ports. Total of 30 input/output and a single output only pin out of 32 pins are available on PORT0. PORT1 has up to 16 pins available for GPIO functions. PORT0 and PORT1 are controlled via two groups of 4 registers. These registers represent the enhanced GPIO features available on the LPC2148. All of these registers are located directly on the local bus of the CPU for the fastest possible read and write timing. An additional feature has been added that provides byte addressability of all GPIO registers. A mask register allows treating groups of bits in a single GPIO port separately from other bits on the same port. The following text will refer to the legacy GPIO as "the slow" GPIO, while GPIO equipped with the enhanced features will be referred as "the fast" GPIO.

GPIO port Direction register (IODIR, Port 0: IO0DIR - 0xE002 8008 and Port 1: IO1DIR - 0xE002 8018) This word accessible register is used to control the direction of the pins when they are configured as GPIO port pins. Direction bit for any pin must be set according to the pin functionality. Legacy registers are the IO0DIR and IO1DIR, while the enhanced GPIO functions are supported via the FIO0DIR and FIO1DIR registers.

GPIO port 0 Direction register (IO0DIR - address 0xE002 8008) bit description

GPIO port 1 Direction register (IO1DIR - address 0xE002 8018) bit description

GPIO port Pin value register (IOPIN, Port 0: IO0PIN - 0xE002 8000 and Port 1: IO1PIN - 0xE002 8010) This register provides the value of port pins that are configured to perform only digital functions. The register will give the logic value of the pin regardless of whether the pin is configured for input or output, or as GPIO or an alternate digital function. For example selecting the pin as an A/D input disconnects the digital features of the pin. In that case, the pin value read in the IOPIN register is not valid. GPIO port 0 Pin value register (IO0PIN - address 0xE002 8000) bit description

GPIO port 1 Pin value register (IO1PIN - address 0xE002 8010) bit description

GPIO port output Set register (IOSET, Port 0: IO0SET - 0xE002 8004 and Port 1: IO1SET - 0xE002 8014) This register is used to produce a HIGH level output at the port pins configured as GPIO in an OUTPUT mode. Writing 1 produces a HIGH level at the corresponding port pins. Writing 0 has no effect. If any pin is configured as an input or a secondary function, writing 1 to the corresponding bit in the IOSET has no effect. Reading the IOSET register returns the value of this register, as determined by previous writes to IOSET and IOCLR (or IOPIN as noted above). This value does not reflect the effect of any outside world influence on the I/O pins.

GPIO port 0 output Set register (IO0SET - address 0xE002 8004 bit description

GPIO port 1 output Set register (IO1SET - address 0xE002 8014) bit description

GPIO port output Clear register (IOCLR, Port 0: IO0CLR - 0xE002800C and Port 1: IO1CLR - 0xE002 801C) This register is used to produce a LOW level output at port pins configured as GPIO in an OUTPUT mode. Writing 1 produces a LOW level at the corresponding port pin and clears the corresponding bit in the IOSET register. Writing 0 has no effect. If any pin is configured as an input or a secondary function, writing to IOCLR has no effect.

GPIO port 0 output Clear register 0 (IO0CLR - address 0xE002 800C) bit description

GPIO port1 output Clear register 1 (IO1CLR - address 0xE002 801C) bit description

2.9 SERIAL COMMUNICATION:

Serial data communication uses two methods, asynchronous and synchronous. The synchronous method transfers a block of data (characters) at a time, while the asynchronous method transfers a single byte at a time. It is possible to write software to use either of these methods, but the programs can be tedious and long. For this reason, there are special ic chips made by many manufacturers for serial data communications. These chips can be commonly referred to as uart (universal asynchronous receiver-transmitter) and usart ( universal synchronous asynchronous receiver-transmitter). The 8051 chip has a built-in uart. Asynchronous serial communication and data framing Start bits and stop bits In the asynchronous method is character is placed between start and stop bits, this is called data framing. In asynchronous communication, at least two extra bits are transmitted with the data word; a start bit and a stop bit. Therefore, if the transmitter is using an 8-bit system, the actual number of bits transmitted per word is ten. In most protocols the start bit is a logic 0 while the stop bit is logic 1. Therefore, when no data is being sent the data line is continuously high. The receiver waits for a 1 to 0 transition. In other words, it awaits a transition from the stop bit (no data) to the start bit (logic 0). Once this transition occurs the receiver knows a data byte will follow. Since it knows the data rate (because it is defined in the protocol) it uses the same clock as frequency as that used by the transmitter and reads the correct number of bits and stores them in a register. For example, if the protocol determines the word size as eight bits, once the receiver sees a start bit it reads the next eight bits and places them in a buffer. Once the data word has been read the receiver checks to see if the next bit is a stop bit,signifying the end of the data. If the next bit is not a logic 1 then something went wrong with the transmission and the receiver dumps the data. If the stop bit was received the receiver waits for the next data word, ie; it waits for a 1 to 0 transition.

Universal Asynchronous Receiver/Transmitter 0 16 byte Receive and Transmit FIFOs Register locations conform to 550 industry standard.

Receiver FIFO trigger points at 1, 4, 8, and 14 bytes. Built-in fractional baud rate generator with autobauding capabilities. Mechanism that enables software and hardware flow control implementation.

Pin description: UART0 pin description

Register description

UART0 Receiver Buffer Register (U0RBR - 0xE000 C000, when

DLAB = 0, Read Only) The U0RBR is the top byte of the UART0 Rx FIFO. The top byte of the Rx FIFO contains the oldest character received and can be read via the bus interface. The LSB (bit 0) represents the oldest received data bit. If the character received is less than 8 bits, the unused MSBs are padded with zeroes. The Divisor Latch Access Bit (DLAB) in U0LCR must be zero in order to access the U0RBR. The U0RBR is always Read Only.

UART0 Transmit Holding Register (U0THR - 0xE000 C000, when DLAB = 0, Write Only) The U0THR is the top byte of the UART0 TX FIFO. The top byte is the newest character in the TX FIFO and can be written via the bus interface. The LSB represents the first bit to transmit. The Divisor Latch Access Bit (DLAB) in U0LCR must be zero in order to access the U0THR. The U0THR is always Write Only.

UART0 Divisor Latch Registers (U0DLL - 0xE000 C000 and U0DLM -

0xE000 C004, when DLAB = 1) The UART0 Divisor Latch is part of the UART0 Fractional Baud Rate Generator and holds the value used to divide the clock supplied by the fractional prescaler in order to produce the baud rate clock, which must be 16x the desired baud rate. The U0DLL and U0DLM registers together form a 16 bit divisor where U0DLL contains the lower 8 bits of the divisor and U0DLM contains the higher 8 bits of the divisor. A 0x0000 value is treated like a 0x0001 value as division by zero is not allowed. The Divisor Latch Access Bit (DLAB) in U0LCR must be one in order to access the UART0 Divisor Latches.

UART0 Divisor Latch LSB register (U0DLL - address 0xE000 C000, when DLAB = 1) bit description

UART0 Divisor Latch MSB register (U0DLM - address 0xE000 C004, when DLAB = 1) bit description

UART0 FIFO Control Register (U0FCR - 0xE000 C008)

The U0FCR controls the operation of the UART0 Rx and TX FIFOs.

UART0 Line Control Register (U0LCR - 0xE000 C00C)

The U0LCR determines the format of the data character that is to be transmitted or received.

UART0 Line Status Register (U0LSR - 0xE000 C014, Read Only) The U0LSR is a read-only register that provides status information on the UART0 TX and RX blocks.

UART0 FIFO Control Register (U0FCR - 0xE000 C008)

The U0FCR controls the operation of the UART0 Rx and TX FIFOs.

Universal Asynchronous Receiver/Transmitter 1

UART1 is identical to UART0, with the addition of a modem interface. 16 byte Receive and Transmit FIFOs. Register locations conform to 550 industry standard. Receiver FIFO triggers points at 1, 4, 8, and 14 bytes. Built-in fractional baud rate generator with autobauding capabilities. Mechanism that enables software and hardware flow control implementation.

Standard modem interface signals included with flow control (auto-CTS/RTS) fully supported in hardware. Pin description:

Register description UART1 registers are identical to UART0 registers. There configuration remains the same.

CHAPTER-3 Power Supply: Regulated Power Supply

In mains-supplied electronic systems the AC input voltage must be converted into a DC voltage with the right value and degree of stabilization. The common DC voltages that are required to power up the devices are generally in the range of 3 VDC to 30 VDC. Typically the fixed types of DC voltages are 5V, 9V, 12V, 15V and 18V DC.

POWER SUPPLY MODULES:

STEP DOWN TRANSFORMER BRIDGE RECTIFIER WITH FILTER VOLTAGE REGULATORS LM1117 3.3V positive Voltage Regulator 7805 5V Positive Voltage Regulator

Transformer Transformers convert AC electricity from one voltage to another with little loss of power. Transformers work only with AC and this is one of the reasons why mains electricity is AC. Step-up transformers increase voltage, step-down transformers reduce voltage. A step down power transformer is used to step down the AC voltage from the line voltage of 110 VAC or 220 VAC i.e, it converts higher voltage at the input side to a lower voltage at the output.

3.1 Rectifier There are several ways of connecting diodes to make a rectifier to convert AC to DC. The bridge rectifier is the most important and it produces full-wave varying DC

Bridge rectifier

Output: full-wave varying DC

Alternate pairs of diodes conduct, changing over (using all the AC wave) the connections so the alternating directions of AC are converted to the one direction of DC. 3.2 Filter Filtering is performed by a large value electrolytic capacitor connected across the DC supply to act as a reservoir, supplying current to the output when the varying DC voltage from the rectifier is falling. The diagram shows the unfiltered varying DC (dotted line) and the filtered DC (solid line). The capacitor charges quickly near the peak of the varying DC, and then discharges as it supplies current to the output.

Typically 1000 f capacitor is used 3.3 Regulator (5V Regulator) This is a simple DC regulated supply project using 7805 voltage regulator to obtain a variable DC voltage range from 5V to 15V

Pin out of the 7805 regulator IC. 1. Unregulated voltage in 2. Ground 3. Regulated voltage out If you need other voltages than +5V, you can modify the circuit by replacing the 7805 chips with another regulator with different output voltage from regulator 78xx chip family. The last numbers in the chip code tells the output voltage. Remember that the input voltage must be at least 3V greater than regulator output voltage to otherwise the regulator does not work well.

3.4 LM1117 (3.3 V Voltage Regulator): Description The LM1117 series of positive adjustable and fixed regulators are designed to provide 1A with high efficiency. All internal circuitry is designed to operate down to 1.3V input to output differential. On-chip trimming adjusts the reference voltage to 1%.

Adjustable or Fixed Output Output Current of 1A Low Dropout, 1.3V max at 1A Output Current 0.04% Line Regulation

0.2% Load Regulation 100% Thermal Limit Burn-in Fast Transient Response

Applications High Efficiency Linear Regulators Post Regulators for Switching Supplies Adjustable Power Supply

Working of relay:

Each relay has two mechanical parts inside. The first one is the contact(s) of the relay. The contacts operates similarly to the contacts of a simple switch or pushbutton. Each relay has two mechanical parts inside. The first one is the contact(s) of the relay. The contacts operates similarly to the contacts of a simple switch or pushbutton.

The two terminals operates as a switch. When the contacts are 'in contact' then the current flows from Terminal 1 to Terminal 2. There are two types of contacts: the NO and the NC. NO stands for Normal Open contact, while NC stands for Normal Closed contact. The Normal Open is a contact like the one showed in the previous illustration. When the contact is still, then no current flows through it (because it is an OPEN circuit).

On the other hand, a Normal Closed contact allows the current to flow when the contact is still. Bellow i illustrate both of these contacts:

AC RELAY:

A relay is an electromagnet with an internal spring-loaded lever to switch electrical contacts. To energize the relay, alternating current (AC) or direct current (DC) is passed through the coil of the electromagnet, magnetizing the core to attract the lever. By this means, a small current applied to the coil will switch a large electrical current in the contacts. This current may be from another switch, the circuit board the relay is on, or another electrical circuit.

Relay Uses

The starter on a car has a combination solenoid and relay. A relatively small current from the key switch activates the relay to direct the large battery current to the starter motor. Low current on the furnace control circuit board uses a relay to engage the high current fan motor. Streetlights use a photo cell to activate a relay, and the relay turns on and off the high current of the streetlight.

Alternating Current

Alternating current (AC) never stays the same and keeps reversing direction. When AC flows, it climbs to a peak and then drops back to 0 in order to reverse direction. Then the current climbs to a peak and drops to 0 again to go forward again. Each time the current reaches a peak, it falls back to 0 so it can change direction. The cycle of going back and forth repeats 50 or 60 times a second, and the magnetism in the core, being generated by the current in the coil, also follows in this back and forth cycle. AC Chatter

In a DC relay, when the current stops and the magnetism in the core falls to 0, the spring-loaded lever starts to pull back to the relaxed position. If AC is applied, the lever doesn't go very far because the core becomes magnetized and attracts the lever again. This cycle of releasing the lever and pulling it back is repeated each time the AC reverses and the relay sounds like it's buzzing, or chattering. Sometimes the electrical contacts may not even switch correctly.

AC Relay

To prevent this chatter, the AC relay has two coils to make a transformer to keep

the core magnetized. The wire of the traditional coil is the transformer primary. The

secondary of the transformer looks like a D-shaped copper washer or ring. Some of the magnetism from the primary coil produces current inside the copper ring. The current in the ring, or transformer secondary, is actually delayed compared to the current in the primary coil to keep the core always partially magnetized. The lever won't chatter against the core because, while the AC is flowing, the continuously magnetized core never releases it.

LIQUID CRYSTAL DISPLAY

INTRODUCTION: An LCD or a liquid crystal display consists of liquid crystals between electrodes. The arrangement consists of polarization filters which are aligned perpendicular to each other. This arrangement doesnt allow any visible light if there was no liquid crystal between the filters. This arrangement is aligned in between transparent conductors. When sufficient voltage is applied to a certain pixel, the crystal at that pixel aligns such that no light passes through it. Therefore that particular pixel appears dark. If such an electric field is applied for a longer period, the alignment of the crystal change, and

the quality of LCD degrades. In a bigger LCD display, to provide voltage sources to each pixel, the rows and column lines are multiplexed.

PIN DESCRIPTION OF THE LCD:

TABLE: PIN DESCRIPTION OF LCD

LCD INTERFAC WITH MICROCONTROLLER

Microcontroller
P O R T P I N S

INTERFACING LCD TO MICROCONTROLLER The LCD is generally interfaced in 8-bit mode or 4-bit mode. in this project LCD is connected in 4-bit mode the interface connections of LCD with microcontroller are as follows RS of LCD is connected to p1.24 of microcontroller EN of LCD is connected to p1.22 of microcontroller D4 of LCD is connected to p0.13of microcontroller D5 of LCD is connected to p0.12of microcontroller D6 of LCD is connected to p0.11of microcontroller D7 of LCD is connected to p0.10of microcontroller

In 8-bit mode, the complete ASCII code is sent at once along with the control signals. But in 4-bit mode, the data is divided into two parts, i.e. MSB & LSB, and are called upper nibble & lower nibble.

The control signals are RS, R/W & E. RS is used to select the internal registers i.e. data register & command register. R/W is used to set the mode of LCD to read mode or write mode. E is used as chip select and is used to push the data internally to the corresponding registers. To transfer the data/command in 8-bit mode, the data is written to the 8-bit data bus after selecting the required register and setting the mode to write mode. The E signal pin is then given a high to low signal to transfer the data. To transfer the data/command in 4-bit mode, the higher nibble is first written to the MSB of the data port and the E is given a high to low signal. After a little delay or when the LCD is not busy, the lower nibble is transferred in the same procedure. LCD COMMANDS

CHAPTER-6 APPLICATION DEVELOPMENT PROCESS ARM Tools

For building applications or compiling source code, software tools like compiler, assembler, linker etc., are required. When developing embedded applications are concerned, certain things should be taken into account regarding compilers. When the developing applications for native architecture i.e., target architecture is same as the host architecture on which applications are developed, native compilers can be used. If the target architecture is different from the host architecture, then cross compilers are required. In this project, Cross compilers are used for developing applications for ARM microcontroller. The cross compilers run on host computer and develops application for different architecture i.e., for ARM architecture.

arm-elf-gcc arm-elf-g++ arm-elf-as

GNU Compiler Collection (GCC) C++ compiler 3.40 GNU assembler (as)

arm-elf-ld arm-elf-addr2line line # arm-elf-ar arm-elf-gcov arm-elf-nm arm-elf-objcopy arm-elf-objdump arm-elf-ranlib arm-elf-readelf arm-elf-size arm-elf-strings arm-elf-strip arm-elf-gdb

GNU linker (ld) Converts addresses to file names &

Creates object code archives Test coverage program for analysis Lists symbols from object files Copies and translates object files Displays information from object files Generates index to archive contents Displays information about ELF objects Lists file section sizes and total sizes Lists printable strings from files Strips debug symbols from binaries GDB Debugger

For complete documentation of each command refer gnuarm website. Writing programs To write source code, you can use notepad or notepad++ applications and save files with appropriate extensions i.e., .C,.h,.S etc. Below figure shows the template.

Project Structure

The project structure is designed to segregation of different files. Project src inc lib

prj Makefile src inc lib prj consists of source files consists of include files consists of user libraries consists of linker script

Make file is placed in the project directory. Make utility and Makefile Make is a program in its own right and can be found on all Unix/Linux systems. Make reads a description of a project from a makefile (by default, called Makefile in the current directory). A makefile specifies a set of compilation rules in terms of targets (such as executables) and their dependencies (such as object files and source files) in the following format: target: dependencies command For each target, make checks the modification time of the corresponding dependency files to determine whether the target needs to be rebuilt using the corresponding command. Note that the command lines in a makefile must be indented with a single TAB character, not spaces. Assume that your application consists only single .c (Test.c) and .h(test.h) only. A makefile for the application is as below. Simple Makefile
Target

Test:Test.o gcc o Test Test.o Test.o:Test.c Test.h gcc c Test.c o Test.o Building applications
Dependency files

To build applications, open the Cygwin environment by clicking on the Cygwin icon on Desktop. Traverse to the application directory/folder where Makefile is stored through the command line. At command prompt give make. That builds the application if there is no error.

Fig. Shows the building applications using make utility. Downloading Hex file onto ARM microcontroller

Using LPC2000 flash utility To program the Philips microcontroller flash memory Semiconductors developed LPC2000 flash utility. This tool the microcontroller. RUN mode and board. If the push button is released then microcontroller is in RUN mode mmicrocontroller executes memory. the application present in the microcontroller flash programs its flash memory in If the push button is holded pressed then microcontroller is in Philips

uses the ISP feature of

Generally, the microcontroller is in one of the two modes. One is the other is PROGRAMMING mode. This mode is decided by

P0.14 high or low signal. This high or low is achieved through one push button on the

PROGRAMMING mode, microcontroller synchronization with LPC2000 flash utility.

The above fig. is the snapshot of the LPC2000 flash utility.

Downloading Hex file onto microcontroller

To

program

the

flash

memory,

first

keep

the

microcontroller

in

PROGRAMMING mode. Launch the LPC2000 flash utility. Select the device as LPC2138; enter 14746 in XTAL Freq (kHz) field and COM1 and 9600 in Communication block. Next, click on the Read Device ID tab; it prompts for reset the board. Acknowledge by resetting the board. If it is successful it returns the Part ID and Boot Loader ID along with an error message Device not supported. Neglect the error message if you find a valid numbers in the Part ID and Boot Loader ID. Now select the hex file in the flash programming block and click on the Upload to Flash.

Software tools used for ATmega8L Code Vision AVR (CVAVR): Is the best IDE for getting started with AVR programming on Windows XP, Vista. It has a very good Code Wizard which generates codes automatically! We need not mess with the assembly words. So in this project we will be using CVAVR. The main window looks like following

Now click on File ---> New --->Project A pop up window will come asking whether you want to use Code Wizard AVR, obviously select yes because that is the reason we are using CVAVR !

Select the chip for which you are going to write the program. Then select the frequency at which Chip is running. By default all chips are set on Internal Oscillator of 1 MHz so select 1 MHz if that is the case. If you want to change the running clock frequency of the chip then you have to change its fuse bits

Now for generating code just go to File ----> Generate, Save and Exit (of the code wizard) now it will ask you name and location for saving three files. Two being project files and one being the .C file which is your program. Try to keep same names of all three files to avoid confusion. By default these files are generated in C:\CVAVR\bin. The generated program will open in the text editor. Now go to c file and find following infinite while loop there. We can start writing our part of program just before the while loop. And as for most of the applications we want microcontroller to perform the same task forever we put our part of code in the infinite while loop provided by the code wizard ! While(1) { // Place your code here }

Now we want to generate the hex file, so first compile the program. Either press F9 or go to Project ---> Compile. It will show compilation errors if any. If program is error free we can proceed to making of hex file. So either press Shift+F9 or go to Project ----> Make. A pop up window will come with information about code size and flash usage etc. So the machine file is ready now ! It is in the same folder where we saved those 3 files.

ISP 3.0 SOFTWARE Introduction This ISP Programmer can be used either for in-system programming or as a standalone spi programmer for Atmel ISP programmable devices. The programming interface is compatibe to STK200 ISP programmer hardware so the users of STK200 can also use the

software which can program both the 8051 and AVR series devices. Hardware The power to the interface is provided by the target system. The 74HCT541 IC isolates and buffers the parallel port signals. It is necessary to use the HCT type IC in order to make sure the programmer should also work with 3V type parallel port. The printer port buffer interface is same as shown in figure 1.For the ucontrollera40pinZIFsocketcanbe used. This programmer circuit can be use to program the 89S series devices and the AVR series device switches are pin compatible to 8051, like 90S8515. For other AVR series devices the user can make an adapter board for 20, 28 and 40 pin devices. The pin numbers shown in brackets correspond to PC parallel port connector.

Software The ISP-30a.zip file contains the main program and the i/o port driver. Place all files in the same folder. The main screen view of the program is shown in figure 3. Also make sure do not program will need a parallel the RSTDISBL to fuse in ATmega8, enable the

ATtiny26 and ATtiny2313 otherwise further spi programming is disable and you programmer spi programming. For the fuses setting consult the datasheet of the respective device. For the auto hardware detection it is necessary to short pin 2 and 12 of

DB25connector, otherwise the software uses the default parallel port i.e. LPT1. Following are the main features of this software, Read and write the Intel Hex file. Read signature, lock and fuse bits. Clear and Fill memory buffer. Verify with memory buffer. Reload current Hex file. Display buffer checksum. Program selected lock bits & fuses.

Auto detection of hardware. Note: The memory buffer contains both the code data and the eeprom data for the devices which have eeprom memory. The eeprom memory address in buffer is started after he code memory, so it is necessary the hex file should contains the eeprom start address after the end of code memory last address i.e. for 90S2313 the start address for eeprom memory is 0x800.

The software are required to

does

not erase

provide the

the

erase

command

because

th

s function is performed

automatically during device

programming.

If you

controller, first use the clear

buffer command then program the controller, this will erase the controller and also set the AVR device fuses to default setting.

Fig Main screen of the program ISP-Pgm Ver 3.0a

REFERENCES 1. WWW.WIKIPEDIA.ORG 2. DATASHEET ARCHIEVE 3. LPC 2148 DATASHEET

Das könnte Ihnen auch gefallen