msp430 controller ultrasonic distance measurment

61
INDEX 1. INTRODUCTION........................................... 3 2. LITERATURE SURVEY......................................5 2.1 Literature survey on microcontrollers................5 2.2 CPU.................................................. 6 2.3 Operating modes...................................... 7 2.4 Key Features......................................... 8 2.5 CLASSIFICATION OF MSP430 MICROCONTROLLER.............9 2.6 MSP430F2274......................................... 10 2.7 Digital I/O overview................................12 2.8 P1 and P2 Interrupts................................14 2.9 Literature survey on ultrasonic transducer..........15 2.10 Brief History on ultrasonic technology.............15 2.11 Survey on liquid crystal display (LCD).............20 3. SOFTWARE/HARDWARE DESIGN AND DEVELOPMENT TOOLS........24 3.1 Block diagram....................................... 24 3.2 System flow chart................................... 25 3.3 Introduction to Simulation and Programming Software. 27 3.4 MSP430 wireless development tool....................28 3.5 Developing with eZ430-RF2500T Target Board..........30 3.6 MSP430 Application UART.............................33 4. RESULTS AND OBSERVATIONS..............................34 4.1 System flow chart of LCD............................36 4.2 Transducer module................................... 37 CONCLUSION AND FUTURE PROSPECT............................38 REFERENCES................................................39 APPENDIX A................................................40 1

Upload: chandre

Post on 18-Nov-2014

2.685 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: msp430 controller ultrasonic distance measurment

INDEX

1. INTRODUCTION........................................................................................................32. LITERATURE SURVEY..........................................................................................5

2.1 Literature survey on microcontrollers........................................................................52.2 CPU............................................................................................................................62.3 Operating modes........................................................................................................72.4 Key Features...............................................................................................................82.5 CLASSIFICATION OF MSP430 MICROCONTROLLER......................................92.6 MSP430F2274..........................................................................................................102.7 Digital I/O overview................................................................................................122.8 P1 and P2 Interrupts.................................................................................................142.9 Literature survey on ultrasonic transducer...............................................................152.10 Brief History on ultrasonic technology..................................................................152.11 Survey on liquid crystal display (LCD).................................................................20

3. SOFTWARE/HARDWARE DESIGN AND DEVELOPMENT TOOLS..........243.1 Block diagram..........................................................................................................243.2 System flow chart.....................................................................................................253.3 Introduction to Simulation and Programming Software..........................................273.4 MSP430 wireless development tool.........................................................................283.5 Developing with eZ430-RF2500T Target Board.....................................................303.6 MSP430 Application UART....................................................................................33

4. RESULTS AND OBSERVATIONS.......................................................................344.1 System flow chart of LCD.......................................................................................364.2 Transducer module...................................................................................................37

CONCLUSION AND FUTURE PROSPECT...............................................................38REFERENCES.................................................................................................................39APPENDIX A....................................................................................................................40

1

Page 2: msp430 controller ultrasonic distance measurment

List of Figures

Figure 1.1 Distance measurement by the pulse-echo method..............................................3Figure 2-1 Register of MSP430...........................................................................................7Figure 2-2 MSP430 Von-Neumann architecture.................................................................9Figure 2-3 Multiple Oscillator Clock System......................................................................9Figure 2-4 MSP430x22x4 device pin out, RHA package..................................................10Figure 2-5 MSP430x22x4 functional block diagram.........................................................12Figure 2-6 Ultrasonic transducer........................................................................................15Figure 2-7 wave propagation.............................................................................................17Figure 2-8 A transducer with a circular radiating surface.................................................18Figure 2-9 liquid crystal display.......................................................................................20Figure 2-10 Pin position for LCD......................................................................................21Figure 3-1 Ultrasonic distance measurement using MSP430 microcontroller..................24Figure 3-2 System flow chart............................................................................................25Figure 3-3 Circuit schematic..............................................................................................27Figure 3-4 eZ430-RF2500..................................................................................................29Figure 3-5 eZ430-RF2500T target boards.........................................................................30Figure 3-6 com-port assignment.......................................................................................33Figure 4-1 Simulation of 16x2 LCD on Proteus................................................................34Figure 4-2 interfacing LCD with MSP430.........................................................................35Figure 4-3 System flow chart of LCD................................................................................36Figure 4-4 Transducer module...........................................................................................37

List of Tables

Table 2-1 Comparisons of various microcontrollers............................................................5Table 2-2 Function Select Registers PxSEL and PxSEL2.................................................13Table 2-3 comparison of various devices...........................................................................15Table 2-4 Pin number, symbol and its function.................................................................21Table 2-5 LCD command codes........................................................................................23Table 4-1 Pin outs..............................................................................................................31Table 4-2 Battery board pin outs........................................................................................32

2

Page 3: msp430 controller ultrasonic distance measurment

1. INTRODUCTION

Microcontrollers have become the basic block in every automation system, system with microcontrollers have become omnipresent. The advantage microcontroller system comes with are: easy system design, wide variety to choose from, very low cost etc.

Motivation behind this project is to build an ultrasonic distance measurements system using ultra low power MSP430 microcontroller. For this we require a pair of an ultrasonic transducer i.e. a transmitter and a receiver, which is to transmit ultrasound of 40 KHz which is not audible to human ear for the measurement of the distance and the measured distance is displayed on a LCD unit.

We are using this specific microcontroller because it has been designed specifically for ultra low power applications. A flexible clocking system, multiple operating modes and zero-power always on brown-out reset (BOR) are implemented to reduce power consumption and dramatical1y extend battery life. The MSP430 BOR function is always active in all low-power modes to ensure the most reliable performance possible. The present system can be used in various applications such as:

1: Biomedical instrument2: Car parking system 3: Sonar4: Quantity measurement

In this system, a distance-measuring system based on ultrasonic sound utilizing the pulses generated by the transducer is used to measure the distance of an object. The system transmits a burst of ultrasonic sound waves towards the object and then receives the corresponding echo. The MSP430 integrated analog comparator is used to detect the arrival of the echo to the system. The time taken for the ultrasonic burst to travel the distance from the system to the object and back to the system is accurately measured by the MSP430 microcontroller.

Figure 1.1 Distance measurement by the pulse-echo method

3

Page 4: msp430 controller ultrasonic distance measurment

In this system the mechanism of sound waves has been encountered. If the speed of sound in the medium is known and the time taken for the sound waves to travel the distance from the source to the object and back to the source is measured, the distance from the source to the object can be computed accurately. This is the measurement principle of this application. Here the medium for the sound waves is air, and the sound waves used are ultrasonic, since it is inaudible to humans. Assuming that the speed of sound in air is 11 00 feet/second at room temperature and that the measured time taken for the sound waves to travel the distance from the source to the object and back to the source is t seconds, the distance d is computed by the formula d=1100 x 12 x t inches. Since the sound waves travel twice the distance between the source and the object, the actual distance between the source and the subject will be d/2.

Ultrasonic detection includes advantages like:

1.) No physical contact with the object to be detected.2.) Detection of any object irrespective of colors.

Figure 1.2 Generalized block diagram

4

Power supply

Microcontroller

LCD

Signal Conditio

ning

TX1

RX1

PC

Page 5: msp430 controller ultrasonic distance measurment

2. LITERATURE SURVEY

2.1 Literature survey on microcontrollers

It is difficult to arrive at a conclusive performance comparison between two embedded processors of differing architecture. To start with we have to define what is meant by performance. For example, this could be the frequency at which a particular task such as the control of a motor can be performed. Such a task would typically include interrupt latency, peripheral performance, memory access speed, table lookup and mathematical calculation efficiency, etc. Such a course definition compares far more than the CPU core. Alternatively a more abstract measure of say measuring "millions of instructions per second" (MIPS) is particularly unhelpful when comparing RISC with CISC architectures, architectures with and without a cache, or when comparing systems programmed in a high level language.

The tests documented here attempt to provide practical information that can be used as part of a comparison process. The tests are performed using the development tools typically used for real embedded application programming - effectively providing information on the "embedded development platform" which includes a particular hardware platform and a particular e compiler. A highly efficient processor is after all wasted if the chosen compiler is weak.

Test MSP430 AVR/IAR PIC16 bit addition 27μs 55.2μs 71.6μs16 bit multiplication 72.4μs 71.4μs 193μs16 bit division 480μs 536μs 940μs32 bit multiplication 182μs 180μs 344μs32 bit subtraction 57.2μs 88.1μs 76.4μsBubble sort 992μs 834μs 3.33msBlock memory move and compare

6.75ms 7.9ms 12.4ms

Conditional branch to procedure

131.2μs 245.6μs 169μs

Pushing and popping 314μs 258μs 412μs

Table 2-1 Comparisons of various microcontrollers

The above comparison reveals that MSP430 microcontroller is far more effective in all domain of comparison so it leads to be the effective choice than other microcontrollers.

A 16-bit RISC CPU, peripherals and flexible clock system are combined by using a von-Neumann common memory address bus (MAB) and memory data bus (MDB). Partnering an optimized CPU with modular memory-mapped analog and digital peripherals, the MSP430 device offers solutions for today’s and tomorrow’s mixed-signal applications.

The MSP430 MCU’s orthogonal architecture provides the flexibility of 16 fully addressable, single-cycle 16-bit CPU registers and the power of a RISC. The modern

5

Page 6: msp430 controller ultrasonic distance measurment

design of the CPU offers versatility using only 27 easy-to-understand instructions and seven consistent- addressing modes. This results in a 16-bit low-power CPU that has more effective processing, is smaller-sized, and more code-efficient than other 8-/16-bit microcontrollers. This will allow you to develop new ultra-low-power, high-performance applications at a fraction of the code size.

The MSP430 is designed specifically for ultra-low-power applications. A flexible clocking system, multiple operating modes and zero-power always on brown-out reset (BOR) are implemented to reduce power consumption and dramatically extend battery life. The MSP430 BOR function is always active in all low-power modes to ensure the most reliable performance possible. The MSP430 CPU architecture with 16 registers and 16-bit data and address buses minimize power consuming fetches to memory and a fast vectored-interrupt structure reduces the need for wasteful CPU software flag polling. Intelligent hardware peripheral features were also designed to allow tasks to be completed more efficiently independent of the CPU. Many MSP430 customers have developed battery-based products that will last for over 10-years from the original battery.

The MSP430 MCU clock system is designed specifically for battery-powered applications. Multiple oscillators are utilized to support event-driven burst activity. A low-frequency Auxiliary Clock (ACLK) is driven directly from a common 32-kHz watch crystal or the internal very low-power oscillator (VLO) – with no additional external components. The ACLK can be used for a background real-time clock self wake-up function. An integrated high-speed digitally controlled oscillator (DCO) can source the master clock (MCLK) used by the CPU and sub-main clock (SMCLK) used by the high-speed peripherals. By design, the DCO is active and stable in 1 μs (F2xx) or <6 μs (x1xx, x4xx, F5xx).

2.2 CPU

TheMSP430 CPU has a 16-bit RISC architecture that is highly transparent to the application. All operations, other than program-flow instructions, are performed as register operations in conjunction with seven addressing modes for source operand and four addressing modes for destination operand.

The CPU is integrated with 16 registers that provide reduced instruction execution time. The register-to-register operation execution time is one cycle of the CPU clock. Four of the registers, R0 to R3, are dedicated as program counter, stack pointer, status register, and constant generator respectively. The remaining registers are general-purpose registers.

Peripherals are connected to the CPU using data, address, and control buses, and can be handled with all instructions.

6

Page 7: msp430 controller ultrasonic distance measurment

Figure 2-2 Register of MSP430

2.3 Operating modes

The MSP430 has one active mode and five software selectable low-power modes of operation. An interrupt event can wake up the device from any of the five low-power modes, service the request, and restore back to the low-power mode on return from the interrupt program.

The following six operating modes can be configured by software: Active mode (AM)

-- All clocks are active Low-power mode 0 (LPM0)

-- CPU is disabled ACLK and SMCLK remain active MCLK is disabled

Low-power mode 1 (LPM1)-- CPU is disabled ACLK and SMCLK remain active

7

Page 8: msp430 controller ultrasonic distance measurment

MCLK is disabled DCO’s dc-generator is disabled if DCO not used in active mode

Low-power mode 2 (LPM2)-- CPU is disabled MCLK and SMCLK are disabled DCO’s dc-generator remains enabled ACLK remains active

Low-power mode 3 (LPM3)-- CPU is disabled MCLK and SMCLK are disabled DCO’s dc-generator is disabled ACLK remains active

Low-power mode 4 (LPM4)-- CPU is disabled ACLK is disabled MCLK and SMCLK are disabled DCO’s dc-generator is disabled Crystal oscillator is stopped

2.4 Key Features

Ultra-low-power architecture and flexible clock system extends battery life. 0.1-μA RAM retention <1-μA RTC mode <250 μA/MIPS Integrated intelligent peripherals including wide range of high-performance

analog and digital peripherals offload the CPU 16-bit RISC CPU architecture enables new applications with industry leading

code density

8

Page 9: msp430 controller ultrasonic distance measurment

Figure 2-3 MSP430 Von-Neumann architecture

Figure 2-4 Multiple Oscillator Clock System

2.5 CLASSIFICATION OF MSP430 MICROCONTROLLER MSP430 XIXX(Flash / ROM /NO LCD)

Flash/ROM based MCUs offer 1.8V to 3.6V operation, up to 60kB and 8 MIPS with Basic Clock.

MSP430 F2XXX(Flash based NO LCD)

9

Page 10: msp430 controller ultrasonic distance measurment

Increases performance up to 16 MHz

Elimination of external EEPROMs MSP430 X3XX(ROM / OTP LCD)

Flexible and powerful processing capabilities Versatile ultralow-power device options includes

1. Masked ROM2. OTP (in-system programmable)3. EPROM (UV-erasable, in-system programmable) 4. --40°C to 85°C operating temperature range5. Up to 64K addressing space

MSP430 X4XX(FLASH / ROM LCD) The ultra-low-power MSP430x4xx devices offer 1.8V-3.6V operation, up to

120kB/ Flash ROM 8MIPS with FLL + SVS along with an integrated LCD controller for low power metering and medical applications.

MSP430 X5XX(FLASH NO LCD) Flash-based featuring 25 MIPS It includes Power Management Module for

1. Optimizing power consumption. 2. An internally controlled voltage regulator. 3. 2x more memory than previous devices.

2.6 MSP430F2274

Figure 2-5 MSP430x22x4 device pin out, RHA package10

Page 11: msp430 controller ultrasonic distance measurment

Key features

Low Supply Voltage Range 1.8 V to 3.6 V Ultralow-Power Consumption -- Active Mode: 270 μA at 1 MHz, 2.2 V -- Standby Mode: 0.7 μA -- Off Mode (RAM Retention): 0.1 μA Ultrafast Wake-Up From Standby Mode in Less Than 1μs 16-Bit RISC Architecture, 62.5-ns Instruction Cycle Time Basic Clock Module Configurations: -- Internal Frequencies up to 16 MHz with Four Calibrated Frequencies to ±1% -- Internal Very-Low-Power Low-Frequency Oscillator -- 32-kHz Crystal -- High-Frequency Crystal up to 16 MHz -- Resonator -- External Digital Clock Source -- External Resistor 16-Bit Timer A With Three Capture/Compare Registers 16-Bit Timer B With Three Capture/Compare Registers Universal Serial Communication Interface -- Enhanced UART Supporting Auto-Baud rate Detection (LIN) -- IrDA Encoder and Decoder 10-Bit, 200-ksps A/D Converter With Internal Reference, Sample-and-Hold, Auto

scan, and Data Transfer Controller Brownout Detector Bootstrap Loader Serial Onboard Programming, No External Programming Voltage Needed

Programmable Code Protection by Security Fuse

11

Page 12: msp430 controller ultrasonic distance measurment

Figure 2-6 MSP430x22x4 functional block diagram

2.7 Digital I/O overview

MSP430 devices have up to eight digital I/O ports implemented, P1 to P7. Each port has eight I/O pins. Every I/O pin is individually configurable for input or output direction, and each I/O line can be individually read or written to. Ports P1 and P2 have interrupt capability. Each interrupt for the P1 and P2 I/O lines can be individually enabled and configured to provide an interrupt on a rising edge or falling edge of an input signal. All P1 I/O lines source a single interrupt vector, and all P2 I/O lines source a different, single interrupt vector.

The digital I/O features include:

Independently programmable individual I/Os Any combination of input or output Individually configurable P1 and P2 interrupts Independent input and output data registers Individually configurable pull-up or pull down resistors

Digital I/O Operation

The digital I/O is configured with user software. The setup and operation of the digital I/O is discussed in the following sections.

12

Page 13: msp430 controller ultrasonic distance measurment

Input Register PxIN

Each bit in each PxIN register reflects the value of the input signal at the corresponding I/O pin when the pin is configured as I/O function.Bit = 0: The input is lowBit = 1: The input is high

Output Registers PxOUT

Each bit in each PxOUT register is the value to be output on the corresponding I/O pin when the pin is configured as I/O function, output direction, and the pull-up/down resistor is disabled.Bit = 0: The output is lowBit = 1: The output is highIf the pin’s pull−up/down resistor is enabled, the corresponding bit in the PxOUT register selects pull-up or pull-down.Bit = 0: The pin is pulled downBit = 1: The pin is pulled up

Direction Registers PxDIR

Each bit in each PxDIR register selects the direction of the corresponding I/O pin, regardless of the selected function for the pin. PxDIR bits for I/O pins that are selected for other functions must be set as required by the other function.Bit = 0: The port pin is switched to input directionBit = 1: The port pin is switched to output direction

Pullup/Pulldown Resistor Enable Registers PxREN

Each bit in each PxREN register enables or disables the pullup/pulldown resistor of the corresponding I/O pin. The corresponding bit in the PxOUT register selects if the pin is pulled up or pulled down.Bit = 0: Pullup/pulldown resistor disabledBit = 1: Pullup/pulldown resistor enabled

Table 2-2 Function Select Registers PxSEL and PxSEL2

PxSEL2 PxSEL Pin Function0 0 I/O function is selected.0 1 Primary peripheral module

function is selected.1 0 Reserved. See device-

specific data sheet.1 1 Secondary peripheral

module function is selected.

13

Page 14: msp430 controller ultrasonic distance measurment

2.8 P1 and P2 Interrupts

Each pin in ports P1 and P2 have interrupt capability, configured with the PxIFG, PxIE, and PxIES registers. All P1 pins source a single interrupt vector, and all P2 pins source a different single interrupt vector. The PxIFG register can be tested to determine the source of a P1 or P2 interrupt.

Interrupt Flag Registers P1IFG, P2IFG

Each PxIFGx bit is the interrupt flag for its corresponding I/O pin and is set when the selected input signal edge occurs at the pin. All PxIFGx interrupt flags request an interrupt when their corresponding PxIE bit and the GIE bit are set. Each PxIFG flag must be reset with software. Software can also set each PxIFG flag, providing a way to generate software initiated interrupt.Bit = 0: No interrupt is pendingBit = 1: An interrupt is pending

Only transitions, not static levels, cause interrupts. If any PxIFGx flag becomes set during a Px interrupt service routine, or is set after the RETI instruction of a Px interrupt service routine is executed, the set PxIFGx flag generates another interrupt. This ensures that each transition is acknowledged.

Interrupt Edge Select Registers P1IES, P2IESEach PxIES bit selects the interrupt edge for the corresponding I/O pin.Bit = 0: The PxIFGx flag is set with a low-to-high transitionBit = 1: The PxIFGx flag is set with a high-to-low transition

Interrupt Enable P1IE, P2IEEach PxIE bit enables the associated PxIFG interrupt flag.Bit = 0: The interrupt is disabled.Bit = 1: The interrupt is enabled

14

Page 15: msp430 controller ultrasonic distance measurment

2.9 Literature survey on ultrasonic transducer

Following are the comparison of various devices which can be used for distance measurement.

Table 2-3 comparison of various devices

Devices Ultrasonic transducer

Laser Optical distance measurement

sensorMode Sound wave laser Sound wave

Operating voltage 5V 10 to 30V 4.5 to 5.5VStorage

temperature -40°C to +85°C -40°C to +70°C -40°C to +70°C

Operating temperature

-30°C to +85°C -10 °C to +50 °C -10°C to +60°C

Distance range 8 to 99 inch 0.2 to 50 m 4 to 30cm

2.10 Brief History on ultrasonic technology

Figure 2-7 Ultrasonic transducer

The roots of ultrasonic technology can be traced back to research on the piezoelectric effect conducted by Pierre Curie around 1880. He found that asymmetrical crystals such as quartz and Rochelle salt (potassium sodium tartrate) generate an electric charge when mechanical pressure is applied. Conversely, mechanical vibrations are obtained by applying electrical oscillations to the same crystals.

One of the first applications for ultrasonic was sonar (an acronym for sound navigation ranging). It was employed on a large scale by the U.S. Navy during World War II to

15

Page 16: msp430 controller ultrasonic distance measurment

detect enemy submarines. Sonar operates by bouncing a series of high frequency, concentrated sound wave beams off a target and then recording the echo. Because the speed of sound in water is known, it is an easy matter to calculate the distance of the target. Prior to World War II researchers were inspired by sonar to develop analogous techniques for medical diagnosis. For example, the use of ultrasonic waves in detecting metal objects was discussed beginning in 1929. In 1931 a patent was obtained for using ultrasonic waves to detect flaws in solids.

Japan played an important role in the field of ultrasonic from an early date. For example, soon after the end of the war, researchers there began to explore the medical diagnostic capabilities of ultrasound. Japan was also the first country to apply Doppler ultrasound, which detects internal moving objects such as blood flowing through the heart.

In the 1950s researchers in the United States and Europe became increasingly aware of the progress that had been made in Japan, and they began work on additional medical applications. The first ultrasonic instruments displayed their results with blips on an oscilloscope screen. That was followed by the use of two dimensional, gray scale imaging. High resolution, color, computer-enhanced images are now common, Ultrasonic technology is now employed in a wide range of applications in research, industry and medicine.

Basic of Ultrasonic Transducers

An ultrasonic transducer is a device that converts energy into ultrasound, or sound waves above the normal range of human hearing. While technically a dog whistle is an ultrasonic transducer that converts mechanical energy in the form of air pressure into ultrasonic sound waves, the term is more apt to be used to refer to piezoelectric transducer that convert electrical energy into sound. Piezoelectric crystals have the property of changing size when a voltage is applied, thus applying an alternating voltage (AC) across them cause them to oscillate at very high frequencies, thus producing very high frequency sound waves.

Since piezoelectric crystals generate a voltage when force is applied to them the same crystal can be used as an ultrasonic detector. Some systems use separate transmitter and receiver components while others combine both in a single piezoelectric transceiver.

What is ultrasound?

Ultrasonic waves can be generated using mechanical, electromagnetic and thermal energy sources. They can be produced in gasses (including air), liquids and solids. Magnetostrictive transducers use the inverse magnetostrictive effect to convert magnetic energy into ultrasonic energy. This is accomplished by applying a strong alternating magnetic field to certain metals, alloys and ferrites.

Piezoelectric transducers employ the inverse piezoelectric effect using natural or synthetic single crystals (such as quartz) or ceramics (such as barium titanate) which have strong piezoelectric behavior. Ceramics have the advantage over crystals in that it is easy to shape them by casting, pressing and extruding. Sound generated above the human hearing range (typically 20 KHz) is called ultrasound. However, the frequency range normally

16

Page 17: msp430 controller ultrasonic distance measurment

employed in ultrasonic nondestructive testing and thickness ranging is 100 KHz to 50 MHz. Although ultrasound behaves in a similar manner to audible sound, it has a much shorter wavelength. This means it can be reflected off very small surfaces such as defects inside materials. It is this property that makes ultrasound useful for nondestructive testing of materials. Velocity of ultrasound and wavelength

The velocity of ultrasound(c) in a perfectly elastic material at a given temperature and pressure is constant. The relation between c, f, λ and T is given by equation:

λ=c/f, λ=cT

λ=wavelengthc=material sound velocity f=frequencyT=period of time

Wave propagation and particle motionThe most common methods of ultrasonic examination utilize either longitudinal waves or shear waves. Others forms of sound propagation exist, including surface waves and lamb waves.

Figure 2-8 wave propagation The longitudinal wave is a compression wave in which the particle motion is in

the same direction as the propagation of the wave The shear wave is a wave motion in which the particle motion is perpendicular to

the direction of the propagation. Surface (Rayleigh) waves have an elliptical particle motion and travel across the

surface of a material. Their velocity is approximately 90% of the shear wave

17

Page 18: msp430 controller ultrasonic distance measurment

velocity of the material and their depth of penetration is approximately equal to one wavelength.

Plate (Lamb) waves have a complex vibration occurring in materials where thickness is less than the wavelength of ultrasound introduced into it.

Radiation Patterns of Transducers and Ultrasonic Sensors

The acoustic radiation pattern, or beam pattern, is the relative sensitivity of a transducer as a function of spatial angle. This pattern is determined by factors such as the frequency of operation and the size, shape, and acoustic phase characteristics of the vibrating surface. The beam patterns of transducers are reciprocal, which means that the beam will be the same whether the transducer is used as a transmitter or as a receiver. It is important to note that the system beam pattern of an ultrasonic sensor is not the same as the beam pattern of its transducer, as will be explained later.

Transducers can be designed to radiate sound in many different types of pattern, from omnidirectional to very narrow beams. For a transducer with a circular radiating surface vibrating in phase, as is most commonly used in ultrasonic sensor applications, the narrowness of the beam pattern is a function of the ratio of the diameter of the radiating surface to the wavelength of sound at the operating frequency, D/λ. The larger the diameter of the transducer as compared to a wavelength of sound, the narrower the sound beam. For example, if the diameter is twice the wavelength, the total beam angle will be ~30°, but if the diameter or frequency is increased so that the ratio becomes 10, the total beam angle will be reduced to ~6°.

Figure 2-9 A transducer with a circular radiating surface

A transducer with a circular radiating surface whose diameter is large in comparison to a wavelength produces a narrow beam Figure above is a 3D representation of the beam pattern produced by a transducer with a diameter that is large compared to a wavelength. As can be seen, the beams are narrow and conical and have a number of secondary lobes separated by nulls. Each of these secondary lobes is sequentially lower in amplitude than

18

Page 19: msp430 controller ultrasonic distance measurment

the previous one. (Even though the beam is called conical, it does not have straight sides and a flat top as the word might imply.) The beam angle is usually defined as the measurement of the total angle where the sound pressure level of the main beam

Has been reduced by 3 dB on both sides of the on-axis peak. However, the transducer still has sensitivity at greater angles, both in the main beam and in the secondary lobes. Figure besides is a family of curves reproduced from Acoustic Design Charts for transducers with circular radiating pistons mounted in an infinite baffle. The curves show the degrees off axis for the beam angle to be reduced from the on-axis amplitude by 3 dB, 6 dB, 10 dB, and 20 dB as a function of D/λ. Note that the angles on these curves are half of the total beam angle.

When describing transducer beam patterns, 2D plots are most commonly used. These show the relative sensitivity of the transducer vs. angle θ in a single plane cut through the 3D beam pattern. For a symmetrical conical pattern such as that shown in Figure above, a simple 2D plot will describe the entire 3D pattern. Figure below shows a 2D polar plot

From -90° to +90° of the beam of a circular radiating piston mounted in an infinite baffle with a diameter equal to two wavelengths of sound. As can be seen, the pattern is smooth as a function of angle, and the -3 dB points are at +15° and -15° off axis, producing a total beam angle of 30°. However, the total angle of the major radiating lobe between the first two nulls is ~70°, and the side lobes peak at approximately +55° and -55°. When using an ultrasonic sensor, it is important to be aware that nearby unwanted targets that are beyond the beam angle can inadvertently be detected because the transducers are still sensitive at angles greater than the beam angle. Some transducers used in sensing applications are specially designed to minimize or eliminate the secondary lobes to avoid detecting unwanted targets.

19

Figure Acoustic Design Charts shows the directional radiation characteristic of circular pistons mounted in an infinite baffle as a function of D/λ.

Figure This 2D polar plot represents the beam pattern of a transducer with a circular disc radiator mounted in an infinite baffle, where D/λ = 2.

Page 20: msp430 controller ultrasonic distance measurment

2.11 Survey on liquid crystal display (LCD)

Figure 2-10 liquid crystal display

A liquid crystal display (LCD) is an electro-optical amplitude modulator realized as a thin, flat display device made up of any number of color or monochrome pixels arrayed in front of a light source or reflector. It is often utilized in battery-powered electronic devices because it uses very small amounts of electric power.

LCDs have become very popular over recent years for information display in many ‘smart’ appliances. They are usually controlled by micro controllers. They make complicated equipment easier to operate.

LCDs come in many shapes and sizes but the most common is the 16character x 2 lines display. It requires only 11 connections –eight bits for data (which can be reduced to four if necessary) and three control lines. It runs with a supply voltage of 5v DC and only needs 1mA of current .the display contrast can be varied by changing the voltage into pin of the display, usually with a trim pot.

In recent years the LCD is finding widespread use replacing LEDs. This is due to following reasons:

1) The declining prices of LCDs2) The ability to display numbers, characters, and graphics. This is in contrast to

LEDs, which are limited to numbers and a few characters.3) Incorporation of a refreshing controller into the LCD, thereby reliving the CPU of

the task of refreshing the LCD. In contrast, the LED must be refreshed by the CPU to keep displaying the data.

4) Ease of programming for character and graphics.

20

Page 21: msp430 controller ultrasonic distance measurment

Figure 2-11 Pin position for LCD

Table 2-4 Pin number, symbol and its function

Pin descriptionsVcc, Vss and Vee :

Vcc and Vss provide +5V and ground respectively, Vee is used to controlling LCD contrast.

21

Page 22: msp430 controller ultrasonic distance measurment

RS, register select:

There are two very important registers inside the LCD. The RS pin is used for their selections as follows. If RS=0, the instruction command code register is selected, allowing the user to send a command such as clear display, cursor at home, etc. if RS=1 the data register is selected, allowing the user to send data to be displayed on the LCD.

R/W read/write:

R/W input allows the user to write information to the LCD or read information from it. R/W=1 when reading; R/W=0 when writing.

E, enable:

The enable pin is used by the LCD to latch information presented to its data pins. When data is supplied to data pins, a high-to-low pulse must be applied to this pin in order for the LCD to latch in the data present at the data pins. This pulse must be a minimum of 450ns wide. D0-D7:

The 8-bit data pins, D0-D7, are used to send information to the LCD or read the contents of the LCDs internals registers. To display the letters and numbers , we send ASCII codes for the letters A-Z, a-z and 0-9 to these pins while making RS=1.

Code(hex) Command to LCD instruction register

1 Clear display screen

2 Return home

4 Decrement cursor(shift to left)

6 Increment cursor(shift to right)

5 Shift display right

7 Shift display left

8 Display off, cursor off

A Display off, cursor on

C Display on ,cursor off

E Display off, cursor blinking

22

Page 23: msp430 controller ultrasonic distance measurment

F Display on, cursor blinking

10 Shift cursor position to left

14 Shift cursor position to right

18 Shift the entire display to the left

1C Shift the entire display to the right

80 Force cursor to beginning of 1st line

C0 Force cursor to beginning of 2nd line

38 2 lines 5x7 matrix

Table 2-5 LCD command codes

Key features

1) 5 x 8 dots with cursor2) +5v power supply3) 1/16 duty cycle4) B/L to be driven by pin 1, pin 2 or pin 5, pin 16 or A.K (LED).5) N.V optional for +3V power supply.

23

Page 24: msp430 controller ultrasonic distance measurment

3. SOFTWARE/HARDWARE DESIGN AND DEVELOPMENT TOOLS

3.1 Block diagram

There are nearly six blocks as we can be observed from the figure

1) LCD: As shown in block diagram there is a LCD interfaced with controller on which we can display the measured distance.

2) TX1: It is the transmitter transducer with a 12-cycle burst of 40-kHz square-wave signal derived from the crystal oscillator.

3) RX1: It is the receiver transducer which receives the weak echo signal when strike to an object.

4) Signal conditioning: It is the signaling stage where amplification of a weak signal is done over here

5) MSP430 Microcontroller: A board with on chip programming for controller with various connectors for transducer and LCD

24

Power supply

MSP430

LCD

Signal Conditio

ning

TX1

RX1

PC

Figure 3-12 Ultrasonic distance measurement using MSP430 microcontroller

Page 25: msp430 controller ultrasonic distance measurment

3.2 System flow chart

Figure 3-13 System flow chart

25

START

Transmitter transmits ultrasonic

sound/Initialization of Timer

Receiver will receive echo.

Comparator will compare the signal

Termination of Timer

LCD

MSP430d= (1100*12*t)/2

Page 26: msp430 controller ultrasonic distance measurment

Brief description

The MSP430 drives the transmitter transducer with a 12-cycle burst of 40-kHz square-wave signal derived from the crystal oscillator.

As soon as transmitter transmit the signal, a timer is initiated which is configured to count the 40-kHz crystal frequency such that the time measurement resolution is 25 μs, which is more than adequate for this application.

The echo received by the receiver transducer is amplified by an operational amplifier and the amplified output is fed to the Comparator input.

The Comparator senses the presence of the echo signal at its input and triggers a capture of Timer count value to capture compare register.

The capture is done exactly at the instant the echo arrives at the system. The captured count is the measure of the time taken for the ultrasonic burst to travel the distance from the system to the object and back to the system.

The distance from the system to the object is computed by the MSP430 using this measured time and displayed on a two-digit static LCD by equation d=1100 X 12 X t.

Since the actual distance measured by the system is twice so the actual distance obtained is d/2.

26

Page 27: msp430 controller ultrasonic distance measurment

Figure 3-14 Circuit schematic

3.3 Introduction to Simulation and Programming Software

Keil

μVision2 Keil for Windows™ [9] is an Integrated Development Environment that combines project management, source code editing, and program debugging in one single, powerful environment. Keil is a complier which is used to generate Hex file from assembly language, C and other high level languages. It has a large collection of micro-controllers which are used to see whether that program would make an error on the

27

Page 28: msp430 controller ultrasonic distance measurment

specified micro controller. As Keil is having large library of C51 architecture based controls, it also have these controller’s header files because of which programming becomes very easy.

Proteus

Proteus Virtual System Modelling (VSM) combines mixed mode SPICE circuit simulation, animated components and microprocessor models to facilitate co-simulation of complete microcontroller based designs. For the first time ever, it is possible to develop and test such designs before a physical prototype is constructed. This is possible because you can interact with the design using on screen indicators such as LED and LCD displays and actuators such as switches and buttons. The simulation takes place in real time (or near enough to it): a 1GMHz Pentium III can simulate a basic 8051 system clocking at over 12MHz. Proteus VSM also provides extensive debugging facilities including breakpoints, single stepping and variable display for both assembly code and high level language source.

Other features of Proteus:

1: Schematic entry.2: Circuit simulation3: Co-Simulation of Microcontroller Software, etc.

CCE (code composer essential)

Code composer essentials (CCE) is a fully integrated MSP430 development environment with up to 8K bytes.CCE is a powerful and easy to use integrated programming and debugging environment for the industry leading MSP430 ultra-low power microcontrollers. Based on the industry standard eclipse open source platform, CCE is enabling to grow into customers evolving needs. Adapted specifically for MSP430 by TI, CCE is stale, intuitive and provides world class code density for MSP430 microcontrollers. Software development in both C and assembly language is supported.

IAR KICKSTART

IAR embedded workbench kickstart for MSP430 is an integrated development environment (IDE) for building and debugging embedded applications for MSP430 microcontrollers. The IDE includes a 4K limited C-compiler, unlimited assembler, FET debugger and simulator. The FET debugger is fully integrated debugger for source and disassembly level debugging with support for complex code and data breakpoints.

3.4 MSP430 wireless development tool

The eZ430-RF2500 is a complete USB-based MSP430 wireless development tool providing all the hardware and software to evaluate the MSP430F2274 microcontroller and CC2500 2.4GHz wireless transceiver.

28

Page 29: msp430 controller ultrasonic distance measurment

The eZ430-RF2500 uses the IAR Embedded Workbench Integrated Development Environment (IDE) or Code Composer Essentials (CCE) to write, download, and debug your application. The debugger is unobtrusive allowing the user to run an application at full speed with both hardware breakpoints and single stepping available while consuming no extra hardware resources.

The eZ430-RF2500T target board is an out-of-the box wireless system that may be used with the USB debugging interface, as a stand-alone system with or without external sensors, or may be incorporated into an existing design.

The new USB debugging interface enables eZ430-RF2500 to remotely send and receive data from your PC using the MSP430 Application UART

EZ430-RF2500 features:

•USB debugging and programming interface featuring a driverless installation and application backchannel.

• 21 available development pins.• Highly integrated, ultra-low-power MSP430 MCU with 16MHz performance.• Two general-purpose digital I/O pins connected to green and red LEDs for visual

feedback.• Interruptible push button for user feedback.• Range up to 450ft at 10kbps and up to 300ft at 250kbps.

Figure 3-15 eZ430-RF2500

29

Page 30: msp430 controller ultrasonic distance measurment

The hardware includes:

• Two eZ430-RF2500T target boards.• One eZ430-RF USB debugging interface.• One AAA battery pack with expansion board (batteries included).

Figure 3-16 eZ430-RF2500T target boards

3.5 Developing with eZ430-RF2500T Target Board

The eZ430-RF2500 can be used as a stand-alone development tool. Additionally, the eZ430-RF2500T target board may also be detached from the debugging interface and integrated into another design by removing the plastic enclosure. The target board features a MSP430F2274 and most of its pins are easily accessible. The following pins are:

30

Page 31: msp430 controller ultrasonic distance measurment

Table 4-6 Pin outs

1 GND Ground Reference2 VCC Supply Voltage3 P2.0 / ACLK / A0 / OA0I0 General-purpose digital I/O pin / ACLK

output / ADC10, analog input A04 P2.1 / TAINCLK / SMCLK / A1 /

OA0OGeneral-purpose digital I/O pin / ADC10, analog input A1Timer_A, clock signal at INCLK, SMCLK signal output

5 P2.2 / TA 0 / A2 / OA0I1 General-purpose digital I/O pin / ADC10, analog input A2Timer_A, capture: CCI0B input/BSL receive, compare: OUT0 output

6 P2.3 / TA 1 / A3 / VREF − /VeREF − / OA1I1 / OA1O

General-purpose digital I/O pin / Timer_A, capture: CCI1B input, compare:OUT1 output / ADC10, analog input A3 / negative reference voltageoutput/input

7 P2.4 / TA 2 / A4 / VREF + /VeREF + / OA1I0

General-purpose digital I/O pin / Timer_A, compare: OUT2 output /ADC10, analog input A4 / positive reference voltage output/input

8 P4.3 / TB0 / A12 / OA0O General-purpose digital I/O pin / ADC10 analog input A12 /Timer_B, capture: CCI0B input, compare: OUT0 output

31

Page 32: msp430 controller ultrasonic distance measurment

9 P4.4 / TB1 / A13 / OA1O General-purpose digital I/O pin / ADC10 analog input A13 / Timer_B, capture: CCI1B input, compare: OUT1 output

10 P4.5 / TB2 / A14 / OA0I3 General-purpose digital I/O pin / ADC10 analog input A14 / Timer_B, compare: OUT2 output

11 P4.6 / TBOUTH / A15 / OA1I3 General-purpose digital I/O pin / ADC10 analog input A15 / Timer_B, switch all TB0 to TB3 outputs to high impedance

12 GND Ground Reference13 P2.6 / XIN (GDO0) General-purpose digital I/O pin / Input

terminal of crystal oscillator14 P2.7 / XOUT (GDO2) General-purpose digital I/O pin / Output

terminal of crystal oscillator15 P3.2 / UCB 0SOMI / UCB 0SCL General-purpose digital I/O pin

USCI_B0 slave out/master in in SPI mode, SCL I2C clock in I2C mode

16 P3.3 / UCB 0CLK / UCA 0STE General-purpose digital I/O pinUSCI_B0 clock input/output / USCI_A0 slave transmit enable

17 P3.0 / UCB 0STE / UCA 0CLK /A5

General-purpose digital I/O pin / USCI_B0 slave transmit enable / USCI_A0 clock input/output / ADC10, analog input A5

18 P3.1 / UCB 0SIMO / UCB 0SDA General-purpose digital I/O pin / USCI_B0 slave in/master out in SPI mode, SDA I2C data in I2C mode

Table 4-7 Battery board pin outs

1 P3.4 / UCA 0TXD / UCA 0SIMO General-purpose digital I/O pin / USCI_A0 transmit data output in UART mode(UART communication from 2274 to PC), slave in/master out in SPI mode

2 GND Ground Reference3 TEST/SBWTCK Selects test mode for JTAG pins on

Port1. The device protection fuse is connected to TEST. Spy-Bi-Wire test clock input during programming and test

4 #RST/SBWTDIO Reset or non maskable interrupt input.Spy-Bi-Wire test data input/output during programming and test

5 VCC (3.6V) Supply Voltage

32

Page 33: msp430 controller ultrasonic distance measurment

6 P3.5 / UCA 0RXD / UCA 0SOMI General-purpose digital I/O pin / USCI_A0 receive data input in UART mode(UART communication from 2274 to PC), slave out/master in SPI mode

3.6 MSP430 Application UART

The Universal Asynchronous Receiver/Transmitter (UART) controller is the key component of the serial communications subsystem of a computer. The UART takes bytes of data and transmits the individual bits in a sequential fashion. At the destination, a second UART re-assembles the bits into complete bytes. Serial transmission of digital information (bits) through a single wire or other medium is much more cost effective than parallel transmission through multiple wires. A UART is used to convert the transmitted information between its sequential and parallel form at each end of the link. Each UART contains a shift register which is the fundamental method of conversion between serial and parallel forms.

The eZ430-RF USB debugging interface features a back channel MSP430 Application UART that may be used independently of a debug session. This allows the user to transfer serial data to a terminal window at a fixed rate of 9600bps with No flow control. See Figure for typical settings.

Figure 3-17 com-port assignment

Check the device manager for com-port assignment of the msp430 application UART.

33

Page 34: msp430 controller ultrasonic distance measurment

4. RESULTS AND OBSERVATIONS

Initially we have started working on 16 x 2 LCD on 89C51.We have connected 16x2 LCD with port1, i.e. the data pins D0-D7 are connected to prot1. The RS pin is connected to port 2.2. We have to send some initialization command to LCD so that to make it start to display.

Following are the initialization command that we used for LCD.38H 2 lines and 5x7 matrix0EH display on, cursor blinking01H clear display screen06H shift cursor to right80H force cursor to beginning of first line

XTAL218

XTAL119

ALE30

EA31

PSEN29

RST9

P0.0/AD0 39

P0.1/AD1 38

P0.2/AD2 37

P0.3/AD3 36

P0.4/AD435

P0.5/AD5 34

P0.6/AD6 33

P0.7/AD7 32

P1.01

P1.12

P1.23

P1.34

P1.45

P1.56

P1.67

P1.78

P3.0/RXD10

P3.1/TXD 11

P3.2/INT0 12

P3.3/INT1 13

P3.4/T0 14

P3.7/RD17

P3.6/WR 16P3.5/T1 15

P2.7/A15 28

P2.0/A8 21

P2.1/A9 22

P2.2/A1023

P2.3/A11 24

P2.4/A12 25

P2.5/A13 26

P2.6/A14 27

U1

AT89C51

X1CRYSTAL

C1

10pf

C2

10pf

C310uF

R18.2k

R310k

BAT15V

BAT25V

D714D613D512D4

11D310D2

9D18D07

E6RW

5RS4

VSS1

VDD2

VEE3

LCD1

LM044L

Figure 4-18 Simulation of 16x2 LCD on Proteus

34

Page 35: msp430 controller ultrasonic distance measurment

INTERFACING 16X2 LCD WITH MSP430

After completing our work on 89C51 microcontroller, we have switched over to our main microcontroller i.e. MSP430 microcontroller .we have interfaced 16 x 2 LCD with it.

Figure 4-19 interfacing LCD with MSP430

Due to pin configuration constraint, we have available with 18 pin. For interfacing LCD we require 12 pins. So to minimize the number of pins for interfacing of LCD we have adapted a technique which uses masking of upper and lower nibble with only four data lines available with user and thus we have configured using seven pins only.

Steps for masking technique:

First we start with mask lower 4-bit and transmits upper 4-bit. We provide some delay Mask upper 4-bit and transmits lower 4-bit. Again provide some delay Complete data is displayed on LCD

35

Page 36: msp430 controller ultrasonic distance measurment

4.1 System flow chart of LCD

Figure 4-20 System flow chart of LCD

36

Start

Mask lower 4 bit data

Transmit upper 4 bit data

Provide some delay

Mask upper 4 bit data

Transmit lower 4 bit data

Provide some delay

Display data on LCD

Page 37: msp430 controller ultrasonic distance measurment

4.2 Transducer module

The devices used to transmit and receive the ultrasonic sound waves in this application are 40-kHz ceramic ultrasonic transducers. The MSP430 drives the transmitter transducer with a 20-cycle burst of 40-kHz square-wave signal derived from the crystal oscillator, and the receiver transducer receives the echo.

Figure 4-21 Transducer module

Test result

We have successfully accomplished our project task

1. Interfaced LCD with MSP4302. Interfaced transducer module with MSP4303. Interfaced UART application module with MSP430

Accuracy obtained is nearly ±2 cm. of the measured distance.

37

Page 38: msp430 controller ultrasonic distance measurment

CONCLUSION AND FUTURE PROSPECT

It has been rightly said that” A conclusion is a place where person get tired of thinking”. Now it’s a high time to think about it. We can conclude here that our project can be of great help to people from all walks of life. Ultrasonic distance measurement is a technique which can be helpful to measure a distance from an obstacle. This technique is widely acceptable in bio-medical industry, car parking, and sonar etc. specifically we have designed our project for car parking application which can avoid many accidental mishap occurring in our day today life. Thus this technique can be boon to industrial system based on distance measurement because no physical contact with an object to be detected and detection of any object irrespective of colors, size and shape.

Future prospect:

Ultrasonic technology can be used to detect moving object on the basis of Doppler frequency shift principle using sensor with high rang mounting on a stepper motor. Hence it acts as radar.

This type of ultrasonic radar can also be used in navigation and civilian applications and military.

The applications to medicine and biology of sound waves that have a frequency higher than the audible spectrum. Biomedical applications of ultrasound range from cell sonicators using frequencies in the kilohertz range to ultrasonic imaging in the megahertz range. The best-known application, ultrasonic imaging is the second most utilized diagnostic imaging modality, after x-rays. High-intensity ultrasound has been used for therapeutic applications.

Ultrasonic imaging possesses numerous advantages over other imaging modalities of similar capabilities such as x-ray computed tomography, radionuclide imaging, and magnetic resonance imaging. It uses radiation that is noninvasive to the human body at the diagnostic intensity level, produces images at a very fast rate of 30 frames per second, and can be used to yield blood flow information by applying the Doppler principle. It has been used in a variety of medical disciplines, including cardiology, obstetrics, and radiology.

38

Page 39: msp430 controller ultrasonic distance measurment

REFERENCES

BOOKS

[1] M. Mazidi and Mazidi, Microcontroller Architecture, Programming and Applications with the 8051, Prentice-Hall of India (2nd edition).[2] Edutech EPB 89C51 user manual.

Websites

[1] http://www.sensorsmag.com/articles/0399/0399_28/main.shtml[2] http://www.senix.com/?gclid=CLmp9bao45oCFZUvpAodAUxPBA[3] http://www.picbasic.org/articles/ultrasonic/ultrasonic_experiments__2519b2c9.png[4]http://focus.ti.com/mcu/docs/mcuprodoverview.tsp?sectionId=95&tabId=140&familyI

d=342[5] http://www.astech.de/english/distance_e.html

39

Page 40: msp430 controller ultrasonic distance measurment

APPENDIX A

Pin position for LCD

Pin number, symbol and its function

40

Page 41: msp430 controller ultrasonic distance measurment

41

Page 42: msp430 controller ultrasonic distance measurment

42

Page 43: msp430 controller ultrasonic distance measurment

43

Page 44: msp430 controller ultrasonic distance measurment

Figure eZ430-RF, USB Debugging Interface, Schematic

44

Page 45: msp430 controller ultrasonic distance measurment

45

Page 46: msp430 controller ultrasonic distance measurment

46