Professional Documents
Culture Documents
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
List of Figures
1
Figure 1.1 Distance measurement by the pulse-echo method..............................................3
Figure 2-1 Register of MSP430...........................................................................................7
Figure 2-2 MSP430 Von-Neumann architecture.................................................................9
Figure 2-3 Multiple Oscillator Clock System......................................................................9
Figure 2-4 MSP430x22x4 device pin out, RHA package..................................................10
Figure 2-5 MSP430x22x4 functional block diagram.........................................................12
Figure 2-6 Ultrasonic transducer........................................................................................15
Figure 2-7 wave propagation.............................................................................................17
Figure 2-8 A transducer with a circular radiating surface.................................................18
Figure 2-9 liquid crystal display.......................................................................................20
Figure 2-10 Pin position for LCD......................................................................................21
Figure 3-1 Ultrasonic distance measurement using MSP430 microcontroller..................24
Figure 3-2 System flow chart............................................................................................25
Figure 3-3 Circuit schematic..............................................................................................27
Figure 3-4 eZ430-RF2500..................................................................................................29
Figure 3-5 eZ430-RF2500T target boards.........................................................................30
Figure 3-6 com-port assignment.......................................................................................33
Figure 4-1 Simulation of 16x2 LCD on Proteus................................................................34
Figure 4-2 interfacing LCD with MSP430.........................................................................35
Figure 4-3 System flow chart of LCD................................................................................36
Figure 4-4 Transducer module...........................................................................................37
List of Tables
Table 2-1 Comparisons of various microcontrollers............................................................5
Table 2-2 Function Select Registers PxSEL and PxSEL2.................................................13
Table 2-3 comparison of various devices...........................................................................15
Table 2-4 Pin number, symbol and its function.................................................................21
Table 2-5 LCD command codes........................................................................................23
Table 4-1 Pin outs..............................................................................................................31
Table 4-2 Battery board pin outs........................................................................................32
2
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.
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 instrument
2: Car parking system
3: Sonar
4: 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.
In this system the mechanism of sound waves has been encountered. If the speed of sound
3
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.
Power supply
TX1
Microcontroller Signal
PC Conditio
ning RX1
LCD
4
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.
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.
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
Figure 2-2 Register of MSP430
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.
7
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
8
Figure 2-3 MSP430 Von-Neumann architecture
9
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 ROM
2. OTP (in-system programmable)
3. EPROM (UV-erasable, in-system programmable)
4. --40°C to 85°C operating temperature range
5. 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
11
Figure 2-6 MSP430x22x4 functional block diagram
The digital I/O is configured with user software. The setup and operation of the digital
I/O is discussed in the following sections.
Input Register PxIN
12
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 low
Bit = 1: The input is high
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 low
Bit = 1: The output is high
If 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 down
Bit = 1: The pin is pulled up
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 direction
Bit = 1: The port pin is switched to output direction
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 disabled
Bit = 1: Pullup/pulldown resistor enabled
13
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.
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 pending
Bit = 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.
14
2.9 Literature survey on ultrasonic transducer
Following are the comparison of various devices which can be used for distance
measurement.
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
detect enemy submarines. Sonar operates by bouncing a series of high frequency,
15
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.
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
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
16
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
λ=wavelength
c=material sound velocity
f=frequency
T=period of time
17
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°.
19
Figure 2-10 liquid crystal display
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:
20
Figure 2-11 Pin position for LCD
Pin descriptions
Vcc, Vss and Vee :
Vcc and Vss provide +5V and ground respectively, Vee is used to controlling LCD
contrast.
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.
Key features
22
1) 5 x 8 dots with cursor
2) +5v power supply
3) 1/16 duty cycle
4) 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
Power supply
TX1
MSP430 Signal
PC Conditio
ning RX1
LCD
24
3.2 System flow chart
START
Transmitter transmits
ultrasonic
sound/Initialization of
Timer
Comparator will
compare the signal
Termination of Timer
MSP430
d= (1100*12*t)/2
LCD
Figure 3-13 System flow chart
25
Brief description
The MSP430 drives the transmitter transducer with a 12-cycle burst of 40-kHz
square-wave signal derived from the crystal oscillator.
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
Figure 3-14 Circuit schematic
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.
1: Schematic entry.
2: Circuit simulation
3: Co-Simulation of Microcontroller Software, etc.
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.
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.
30
Table 4-6 Pin outs
32
mode(UART communication from 2274
to PC), slave out/master in SPI mode
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.
Check the device manager for com-port assignment of the msp430 application UART.
33
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.
C1
10pf U1
19 XTAL1 P0.0/AD0 39
X
1 P0.1/AD1 38 BAT1
CRYST
AL P0.2/AD2 37 5V
C2 18 XTAL2 P0.3/AD3 36
35
P0.4/AD4
P0.5/AD5 34
10pf
P0.6/AD6 33
9
RST P0.7/AD7
32 R3
10k LC
D1
21
P2.0/A8
C3 P2.1/A9 22 1 VSS
10uF 23 2 VDD
P2.2/A10
29 PSEN P2.3/A11 24 3 VEE
30
ALE P2.4/A12 25
31 EA P2.5/A13 26 4 RS
27 5
P2.6/A14 RW
P2.7/A15 28 6 E
BAT2 1 P1.0
P3.0/RXD
10 7 D0
5V 2 P1.1 P3.1/TXD 11 8 D1
R1 3
P1.2 P3.2/INT0
12 9
D2
8.2k 4 P1.3 P3.3/INT1 13 10 D3
5 11
P1.4 P3.4/T0 14 D4
6 P1.5 P3.5/T1 15 12 D5
7 P16. P3.6/WR 16 13 D6
8 17 14
P1.7 P3.7/RD D7
AT89C51
LM
044L
34
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.
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.
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
4.1 System flow chart of LCD
Start
36
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.
37
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.
38
REFERENCES
BOOKS
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
APPENDIX A
Pin position for LCD
40
41
42
Figure eZ430-RF, USB Debugging Interface, Schematic
43
44
45