A PROJECT REPORT ON Handicap Assistance Device for Appliance Control Using User Defined Gestures Submitted In Partial Fulfillment of the Requirement for the Award of the Degree Of BACHELOR OF TECHNOLOGY IN ELECTRONICS AND COMMUNICATION ENGINEERING Jawaharlal Nehru Technological University, Hyderabad BY Naresh Mailarapu (07J81A0425) Narayana reddy k (07J81A0423 Under the Guidance of Miss T K Padmalatha Asst Prof Department of Electronics & Communication Engineering P.INDRA REDDY MEMORIAL ENGINEERING COLLEGE (Affiliated to Jawaharlal Nehru Technology University, Hyderabad, A.P) Chevella, Ranga Reddy Dist-501503. 1 CERTIFICATE This is to certify that this project work entitled “Handicap Assistance Device for Appliance Control Using User Defined Gestures” is being submitted by Naresh Mailarapu (07J81A0425) Narayana reddy k (07J81A0423) To the Jawaharlal Nehru Technological University, Hyderabad for the award of the degree of Bachelor of Technology in Electronics and Communication Engineering is a record of bonafide work carried out by them under our supervision and guidance The results embodied in this project have not been submitted to any other university or institute for the award of any degree or diploma INTERNAL GUIDE PRINCIPAL HEAD OF THE DEPARTMENT EXTERNAL EXAMINER 2 ACKNOWLEDGEMENT We would like to express a deep sense of gratitude and thanks profusely to our guide without the wise counsel and able guidance, it would have been impossible to complete the project in this manner. We express our deep sense of gratitude to Head of the Department, for his technical support and guidance. His critical evaluation of work and suggestions has been of great help to us. We also express our gratitude to Principal of our college, for his guidance and cooperation during our course of study. We are highly thankful to Prayog Labs Pvt Ltd., Hyderabad where every facility for the project was provided. Their round the clock service and R&D laboratory facilities helped us to complete the project in time. Great acknowledgement is expressed to Coordinator, teaching and Non-teaching staff members whose guidance cannot be ignored in completing this project. 3 INDEX CONTENTS Page No. CHAPTER 1 INTRODUCTION CHAPTER 2 EMBEDDED SYSTEMS 2.1 History 2.2 Tools 2.3 Resources 2.4 Real Time Issues 2.5Need For Embedded Systems CHAPTER 3 HARDWARE DESCRIPTION 3.1 Introduction 3.2 Block diagram 3.3Main blocks of project CHAPTER 4 MICROCONTROLLER 4.1 Introduction to Microcontrollers 4.2 Features 4.3 Pin diagram: 4.4 Pin Descriptions 4 CHAPTER 5 HARD WARE COMPONENTS 5.1 REGULATED POWER SUPPLY 5.1.1Introduction: 5.1.2Block Diagram: 5.1.3 Rectifiers 5.1.4 Filters: 5.1.5 Voltage Regulator: 5.1.6LED 5.2 ACCELEROMETER MMA 1260D 5.2.1 Features 5.2.2 Principle of operation 5.2.3 Pin diagram 5.2.4 Pin Description 5.3 ACCELEROMETER MMA2260D 5.3.1 Features 5.3.2 Principle of operation 5.3.3 Pin diagram 5.3.4 Pin Description 5.4 BUZZERS 5 5.5 CONTACT BUTTONS 5.6 5 DOF SENSOR 5.6.1 3-Axis ±3g MEMS Accelerometer (ADXL330) 5.6.1.1 Features 5.6.1.2 Principle of operation 5.6.1.3 Pin diagram 5.6.1.4 Pin Description 5.6.2 Integrated Dual-Axis Gyro IDG-300 5.6.2.1 Features 5.6.2.2 Principle of operation 5.6.2.3Pin diagram 5.6.2.4Pin Description: 5.7 WI.232FHSS-250-R 5.7.1 Features 5.7.2 Principle of operation 5.7.3 Pin diagram 5.7.4 Pin Description 6 CHAPTER 6 SCHAMATIC 6.1 Left hand controller 6.2 Right hand controller 6.3 Receiver CHAPTER 7 SOFTWARE IMPLEMENTATION 7.1 Software Tools 7.2 Screen Shots 7.3 coding CHAPTER 8 APPLICATIONS CHAPTER 9 RESULTS CHAPTER 10 CONCLUSION CHAPTER11 BIBLIOGRAPHY 7 List of figures Figure name Page no Fig :1 A modern example of embedded system 12 Fig:2 block diagram Fig:3 Micro controller 15 Fig;4 Pin diagram of AT 644 PA 18 Fig 5: Regulated Power Supply 20 Fig 6: Circuit diagram of Regulated Power Supply with Led 21 Fig 7: Step-Down Transformer 22 Fig 8: Hi-Watt 9V Battery 24 Fig 9: Pencil Battery of 1.5V 25 8 Fig 10: Bridge rectifier: a full-wave rectifier using 4 diodes 26 Fig 11: DB107 27 Fig 12: Voltage Regulator 28 Fig 13: Inside a LED 29 Fig 14: Parts of a LED 29 Fig 15: Electrical Symbol & Polarities of LED 30 Fig 16:Transducer physical model 33 Fig 17: Pin diagram of mma1260d 33 Fig 19:Pin diagram of MMA2260d Figure 20: Buzzer Fig 21:pin diagram of ADXL330 Fig 22: pin diagram of IDG 300 9 Fig 23 pin diagram of WI.232FHSS-250-R Abstract Prayog Gloves is a wireless USB gesture input system that enables a person to use a computer by performing intuitive hand and finger motions in the air. While wearing a glove controller on the right hand, the user can move the cursor by forming a pointing gesture and click by curling the index finger or thumb. Other right hand gestures enable scrolling and provide access to various keyboard shortcuts. Wearing a glove device on the left hand allows the user to type different keys through a combination of tilting the hand and touching different portions of the palm and fingers with the thumb. The left and right controllers are attached to each other but communicate to the computer wirelessly through a base station. Mister Gloves uses a low-speed USB 1.1 interface and does not require the installation of additional drivers. Our gesture input system can be conveniently used by anyone who wishes not to be tied down to a desk when using a computer, making it perfect for giving presentations or web surfing from the couch. The intuitive hand motion controls also allow it to serve as an alternative video game controller. Additionally, since our input system does not exert pressure on the median nerve at the wrist while in use, it may prevent the development of carpal tunnel syndrome and other repetitive stress injuries. The motivation for our project was to create an intuitive input system that would be easy and fun to use for computer applications that are not particularly keystroke-intensive, such as surfing the web and playing (certain) video games. Glove and Peregrine are both glove controllers that rely on various finger, thumb, and palm touch actions. We decided to improve upon this concept by incorporating accelerometers to detect the tilt of the hand as well, thus permitting wrist movements to control the keystroke input in combination with the touch actions. This also allows for a comparable assortment of possible keystrokes with a reduced number of touch or contact sensors, which in turn enables us to define larger contact zones to allow easier activation. 10 EMBEDDED SYSTEMS Embedded Systems: 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 generalpurpose 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. 11 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 :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 12 efficiency not seen in most PC applications. Below is a list of issues specific to the embedded field. History: In the earliest years of computers in the 1930–40s, 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 of programmable controllers evolved from traditional electromechanical sequencers, via solid state devices, to the use of computer technology. One of the first recognizably modern embedded systems was the Apollo Guidance Computer, developed by Charles Stark Draper at 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 Autonetics D-17 guidance computer for the Minuteman missile, released in 1961. It was built from transistor logic and had a hard disk for 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. 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. 13 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. 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 "malloc" 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. 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 14 able to put off/skip low priority tasks such as UI in favor of high priority tasks like hardware control. 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. 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. 15 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. Reliability: Embedded systems often reside in machines that are expected to run continuously for years without errors and in some cases recover by them 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 backup s is selected by an operator. Examples include aircraft navigation, reactor control systems, safety-critical chemical factory controls, train signals, engines on single-engine aircraft. 16 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 errors—both 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 Programming 17 HARDWARE DESCRIPTION Introduction: In this chapter the block diagram of the project and design aspect of independent modules are considered. Block diagram is shown in BLOCK DIAGRAM LEFT HAND CONTROL 14 X&Y CONTACT POWER ACCELAR BUTTONS SUPPLY OMETERS PIEZO TILT LEFT BUTTONS HAND ELECTRIC BUZZER MCU RIGHT HAND CONTROL (SENSOR READINGS FLEX 5 DOF SENSOR SENSOR THROUGH WIRE) RIGHT HAND MCU TILT BUTTONS 18 SENSOR INPUT READINGS (WIRELESS) PACKET RADIO BASE STATION PACKET PACKET RADIO RADIO MCU MCU BASED RxrRxr BASED DEBOUNCED AND FORMATTES INPUT REQUEST MCU BASE MCU BASE USB USB 19 The main blocks of this project are: Microcontrollers Accelerometers Flex sensor 5DOF sensor Tilt state buttons Piezo electric buzzers Programming/controlling packet radios 20 Micro controller fig:3 Micro controller 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. 21 The microcontroller used in this project is ATmega644PA. The ATmega families of microcontrollers are developed by Atmel corporation. The ATmega16 is a lowpower CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega16 achieves throughputs approaching 1 MIPS per MHz allowing the system designer to optimize power consumptionversus processing speed. Features High-performance, Low-power Atmel® AVR® 8-bit Microcontroller Advanced RISC Architecture 131 Powerful Instructions – Most Single-clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static Operation Up to 16 MIPS Throughput at 16 MHz On-chip 2-cycle Multiplier High Endurance Non-volatile Memory segments o 16 Kbytes of In-System Self-programmable Flash program memory o 512 Bytes EEPROM o 1 Kbyte Internal SRAM Write/Erase Cycles: 10,000 Flash/100,000 EEPROM Data retention: 20 years at 85°C/100 years at 25°C Optional Boot Code Section with Independent Lock Bits In-System Programming by On-chip Boot Program True Read-While-Write Operation Programming Lock for Software Security Peripheral Features 22 Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture Mode Real Time Counter with Separate Oscillator Four PWM Channels 8-channel, 10-bit ADC 8 Single-ended Channels 7 Differential Channels in TQFP Package Only 2 Differential Channels with Programmable Gain at 1x, 10x, or 200x Byte-oriented Two-wire Serial Interface Programmable Serial USART Master/Slave SPI Serial Interface Programmable Watchdog Timer with Separate On-chip Oscillator On-chip Analog Comparator Special Microcontroller Features Power-on Reset and Programmable Brown-out Detection Internal Calibrated RC Oscillator External and Internal Interrupt Sources Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby and Extended Standby. I/O and Packages 32 Programmable I/O Lines 40-pin PDIP, 44-lead TQFP, and 44-pad QFN/MLF Operating Voltages 4.5V - 5.5V for ATmega16 23 Pin diagram: Fig;4 Pin diagram of AT 644 PA Pin Descriptions VCC Digital supply voltage. GND Ground. Port A (PA7..PA0) Port A serves as the analog inputs to the A/D Converter.Port A also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used. Port pinscan 24 provide internal pull-up resistors (selected for each bit). The Port A output buffers have symmetricaldrive characteristics with both high sink and source capability. When pins PA0 to PA7are used as inputs and are externally pulled low, they will source current if the internal pull-upresistors are activated. The Port A pins are tri-stated when a reset condition becomes active,even if the clock is not running. Port B (PB7..PB0) Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset condition becomes active , even if the clock is not running. Port C (PC7..PC0) Port C is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port C output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if the clock is not running. If the JTAG interface is enabled, the pull-up resistors on pins PC5( TDI), PC3(TMS) and PC2(TCK) will be activated even if a reset occurs. Port D (PD7..PD0) Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port D output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up resistors are activated. The Port D pins are tri-stated when a reset condition becomes active, even if the clock is not runnning. RESET Reset Input. A low level on this pin for longer than the minimum pulse length will generate a reset, even if the clock is not running. XTAL1 Input to the inverting Oscillator amplifier and input to the internal clock operating circuit. XTAL2 Output from the inverting Oscillator amplifier. 25 AVCC AVCC is the supply voltage pin for Port A and the A/D Converter. It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter. AREF AREF is the analog reference pin for the A/D Converter. REGULATED POWER SUPPLY: Introduction: Power supply is a supply of electrical power. A device or system that supplies electrical or other types of energy to an output load or group of loads is called a power supply unit or PSU. 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 converting AC line voltage to a well-regulated lower-voltage DC for electronic devices. Low voltage, low power DC power supply units are commonly integrated with the devices they supply, such as computers and household electronics. Batteries. Chemical fuel cells and other forms of energy storage systems. Solar power. Generators or alternators. Block Diagram: 26 Transformer Rectifier Filter Regulator Fig 5: Regulated Power Supply The basic circuit diagram of a regulated power supply (DC O/P) with led connected as load is shown in fig. Fig 6: Circuit diagram of Regulated Power Supply with Led The 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: 27 Transformation: The process of transforming energy from one device to another is called transformation. For transforming energy we use transformers. Transformers: A transformer is a device that transfers electrical energy from one circuit to another through inductively coupled conductors without changing its frequency. A varying current in the first or primary winding creates a varying magnetic flux in the transformer's core, and thus a varying magnetic field through the secondary winding. This varying magnetic field induces a varying electromotive force (EMF) or "voltage" in the secondary winding. This effect is called mutual induction. If a load is 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 the current is increased, the lines of force move outwards from the coil. If the current is reduced, the lines of force move inwards. 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. 28 Fig 7: 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 turn’s 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: 29 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 transformer: Incase 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: A battery is 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 HiWatt 9V battery Fig 8: Hi-Watt 9V Battery The most commonly used dry-cell battery is the carbon-zinc dry cell battery. Dry-cell batteries are made by stacking a carbon plate, a layer of electrolyte paste, and a zinc plate alternately until the desired total voltage is achieved. The most common drycell batteries have one of the following voltages: 1.5, 3, 6, 9, 22.5, 45, and 90. During the 30 discharge of a carbon-zinc battery, the zinc metal is converted to a zinc salt in the electrolyte, and magnesium dioxide is reduced at the carbon electrode. These actions establish a voltage of approximately 1.5 V. The lead-acid storage 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 volt car battery uses 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 A nickel-cadmium battery 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. Fig 9: 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 31 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 unidire Input output 32 Fig 10: Bridge rectifier: a full-wave rectifier using 4 diodes DB107: 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 11: DB107 33 Filtration: 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. Regulation: The process of converting a varying voltage to a constant regulated voltage is called as regulation. For the process of regulation we use voltage regulators. 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 34 apply reverse voltage to its input. Reverse polarity destroys the regulator almost instantly. Fig: 3.3.11 shows voltage regulator. Fig 12: Voltage Regulator 3.4. LED: A light-emitting diode (LED) is a semiconductor light source. LED’s are used as indicator lamps in many devices, and are increasingly used for lighting. Introduced as a practical electronic component in 1962, early LED’s 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 in figures 3.4.1 and 3.4.2 respectively. Fig 13: Inside a LED Fig 14: Parts of a LED Working: 35 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 1 mm2), and integrated optical components are used to shape its radiation pattern and assist in reflection. LED’s 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 LED’s 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 15: Electrical Symbol & Polarities of LED LED lights have a variety of advantages over other light sources: High-levels of brightness and intensity 36 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. 37 Accelerometer MMA 1260D (+/- 1.5g Z-Axis Micromachined Accelerometer) The accelerometer which we used here is MMA1260D The MMA series of silicon capacitive, micromachined accelerometers features signal conditioning, a 2-pole low pass filter and temperature compensation. Zero-g offset full scale span and filter cut-off are factory set and require no external devices. A full system self-test capability verifies system functionality. Features • Integral Signal Conditioning • Linear Output • 2nd Order Bessel Filter • Calibrated Self-test • EPROM Parity Check Status • Transducer Hermetically Sealed at Wafer Level for Superior Reliability • Robust Design, High Shock Survivability Principle of operation The device consists of a surface micromachined capacitive sensing cell (g-cell) and a CMOS signal conditioning ASIC contained in a single integrated circuit package. The sensing element is sealed hermetically at the wafer level using a bulk micromachined .cap 38 wafer.The g-cell is a mechanical structure formed from semiconductor materials (polysilicon) using semiconductor processes (masking and etching). It can be modeled as twostationary plates with a moveable plate in-between. The center plate can be deflected from its rest position by subjecting the system to an acceleration. When the center plate deflects, the distance from it to onefixed plate will increase by the same amount that the distance to the other plate decreases. The change in distance is a measure of acceleration.The g-cell plates form two back-to-back capacitors.As the center plate moves with acceleration, the distance between the plates changes and each capacitor .S value will change, (C = Aε/D). Where A is the area of the plate, ε is the dielectric constant, and D is the distance between the plates. The CMOS ASIC uses switched capacitor techniques to measure the g-cell capacitors and extract the accelerationdata from the difference between the two capacitors. The ASIC also signal conditions and filters (switched capacitor) the signal, providing a high level output voltage that is ratio metric and proportional to acceleration. Fig 16:Transducer physical model Pin diagram 39 Pin no 1 thru Pim name Vss 4 5 6 7 8 9 thru 13 14 thru 16 Vout Status Vdd Vss ST Trim Pins ------------ Description Redundant connections to the int ernal VSS and may be left unconnected. Output voltage of the accelerometer. Logic output pin used to indicate fault. The power supply input. The power supply ground. Logic input pin used to initiate self-test. Used for factory trim.Leave unconnected. No internal connection.Leave unconnected. Fig 17: Pin diagram of mma1260d Pin Description: Accelerometer MMA2260D (+/- 1.5g X-Axis Micromachined Accelerometer) 40 The MMA series of silicon capacitive, micromachined accelerometers feature signal conditioning, a 2-pole low pass filter and temperature compensation. Zerog offset full scale span and filter cut-off are factory set and require no external devices. A full system self-test capability verifies system functionality. Features Integral Signal Conditioning High Sensitivity Linear Output 2nd Order Bessel Filter Calibrated Self-test EPROM Parity Check Status Transducer Hermetically Sealed at Wafer Level for Superior Reliability Robust Design, High Shock Survivability Principle of operation The Freescale accelerometer is a surface-micromachined integrated-circuit accelerometer. The device consists of a surface micromachined capacitive sensing cell (gcell) and a CMOS signal conditioning ASIC contained in a single integrated circuit package. The sensing element is sealed hermetically at the wafer level using a bulk micromachined .cap’’ wafer. The g-cell is a mechanical structure formed from semiconductor materials (polysilicon) using semiconductor processes (masking and etching). It can be modeled as a set of beams attached to a movable central mass that moves between fixed beams. The movable beams can be deflected from their rest position by subjecting the system to an acceleration .As the beams attached to the central mass move, the distance from them to the fixed beams on one side will increase by the same amount that the 41 distance to the fixed beams on the other side decreases. The change in distance is a measure of acceleration. The g-cell beams form two back-to-back capacitors . As the central mass moves with acceleration, the distance between the beams change and each capacitor’s value will change, (C = NAε/D). Where A is the area of the facing side of the beam, e is the dielectric constant, D is the distance between the beams, and N is the number of beams. The CMOS ASIC uses switched capacitor techniques to measure the g-cell capacitors and extract the acceleration data from the difference between the two capacitors. The ASIC also signal conditions and filters (switched capacitor) the signal, providing a high level output voltage that is ratiometric and proportional to acceleration. Acceleration Pin no Pim name Description Fig 18: Transducer physical model Pin diagram of MMA2260d Fig 19:Pin diagram of MMA2260d Pin Description: 42 1 thru Vss 4 5 6 7 8 9 thru 13 14 thru 16 Vout Status Vdd Vss ST Trim Pins ------------ Redundant connections to the int ernal VSS and may be left unconnected. Output voltage of the accelerometer. Logic output pin used to indicate fault. The power supply input. The power supply ground. Logic input pin used to initiate self-test. Used for factory trim.Leave unconnected. No internal connection.Leave unconnected. Buzzer 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. 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. The metal plate bonded to the piezoelectric element does not expand. Conversely, when the piezoelectric element shrinks, the piezoelectric diaphragm bends in the direction Thus, when 43 AC voltage is applied across electrodes, the bending is repeated, producing sound waves in the air. To interface a buzzer the standard transistor interfacing circuit is used. Note that if a different power supply is used for the buzzer, the 0V rails of each power supply must be connected to provide a common reference. If a battery is used as the power supply, it is worth remembering that piezo sounders draw much less current than buzzers. Buzzers also just have one ‘tone’, whereas a piezo sounder is able to create sounds of many different tones. To switch on buzzer -high 1 To switch off buzzer -low 1 Notice (Handling) In Using Self Drive Method: 1) When the piezoelectric buzzer is set to produce intermittent sounds, sound may be heard continuously even when the self drive circuit is turned ON / OFF at the "X" point shown in Fig. 9. This is because of the failure of turning off the feedback voltage. 2) Build a circuit of the piezoelectric sounder exactly as per the recommended circuit shown in the catalog. Life of the transistor and circuit constants is designed to ensure stable oscillation of the piezoelectric sounder. 3) Design switching which ensures direct power switching. 4) The self drive circuit is already contained in the piezoelectric buzzer. So there is no need to prepare another circuit to drive the piezoelectric buzzer. 5) Rated voltage (3.0 to 20Vdc) must be maintained. Products which can operate with voltage higher than 20Vdc are also available. 6) Do not place resistors in series with the power source, as this may cause abnormal oscillation. If a resistor is essential to adjust sound pressure, place a capacitor (about 1μF) in parallel with the piezo buzzer. 44 7) Do not close the sound emitting hole on the front side of casing. 8) Carefully install the piezo buzzer so that no obstacle is placed within 15mm from the sound release hole on the front side of the casing. Figure 20: Buzzer Contact buttons Contact buttons simply a collection of 3M Red Dot electrodes. The input pins have the internal pull-up resistor activated.when a contact sensor is touched by the thumb, the pin receives a logic low value. Otherwise, it is pulled up to logic high.If the thumb does not push firmly on the contact sensors, there is a significant amount of bouncing between logic high and low due to vibrations and uneven metal surfaces. Thus, this requires some software debouncing. 5 DOF SENSOR It is actually a breakout board that combines the Analog Devices ADXL330, which is a 3-axis +/- 3g accelerometer, and a 2-axis 500 degree/sec gyro, the IDG300. Used to control mouse cursor movement since they measure rotational acceleration about an axis. The accelerometer is mounted such that the Z-axis runs transverse to the plane of the hand, and 45 rotating the wrist left or right will change its angle towards the direction of gravity. This axis, then, can be used to control horizontal cursor movement. The X-axis lies in the plane of the hand and runs in the direction of the fingers. It changes value when hand tilts up and down. Thus, it is used to control vertical cursor movement. 3-Axis ±3g MEMS Accelerometer (ADXL330) GENERAL DESCRIPTION The ADXL330 is a small, thin, low power, complete three axis accelerometer with signal conditioned voltage outputs, all on a single monolithic IC. The product measures acceleration with a minimum full-scale range of ±3 g. It can measure the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion, shock, or vibration. The user selects the bandwidth of the accelerometer using the CX, CY, and CZ capacitors at the XOUT, YOUT, and ZOUT pins. Bandwidths can be selected to suit the application, with a range of 0.5 Hz to 1,600 Hz for X and Y axes, and a range of 0.5 Hz to 550 Hz for the Z axis. FEATURES 3-axis sensing Small, low-profile package (4 mm × 4 mm × 1.45 mm LFCSP ) Low power (200 μA at VS = 2.0 V (typical)) Single-supply operation (2.0 V to 3.6 V) 10,000 g shock survival Excellent temperature stability BW adjustment with a single capacitor per axis Pin diagram 46 Fig 21:pin diagram of ADXL330 Pin description: Pin no Mnemonic Description 1 NC No Connect 2 ST Self-Test 3 COM Common 4 NC No Connect 5 COM Common 6 COM Common 7 COM Common 47 8 Zout Z Channel Output 9 NC No Connect 10 Yout Y Channel Output 11 NC No Connect 12 Xout X Channel Output 13 NC No Connect 14 Vs Supply Voltage (2.0 V to 3.6 V) 15 Vs Supply Voltage (2.0 V to 3.6 V) 16 NC No Connect Princeple of operation The ADXL330 is a complete 3-axis acceleration measurement system on a single monolithic IC. The ADXL330 has a measure-ment range of ±3 g minimum. It contains a polysilicon surface micromachined sensor and signal conditioning circuitry to implement an open-loop acceleration measurement architecture. The output signals are analog voltages that are proportional to acceleration. The accelerometer can measure the static accelera-tion of gravity in tilt sensing applications as well as dynamic acceleration resulting from motion, shock, or vibration. The sensor is a polysilicon surface micromachined structure built on top of a silicon wafer. Polysilicon springs suspend the structure over the surface of the wafer and provide a resistance against acceleration forces. Deflection of the structure is meas-ured using a differential capacitor that consists of independent fixed plates and plates attached to the moving mass. The fixed plates are driven by 180° out-of-phase square waves. Acceleration 48 deflects the moving mass and unbalances the differential capacitor resulting in a sensor output whose amplitude is proportional to acceleration. Phase-sensitive demodulation techniques are then used to determine the magnitude and direction of the acceleration. The demodulator output is amplified and brought off-chip through a 32 kΩ resistor. The user then sets the signal band-width of the device by adding a capacitor. This filtering improves measurement resolution and helps prevent aliasing. Integrated Dual-Axis Gyro IDG-300 GENERAL DESCRIPTION The IDG-300 is an integrated dual-axis angular rate sensor (gyroscope). It uses InvenSense’s proprietary and patented MEMS technology with vertically driven, vibrating masses to make a functionally complete, lowcost,dual-axis angular rate sensor. All requiredelectronics are integrated onto a single chip with the sensor. The IDG-300 gyro uses two sensor elements with novelvibrating dual-mass bulk silicon configurations that sense the rate of rotation about the X- and Y-axis (in-plane 49 sensing). This results in a unique, integrated dual-axis gyro with guaranteed-by-design vibration rejection and high cross-axis isolation. It is specifically designed for demanding consumer applications requiring low cost, small size and high performance. The IDG-300 gyro includes integrated electronics necessary for application-ready functionality. It incorporates X- and Y-axis low-pass filters and an EEPROM for on-chip factory calibration of the sensor. Factory trimmed scale factors eliminate the need for external active components and end-user calibration.This product is lead-free and Green Compliant. FEATURES • Integrated X- and Y-axis gyro on a single chip • Factory trimmed full scale range of ±500°/sec • Integrated low-pass filters • Superior vibration rejection over a wide frequency range • High cross-axis isolation by design • 3V single supply operation • 5000 g shock tolerance • RoHS compliant (completely lead free) • 6 x 6 x 1.5mm QFN package. Pin diagram 50 Fig 22: pin diagram of IDG 300 Pin description Number Pin Description 2, 22, 25, 38, 39, 40 GND Ground 14, 29, 34 VDD Positive supply voltage: +3.0V to +3.3V 51 3 X-Rate Out X-Rate Out 8 XAGC Amplitude control filter 17 CPOUT Charge pump capacitor 23 YAGC Amplitude control filter 28 Y-Rate Out Y-Rate Out 32 VREF 1.23V precision reference output 1, 9, 10,11, 12, 13, 15,16, 18, 19, 20, 21, 30, 31, 33, 35, 36, 37 RESV 4 ,5, 6, 7, 24, 26, 27 NC Reserved. Do not connect. Used for factory trimming Not internally connected 1.Overview The IDG-300 gyro is a dual-axis gyroscope consisting of two independent vibratory MEMS gyroscopes. One detects rotation about the X-axis; the other detects rotation about the Y-axis. Each structure is fabricated using InvenSense’s proprietary bulk silicon technology. The structures are covered and hermetically sealed at the wafer-level. The cover shields the gyro from EMI. The gyroscope’s proof-masses are electrostatically oscillated at resonance. An internal automatic gain control circuit precisely sets the oscillation of the proof masses. When the sensor is rotated about the X- or Y-axis, the Coriolis effect causes a vibration that can be detected by a capacitive pickoff. The resulting signal is amplified, demodulated, and filtered to produce an analog voltage that is proportional to the angular rate. 2. Amplitude Control The scale factor of the gyroscope depends on the amplitude of the mechanical motion and the trim setting of the internal programmable gain stages. The oscillation circuit precisely controls the amplitude to maintain constant sensitivity over the temperature range. The capacitors (0.22μF, ±10%) connected to Pin 8 (XAGC) and Pin 23 (YAGC) are compensation capacitors for the amplitude control loops. 52 3. External Low-Pass Filter An external low-pass filter is recommended to attenuate high-frequency noise. The cutoff frequency should be less than 2 kHz to attenuate tones above 10 kHz generated by the vibrating proof-masses. Recommended RC values for the 2 kHz filter are RLPX/RLPY and CLPX/CLPY are 750Ω and 0.1μF respectively. The sensor bandwidth is limited to 140 Hz by the internal low-pass filter. Applications that require lower bandwidth should choose an external filter with a cutoff frequency less than 140Hz. 4. Scale Factor The IDG-300 Rate-Out is not ratiometric to the supply voltage. The scale factor is calibrated at the factory and is nominally independent of supply voltage. 5. Power Supply Filtering The IDG-300 gyro should be isolated from system power supply noise by a combination of an RC filter that attenuates high frequency noise and a Low Drop Out power supply regulator (LDO) that attenuates low frequency noise. Figure below shows a typical configuration. 6. VREF VREF is a temperature independent voltage reference that can be used as a reference for an ADC. There is offset between the zero rate output and VREF WI.232FHSS-250-R General description:The Wi.232FHSS module is one of a family of WiSE™ (Wireless Serial Engine) modules. A WiSE module combines a state-of-the-art FSK data transceiver and a high-performance protocol controller to create a complete embedded wireless communications link in a small 53 IC-style package. The 250mW RF transceiver is built around the Analog Devices ADF7020 IC, whereas the 25mW version uses the Semtech XE1203F transceiver IC. Both transceivers are designed with the components necessary to facilitate operation in the 902-928MHz US ISM band. Features • True UART to Antenna Solution • 16-bit CRC Error Checking • 153.6 kbit/ sec Maximum RF Data Rate • 6 Hop Sequences • GUID/MAC Addressing Mode • Flexible User Addressing Mode • Link Layer Supports Assured Delivery • Small Size (0.80” x 0.935” x 0.12”) for the WI.232FHSS-25-R • Small Size (1.20” x 1.20” x 0.20”) for the WI.232FHSS-250-R • Low Power Standby, Sleep, and Deep Sleep Modes • PHY, MAC, and Link Layer Protocol Built-in Pin Diagram 54 Fig 23 pin diagram of WI.232FHSS-250-R Pin description Pin NO Description 1 Ground 2 Exception Output 3 Buffer Empty 4 Command input – active low 5 UART receive input 6 UART transmit output 7 UART clear to send output – active low 8 Command Response indication 9 Analog RSSI 10 Reserved – ISP pin 11 ISP pin/Wake from DEEP SLEEP/Module Reset 12 Ground 13 Antenna port – 50 ohm 55 14 Ground 15 Ground 16 Ground 17 Ground 18 Ground 19 VCC – 2.7 to 3.6 VDC UART Interface Pin Direction Description CTS OUT CMD IN RxD IN TxD OUT RTS IN Clear to send – this pin indicates to the host micro when it is ok to send data.When CTS is high, the host micro should stop sending data to the module until CTS returns to the low state. Command – the host micro will bring this pin low to put the module in command mode. Command mode is used to set and read the internal registers that control the operation of the module. When CMD is high, the module will transparently transfer data to and from other modules on the same channel. Note: If this pin is low when the module comes out of reset, the non-volatile registers will be reset to their factory programmed defaults. It is important to ensure that CMD is held high or left floating during power-up under normal conditions. Receive data input. UART data should be sent to the module with no parity, 1 start bit, 1 stop bit, 8 data bits, least-significant bit first. Transmit data output. UART data will be sent by the module with no parity, 1 start bit, 1 stop bit, 8 data bits, least-significant bit first. Currently unimplemented, this pin is reserved for future use/reassignment. Additional Module Pins Additional module pins indicate the operational status of different functional blocks, or provide additional control. There is no requirement that these pins be connected for normal operation , However they can provide additional insight into the module. They may prove useful in the optimization of the end application. 56 Buffer Empty (BE) The BE pin indicates the state of the incoming UART buffer. When the module receives data in the RxD pin,and the CMD pin is high, the BE pin is lowered until all data in this buffer has been processed by the RF engine. If acknowledgement is not enabled, the BE pin will be raised as soon as the RF engine processes the outgoing packets. If acknowledgement is enabled, the buffer will not be updated until either the data transmissions are acknowledged by the remote end, or the maximum number of retries has been exceeded. Exception (EX) The EX pin indicates whether a module exception has occurred. The pin is normally low. When an exception occurs that passes masking the EX pin is raised. When the regEXCEPTION register is read, the exception is cleared and the EX pin will return low. If more than one exception occurs before the regEXCEPTION register is read, the old exception will be overwritten by the new one. RF Processing Incoming Packet (PROC_PKT) Available on 250-R modules with firmware release 1.1.0 or later, the PROC_PKT pin indicates whether the RF engine has determined there to be either valid or potentially valid data incoming. The line is normally low (not processing). When awake and not transmitting, the RF engine is constantly searching for an incoming signal. When scoring indicates that a potential packet is inbound, this line is raised until the scoring falls below a given threshold or the complete packet is received. It is possible that the packet scoring will fall below the PROC_PKT threshold during reception, causing the line to be lowered. Such an instance can occur when the module hops to a channel late in the transmitter’s extended preamble. Since there aren’t a large number of valid bits to score, the line may fall low during the packet start sequence. Once this sequence arrives, the PROC_PKT signal will re-raise and latch for the duration of the packet reception. 57 Command Response (CMD_RSP) The CMD_RSP pin is normally high. When the module’s command processor responds to a command, such as a register read, the CMD_RSP pin lowers as the characters are transmitted out of the TxD pin.Some host processors cannot react quickly enough to this signal, and may not able to separate thecommand responses from incoming data. In this case, the regCMDHALT register may be of use. This register controls the behavior of the TxD line when the CMD pin is low. If this register is set to 0x01 and the CMD pin is low, the module stops the flow of incoming RF data to the TxD pin, internally buffering it. Oncethe CMD pin is raised, the buffered incoming RF data resumes transport out the TxD pin. Reset (C2CK/RST) The C2CK/RST pin is normally high. It is an open-drain input/output pin with an integrated weak pull-up.Because it periodically operates as an output, care must be taken when interfacing to this pin. When operating as an input, it has different functions depending on the state the module is in. SOFT WARES USED 58 About software: Software used are: Ki cad for PCB layout designing AVR simulator for coding AVR simulator PROCEDURE Installing and Running First, download and install the software (as administrator) in the order listed in the COMPONENTS section above onto your PC. Reboot the PC afterward if you're prompted to do so for the installation to complete properly.Once you have the software loaded on your machine, you should be able to go ahead and run AVRStudio. If it didn't create a desktop icon when it was installed, you'll just have to rough it and find it in the Windows Start menu Creating a Project Once AVR Studio is running you should be prompted for a project to work with, either by creating a new one, or by using an existing project. In this case, click New Project 59 Select Project type AVR GCC, enter Project name simcounter, select both Create initial file and Create folder and select (and remember!) a directory in which to put the new simcounter project directory, then click Next. Select Debug Platform AVR Simulator, and Device ATmega16, then click Finish. 60 You should now see the default window layout in AVR Studio. Because you checked Create initial file when creating the project, AVR Studio has created a blank simcounter.c file and pre-opened this file for you. If you click on the expand-group icon (the Plus icon) in front of Source Files in the lefthand window, you'll find that simcounter.c has been added to the simcounter project. If you needed to include any additional files source files for your project, you would right-click on Source Files and choose the appropriate method to do this. You won't need to for this example, but you will for labs later in the semester. At this point, cut-and-paste the contents of simcounter.c from the final section of this document into the blank window created for your project's simcounter.c. While you're at it, save the contents of this file by doing a File->Save (or typing CTRL-S, or pressing the floppy disk icon). If you had a copy of simcounter.c already on your computer, you could also have used Add Existing File and pointed it to the file's location to add it to the project's source files. 61 Create a new file called simcounter-PORTA.sti by right-clicking on Other Files in the lefthand window and selecting Create New File. Cut-and-paste the contents of this file from the simcounter-PORTA.sti section at the bottom of this document into the window that was created for this file, and similarly save it to disk. 62 Configuring and Building Project In Project->Configuration Options->General, set Frequency to 8000000 and Optimization to O0 (note that this is capital-oh zero). It should be noted that this optimization setting is usually not the most popular for generating code to be downloaded to a real microcontroller, but it seems to be a safe choice for code to be simulated. In the future, once you're ready to start programming your microcontollers in the lab, you'll often be directed to change this setting -O2 as you'll see in subsequent weeks. Should you need to revert to simulating code again generating code for a real processor, don't forget to reset this option back to -O0. If you ever start seeing strange behavior when stepping execution through simulated programs, it's probable that you weren't using -O0 for the code to be simulated. What usually happens is that while stepping through your program, the cursor doesn't accurately advance from line to line correctly. After changing this optimization setting to -O0, do a Build->Rebuild All, and you should be all set.Please note that doing a Rebuild All rather than just a Build is always a good idea after you have changed any project configuration options that have to do with compilation. In fact, it's always safe(st) to do a Rebuild All rather than just a Build – it's just that it may take somewhat longer. 63 In Debug->Select device and debug platform, set Debug Platform to AVR Simulator and Device to Atmega16, then click Finish. Compile the simcounter project with Build->Build (or F7). When the build is complete, confirm that the last line in the Build window at the bottom of the screen is Build succeeded with 0Warnings... as shown above. If this isn't what you see, somehow you boffed your cutand-paste, so go back and try it again. For some reason, there are certain configuration settings in AVR Studio that cannot be set unless you've already started simulating a program, and the following is one of them. To do so, initiate the simulationwith Debug->Start Debugging. Now in Debug->AVR Simulator Options you should set Frequency to 8.00MHz.. 64 Starting and Stepping through Execution If you hadn't just done so immediately above, normally you'd start simulating the execution of theprogram with Debug->Start Debugging, or by pressing the green right-facing triangle in the toolbar The first thing that the simulator then does is to start-up and then stop before the very first simulated instruction is executed. It stops here to give you the chance to do all the setup you need before starting the run The important thing to notice at this point is that there should be a little yellow right-facing arrow pointing to the opening curly-brace of the function main(). This arrow indicates the next statement to be executed the At any point when you have control of the running program (that is, when it isn't freerunning at fullspeed uninterrupted), you can step through the program slowly, line-by-line, at your own pace. There are three ways to step – step into, step over, and step out. Step into and step over behave similarly except when a function call is next statement to be executed. Step into steps into (imagine that!) the function and pauses execution at the beginning of the called function. Step over executes the entire function as a single statement and advances to the next statement after the function call. Step over is a huge time-saver once you know that you don't care about stepping through that function line-by-line. However if you want/need to see what's going on in the function, by all means step into it. Step out is what's used once you're in a function and you no longer care about what's going on inside the rest of itand just want to get back to the code that called the function. Step Over completes executing the function and 65 gets you back to where you were when you called it. Just to get the hang of single-stepping, we're going to start with Step Into. You can do this (and most of the simulator functions) one of three ways. In decreasing order of pain, they are: in the menu bar do Debug->Step Into, in the toolbar click on the Step Into icon (the one immediately to the right of the yellow arrow in the toolbar, or by pressing the F11 key. Learn to know and love the F11 (and F10, which is coming-up later) key, as the function keys are by far the easiest ones to use 500 times in an hour Press the F11 key once. It should now point to the statement where buttonPresses is intialiized. Note again that this is the next statement to be executed. Press the F11 key again and you should see the arrow pointing to uint8_t thisState, prevState=0x00, changed At this point, wouldn't it be cool to know that the value of buttonPresses is actually zero? Well, you can, and there are two ways to do this. The first way is to use your cursor to point to the variable buttonPresses anywhere in the source window and it'll pop-up a floating balloon that says that the current value is 0 (along with some other details about the variable). The second way is the power-user way, and you're also going to learn that now. You can maintain a window on the screen containing any variables that you want to watch along with their current values. This window is called the Watch window, and you can open it by doing a View- >Watch. Do this and right-click the first cell under the label Name and click Add Item. If you enter buttonPresses, it will give you an entry showing the current name and 66 value for this variable. Not only that, this value will be updated as you execute the program under your control (it isn't updated as the program free-runs though). An alternate way to add a new variable to be watched is to doubleclick in an empty Name field cell and you can enter a variable name that way. If that weren't enough, there's third way to add a variable to the watch window – just right-click on the variable name anywhere the editing window and select Add Watch. While you are here, use any of these three methods to add watch entries for the variables thisState, prevState and changed. You should notice at this point in program execution that we have notyet initialized these three variables. If you look where the yellow arrow is pointing, we're still before their initialization statements. They are currently what's known as “initialized to garbage”. This is programmer-speak for a variable that has been declared but not yet set (initialized) to a known value –it contains whatever garbage was there when that particular memory location was last used. It is a very,very, very bad thing to ever use a value that has not been initialized. Multibillion dollar satellites (andperhaps your job with it) can be lost forever when this happens, so it's usually best to try to avoid it. So, observe that these three variables currently contain some random, likely non-zero, value. Then go ahead an press F11 again to execute their initialization statements. Zero now for all of them, presto 67 Before you go any farther you're going to learn how to view the I/O registers for the microcontroller. All PORTA-related registers can be viewed by expanding the PORTA group (click the plus-sign) in the right-hand I/O View window, as well as for all of the other functional groupings of I/O registers. Here you will find the current simulated values for PORTA, DDRA and PINA both there as well as in their own more-detailed-view window below. Go ahead and expand the PORTB set also. Now if you can't see the full contents of each of these entries' columns, especially in the lower of the two windows, stretch your windows out so that you can see everything. In particular, you want to be able to see all eight squares in the Bits column for each of the three PORTA/PORTB-related registers. These types of registers are very important as they are the chip's interface to the outside world. At this point, program execution should be right before the function call to init(). Let's demonstrate Step Into first. The first time that you hit F11 you'll find yourself entering init(). As you hit F11 to execute the following two lines one at a time, DDRA = 0x00; // PORTA used entirely for input DDRB = 0xff; // PORTB used entirely for output 68 You should notice that the values for DDRA and DDRB (also known as Port A/B Data direction register) in the I/O View window are updated. Especially note that the hollow squares in the lower window are blackened for bits that contain high (1) values. This representation is very useful for quickly visualizing which bits are set within an 8-bit value. In the case of DDRB, all bits are high/black – assuming that you have the PORTB group selected in the upper window. You will often be using these windows frequently when following your code's execution. At this point you should be done executing the last statement in init() and ready to return. Using F11 will return you to the next statement after the one that called this function. Since we've missed our only opportunity to demonstrate the use of Step Out (because there's only one function call in our demonstration program, and we're never calling it again), let's re-run the program from the beginning. You'll do this often when you get to a point where you've missed something that you mindlessly blew-over and need to start over again. Unfortunately, few simulators are able to backup through a simulation, so you'll have to start at the beginning again. To halt execution and start over again, press the Stop icon in the menu bar, the blue square (or Debug- >Stop Debugging). To restart, as before, press the green triangle (essentially, start) to continue and halt at the first executable statement. Press F11 until you get just inside init(). Rather than stepping through the rest of the function that you no longer care about, you can use Step Out to leave this function. As usual, you can use the Step Out icon to do this, Debug->Step Out, or the appropriate function key. To demonstrate the final stepping control, do a Debug->Stop Debugging, then Debug>Start Debugging to start the program again, and F11 until you are just about to call init() again. Now use Step Over to execute init() without bothering to step into it. You'll do this often once you are comfortable with what a function does and no longer care about crawling 69 through it again. Stepping into functions that you don't care about is often a huge waste of time. Even better, notice that F10 is the keyboard shortcut for Step Over. F10 is even more useful than F11 in many circumstances. To be honest, I never know remember which one is which. I'll either use the menu or the toolbar to pick which one that I want the first time, look at the FunctionKey label that is displayed, then just use the FunctionKey from that point on. Just trust me and use the keys – repetitive-stress injuries aren't pretty and every mouse click adds up, trust me. By the way, one thing that's easy to do is to keep on pressing F11 and then end up in a function you didn't intend to enter. In that case, just do a Step Out and you're back to where you wanted to be. In summary, those are the three flavors of single-stepping and how each of them are useful, or more efficient, depending on how deliberate you need to be when stepping through code. 70