123
ANDROID CONTROLLED SCROLLING LED MESSAGE DISPLAY CHAPTER 1 Introduction 1.1 Introduction The project aims at designing a LED based scrolling message display controlled from an Android mobile phone. The proposed system makes use of Bluetooth technology to communicate from Android phone to LED display board. Android is a software stack for mobile devices that includes an operating system, middleware and key applications. Android boasts a healthy array of connectivity options, including Wi-Fi, Bluetooth, and wireless data over a cellular connection (for example, GPRS, EDGE (Enhanced Data rates for GSM Evolution), and 3G). Android provides access to a wide range of useful libraries and tools that can be used to build rich applications. In addition, Android includes a full set of tools that have been built from the ground up alongside the platform providing developers with high productivity and deep insight into their applications. The main controlling device of the whole system is a Microcontroller. Bluetooth modem and buzzer are interfaced to Microcontroller. The message sent through predefined application from user Android mobile phone is received by the Bluetooth modem. Bluetooth modem feds this information to microcontroller which process it and displays it on the LED display. Also, the Microcontroller horns a buzzer for every new message. To perform SPHOORTHY ENGINEERING COLLEGE (ECE) 1

Android Controlled Scrolling LED Message(1)

Embed Size (px)

Citation preview

ANDROID CONTROLLED SCROLLING LED MESSAGE DISPLAY

ANDROID CONTROLLED SCROLLING LED MESSAGE DISPLAY

CHAPTER 1Introduction1.1 IntroductionThe project aims at designing a LED based scrolling message display controlled from an Android mobile phone. The proposed system makes use of Bluetooth technology to communicate from Android phone to LED display board.

Android is a software stack for mobile devices that includes an operating system, middleware and key applications. Android boasts a healthy array of connectivity options, including Wi-Fi, Bluetooth, and wireless data over a cellular connection (for example, GPRS, EDGE (Enhanced Data rates for GSM Evolution), and 3G). Android provides access to a wide range of useful libraries and tools that can be used to build rich applications. In addition, Android includes a full set of tools that have been built from the ground up alongside the platform providing developers with high productivity and deep insight into their applications.

The main controlling device of the whole system is a Microcontroller. Bluetooth modem and buzzer are interfaced to Microcontroller. The message sent through predefined application from user Android mobile phone is received by the Bluetooth modem. Bluetooth modem feds this information to microcontroller which process it and displays it on the LED display. Also, the Microcontroller horns a buzzer for every new message. To perform this intelligent task, Microcontroller is loaded with an intelligent program written using embedded C language.1.2 Project Overview

An embedded system is a combination of software and hardware to perform a dedicated task. Some of the main devices used in embedded products are Microprocessors and Microcontrollers. Microprocessors are commonly referred to as general purpose processors as they simply accept the inputs, process it and give the output. In contrast, a microcontroller not only accepts the data as inputs but also manipulates it, interfaces the data with various devices, controls the data and thus finally gives the result.

The Android controlled scrolling LED message display using PIC16F73 microcontroller is an exclusive project which is used to control the devices in an industry using PC hyper terminal.1.3 Thesis The thesis explains the implementation of Android controlled scrolling LED message display using PIC16F73 microcontroller. The organization of the thesis is explained here with:

Chapter 1 Presents introduction to the overall thesis and the overview of the project. In the project overview a brief introduction of interfacing mobile to Micro Controller, Bluetooth, led display board and its applications are discussed.

Chapter 2 Presents the topic embedded systems. It explains the about what is embedded systems, need for embedded systems, explanation of it along with its applications.

Chapter 3 Presents the hardware description. It deals with the block diagram of the project and explains the purpose of each block. In the same chapter the explanation of Micro Controller, Bluetooth, power supplies, buzzer, mobile, led notice board are considered.

Chapter 4 Presents the software description. It explains the implementation of the project using PIC C Compiler software.

Chapter 5 Presents the project description along with Bluetooth, Led Notice board, and buzzer interfacing to microcontroller.

Chapter 6 Presents the advantages, disadvantages and applications of the project.

Chapter 7 Presents the results, conclusion and future scope of the project.

CHAPTER 2EMBEDDED SYSTEMS2.1Introduction

An embedded system is a computer system designed to perform one or a few dedicated functions 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 are controlled by one or more main processing cores that are typically either microcontrollers or digital signal processors (DSP). The key characteristic, however, is being dedicated to handle a particular task, which may require very powerful processors. For example, air traffic control systems may usefully be viewed as embedded, even though they involve mainframe computers and dedicated regional and national networks between airports and radar sites. (Each radar probably includes one or more embedded systems of its own.)

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, or the systems controlling nuclear power plants. 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.

In general, "embedded system" is not a strictly definable term, as most systems have some element of extensibility or programmability. For example, handheld computers share some elements with embedded systems such as the operating systems and microprocessors which power them, but they allow different applications to be loaded and peripherals to be connected. Moreover, even systems which don't expose programmability as a primary feature generally need to support software updates. On a continuum from "general purpose" to "embedded", large application systems will have subcomponents at most points even if the system as a whole is "designed to perform one or a few dedicated functions", and is thus appropriate to call "embedded". A modern example of embedded system is shown in fig: 2.1.

Fig 2.1:A modern example of embedded system

Labeled parts include microprocessor (4), RAM (6), flash memory (7).Embedded systems programming is not like normal PC programming. In many ways, programming for an embedded system is like programming PC 15 years ago. The hardware for the system is usually chosen to make the device as cheap as possible. Spending an extra dollar a unit in order to make things easier to program can cost millions. Hiring a programmer for an extra month is cheap in comparison. This means the programmer must make do with slow processors and low memory, while at the same time battling a need for efficiency not seen in most PC applications. Below is a list of issues specific to the embedded field.

2.1.1 History

In the earliest years of computers in the 193040s, computers were sometimes dedicated to a single task, but were far too large and expensive for most kinds of tasks performed by embedded computers of today. Over time however, the concept ofprogrammable controllers evolved from traditionalelectromechanicalsequencers, via solid state devices, to the use of computer technology.

One of the first recognizably modern embedded systems was theApollo Guidance Computer, developed byCharles Stark Draperat the MIT Instrumentation Laboratory. At the project's inception, the Apollo guidance computer was considered the riskiest item in the Apollo project as it employed the then newly developed monolithic integrated circuits to reduce the size and weight. An early mass-produced embedded system was the Automatics D-17 guidance computer for theMinuteman missile, released in 1961. It was built fromtransistorlogicand had a hard diskfor main memory. When the Minuteman II went into production in 1966, the D-17 was replaced with a new computer that was the first high-volume use of integrated circuits.

2.1.2 Tools

Embedded development makes up a small fraction of total programming. There's also a large number of embedded architectures, unlike the PC world where 1 instruction set rules, and the Unix world where there's only 3 or 4 major ones. This means that the tools are more expensive. It also means that they're lowering featured, and less developed. On a major embedded project, at some point you will almost always find a compiler bug of some sort.

Debugging tools are another issue. Since you can't always run general programs on your embedded processor, you can't always run a debugger on it. This makes fixing your program difficult. Special hardware such as JTAG ports can overcome this issue in part. However, if you stop on a breakpoint when your system is controlling real world hardware (such as a motor), permanent equipment damage can occur. As a result, people doing embedded programming quickly become masters at using serial IO channels and error message style debugging.

2.1.3 Resources

To save costs, embedded systems frequently have the cheapest processors that can do the job. This means your programs need to be written as efficiently as possible. When dealing with large data sets, issues like memory cache misses that never matter in PC programming can hurt you. Luckily, this won't happen too often- use reasonably efficient algorithms to start, and optimize only when necessary. Of course, normal profilers won't work well, due to the same reason debuggers don't work well.

Memory is also an issue. For the same cost savings reasons, embedded systems usually have the least memory they can get away with. That means their algorithms must be memory efficient (unlike in PC programs, you will frequently sacrifice processor time for memory, rather than the reverse). It also means you can't afford to leak memory. Embedded applications generally use deterministic memory techniques and avoid the default "new" and "mallow" functions, so that leaks can be found and eliminated more easily. Other resources programmers expect may not even exist. For example, most embedded processors do not have hardware FPUs (Floating-Point Processing Unit). These resources either need to be emulated in software, or avoided altogether.

2.1.4 Real Time Issues

Embedded systems frequently control hardware, and must be able to respond to them in real time. Failure to do so could cause inaccuracy in measurements, or even damage hardware such as motors. This is made even more difficult by the lack of resources available. Almost all embedded systems need to be able to prioritize some tasks over others, and to be able to put off/skip low priority tasks such as UI in favor of high priority tasks like hardware control.

2.2 Need For Embedded Systems

The uses of embedded systems are virtually limitless, because every day new products are introduced to the market that utilizes embedded computers in novel ways. In recent years, hardware such as microprocessors, microcontrollers, and FPGA chips have become much cheaper. So when implementing a new form of control, it's wiser to just buy the generic chip and write your own custom software for it. Producing a custom-made chip to handle a particular task or set of tasks costs far more time and money. Many embedded computers even come with extensive libraries, so that "writing your own software" becomes a very trivial task indeed. From an implementation viewpoint, there is a major difference between a computer and an embedded system. Embedded systems are often required to provide Real-Time response. The main elements that make embedded systems unique are its reliability and ease in debugging.

2.2.1 Debugging

Embedded debugging may be performed at different levels, depending on the facilities available. From simplest to most sophisticate they can be roughly grouped into the following areas:

Interactive resident debugging, using the simple shell provided by the embedded operating system (e.g. Forth and Basic)

External debugging using logging or serial port output to trace operation using either a monitor in flash or using a debug server like the Remedy Debugger which even works for heterogeneous multi core systems.

An in-circuit debugger (ICD), a hardware device that connects to the microprocessor via a JTAG or Nexus interface. This allows the operation of the microprocessor to be controlled externally, but is typically restricted to specific debugging capabilities in the processor.

An in-circuit emulator replaces the microprocessor with a simulated equivalent, providing full control over all aspects of the microprocessor.

A complete emulator provides a simulation of all aspects of the hardware, allowing all of it to be controlled and modified and allowing debugging on a normal PC.

Unless restricted to external debugging, the programmer can typically load and run software through the tools, view the code running in the processor, and start or stop its operation. The view of the code may be as assembly code or source-code.

Because an embedded system is often composed of a wide variety of elements, the debugging strategy may vary. For instance, debugging a software(and microprocessor) centric embedded system is different from debugging an embedded system where most of the processing is performed by peripherals (DSP, FPGA, co-processor). An increasing number of embedded systems today use more than one single processor core. A common problem with multi-core development is the proper synchronization of software execution. In such a case, the embedded system design may wish to check the data traffic on the busses between the processor cores, which requires very low-level debugging, at signal/bus level, with a logic analyzer, for instance.

2.2.2 Reliability

Embedded systems often reside in machines that are expected to run continuously for years without errors and in some cases recover by themselves if an error occurs. Therefore the software is usually developed and tested more carefully than that for personal computers, and unreliable mechanical moving parts such as disk drives, switches or buttons are avoided.

Specific reliability issues may include:

The system cannot safely be shut down for repair, or it is too inaccessible to repair. Examples include space systems, undersea cables, navigational beacons, bore-hole systems, and automobiles.

The system must be kept running for safety reasons. "Limp modes" are less tolerable. Often backups are selected by an operator. Examples include aircraft navigation, reactor control systems, safety-critical chemical factory controls, train signals, engines on single-engine aircraft.

The system will lose large amounts of money when shut down: Telephone switches, factory controls, bridge and elevator controls, funds transfer and market making, automated sales and service.

A variety of techniques are used, sometimes in combination, to recover from errorsboth software bugs such as memory leaks, and also soft errors in the hardware:

Watchdog timer that resets the computer unless the software periodically notifies the watchdog

Subsystems with redundant spares that can be switched over to

software "limp modes" that provide partial function

Designing with a Trusted Computing Base (TCB) architecture[6] ensures a highly secure & reliable system environment

An Embedded Hypervisor is able to provide secure encapsulation for any subsystem component, so that a compromised software component cannot interfere with other subsystems, or privileged-level system software. This encapsulation keeps faults from propagating from one subsystem to another, improving reliability. This may also allow a subsystem to be automatically shut down and restarted on fault detection.

Immunity Aware Programming2.3 Explanation of Embedded systems 2.3.1 Software Architecture

There are several different types of software architecture in common use.

Simple Control Loop:

In this design, the software simply has a loop. The loop calls subroutines, each of which manages a part of the hardware or software.

Interrupt Controlled System:

Some embedded systems are predominantly interrupt controlled. This means that tasks performed by the system are triggered by different kinds of events. An interrupt could be generated for example by a timer in a predefined frequency, or by a serial port controller receiving a byte. These kinds of systems are used if event handlers need low latency and the event handlers are short and simple.

Usually these kinds of systems run a simple task in a main loop also, but this task is not very sensitive to unexpected delays. Sometimes the interrupt handler will add longer tasks to a queue structure. Later, after the interrupt handler has finished, these tasks are executed by the main loop. This method brings the system close to a multitasking kernel with discrete processes.

Cooperative Multitasking:

A non-preemptive multitasking system is very similar to the simple control loop scheme, except that the loop is hidden in an API. The programmer defines a series of tasks, and each task gets its own environment to run in. When a task is idle, it calls an idle routine, usually called pause, wait, yield, nap (stands for no operation), etc. The advantages and disadvantages are very similar to the control loop, except that adding new software is easier, by simply writing a new task, or adding to the queue-interpreter.

Primitive Multitasking:

In this type of system, a low-level piece of code switches between tasks or threads based on a timer (connected to an interrupt). This is the level at which the system is generally considered to have an "operating system" kernel. Depending on how much functionality is required, it introduces more or less of the complexities of managing multiple tasks running conceptually in parallel.

Because of these complexities, it is common for organizations to buy a real-time operating system, allowing the application programmers to concentrate on device functionality rather than operating system services, at least for large systems; smaller systems often cannot afford the overhead associated with a generic real time system, due to limitations regarding memory size, performance, and/or battery life.

Microkernels And Exokernels:

A microkernel is a logical step up from a real-time OS. The usual arrangement is that the operating system kernel allocates memory and switches the CPU to different threads of execution. User mode processes implement major functions such as file systems, network interfaces, etc.

In general, microkernels succeed when the task switching and interties communication is fast, and fail when they are slow. Exokernels communicate efficiently by normal subroutine calls. The hardware and all the software in the system are available to, and extensible by application programmers. Based on performance, functionality, requirement the embedded systems are divided into three categories:

2.3.2 Stand Alone Embedded System

These systems takes the input in the form of electrical signals from transducers or commands from human beings such as pressing of a button etc.., process them and produces desired output. This entire process of taking input, processing it and giving output is done in standalone mode. Such embedded systems comes under stand alone embedded systems

Egg: microwave oven, air conditioner etc..

2.3.3 Real-time embedded systems

Embedded systems which are used to perform a specific task or operation in a specific time period those systems are called as real-time embedded systems. There are two types of real-time embedded systems.

Hard Real-time embedded systems:

These embedded systems follow an absolute dead line time period i.e.., if the tasking is not done in a particular time period then there is a cause of damage to the entire equipment.

Egg: consider a system in which we have to open a valve within 30 milliseconds. If this valve is not opened in 30 ms this may cause damage to the entire equipment. So in such cases we use embedded systems for doing automatic operations.

Soft Real Time embedded systems:

These embedded systems follow a relative dead line time period i.e.., if the task is not done in a particular time that will not cause damage to the equipment.

Eg: Consider a TV remote control system ,if the remote control takes a few milliseconds delay it will not cause damage either to the TV or to the remote control. These systems which will not cause damage when they are not operated at considerable time period those systems comes under soft real-time embedded systems.

2.3.4 Network communication embedded systemsA wide range network interfacing communication is provided by using embedded systems.

Eg:

Consider a web camera that is connected to the computer with internet can be used to spread communication like sending pictures, images, videos etc.., to another computer with internet connection throughout anywhere in the world.

Consider a web camera that is connected at the door lock.

Whenever a person comes near the door, it captures the image of a person and sends to the desktop of your computer which is connected to internet. This gives an alerting message with image on to the desktop of your computer, and then you can open the door lock just by clicking the mouse. Fig: 2.2 show the network communications in embedded systems.

Fig 2.2: Network communication embedded systems2.3.5 Different types of processing units

The central processing unit (c.p.u) can be any one of the following microprocessor, microcontroller, digital signal processing.

Among these Microcontroller is of low cost processor and one of the main advantage of microcontrollers is, the components such as memory, serial communication interfaces, analog to digital converters etc.., all these are built on a single chip. The numbers of external components that are connected to it are very less according to the application.

Microprocessors are more powerful than microcontrollers. They are used in major applications with a number of tasking requirements. But the microprocessor requires many external components like memory, serial communication, hard disk, input output ports etc.., so the power consumption is also very high when compared to microcontrollers.

Digital signal processing is used mainly for the applications that particularly involved with processing of signals2.4 Applications of embedded systems2.4.1 Consumer applications

At home we use a number of embedded systems which include microwave oven, remote control, vcd players, dvd players, camera etc.2.4.2 Office automation

We use systems like fax machine, modem, printer etc

2.4.3. Industrial automation

Today a lot of industries are using embedded systems for process control. In industries we design the embedded systems to perform a specific operation like monitoring temperature, pressure, humidity ,voltage, current etc.., and basing on these monitored levels we do control other devices, we can send information to a centralized monitoring station.In critical industries where human presence is avoided there we can use robots which are programmed to do a specific operation.2.4.5 Computer networking

Embedded systems are used as bridges routers etc.. 2.4.6 Tele communications:Cell phones, web cameras etc.CHAPTER 3

Hardware description3.1 Introduction

In this chapter the block diagram of the project and design aspect of independent modules are considered. Block diagram is shown in fig: 3.1:

FIG 3.1 Android controlled scrolling LED message displayThe main blocks of this project are:1. Micro controller (16F73)2. Reset button

3. Crystal oscillator

4. Regulated power supply (RPS)

5. LED Notice board6. LED7. Buzzer8. Android phone3.2 Micro controller:

Fig: 3.2 Microcontrollers3.2.1 Introduction to Microcontrollers:

Circumstances that we find ourselves in today in the field of microcontrollers had their beginnings in the development of technology of integrated circuits. This development has made it possible to store hundreds of thousands of transistors into one chip. That was a prerequisite for production of microprocessors, and the first computers were made by adding external peripherals such as memory, input-output lines, timers and other. Further increasing of the volume of the package resulted in creation of integrated circuits. These integrated circuits contained both processor and peripherals. That is how the first chip containing a microcomputer, or what would later be known as a microcontroller came about.

Microprocessors and microcontrollers are widely used in embedded systems products. Microcontroller is a programmable device. A microcontroller has a CPU in addition to a fixed amount of RAM, ROM, I/O ports and a timer embedded all on a single chip. The fixed amount of on-chip ROM, RAM and number of I/O ports in microcontrollers makes them ideal for many applications in which cost and space are critical.

The microcontroller used in this project is PIC16F72. The PIC families of microcontrollers are developed by Microchip Technology Inc. Currently they are some of the most popular microcontrollers, selling over 120 million devices each year. There are basically four families of PIC microcontrollers:

PIC12CXXX 12/14-bit program word

PIC 16C5X 12-bit program word

PIC16CXXX and PIC16FXXX 14-bit program word

PIC17CXXX and PIC18CXXX 16-bit program word

The features, pin description of the microcontroller used are discussed in the following sections.3.2.2 Description:

Introduction to PIC Microcontrollers:

PIC stands for Peripheral Interface Controller given by Microchip Technology to identify its single-chip microcontrollers. These devices have been very successful in 8-bit microcontrollers. The main reason is that Microchip Technology has continuously upgraded the device architecture and added needed peripherals to the microcontroller to suit customers' requirements. The development tools such as assembler and simulator are freely available on the internet at www.microchip.com Low - end PIC Architectures: Microchip PIC microcontrollers are available in various types. When PIC microcontroller MCU was first available from General Instruments in early 1980's, the microcontroller consisted of a simple processor executing 12-bit wide instructions with basic I/O functions. These devices are known as low-end architectures. They have limited program memory and are meant for applications requiring simple interface functions and small program & data memories. Some of the low-end device numbers are

12C5XX 16C5X 16C505Mid range PIC Architectures: Mid range PIC architectures are built by upgrading low-end architectures with more number of peripherals, more number of registers and more data/program memory. Some of the mid-range devices are

16C6X 16C7X 16F87X Program memory type is indicated by an alphabet.

C = EPROM, F = Flash, RC = Mask ROM

Popularity of the PIC microcontrollers is due to the following factors.

1. Speed: Harvard Architecture, RISC architecture, 1 instruction cycle = 4 clock cycles.

2. Instruction set simplicity: The instruction set consists of just 35 instructions (as opposed to 111 instructions for 8051).

3. Power-on-reset and brown-out reset. Brown-out-reset means when the power supply goes below a specified voltage (say 4V), it causes PIC to reset; hence malfunction is avoided. A watch dog timer (user programmable) resets the processor if the software/program ever malfunctions and deviatesfrom its normal operation.

4. PIC microcontroller has four optional clock sources.

Low power crystal

Mid range crystal

High range crystal

RC oscillator (low cost).

5. Programmable timers and on-chip ADC.

6. Up to 12 independent interrupt sources.

7. Powerful output pin control (25 mA (max.) current sourcing capability per pin.)

8. EPROM/OTP/ROM/Flash memory option.9. I/O port expansion capability. Basically, all PIC microcontrollers offer the following features:

RISC instruction set with around 35 instructions _9 Digital I/O ports

On-chip timer with 8-bit prescaler.

Power-on reset

Watchdog timer

Power saving SLEEP mode

Direct, indirect, and relative addressing modes

External clock interface RAM data memory

EPROM (or OTP) program memory Peripheral features: High sink/source current 25mA

Timer0: 8-bit timer/counter with 8-bit prescaler can be incremented during sleep via external crystal/clock

Timer2:8-bit timer/counter with 8-bit period register prescaler and post scalar.

Capture, Compare, PWM (CCP) module

Capture is 16-bit, max resolution is 12.5ns

Compare is 16-bit, max resolution is 200 ns

PWM max, resolution is 10-bit

8-bit 5 channel analog-to-digital converter

Synchronous serial port (SSP) with SPI (Master/Slave) and (Slave)Some devices offer the following additional features:

Analogue input channels

Analogue comparators

Additional timer circuits

EEPROM data memory

Flash EEPROM program memory

External and timer interrupts

In-circuit programming

Internal oscillator

USART serial interface3.2.3 Introduction to PIC16F73 microcontrollerThe PIC16F73 CMOS FLASH-based 8-bit microcontroller is upward compatible with the PIC16C73B/74B/76/77, PIC16F873/874/876/877devices. It features 200 ns instruction execution, self programming, an ICD, 2 Comparators, 8 channels of 8-bit Analog-to-Digital (A/D) converter, 2 capture/compare/PWM functions, a synchronous serial port that can be configured as either 3-wire SPI or 2-wire I2C bus, a USART, and a Parallel Slave Port.

High-Performance RISC CPU

Only 35 single word instructions to learn

All single cycle instructions except for program branches which are two-cycle

Operating speed: DC - 20 MHz clock input

DC - 200 ns instruction cycle

Up to 8K x 14 words of FLASH Program Memory, Up to 368 x 8 bytes of Data Memory (RAM)

Pin out compatible to the PIC16C73B/74B/76/77

Pin out compatible to the PIC16F873/874/876/877

Interrupt capability (up to 12 sources)

Eight level deep hardware stack

Direct, Indirect and Relative Addressing modes

Processor read access to program memorySpecial Microcontroller Features

Power-up Timer (PWRT) and oscillator Start-up Timer (OST)

Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation

Programmable code protection

Power saving SLEEP mode

Selectable oscillator options

In-Circuit Serial Programming (ICSP) via two Pins

Peripheral Features

Timer0: 8-bit timer/counter with 8-bit prescaler

Timer1: 16-bit timer/counter with prescaler, can be incremented during SLEEP via external crystal/clock

Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler

Two Capture, Compare, PWM modules

- Capture is 16-bit, max resolution is 12.5 ns

- Compare is 16-bit, max resolution is 200 ns

- PWM max resolution is 10-bit

8-bit, up to 8-channel Analog-to-Digital converter

Synchronous Serial Port (SSP) with SPI (Master mode) and I2C (Slave)

Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI)

Parallel Slave Port (PSP), 8-bits wide with external RD, WR and CS controls

Brown-out detection circuitry for Brown-out Reset (BOR)

Analog Comparator module

2 analog comparators

Programmable on-chip voltage reference module

Programmable input multiplexing from device inputs and internal VREF

Comparator outputs are externally accessible

CMOS Technology:

Low power, high speed CMOS FLASH technology

Fully static design

Wide operating voltage range: 2.0V to 5.5V

High Sink/Source Current: 25 mA

Industrial temperature range

Low power consumption:

- < 2 mA typical @ 5V, 4 MHz

- 20 A typical @ 3V, 32 kHz

- < 1 A typical standby current

Following are the major blocks of PIC Microcontroller.

Program memory (FLASH) is used for storing a written program.Since memorymade in FLASH technology can be programmed and cleared more than once, it makes this microcontroller suitable for device development.EEPROM - data memory that needs to be saved when there is no supply. It is usually used for storing important data that must not be lost if power supply suddenly stops. For instance, one such data is an assigned temperature in temperature regulators. If during a loss of power supply this data was lost, we would have to make the adjustment once again upon return of supply. Thus our device looses on self-reliance.RAM-Data memory used by a program during its execution. In RAM are stored all inter-results or temporary data during run-time. PORTS are physical connections between the microcontroller and the outside world. PIC16F73 has 22I/O.FREE-RUN TIMER is an 8-bit register inside a microcontroller that works independently of the program. On every fourth clock of the oscillator it increments its value until it reaches the maximum (255), and then it starts counting over again from zero. As we know the exact timing between each two increments of the timer contents, timer can be used for measuring time which is very useful with some devices.CENTRAL PROCESSING UNIT has a role of connective element between other blocks in the microcontroller. It coordinates the work of other blocks and executes the user program.

CISC, RISC

It has already been said that PIC16F73 has RISC architecture. This term is often found in computer literature, and it needs to be explained here in more detail. Harvard architecture is a newer concept than von-Neumann. It rose out of the need to speed up the work of a microcontroller. In Harvard architecture, data bus and address bus are separate. Thus a greater flow of data is possible through the central processing unit, and of course, a greater speed of work. Separating a program from data memory makes it further possible for instructions not to have to be 8-bit words. PIC16F73 uses 14 bits for instructions which allows for all instructions to be one word instructions. It is also typical for Harvard architecture to have fewer instructions than von-Neumann's, and to have instructions usually executed in one cycle.Microcontrollers with Harvard architecture are also called "RISC microcontrollers". RISC stands for Reduced Instruction Set Computer. Microcontrollers with von-Neumann's architecture are called 'CISC microcontrollers' title CISC stands for Complex Instruction Set Computer.

Since PIC16F73 is a RISC microcontroller, that means that it has a reduced set of instructions, more precisely 35 instructions. (Ex. Intel's and Motorola's microcontrollers have over hundred instructions) All of these instructions are executed in one cycle except for jump and branch instructions. According to what its maker says, PIC16F73 usually reaches results of 2:1 in code compression and 4:1 in speed in relation to other 8-bit microcontrollers in its class.

Applications

PIC16F73 perfectly fits many uses, from automotive industries and controlling home appliances to industrial instruments, remote sensors, electrical door locks and safety devices. It is also ideal for smart cards as well as for battery supplied devices because of its low consumption.

EEPROM memory makes it easier to apply microcontrollers to devices where permanent storage of various parameters is needed (codes for transmitters, motor speed, receiver frequencies, etc.). Low cost, low consumption, easy handling and flexibility make PIC16F73 applicable even in areas where microcontrollers had not previously been considered (example: timer functions, interface replacement in larger systems, coprocessor applications, etc.).

In System Programmability of this chip (along with using only two pins in data transfer) makes possible the flexibility of a product, after assembling and testing have been completed. This capability can be used to create assembly-line production, to store calibration data available only after final testing, or it can be used to improve programs on finished products.

Clock / instruction cycle

Clock is microcontroller's main starter, and is obtained from an externalcomponent called an "oscillator". If we want to compare a microcontroller with a time clock, our "clock" would then be a ticking sound we hear from the time clock. In that case, oscillator could be compared to a spring that is wound so time clock can run. Also, force used to wind the time clock can be compared to an electrical supply.Clock from the oscillator enters a microcontroller via OSC1 pin where internal circuit of a microcontroller divides the clock into four even clocks Q1, Q2, Q3, and Q4 which do not overlap. These four clocks make up one instruction cycle (also called machine cycle) during which one instruction is executed.

Instruction cycle consists of cycles Q1, Q2, Q3 and Q4. Cycles of calling and executing instructions are connected in such a way that in order to make a call, one instruction cycle is needed, and one more is needed for decoding and execution. However, due to pipelining, each instruction is effectively executed in one cycle. If instruction causes a change on program counter, and PC doesn't point to the following but to some other address (which can be the case with jumps or with calling subprograms), two cycles are needed for executing an instruction. This is so because instruction must be processed again, but this time from the right address. Cycle of calling begins with Q1 clock, by writing into instruction register (IR). Decoding and executing begins with Q2, Q3 and Q4 clocks.

Pin description

PIC16F73 has a total of 28 pins. It is most frequently found in a DIP28 type of case but can also be found in SMD case which is smaller from a DIP. DIP is an abbreviation for Dual In Package. SMD is an abbreviation for Surface Mount Devices suggesting that holes for pins to go through when mounting aren't necessary in soldering this type of a component.

Pins on PIC16F73 microcontroller have the following meaning:There are 28 pins on PIC16F73. Most of them can be used as an IO pin. Others are already for specific functions. These are the pin functions.1. MCLR to reset the PIC2. RA0 port A pin 03. RA1 port A pin 14. RA2 port A pin 25. RA3 port A pin 36. RA4 port A pin 47. RA5 port A pin 58. VSS ground9. OSC1 connect to oscillator10. OSC2 connect to oscillator11. RC0 port C pin 0 VDD power supply12. RC1 port C pin 113. RC2 port C pin 214. RC3 port C pin 315. RC4 - port C pin 416. RC5 - port C pin 517. RC6 - port C pin 618. RC7 - port C pin 719. VSS - ground20. VDD power supply21. RB0 - port B pin 022. RB1 - port B pin 123. RB2 - port B pin 224. RB3 - port B pin 325. RB4 - port B pin 426. RB5 - port B pin 527. RB6 - port B pin 628. RB7 - port B pin 7By utilizing all of this pin so many application can be done such as:1. LCD connect to Port B pin.2. LED connect to any pin declared as output.3. Relay and Motor - connect to any pin declared as output.4. External EEPROM connect to I2C interface pin RC3 and RC4 (SCL and SDA) 5. LDR, Potentiometer and sensor connect to analogue input pin such as RA0.6. GSM modem dial up modem connect to RC6 and RC7 the serial communication interface using RS232 protocol.

PortsTerm "port" refers to a group of pins on a microcontroller which can be accessed simultaneously, or on which we can set the desired combination of zeros and ones, or read from them an existing status. Physically, port is a register inside a microcontroller which is connected by wires to the pins of a microcontroller. Ports represent physical connection of Central Processing Unit with an outside world. Microcontroller uses them in order to monitor or control other components or devices. Due to functionality, some pins have twofold roles like PA4/TOCKI for instance, which is in the same time the fourth bit of port A and an external input for free-run counter.All port pins can be designated as input or output, according to the needs of a device that's being developed. In order to define a pin as input or output pin, the right combination of zeros and ones must be written in TRIS register. If the appropriate bit of TRIS register contains logical "1", then that pin is an input pin, and if the opposite is true, it's an output pin. Every port has its proper TRIS register. Thus, port A has TRISA, and port B has TRISB. Pin direction can be changed during the course of work which is particularly fitting for one-line communication where data flow constantly changes direction. PORTA and PORTB state registers are located in bank 0, while TRISA and TRISB pin direction registers are located in bank 1.PORTB and TRISB PORTB have adjoined 8 pins. The appropriate register for data direction is TRISB. Setting a bit in TRISB register defines the corresponding port pin as input, and resetting a bit in TRISB register defines the corresponding port pin as output.

Each PORTB pin has a weak internal pull-up resistor (resistor which defines a line to logic one) which can be activated by resetting the seventh bit RBPU in OPTION register. These 'pull-up' resistors are automatically being turned off when port pin is configured as an output. When a microcontroller is started, pull-ups are disabled.Four pins PORTB, RB7:RB4 can cause an interrupt which occurs when their status changes from logical one into logical zero and opposite. Only pins configured as input can cause this interrupt to occur (if any RB7:RB4 pin is configured as an output, an interrupt won't be generated at the change of status.) This interrupt option along with internal pull-up resistors makes it easier to solve common problems we find in practice like for instance that of matrix keyboard. If rows on the keyboard are connected to these pins, each push on a key will then cause an interrupt. A microcontroller will determine which key is at hand while processing an interrupt It is not recommended to refer to port B at the same time that interrupt is being processed PORTA and TRISA PORTA have 5 adjoining pins. The corresponding register for data direction is TRISA at address 85h. Like with port B, setting a bit in TRISA register defines also the corresponding port pin as input, and clearing a bit in TRISA register defines the corresponding port pin as output.

It is important to note that PORTA pin RA4 can be input only. On that pin is also situated an external input for timer TMR0. Whether RA4 will be a standard input or an input for a counter depends on T0CS bit (TMR0 Clock Source Select bit). This pin enables the timer TMR0 to increment either from internal oscillator or via external impulses on RA4/T0CKI pin.

Memory organizationPIC16F73 has two separate memory blocks, one for data and the other for program. EEPROM memory with GPR and SFR registers in RAM memory make up the data block, while FLASH memory makes up the program block.Program memory Program memory has been carried out in FLASH technology which makes it possible to program a microcontroller many times before it's installed into a device, and even after its installment if eventual changes in program or process parameters should occur. The size of program memory is 1024 locations with 14 bits width where locations zero and four are reserved for reset and interrupt vector.Data memory Data memory consists of EEPROM and RAM memories. EEPROM memory consists of 256 eight bit locations whose contents are not lost during loosing of power supply. EEPROM is notdirectly addressable, but is accessed indirectly through EEADR and EEDATA registers. As EEPROM memory usually serves for storing important parameters (for example, of a given temperature in temperature regulators) , there is a strict procedure for writing in EEPROM which must be followed in order to avoid accidental writing. RAM memory for data occupies space on a memory map from location 0x0C to 0x4F which comes to 68 locations. Locations of RAM memory are also called GPR registers which is an abbreviation for General Purpose Registers. GPR registers can be accessed regardless of which bank is selected at the moment.

3.3 Regulated power supply 3.3.1 Introduction

Power supplyis a supply ofelectrical power. A device or system that supplieselectrical or other types ofenergyto an output loador group of loads is called a power supply unitorPSU. The term is most commonly applied to electrical energy supplies, less often to mechanical ones, and rarely to others.

A power supply may include a power distribution system as well as primary or secondary sources of energy such as Conversion of one form of electrical power to another desired form and voltage, typically involving convertingACline voltage to a well-regulated lower-voltageDCfor electronic devices. Low voltage, low power DC power supply units are commonly integrated with the devices they supply, such ascomputersand household electronics.

Batteries.

Chemicalfuel cellsand other forms ofenergy storagesystems.

Solar power.

Generators oralternators. 3.3.2 Block Diagram: Fig 3.3.2 Regulated Power Supply

The basic circuit diagram of a regulated power supply (DC O/P) with led connected as load is shown in fig: 3.3.3.

Fig 3.3.3 Circuit diagram of Regulated Power Supply with Led connectionThe components mainly used in above figure are 230V AC MAINS

TRANSFORMER

BRIDGE RECTIFIER(DIODES)

CAPACITOR

VOLTAGE REGULATOR(IC 7805)

RESISTOR

LED(LIGHT EMITTING DIODE)

The detailed explanation of each and every component mentioned above is as follows: Transformation: The process of transforming energy from one device to another is called transformation. For transforming energy we use transformers.Transformers: Atransformeris a device that transferselectrical energyfrom onecircuitto another throughinductively coupledconductors without changing its frequency. A varyingcurrentin the first or primarywinding creates a varyingmagnetic fluxin the transformer's core, and thus a varyingmagnetic fieldthrough thesecondarywinding. This varying magnetic fieldinducesa varyingelectromotive force (EMF)or "voltage" in the secondary winding. This effect is calledmutual induction.

If aloadis connected to the secondary, an electric current will flow in the secondary winding and electrical energy will be transferred from the primary circuit through the transformer to the load. This field is made up from lines of force and has the same shape as a bar magnet. If another coil is placed adjacent to the first coil then, as the field moves out or in, the moving lines of force will "cut" the turns of the second coil. As it does this, a voltage is induced in the second coil. With the 50 Hz AC mains supply, this will happen 50 times a second. This is called MUTUAL INDUCTION and forms the basis of the transformer.

The input coil is called the PRIMARY WINDING; the output coil is the SECONDARY WINDING. Fig: 3.3.4 shows step-down transformer.

Fig 3.3.4: Step-Down Transformer

The voltage induced in the secondary is determined by the TURNS RATIO.

For example, if the secondary has half the primary turns; the secondary will have half the primary voltage.

Another example is if the primary has 5000 turns and the secondary has 500 turns, then the turns ratio is 10:1.

If the primary voltage is 240 volts then the secondary voltage will be x 10 smaller = 24 volts. Assuming a perfect transformer, the power provided by the primary must equal the power taken by a load on the secondary. If a 24-watt lamp is connected across a 24 volt secondary, then the primary must supply 24 watts.

To aid magnetic coupling between primary and secondary, the coils are wound on a metal CORE. Since the primary would induce power, called EDDY CURRENTS, into this core, the core is LAMINATED. This means that it is made up from metal sheets insulated from each other. Transformers to work at higher frequencies have an iron dust core or no core at all.

Note that the transformer only works on AC, which has a constantly changing current and moving field. DC has a steady current and therefore a steady field and there would be no induction.

Some transformers have an electrostatic screen between primary and secondary. This is to prevent some types of interference being fed from the equipment down into the mains supply, or in the other direction. Transformers are sometimes used for IMPEDANCE MATCHING.

We can use the transformers as step up or step down.

Step Up transformer In case of step up transformer, primary windings are every less compared to secondary winding. Because of having more turns secondary winding accepts more energy, and it releases more voltage at the output side.

Step down transformerIn case of step down transformer, Primary winding induces more flux than the secondary winding, and secondary winding is having less number of turns because of that it accepts less number of flux, and releases less amount of voltage.

Battery power supply

Abatteryis a type of linear power supply that offers benefits that traditional line-operated power supplies lack: mobility, portability and reliability. A battery consists of multiple electrochemical cells connected to provide the voltage desired. Fig: 3.3.5 shows Hi-Watt 9V battery

Thelead-acidstorage battery may be used. This battery is rechargeable; it consists of lead and lead/dioxide electrodes which are immersed in sulfuric acid. When fully charged, this type of battery has a 2.06-2.14 V potential (A 12 voltcar batteryuses 6 cells in series). During discharge, the lead is converted to lead sulfate and the sulfuric acid is converted to water. When the battery is charging, the lead sulfate is converted back to lead and lead dioxide Anickel-cadmiumbattery has become more popular in recent years.This battery cell is completely sealed and rechargeable. The electrolyte is not involved in the electrode reaction, making the voltage constant over the span of the batteries long service life. During the charging process, nickel oxide is oxidized to its higher oxidation state and cadmium oxide is reduced. The nickel-cadmium batteries have many benefits. They can be stored both charged and uncharged. They have a long service life, high current availabilities, constant voltage, and the ability to be recharged. Fig: 3.3.6 shows pencil battery of 1.5V.

Rectification: The process of converting an alternating current to a pulsating direct current is called as rectification. For rectification purpose we use rectifiers.Rectifiers: A rectifier is an electrical device that converts alternating current (AC) to direct current (DC), a process known as rectification. Rectifiers have many uses including as components of power supplies and as detectors of radio signals. Rectifiers may be made of solid-state diodes, vacuum tube diodes, mercury arc valves, and other components.

A device that it can perform the opposite function (converting DC to AC) is known as an inverter. When only one diode is used to rectify AC (by blocking the negative or positive portion of the waveform), the difference between the term diode and the term rectifier is merely one of usage, i.e., the term rectifier describes a diode that is being used to convert AC to DC. Almost all rectifiers comprise a number of diodes in a specific arrangement for more efficiently converting AC to DC than is possible with only one diode. Before the development of silicon semiconductor rectifiers, vacuum tube diodes and copper (I) oxide or selenium rectifier stacks were used.Bridge full wave rectifier:

The Bridge rectifier circuit is shown in fig: 3.3.7, which converts an ac voltage to dc voltage using both half cycles of the input ac voltage. The Bridge rectifier circuit is shown in the figure. The circuit has four diodes connected to form a bridge. The ac input voltage is applied to the diagonally opposite ends of the bridge. The load resistance is connected between the other two ends of the bridge. For the positive half cycle of the input ac voltage, diodes D1 and D3 conduct, whereas diodes D2 and D4 remain in the OFF state. The conducting diodes will be in series with the load resistance RL and hence the load current flows through RL. For the negative half cycle of the input ac voltage, diodes D2 and D4 conduct whereas, D1 and D3 remain OFF. The conducting diodes D2 and D4 will be in series with the load resistance RL and hence the current flows through RL in the same direction as in the previous half cycle. Thus a bi-directional wave is converted into a unidirectional wave.

Input

Output

Fig 3.3.7: Bridge rectifier: a full-wave rectifier using 4 diodesDB107: Now -a -days Bridge rectifier is available in IC with a number of DB107. In our project we are using an IC in place of bridge rectifier. The picture of DB 107 is shown in fig: 3.3.8. Features:

Good for automation insertion

Surge overload rating - 30 amperes peak

Ideal for printed circuit board

Reliable low cost construction utilizing molded

Glass passivated device

Polarity symbols molded on body

Mounting position: Any Weight: 1.0 gram

Fig 3.3.8: DB107Filtration: The process of converting a pulsating direct current to a pure direct current using filters is called as filtration.Filters: Electronic filters are electronic circuits, which perform signal-processing functions, specifically to remove unwanted frequency components from the signal, to enhance wanted ones.

Introduction to Capacitors:TheCapacitoror sometimes referred to as aCondenseris a passive device, and one which stores energy in the form of an electrostatic field which produces a potential (static voltage) across its plates. In its basic form a capacitor consists of two parallel conductive plates that are not connected but are electrically separated either by air or by an insulating material called theDielectric. When a voltage is applied to these plates, a current flows charging up the plates with electrons giving one plate a positive charge and the other plate an equal and opposite negative charge this flow of electrons to the plates is known as theCharging Currentand continues to flow until the voltage across the plates (and hence the capacitor) is equal to the applied voltageVcc. At this point the capacitor is said to be fully charged and this is illustrated below. The construction of capacitor and an electrolytic capacitor are shown in figures 3.3.9 and 3.3.10 respectively.

Fig 3.3.9:Construction Of a Capacitor Fig 3.10:Electrolytic CapaticorUnits of Capacitance:

Microfarad(F)1F = 1/1,000,000 = 0.000001 = 10-6F

Nanofarad(nF)1nF = 1/1,000,000,000 = 0.000000001 = 10-9F

Pico farad(pF)1pF = 1/1,000,000,000,000 = 0.000000000001 = 10-12F

Operation of Capacitor:Think of water flowing through a pipe. If we imagine a capacitor as being a storage tank with an inlet and an outlet pipe, it is possible to show approximately how an electronic capacitor works. First, let's consider the case of a "coupling capacitor" where the capacitor is used to connect a signal from one part of a circuit to another but without allowing any direct current to flow.

Voltage Regulator

A voltage regulator (also called a regulator) with only three terminals appears to be a simple device, but it is in fact a very complex integrated circuit. It converts a varying input voltage into a constant regulated output voltage. Voltage Regulators are available in a variety of outputs like 5V, 6V, 9V, 12V and 15V. The LM78XX series of voltage regulators are designed for positive input. For applications requiring negative input, the LM79XX series is used. Using a pair of voltage-divider resistors can increase the output voltage of a regulator circuit.It is not possible to obtain a voltage lower than the stated rating. You cannot use a 12V regulator to make a 5V power supply. Voltage regulators are very robust. These can withstand over-current draw due to short circuits and also over-heating. In both cases, the regulator will cut off before any damage occurs. The only way to destroy a regulator is to apply reverse voltage to its input. Reverse polarity destroys the regulator almost instantly. Fig: 3.3.11 shows voltage regulator.

Resistors:

A resistor is a two-terminal electronic component that produces a voltage across its terminals that is proportional to the electric current passing through it in accordance with Ohm's law:

V = IRResistors are elements of electrical networks and electronic circuits and are ubiquitous in most electronic equipment. Practical resistors can be made of various compounds and films, as well as resistance wire (wire made of a high-resistivity alloy, such as nickel/chrome).

The primary characteristics of a resistor are the resistance, the tolerance, maximum working voltage and the power rating. Other characteristics include temperature coefficient, noise, and inductance. Less well-known is critical resistance, the value below which power dissipation limits the maximum permitted current flow, and above which the limit is applied voltage. Critical resistance is determined by the design, materials and dimensions of the resistor. Resistors can be made to control the flow of current, to work as Voltage dividers, to dissipate power and it can shape electrical waves when used in combination of other components. Basic unit is ohms.Power dissipation:

The power dissipated by a resistor (or the equivalent resistance of a resistor network) is calculated using the following:

3.4. LED:

A light-emitting diode (LED) is a semiconductor light source. LEDs are used as indicator lamps in many devices, and are increasingly used for lighting. Introduced as a practical electronic component in 1962, early LEDs emitted low-intensity red light, but modern versions are available across the visible, ultraviolet and infrared wavelengths, with very high brightness. The internal structure and parts of a led are shown below.

Fig 3.4.1: Inside a LED Fig 3.4.2: Parts Of a LEDWorking:

The structure of the LED light is completely different than that of the light bulb. Amazingly, the LED has a simple and strong structure. The light-emitting semiconductor material is what determines the LED's color. The LED is based on the semiconductor diode.

When a diode is forward biased (switched on), electrons are able to recombine with holes within the device, releasing energy in the form of photons. This effect is called electroluminescence and the color of the light (corresponding to the energy of the photon) is determined by the energy gap of the semiconductor. An LED is usually small in area (less than 1mm2), and integrated optical components are used to shape its radiation pattern and assist in reflection. LEDs present many advantages over incandescent light sources including lower energy consumption, longer lifetime, improved robustness, smaller size, faster switching, and greater durability and reliability. However, they are relatively expensive and require more precise current and heat management than traditional light sources. Current LED products for general lighting are more expensive to buy than fluorescent lamp sources of comparable output. They also enjoy use in applications as diverse as replacements for traditional light sources in automotive lighting (particularly indicators) and in traffic signals. The compact size of LEDs has allowed new text and video displays and sensors to be developed, while their high switching rates are useful in advanced communications technology. The electrical symbol and polarities of led are shown in fig: 3.4.3.

Fig 3.4.3: Electrical Symbol & Polarities of LEDLED lights have a variety of advantages over other light sources: High-levels of brightness and intensity

High-efficiency

Low-voltage and current requirements

Low radiated heat

High reliability (resistant to shock and vibration)

No UV Rays

Long source life

Can be easily controlled and programmed

Applications of LED fall into three major categories:

Visual signal application where the light goes more or less directly from the LED to the human eye, to convey a message or meaning.

Illumination where LED light is reflected from object to give visual response of these objects.

Generate light for measuring and interacting with processes that do not involve the human visual system.3.5: LED Notice Board3.5.1 One LED, no resistorI thought that I would start as simply as I possibly could - just one LED with no resistor. First I had to decide what power source to use and which LED to light up. This may seem obvious, but this was my first time through so I might as well be as clear as possibleLEDs require sufficient voltage to light them. Sometimes if you give them too little voltage they wont light at all, other times they will just shine dimly with low voltage. Too much voltage is bad and can burn out the LED instantaneously.So ideally you would like the voltage of the LED to match the voltage of your power supply, or even be slightly less. To do this you can do a couple of things: change your power supply voltage, change the LED your using, or you can use a resistor that allows you use a higher voltage power supply with a lower voltage LED.

3.5.1 One LED, no resistor

For now I just wanted to get one lit up so I chose my the power supply that had the lowest voltage - the single AA battery which outputs 1.5V.I chose to light the red 1.7V LED since the battery outputs 1.5V and I knew I wouldn't kill the LED with too much power.I wrapped my positive wire from the battery to the positive electrode of the LED and wrapped the negative wire from the battery to my negative electrode and presto - let there be LED light! This first experiment was pretty easy to do - just some wire twisting and enough knowledge to know that the 1.5V power supply would light the 1.7V LED without need a resistor.3.5.2 It was just a coincidence that I bought an LED that was 1.7V and that it ended up working being able to be powered by my 1.5V power supply without the use of a resistor. For this second setup I decided to use the same LED, but up my power supply to the three AA batteries wired together which output 4.5V - enough power to burn out my 1.7V LED, so I would have to use a resistor.

3.5.2 One LED with a resistorTo figure out which resistor to use I used the formula: R = (V1 - V2) / I where: V1 = power supply voltage V2 = LED voltage . I = LED current (usually 20mA which is .02A). Now there are lots of calculators online that will do this for you - and many other instructorless referencethisas a good one, however, the math really isn't too hard and so I wanted to go through the calculation myself and understand whets going on. Again, my LED is 1.7V, it takes 20mA (which is .02 A) of current and my supply is 4.5V. So the math is... R = (4.5V - 1.7V) / .02 A R = 140 ohms Once I knew that I needed a resistor of 140 ohms to get the correct amount of voltage to the LED I looked into my assortment package of resistors to see if I could find the right one. Knowing the value of a resistor requires reading the code from the color bands on the resistor itself. The package didn't come with a 140 ohm resistor but it did come with a 150 ohm one. Its always better to use the next closest value resistor greater than what you calculated. Using a lower value could burn out your LED. To figure out the color code you basically break down the first two digits of the resistor value, use the third digit to multiply the first two by and then assign the fourth digit as an indicator of tolerance. That sounds a lot more difficult than it really is. Using the color to number secret decoder website foundhere, a 150ohm resistor should have the following color code. Brown because the first digit in the value resistor I needed is 1Green because the fifth digit is 5 Brown because in order to get to 150 you have to add one 0 to 15 to get to 150. Gold - the resistors I got all have 5% tolerance and 5% is represented by gold I looked through all the resistors, found the one that was brown, green, brown, gold, and wired it in line on the positive electrode of the LED. (Whenever using a resistor on an LED it should get placed before the LED on the positive electrode). Low and behold, the LED lit up once again. The 150 ohm resistor stopped enough of the 4.5V power supply from reaching the 1.7V LED that it lit up safely and kept it from burning out. This is just the process that I went through to figure out what resistor to use with my particular LED with my particular power supply. You can easily use the formula above to figure out what value resistor to use with whatever LED and power source you happen to be using. 3.5.3 Multiple LEDs in series

When it comes to wiring more than one LED to a power supply there are two options. The first option is to wire them in series and the second is to wire them in parallel.To see an in depth explanation about the difference between series and parallel check outthis page. I'm going to cover wiring LEDs in series first. LEDs wired in series are connected end to end (the negative electrode of the first LED connects to the positive electrode of the second LED and the negative electrode of the second LED connects to the positive electrode of the third LED and so on and so on...). The main advantage of wiring things in series is that it distributes the total voltage of the power source between all of the LEDs. What that means is that if I had a 12V car battery, I could power 4, 3V LEDs (attaching a resistor to each of them). Hypothetically this could also work to power 12, 1V LEDs; 6, 2V LEDs; or even 1 12V LED if such a thing existed.

R=(9V-5.2V).02AR=190Ohms Now the variety package of resistors didn't come with a 190 or 200 Ohm resistor, but it did come with other resistors which I could use to make a 200 Ohm resistor. Just like LEDs, resistors can be wired together in either series or parallel. When same value resistors are wired together in series you add their resistance. When same value resistors are wired together in parallel you divide the value of the resistor by the number of resistors wired together. So, in the most simplified sense, two 100 Ohm resistors wired together in series will equal 1 200 Ohm resistor (100 + 100 = 200). Two 100 Ohm resistors wired together in parallel will equal one 50 Ohm resistor (100 / 2 = 50). Unfortunately, I learned this key point after I wired my resistors together for the experiment. I had originally wanted to wire two 100 Ohm resistors together to equal the 200 Ohms of resistance I needed to protect my LEDs. Instead of wiring them in series, as it should have been, I wired my resistors in parallel (did I mention I am beginner with resistors?) So my resistors were only providing 50 Ohms of resistance - which apparently worked out OK on my LEDs in the short duration of the experiment. Having too much power getting to the LEDs would probably burn them out in the long term. (Thanks beanwaur and shark500 for pointing this out.) I took my resistors and placed them in front of the positive lead of the first LED that was wired in series and hooked them up to the battery and once again, there was LED light! With three different combinations of LEDs and battery power supplies and no puffs of plastic smoke yet things were looking good - aside from my little confusion between wiring resistors in series and in parallel.3.6 Buzzer

A buzzer or beeper is an audio signaling device, which may be magnetic or piezoelectric.

1. Magnetic Transducer Magnetic transducers contain a magnetic circuit consisting of an iron core with a wound coil and a yoke plate, a permanent magnet and a vibrating diaphragm with a movable iron piece. The diaphragm is slightly pulled towards the top of the core by the magnet's magnetic field. When a positive AC signal is applied, the current flowing through the excitation coil produces a fluctuating magnetic field, which causes the diaphragm to vibrate up and down, thus vibrating air. Resonance amplifies vibration through resonator consisting of sound hole(s) and cavity and produces a loud sound.

2. Magnetic Buzzer (Sounder)Buzzers like the TMB-series are magnetic audible signal devices with built-in oscillating circuits. The construction combines an oscillation circuit unit with a detection coil, a drive coil and a magnetic transducer. Transistors, resistors, diodes and other small devices act as circuit devices for driving sound generators. With the application of voltage, current flows to the drive coil on primary side and to the detection coil on the secondary side. The amplification circuit, including the transistor and the feedback circuit, causes vibration. The oscillation current excites the coil and the unit generates an AC magnetic field corresponding to an oscillation frequency. This AC magnetic field magnetizes the yoke comprising the magnetic circuit. The oscillation from the intermittent magnetization prompts the vibration diaphragm to vibrate up and down, generating buzzer sounds through the resonator.

3.6.1 Buzzer

3.6.2 Buzzer structure

SpecificationsRated Voltage: A magnetic buzzer is driven by 1/2 square waves(Vo-p).Operating Voltage: For normal operating. But it is not guaranteed to make the minimum Sound Pressure Level (SPL) under the rated voltage.Consumption Current: The current is stably consumed under the regular operation. However, it normally takes three times of current at the moment of starting to work.Direct Current Resistance: The direct current resistance is measured by ammeter directly.Sound Output: The sound output is measured by decibel meter. Applying rated voltage and 1/2 square waves, and the distance of 10 cm.Rated Frequency: A buzzer can make sound on any frequencies, but we suggest that the highest and the most stable SPL comes from the rated frequency.Operating Temp. : Keep working well between -30 and +70.

How to choose:

Driving methods: AX series with built drive circuit will be the best choice when we cannot provide frequency signal to a buzzer, it only needs direct current.Dimension: Dimension affects frequency, small size result in high frequency.Voltage: Depend on V o-p (1/2 square waves)Fixed methods: From the highest cost to the lowest- DIP, wires/ connector, SMD.Soldering methods: AS series is soldered by hand, the frequency is lower because of the holes on the bottom. On the other hand, we suggest AC series for the reflow soldering, the reliability is better.

How to choose a buzzer

There are many different kinds of buzzer to choose, first we need to know a few parameters, such as voltage, current, drive method, dimension, mounting type, and the most important thing is how much SPL and frequency we want.Operating voltage: Normally, the operating voltage for a magnetic buzzer is from 1.5V to 24V, for a piezo buzzer is from 3V to 220V. However, in order to get enough SPL, we suggest giving at least 9V to drive a piezo buzzer.Consumption current: According to the different voltage, the consumption current of a magnetic buzzer is from dozens to hundreds of mill amperes; oppositely, the piezo type saves much more electricity, only needs a few mill amperes, and consumes three times current when the buzzer start to workDriving method: Both magnetic and piezo buzzer have self drive type to choose. Because of the internal set drive circuit, the self drive buzzer can emit sound as long as connecting with the direct current. Due to the different work principle, the magnetic buzzer need to be driven by 1/2 square waves, and the piezo buzzer need square waves to get better sound output.Dimension: The dimension of the buzzer affects its SPL and the frequency, the dimension of the magnetic buzzer is from 7 mm to 25 mm; the piezo buzzer is from 12 mm to 50 mm, or even bigger.Connecting way: Dip type, Wire type, SMD type, and screwed type for big piezo buzzer are usually seen.Sound Pressure Level (SPL): Buzzer is usually tested the SPL at the distance of 10 cm, if distance double, the SPL will decay about 6 dB; oppositely, the SPL will increase 6 dB when the distance is shortened by one time. The SPL of the magnetic buzzer can reach to around 85 dB/ 10 cm; the piezo buzzer can be designed to emit very loud sound, for example, the common siren, are mostly made of piezo buzzer.

3. Piezoelectric buzzers:

Piezoelectric buzzer comes under electronic type of buzzer which is horned by proper electronic oscillatory circuit.

Basically, the sound source of a piezoelectric sound component is a piezoelectric diaphragm. A piezoelectric diaphragm consists of a piezoelectric ceramic plate which has electrodes on both sides and a metal plate (brass or stainless steel, etc.).

A piezoelectric ceramic plate is attached to a metal plate with adhesives. Fig. 2 shows the oscillating system of a piezoelectric diaphragm. Applying D.C. voltage between electrodes of a piezoelectric diaphragm causes mechanical distortion due to the piezoelectric effect. For a misshaped piezoelectric element, the distortion of the piezoelectric element expands in a radial direction. And the piezoelectric diaphragm bends toward the direction shown in Fig.2 (a). The metal plate bonded to the piezoelectric element does not expand. Conversely, when the piezoelectric element shrinks, the piezoelectric diaphragm bends in the direction shown in Fig.2 (b). Thus, when AC voltage is applied across electrodes, the bending shown in Fig.2 (a) and Fig.2 (b) is repeated as shown in Fig.2 (c), producing sound waves in the air.

In general, man's audible frequency range is about 20 Hz to 20 kHz. Frequency ranges of 2 kHz to 4 kHz are most easily heard. For this reason, most piezoelectric sound components are used in this frequency range, and the resonant frequency (f0) is generally selected in the same range too. As shown in Fig. 3, the resonant frequency depends on methods used to support the piezoelectric diaphragm. If piezoelectric diaphragms are of the same shape, their values will become smaller in the order of (a), (b) and (c). In general, the piezoelectric diaphragm is installed in a cavity to produce high sound pressure. The resonant frequency (fcav) of the cavity in Fig. 4 is obtained from Formula (1) (Helmholtz's Formula). Since the piezoelectric diaphragm and cavity have proper resonant frequencies, (f0) and (fcav) respectively, sound pressure in specific frequencies can be increased and a specific bandwidth can be provided by controlling both positions.

\Specifications:

Rated Voltage: A piezo buzzer is driven by square waves (V p-p).Operating Voltage: For normal operating. But it is not guaranteed to make the minimum SPL under the rated voltage.Consumption Current: The current is stably consumed under the regular operation. However, it normally takes three times of current at the moment of starting to work.Capacitance: A piezo buzzer can make higher SPL with higher capacitance, but it consumes more electricity.Sound Output: The sound output is measured by decibel meter. Applying rated voltage and square waves, and the distance of 10 cm.Rated Frequency: A buzzer can make sound on any frequencies, but we suggest that the highest and the most stable SPL comes from the rated frequency.Operating Temp.: Keep working well between -30 and +70.

How to choose:

Driving methods: AZ-xxxxS-x series with built drive circuit will be the best choice when we cannot provide frequency signal to a buzzer, it only needs direct current. Besides, there are different tone nature for you to choose, such as continuous, fast pulse, and slow pulse. Dimension: Dimension affects frequency, small size result in high frequency.Voltage: Driven by square waves (V p-p), the higher voltage results in the higher SPL.Pin Pitch: The numerous spec. for the piezo buzzers lead to the difficulty in finding a spec. in facsimile, therefore we suggest that you can firstly choose a spec. with the same pitch and similar frequency.Introduction of Micro Speaker

How to choose:

The factors which affect the SPL: the square measure of diaphragm, the amplitude of vibration, magnetic field intensity, power, impedance, resonant chamber, the pattern and the thickness of diaphragm, and the holes. Power vs. SPL: Suppose all the conditions are the same, increasing the power dose not mean the SPL will increase as well. We need to revise the diaphragm and the sound coil to load the higher power, but it leads to lower SPL instead.Dimension vs. SPL: A larger speaker can vibrate more air, therefore it provides higher SPL. In addition, the thicker speaker can give wider amplitude of vibration which also leads to higher SPL.Acoustics: What we request most is how much SPL a micro speaker can output.Matching: It will be better to provide the power slight higher than the rated power for the enlarged circuit.

Question for mechanism:

The volume of the resonant chamber: The general problem of the consuming products is that the resonant chambers are not big enough. We can only try to find space to enlarge the volume of the resonant chamber.Sound Hole: Must be more than 1/8 of the diaphragms area at least.Airtight: The front and back sound fields of the speaker should be separated to avoid neutralization.Shock absorber: When a speaker works the vibration will also happen at the same time. In order to reduce interference, it will do good to have some material between speaker and case to absorb the shock.Mounting: The speakers are usually fixed on the case. Firmly fixed is important especially for the iron housing or the large size to avoid separating in the drop test.How to choose the speaker

Dimension: To the micro speaker, size has decisive influence on its volume. 5mm difference of diameter might result in double or half area of diaphragm, therefore the SPL is quite different. Besides, the thicker speaker has more space to vibrate the air, and usually has bigger magnet, so it will be more powerful to push the air and emit louder sound.

Power: Mainly refer to how much power can a speaker bear, there is no direct relation to the SPL. The speaker with larger power needs to use thicker diaphragm and sound coil to bear larger power, which will lead to lower efficiency (SPL). Therefore, according to the mechanical design, try to select a larger speaker which matches the outputting power from the amplified circuit, then the best SPL would be emitted.

Impedance: Higher impedance can save more electricity, however, the SPL and the loaded power will go down. The reason is that we have to use thinner wire or to coil more, the front makes the power lower, and the after leads to heaviness and low efficiency. The material of diaphragm: Most speakers (diameter less than 50mm) use mylar diaphragms, which are easily finished, cheaper and waterproof. However, mylar diaphragm is not good at heatproof and the sound is stiff. The patterns of diaphragm: The speaker with concentric circles diaphragm is good for the speech sounds. Generally, the SPL is good at the frequency before 5-6 KHz, but will dramatically decrease after 6 KHz. On the other hand, the speaker with radiate diaphragm has average frequency response. Supposing other conditions are all the same, the SPL of radiate diaphragm will lower than the concentric circles one at the frequency before 6 KHz. 3.7 Bluetooth

Bluetooth is an open standard specification for a radio frequency (RF)-based, short-range connectivity technology that promises to change the face of computing and wireless communication. It is designed to be an inexpensive, wireless networking system for all classes of portable devices, such as laptops, PDAs (personal digital assistants), and mobile phones. It also will enable wireless connections for desktop computers, making connections between monitors, printers, keyboards, and the CPU cable-free.

The idea of a cable-free, or wireless, technology was initially conceived by Ericsson in 1994, when the company began a study to investigate the feasibility of a low-power, low-cost radio interface between mobile phones and their accessories. The companys goal was to eliminate the need for cables. The original idea was to create a small, inexpensive radio chip that could be used in mobile computers, printers, mobile phones, and so on, to transmit data between these devices. The radio chip, of course, would replace cables. The projected cost of the chip was around $5, and it was to require low power so that it could be used in devices that rely on battery life.

As the idea grew, a special interest group (SIG) was formed to create a standard for this technology.

The original SIG, formed in 1998, consisted of five companies:

Ericsson

IBM

Intel

Nokia

Toshiba

Four other major companies (Microsoft, 3Com, Lucent, and Motorola) later joined this founding group to form the Bluetooth Promoter Group. Many more companies have since become part of the Bluetooth revolution, expanding on the original vision, and helping drive the development of this new technology.

The name Bluetooth comes from Danish history. Harald Blatand, who was called Bluetooth, was the son of King Gorm the Old, who ruled Jutland, the main peninsula of Denmark. By the time Harald became king, he was a skilled Viking warrior. So, when his sister asked for help to secure control in Norway after her husband died, Harald quickly seized the opportunity to unite the countries and expand his kingdom. By 960 A.D., according to the story, Harald was at the height of his powers, and ruled both Denmark and Norway. He was later credited with bringing Christianity to his Viking realm. Although its popularly believed that King Harald had a blue tooth, and various stories explain how this came about, its more likely that the Bluetooth name is the English derivative of the original Viking word, Blatand. The Bluetooth name was chosen for the wireless technology because its developers and promoters hope it will unite the mobile world, just as King Harald united his world.Bluetooth Components:

A complete Bluetooth system will require these elements:

An RF portion for receiving and transmitting data

A module with a baseband microprocessor

Memory

An interface to the host device (such as a mobile phone)

Bluetooth terminology:

The Bluetooth specification, while innovative, does not define a totally new technology. In fact, Bluetooth draws heavily on existing radio communications and networking technologies, which enables it to be operationally compatible with the existing devices that also use these technologies. Many of the various terms and concepts used in Bluetooth are borrowed from other areas and included in the specification of Bluetooths elements, such as baseband, RF communications, and many of the upper- and lower-layer protocols. What makes Bluetooth unique is how it applies its proprietary components and the existing technologies to define its central core operations and its application profiles. Regardless of their source, the terms that are integral to Bluetooth are worth examining a little more closely.Bluetooth stack:

As already noted, the baseband, or radio module, is the hardware that enables wireless communication between devices. The building block of this technology is the Bluetooth stack, which includes the hardware and software portions of the system. Figure shows a graphic representation of the stack. Essentially, the stack contains a physical-level protocol (baseband) and a link level protocol (Link Manager Protocol, or LMP) with an adaptation layer (Logical Link Control and Adaptation Layer Protocol, or L2CAP), enabling upper-layer protocols to interact with the lower layer.

The Bluetooth stack has the following components:

RF portion for reception and transmission

Baseband portion with microcontroller

Link control unit

Link manager to support lower-layer protocols

Interface to the host device

Host processor to support upper-layer protocols

L2CAP to support upper-layer protocolsThe radio frequency (RF) portion provides the digital signal processing component of the system, and the baseband processes these signals. The link controller handles all the baseband functions and supports the link manager. It sends and receives data, identifies the sending device, performs authentication, and determines the type of frame to use for sending transmissions. The link controller also directs how devices listen for transmissions from other devices and can move devices into power-saving modes.

The link manager, located on top of the link controller, controls setup, authentication, link configuration, and other low-level protocols. Together, the baseband and the link manager establish connections for the network.

The host controller interface (HCI) communicates the lower-layer protocols to the host device (mobile computer or mobile phone, for example). The host contains a processor, the L2CAP, which supports the upper-layer protocols and communicates between upper and lower layers. The upper-layer protocols consist of service-specific applications that must be integrated into the host application.

Another element in the Bluetooth stack that relates to radio communications is the RFCOMM protocol, which allows for the emulation of serial ports over the L2CAP.The Service Discovery Protocol (SDP) provides the means for Bluetooth applications to discover the services and the characteristics of the available services that are unique to Bluetooth.

The Bluetooth device manager provides for device inquiry and connection management services.Links and channels Links and channels are used to transmit data between Bluetooth units. First, the links are established. Bluetooth technology supports two link types: synchronous connection-oriented (SCO) and asynchronous connectionless (ACL) links. The SCO links are used primarily for voice communications. The ACL links are used for packet data. Bluetooth devices can use either link type and can change link types during transmissions, although an ACL link must be established before an SCO link can be used. After the link has been established, Bluetooth uses five logical channels to transfer different types of information between devices:

Link control (LC) manages the flow of packets over the link interface.

Link manager (LM) transports link management information between participating stations.

User asynchronous (UA) carries user data.

User isochronous (UI) carries user data.

User synchronous (US) carries synchronous (SCO) data.

Protocols Bluetooth protocols are sets of conventions that govern the transmittal of data in upper and lower layers of the system. The lower-layer protocols pertain to establishing connections, and the upper layers correspond to specific types of applications.LINK CONTROL PROTOCOL The link control protocol is responsible for delivery of the basic data elements. All packet information is transmitted in a specific time-slot format (a single time slot in the Bluetooth system lasts 625 s), and specific links are designed to transport a range of data types.

The Bluetooth link control protocol can be used to manage the associations and delivery of information between the various units within a Bluetooth network. This format is used for both synchronous (voice) and asynchronous (data) modes of operation, with specific formats specified for voice transp