single room indoor positioning system › 2014 › ...indoor positioning systems employ radio,...
TRANSCRIPT
Single Room Indoor Positioning System
By
Keith Moran
Tuesday 27th May 2014
Supervisor: Mr Damon Berry
This Final Year Report is submitted in partial fulfilment of the
requirements of the B.Eng. in Electrical and Electronic Engineering of
the Dublin Institute of Technology
i
I certify that this report, which I submit in accordance of the requirements of the honours Degree in
Electrical and Electronic Engineering (DT021) of the Dublin Institute of Technology, is a product of
my own work and that any content reproduced in this report that relates to the work of other
individuals are acknowledged through appropriate referencing.
Signed: .
Date: .
ii
Acknowledgements
I wish to express my gratitude and appreciation to everyone who supported me throughout the
duration of this project. I would particularly like to thank Damon Berry for his guidance and direction
in the technical aspects of this project. I would also like to thank Mr Tony Kelly who contributed his
time to support and advise me on the digital communications aspects and Dr Ted Burke who
contributed his time to advise me on the software aspects. I would like to express my appreciation
to technician Finbarr O’Meara who provided me with the parts needed to complete this project.
iii
Table of Contents List of Figures .......................................................................................................................................... v
Abstract .................................................................................................................................................. vi
Chapter 1: Introduction .......................................................................................................................... 1
Introduction ........................................................................................................................................ 1
Ultrasonic and Radio frequency .......................................................................................................... 1
Radio Frequency ................................................................................................................................. 2
Ultrasonic ............................................................................................................................................ 2
DsPIC30F4011 and dsPIC30F3012 Microcontrollers ........................................................................... 3
Project Objectives ................................................................................................................................... 4
Report Outline ........................................................................................................................................ 4
Chapter 2: Literature Review .................................................................................................................. 5
Low cost indoor positioning system ................................................................................................... 5
Global Positioning System (GPS) ......................................................................................................... 5
Ibeacon ................................................................................................................................................ 6
Bat Ultrasonic System ......................................................................................................................... 6
Chapter 3: Design and Implementation .................................................................................................. 7
Components ........................................................................................................................................ 7
Ultrasonic transmitter & Receiver .................................................................................................. 7
Radio Frequency transmitter & Receiver ........................................................................................ 7
PRBS and PWM ................................................................................................................................... 9
Signal Generation ................................................................................................................................ 9
PRBS Sequence ................................................................................................................................ 9
40 kHz PWM Signal ....................................................................................................................... 10
Max233 ............................................................................................................................................. 10
Envelope Detector ............................................................................................................................ 11
System Block Diagram ....................................................................................................................... 13
Ultrasonic Receiver Circuit ................................................................................................................ 14
Possible System Configurations ........................................................................................................ 15
One transmitter & two receivers .................................................................................................. 15
Three transceivers ......................................................................................................................... 16
PRBS Length ...................................................................................................................................... 17
Cross Correlation............................................................................................................................... 17
Calculations ....................................................................................................................................... 17
iv
Chapter 4: Testing & Results ................................................................................................................. 19
Radio Frequency Distance Testing .................................................................................................... 19
Ultrasonic Distance Testing............................................................................................................... 21
Ultrasonic Angle Testing ................................................................................................................... 22
Frequency Impact on Receiver ......................................................................................................... 26
Max233 Testing ................................................................................................................................. 27
Transmitting and Receiving Testing .................................................................................................. 31
Chapter 5: Discussion & Conclusion ..................................................................................................... 32
Discussion.......................................................................................................................................... 32
Conclusion ......................................................................................................................................... 33
Appendix A: References ........................................................................................................................ 34
Appendix B: Software Code .................................................................................................................. 35
PRBS Generation ............................................................................................................................... 35
PWM ................................................................................................................................................. 36
Appendix C: Circuit Diagram ................................................................................................................. 38
v
List of Figures Figure 1: Electromagnetic Spectrum Regions ......................................................................................... 2
Figure 2: Ultrasonic Sensors .................................................................................................................... 7
Figure 3: Radio Frequency Transmitter & Receiver ................................................................................ 7
Figure 4: Radio Frequency Pin Outs ........................................................................................................ 8
Figure 5: PRBS Signal from pin RD0 ........................................................................................................ 9
Figure 6: 40 kHz PWM Signal of pin 37 ................................................................................................. 10
Figure 7: Max233 .................................................................................................................................. 11
Figure 8: Envelope Detector Simulation ............................................................................................... 12
Figure 9: System Block Diagram ............................................................................................................ 13
Figure 10: Ultrasonic Receiver Circuit ................................................................................................... 14
Figure 11: 1 Tx & 2 Rx configuration ..................................................................................................... 15
Figure 12: 3 Transceivers configuration ................................................................................................ 16
Figure 13: Cosine configuration ............................................................................................................ 18
Figure 14: Radio Frequency equipment set up ..................................................................................... 19
Figure 15: Distance 137cm .................................................................................................................... 19
Figure 16: Distance 193cm .................................................................................................................... 20
Figure 17: Distance 289cm .................................................................................................................... 20
Figure 18: Ultrasonic Angle Testing set up ........................................................................................... 22
Figure 19: Pk – Pk voltage: 1 metre at 30 degrees ............................................................................... 23
Figure 20: Pk - Pk voltage: 1 metre at 60 degrees ................................................................................ 23
Figure 21: Pk - Pk voltage: 1 metre at 90 degrees ................................................................................ 23
Figure 22: Pk - Pk voltage: 2 metres at 30 degrees ............................................................................... 24
Figure 23: Pk - Pk voltage: 2 metres at 60 degrees ............................................................................... 24
Figure 24: Pk - Pk voltage: 2 metres at 90 degrees ............................................................................... 24
Figure 25: Pk - Pk voltage: 3 metres at 30 degrees .............................................................................. 25
Figure 26: Pk - Pk voltage: 3 metres at 60 degrees ............................................................................... 25
Figure 27: Pk - Pk voltage: 3 metres at 90 degrees ............................................................................... 25
Figure 28: 38 kHz ................................................................................................................................... 26
Figure 29: 42 kHz ................................................................................................................................... 26
Figure 30: 40 kHz ................................................................................................................................... 26
Figure 31: Max233 experiment set up .................................................................................................. 27
Figure 32: Pk - Pk voltage: Straight on Figure 33: Pk - Pk voltage: 30 degrees ........................ 27
Figure 34: Pk - Pk voltage: 60 degrees Figure 35: Pk - Pk voltage: 90 degrees ........................ 28
Figure 36: Pk - Pk voltage: Straight on Figure 37: Pk - Pk voltage: 30 degrees ........................ 28
Figure 38: Pk - Pk voltage: 60 degrees Figure 39: Pk - Pk voltage: 90 degrees ........................ 29
Figure 40: Pk - Pk voltage: Straight on Figure 41: Pk - Pk voltage: 30 degrees ........................ 29
Figure 42: Pk - Pk voltage: 60 degrees Figure 43: Pk - Pk voltage: 90 degrees ........................ 30
Figure 44: Transmitter Circuit ............................................................................................................... 31
Figure 45: PRBS Signal Sent by RF and ultrasonic ................................................................................. 31
vi
Abstract
In recent years and in the years to come the popularity of indoor positioning systems will continue to
grow. These systems provide much greater accuracy than the most well-known positioning system
to date. This system is the Global positioning system (GPS). The limited accuracy of the GPS is down
to the signal attenuation through construction materials in a building. An indoor positioning system
would not have to deal with the same signal attenuation meaning greater accuracy can be achieved.
This project documents the design, building and testing of a low cost indoor positioning system. This
system contains a number of similar devices comprising of both ultrasonic and radio frequency
equipment. A PRBS signal is sent over ultrasonic and radio frequency, the signal will be received first
by the radio frequency followed by a delayed signal via ultrasonic. The time delay between the two
signals is directly proportional to the distance between the transmitter and receiver. Experiments
were carried out to test the range and angle sensitively of the system components. Overall range
improvement tests by the use of max233 were also carried out and results were documented.
Possible system configurations are also discussed.
1
Chapter 1: Introduction
Introduction In today’s modern home it can be very easy to misplace or forget were everyday items such as
phones or TV remotes are. But now picture a new system which could solve this problem at the push
of a button. This report contains all the design, testing and implementation of such a system capable
of locating an object within a room. Indoor positioning systems are rapidly increasing and becoming
more popular in recent years. The principle behind these systems is to be able to provide a way for
objects to be located inside a building. The ever growing need for a high accuracy indoor positioning
systems is sustained by the fact that the satellite based global positioning system (GPS) is ineffective
and unreliable indoors. The cause of this is due to the attenuation of signals through construction
materials in a building [2]. The GPS has an accuracy of within 10metres [1] while the system
designed in this project is hoped to have an accuracy of less than 10cm.
Indoor positioning systems employ radio, ultrasonic or infrared signals to locate an object. One big
advantage of such signals is the wide availability and low-cost of the respective components. In the
work of this report the possible configurations of devices will be explored to establish both
advantages and disadvantages.
Ultrasonic and Radio frequency
A basic requirement for a positioning system is a pair cooperating components that will continuously
measure the distance between the two. The chosen pair of components in this project will be radio
frequency and ultrasonic. For the purpose of this system two separate channels will be used.
Channel one will consist of the signal been transmitted and received almost instantly using a radio
frequency transmitter and receiver. Channel two will consist of the signal been transmitted and
received at the speed of sound using an ultrasonic transmitter and receiver. Transmitting the same
signal using these two channels means there will be a delay between the signals arriving at the
receiver. This delay is directly proportional to the distance between transmitter and receiver.
2
Radio Frequency
Radio waves are part of a larger group of waves classified all together as electromagnetic radiation.
This is a term used to describe different kinds of energies. Other examples would include TV, light,
Radar, Short and microwaves [9]. A signal travelling at the speed of light is considered to be
transmitted almost instantly compared to a signal travelling at the speed of sound is much slower.
Based on this principle a signal transmitted by radio frequency will be received first compared to a
signal transmitted by ultrasonic. Using the delay between the two the distance could be calculated.
An advantage of radio frequency transmission is that objects in line to the receiver do not interfere.
The frequency at which the chosen radio frequency transmitter and receiver operate at is 434 MHz.
Figure 1: Electromagnetic Spectrum Regions
Ultrasonic
Ultrasonic waves operate at a frequency greater than the upper limit of the human hearing range of
20 KHz so they cannot be heard by humans. A benefit of this is that ultrasonic can be used in many
systems without affecting human activity [4]. Systems which have ultrasonic aspects include parking
assistance devices in cars and trucks, motion detection, cell disintegration and degassing of liquids
[6]. An ultrasonic wave is generated when an electrical field is applied to an array of piezoelectric
crystals located on the transducer surface [3]. Ultrasonic waves are components that convert
electrical energy into mechanical energy to transmit and receive sound waves. These sound waves
can travel through all solids, liquids and gases. A common use of ultrasonic is in distance
measurement systems [5]. An ultrasonic receiver operates by receiving a signal from the transmitter,
the time taken from transmitter to receiver is known as the time of flight of a signal. Since the speed
of sound is known, it can be used in conjunction with the time of flight to calculate the distance
between transmitter and receiver.
3
A sound wave is defined as a pressure disturbance that travels through a medium by means of
particle-to-particle interaction [7]. Sound is unable to travel through a vacuum and must have a
medium present in order to travel. The speed at which sound travels through a solid, liquid and gas
varies. Sound travels effectively through liquids but even more effectively in solids and least
effectively in gases [8]. Throughout this project the primary concern is the speed of sound in air. The
idea behind it would be to measure the distance between two objects. An ultrasonic pulse would be
emitted by one object and received by the second.
DsPIC30F4011 and dsPIC30F3012 Microcontrollers
The microcontroller used in this project was the dsPIC30f4011 (referred to hereafter as 4011) or
dsPIC30f3012 (referred to hereafter as 3012). The 4011 is a 40-pin 16-bit microcontroller. There are
many similar microcontrollers available on the market in the same price band which perform similar
tasks as the 4011. There were a number of factors both good and bad in deciding to select the 4011
for this project.
Advantages
Low cost and wide availability
Contains PWM (Pulse width Modulation) Pins useful for generating carrier frequency
Pins specifically spaced apart to accommodate use with breadboard
Contains clock cycle frequency capable of carrying out required instructions
Disadvantages
Is large in size taking up a lot of small on a breadboard
The 3012 was found to be slightly cheaper in cost
Also the advantages and disadvantages of the 3012 were to be considered.
Advantages
Much smaller in size compared to the 4011
Slightly cheaper in cost compared to 4011
Disadvantages
Does not contain PWM Pins
4
Project Objectives
The main objective of this project is to not to produce a commercially finished product which
can be sold but to investigate if an indoor positioning system, which is capable of detecting
where an object is in a room can be achieved using relatively lost cow equipment and
materials
Compilation of a software programme capable of transmitting and receiving signals using
both ultrasonic and radio frequency components
Establish the time delay between receiving the signal by ultrasonic and radio frequency and
use cross correlation to calculate where an object is in a room
Implementation of the completed software programme onto at least two hardware devices
containing either a 4011/3012 microcontroller which is capable of transmitting and receiving
a radio frequency and ultrasonic signal
Report Outline
Chapter one will introduce the project itself and the motivation behind it. This chapter also contains
information on the two methods used in the transmitter and the microcontrollers used in this
project. Chapter two contains information on similar products on today’s markets and there basic
principles. It also contains publications of engineering principles on which the system is based.
Chapter three contains a detailed review of the design and implementation work carried out during
the course of this project. It contains descriptions on the generated signals used, hardware and
software used in this project and possible system configurations explored to locate an object.
Chapter four documents all the relevant tests and experiments carried out including range testing
and the addition of a max233 chip into the system. Chapter five explains and discusses all the issues,
problems and solutions encountered during the project. It also contains possible recommendations
for future investigation.
5
Chapter 2: Literature Review
This Chapter contains information on similar products on today’s markets and there basic principles.
It also contains publications of engineering principles on which the system is based.
Low cost indoor positioning system
A system similar to the work in this project is “Low Cost Indoor Positioning System” by Cliff Randell &
Henk Muller [10]. This system uses a combination of radio frequency and ultrasonics. Using a single
Radio frequency transmitter and four ceiling mounted ultrasonic transmitters it provides coverage in
a typical room in an area greater than 8m * 8m. The ceiling mounted ultrasonic transmitters are
positioned to face downwards into the room. The Radio frequency transmitter sends a pulse,
followed by four timed ultrasonic chirps [10]. The delays between the radio frequency signal and
each ultrasonic signal are converted to distances using the speed of sound. A big disadvantage of this
system is that there needs to be a clear path between the ultrasonic sensors. This would be
impractical in a room will a large number of people or objects.
Global Positioning System (GPS)
The most successful positioning system in use in the world today is the Global Positioning System
(GPS). GPS is a technology that uses the position of satellites to determine locations on earth [11].
Some of the main beneficiaries of the GPS include military, civil and commercial users around the
world. GPS can calculate the longitude and latitude of locations and transmit this information to a
receiver. GPS applications generally fall into 5 major categories:
1. Location - determining a position
2. Navigation - getting from one location to another
3. Tracking - monitoring object or personal movement
4. Mapping - creating maps of the world
5. Timing - bringing precise timing to the world
GPS satellites are located high above the earth transmit messages including information such as a
time stamp and satellite position. The receiver will then calculate the distance to each satellite based
on the time of flight.
6
Ibeacon The ibeacon system developed by Apple is a low powered, lost cost system that can notify nearby
iOS devices presence. This system works on Bluetooth low energy sensing to transmit a unique
identifier which is picked up by compatible app or operating system. The ibeacon is not just confined
to iOS devices it can also be used on the android operating system. The ibeacon technology could
greatly change the retail environment and how companies interact with their customers [12].
Bat Ultrasonic System
This system is based on the principle of trilateration, position finding by measurement of distances.
A narrow pulse of ultrasound is emitted from a transmitter which is called “The Bat”. This bat is
attached to the object which is to be located. A number of ultrasonic receivers will receive this pulse
and using the time to flight the distance between transmitter and receiver can be calculated [13].
7
Chapter 3: Design and Implementation
This design and implementation chapter will describe and explain in detail all design work carried
out during the project. It will contain an in-depth look at the chosen working method, relative
software code used to implement the task along with the constructed hardware.
Components
Ultrasonic transmitter & Receiver
Figure 2: Ultrasonic Sensors
Radio Frequency transmitter & Receiver
Figure 3: Radio Frequency Transmitter & Receiver
8
Pin out for Transmitter and Receiver
Figure 4: Radio Frequency Pin Outs
Operating Frequency 434 MHz
Supply Voltage 5 Volts
Data Rate Tx 8kbps, Rx 4800bps
Range 500 ft. (Ideal Conditions)
9
PRBS and PWM
This sub-section describes how PRBS (Pseudo Random Binary Sequence) and PWM (Pulse Width
Modulation) signals will be generated for transmission from the 4011/3012. The PRBS signal was
chosen for transmission because a PRBS signal is a long random sequence and can be easily
identified in a noisy environment allowing each device to have its own unique identity by each
device transmitting a unique PRBS signal. A PRBS sequence is better to transmit than a pulse or
square waveform because there will be a large number of edges at matching random intervals.
These edges will be present in the two signals which will result in peak when the two signals are
correlated. The PWM signal generated will be at 40 kHz which will act as a carrier signal for the PRBS
signal which is to be transmitted.
Signal Generation
PRBS Sequence
Below is the PRBS output on pin RD0 of the 4011. The code in which generates this waveform is
contained in appendix B subsection PRBS.
Figure 5: PRBS Signal from pin RD0
10
40 kHz PWM Signal
Along with generating a PRBS sequence a 40 kHz signal is also generated from the PWM output pins
of the 4011. A PWM signal is square wave that has a duty cycle that is changed to get a varying
output as a result of the average value of the waveform [15]. When using the 4011 to generate a 40
kHz PWM signal, a number of pre-sets are required. The code in which generates the PWM signal is
contained in appendix B subsection PWM.
Figure 6: 40 kHz PWM Signal of pin 37
Max233
The Max233 is a voltage driver chip which takes in a 5volt signal and outputs a voltage of +/- 10volts.
The introduction of a Max233 to the circuit to supply the ultrasonic transmitters would improve the
overall range of the system. Although the supply voltage to the circuit is 5volts, the ultrasonic
transceivers are capable of operating at a voltage of up to 20 volts. Figure 7 displays how the
max233 chip will be wired up to carry out the necessary experiments.
11
Figure 7: Max233
Envelope Detector
To investigate the signal been received by the ultrasonic receiver the initial idea was to feed the
signal into an envelope detector. The purpose of the envelope detector was to try and produce an
outline of the transmitted signal before it was fed to the next stage which was the voltage
comparator. Before any hardware was built figure 8 below shows some simple simulations using
Pspice [14]. For the purpose of explaining why an envelope detector could not be used the key area
is circled in red when the PRBS signal is changing from a one to a zero. The bottom two windows
show the output of two envelope detectors, one with a time constant of 25us and the second with a
time constant of 50us. For both detector cases of the capacitor will store charge as the signal edges
rises and discharges as the signal begins to fall. The problem with this is that the capacitor will not
discharge quickly enough. For example if the capacitor takes 25us to discharge the PRBS signal could
have already changed its state within that time which can lead to false results when sampling. Also if
a threshold voltage had been set up the capacitor discharging could lead to the signal saying it is
above the threshold were as in fact the actual signal is below the threshold.
12
Figure 8: Envelope Detector Simulation
13
System Block Diagram
Figure 9: System Block Diagram
Figure 9 displays an overall block diagram for the system. Each device will contain a 4011. One
device will contain the transmitter for both radio frequency and ultrasonic while the second device
will contain the receiver for both components.
14
Ultrasonic Receiver Circuit
Figure 10: Ultrasonic Receiver Circuit
Figure 10 displays the ultrasonic receiver circuit. The ultrasonic receiver receives the ultrasonic
receiver from the transmitter and sends it into a level shifting non inverting amplifier. The input
signal is level shifted to centre at 2.5volts. The purpose for this is to eliminate the negative aspect of
the incoming signal. The signal is then amplified by a gain of eleven. The output of the first amplifier
is then fed into the second amplifier on the same chip of the LM358. The LM358 is a dual operational
amplifier consisting of two independent high gain operational amplifiers. The signal is then further
amplified by a gain of 2.8. The output of the second amplifier is fed into a third operational amplifier
which is acting as a voltage comparator. The comparator detects the voltage above a threshold of
0.45volts as high.
15
Possible System Configurations
This subsection describes possible configurations for the system. Each configuration is displayed by
means of a block diagram. Also the advantages and disadvantages will be discussed for each
configuration.
One transmitter & two receivers
Figure 11: 1 Tx & 2 Rx configuration
Figure 11 displays the configuration for a one transmitter and two receivers system. Device A
contains both radio frequency and ultrasonic transmitters were as devices B and C contain just radio
frequency and ultrasonic receivers.
Advantages
Lower power consumption than three transceivers configuration
Disadvantages
Reduced accuracy compared to three transceivers configuration
Unable to display location result
16
Three transceivers
Figure 12: 3 Transceivers configuration
Figure 12 displays the configuration for a three transceivers system. Each device of A, B and C would
contain a radio frequency transmitter and receiver along with an ultrasonic transmitter and receiver.
This would allow each device to communicate with each other. Devices B and C would be located at
fixed points, for example up in a corner of a room, were as device A would be located on the object
which is to be located by the system.
Advantages
Having three transceivers would increase the system accuracy
Time delay can be found between any two devices
Disadvantages
Greater Power consumption because of all three devices
17
PRBS Length
The length of the PRBS signal been transmitted by both the Radio frequency and ultrasonic plays a
key part in this project. A limiting factor would be the amount of RAM in the 4011 which is two
kilobytes. Since there will be two signals arriving at the 4011 the chosen length for the PRBS will
have to 256bytes meaning 512bytes will be taken up by the two signals. To calculate the delay
between the signals cross correlation will occur. Cross correlation will require 1024bytes which is
twice the amount of the two stored signals which is why 1024bytes is required for cross correlation
and not 512bytes. This will now leave 512bytes free to be used up by any variables. There will also
be a small bit of memory left for the slack of the delay between the radio frequency and ultrasonic
signals.
Cross Correlation
Cross correlation is the measure of similarity of two waveforms as a function of a time-lag applied to
one waveform. Cross correlation works by using one signal as a reference and shifting the other
from left to right until the first bit of the reference is in line with the last bit of the second signal. The
result of each shift is added to the previous and the total will be summed together. When the signals
have been correlated a peak will appear when both signals are lined up on top of each other. This
peak determines the delay.
Calculations
In a room 4m*4m there will be a delay between the ultrasonic signal and the radio frequency signal
by the receiver. As Radio frequency is transmitted instantly the ultrasonic will lag behind.
Spatial Resolution
Speed of Sound
PRBS signal can travel 3.4cm in 10us. To travel a room of size 4metres would take:
18
Carrier frequency
Period of Carrier Frequency is 25us
A key point to be tested is how long it will take the 4011 to take one sample.
Sampling Frequency of 200 kHz with a period of 5us
There will be 2 cycles per bit = 10us/sample
Importantly is less than the PRBS length of 256bytes if there are 4 samples per sampled PRBS bit.
Position locating
A possible option to locate an object is to use the cosine rule. Figure 13 displays an example system
configuration. Distances a, b and c will be known by means of the three devices communicating with
each other. Device 1 has the coordinates of (0,0) and device 2 has the coordinates of (B.cos ,
B.sin ). For device 3 coordinates to be found the angle must be calculated using the cosine rule.
Cosine Rule
(
)
Figure 13: Cosine configuration
19
Chapter 4: Testing & Results
Radio Frequency Distance Testing
The first experiment set up was to test the range of the radio frequency transmitter and receiver at
different distances and record the receiver output. This was necessary to discover if the distance
impacts on the receiver output.
Procedure:
Set up Radio frequency equipment as shown below in Figure 14.
Figure 14: Radio Frequency equipment set up
Tests were carried out at different distances between transmitter and receiver.
Test 1 Distance: 137cm
Test 2 Distance: 193cm
Test 3 Distance: 289cm
Figure 15: Distance 137cm
20
Figure 16: Distance 193cm
Figure 17: Distance 289cm
Figure 15, 16 and 17 displays the transmitted and received signal at each chosen distance. A point
seen from gathering these results showed there was a slight delay on the receiver side of approx.
100us. Further tests showed the delay is consistently around 100us and is not dependent on
distance meaning the delay at one metre is the same as the delay at the other side of the room. This
wasn’t expected because it was over such a short distance and RF is instantaneous.
Amplitude of 5volts peak to peak was used and is suitable because it can be picked up within the
whole of testing. This amplitude gives a suitable output signal on the receiver side (Pin2). Obstacles
within the room such as tables, chairs or pillars make little difference to receiver output.
21
Ultrasonic Distance Testing
The objective of this experiment was to test the range of the ultrasonic sensors to get an idea of the
receiver output at different ranges such as one, two and three metres between transmitter and
receiver. The transmitted signal used during this test is 5 volts peak to peak amplitude with a
frequency of 40 kHz originating from a function generator.
Firstly the transmitter and receiver will be placed directly facing each other.
Distance: 1 metre
Distance: 2 metres
Distance: 3 metres
Distance: 4 metres
Following these results the next step was to see the difference between having the receiver facing
straight on with the transmitter and having the receiver at different angles to the transmitter. The
receiver was turned at 30, 60 and 90 degrees away from the receiver at each of the same distances
as before.
22
Table comparing signals at receiver
Distance (metres) Peak to Peak Voltage (mV)
1m 41.6
2m 21.0
3m 10.8
4m 10.1
As the distance between the transmitter and receiver increases the receiver voltage decreases. The
transmitted amplitude of 5 volts peak to peak can be seen on the receiver end up to the 4 metre
test. At 4 metres the peak to peak voltage is quiet small. If the amplitude was doubled to 10 volts
this would provide a higher peak to peak voltage at 4metres or as will be seen in the MAX233 testing
section the overall range can be improved with the addition of the Max233. A key point that was
discovered was that if an object such as a book or even your own hand is placed in the path between
transmitter and receiver the receiver signal will be distorted.
Ultrasonic Angle Testing
The objective of this experiment was to test a suitable angle at which the ultrasonic sensors are still
capable of working at. This is key point in the system design because this will determine how many
transmitters would be needed to cover a full 360 degrees. An example would be if the discovered
suitable angle was 90 degrees then only four transmitters would cover the full 360 degrees to allow
transmission in all directions.
Procedure:
Set up Ultrasonic equipment as shown below in Figure 18.
Figure 18: Ultrasonic Angle Testing set up
23
Distance: 1 metre
Figure 19: Pk – Pk voltage: 1 metre at 30 degrees
Figure 20: Pk - Pk voltage: 1 metre at 60 degrees
Figure 21: Pk - Pk voltage: 1 metre at 90 degrees
24
Distance: 2 metres
Figure 22: Pk - Pk voltage: 2 metres at 30 degrees
Figure 23: Pk - Pk voltage: 2 metres at 60 degrees
Figure 24: Pk - Pk voltage: 2 metres at 90 degrees
25
Distance: 3 metres
Figure 25: Pk - Pk voltage: 3 metres at 30 degrees
Figure 26: Pk - Pk voltage: 3 metres at 60 degrees
Figure 27: Pk - Pk voltage: 3 metres at 90 degrees
Figures 19 to 27 display the receiver peak to peak voltage at different angles to the transmitted. An
angle of 60degrees was found to be suitable allowing the transmitter and receiver to operate
correctly. As the angle and distance increases the voltage decreases. This would now mean six
transmitters would be needed to cover the full 360degrees.
26
Frequency Impact on Receiver
A noticeable point discovered during this testing was the frequency had to be exactly at 40 kHz
to ensure a correct signal could be seen on the receiver. If the frequency goes above or below
this 40 kHz the receiver signal will become distorted and almost drop to zero. Figures 28, 29 and
30 show the impact different frequencies have on the receiver voltage.
Figure 28: 38 kHz
Figure 29: 42 kHz
Figure 30: 40 kHz
27
Max233 Testing
The objective of this experiment was to see if the overall range for the ultrasonic sensors could be
improved; the same ultrasonic distance testing will be done with a max233cpp. A max 233 is usually
powered between 3/5 volts but can increase or shift the voltage much higher if required, possibly
increasing the range of a transmitter if needed. To carry out this test the ultrasonic and max233
equipment will be set up as shown in figure 31. The function generator will generate a 5volts peak to
peak, 40 kHz sine wave which is fed into the max233 chip. The output of the max233 is then
connected to the ultrasonic transmitter to be emitted and picked up by the receiver.
Figure 31: Max233 experiment set up
Distance: 1 metre
Figure 32: Pk - Pk voltage: Straight on Figure 33: Pk - Pk voltage: 30 degrees
28
Figure 34: Pk - Pk voltage: 60 degrees Figure 35: Pk - Pk voltage: 90 degrees
Distance: 2 metres
Figure 36: Pk - Pk voltage: Straight on Figure 37: Pk - Pk voltage: 30 degrees
29
Figure 38: Pk - Pk voltage: 60 degrees Figure 39: Pk - Pk voltage: 90 degrees
Distance: 3 metres
Figure 40: Pk - Pk voltage: Straight on Figure 41: Pk - Pk voltage: 30 degrees
30
Figure 42: Pk - Pk voltage: 60 degrees Figure 43: Pk - Pk voltage: 90 degrees
Figures 32 to 43 display the peak to peak voltage of the receiver from the same distances and angles
as the previous ultrasonic experiments but with the addition of the max233 circuit. A key point seen
from this testing showed the waveform on the receiver side did keep jumping slightly with its peak
to peak voltage varying up and down. A possible cause of this would be an echoing issue, meaning
moving objects or people in the room could affect the results. This not necessarily will be an issue
with the system as the PRBS signal will hopefully eliminate this problem. As can be seen the output
voltage has been greatly increased, meaning the system could operate at a further distance.
31
Transmitting and Receiving Testing
The objective of this experiment was to test if the PRBS signal could be transmitted and received by
the radio frequency and ultrasonic components.
Figure 44: Transmitter Circuit
Figure 45: PRBS Signal Sent by RF and ultrasonic
Figure 44 displays the constructed transmitter circuit. The radio frequency transmitter can be seen
along with a radio frequency receiver. Figure 45 display the modulated PWM and PRBS signal which
is used as the transmission signal. This is the signal which will be sent by radio frequency and
ultrasonic. The delay between the two signals arriving at the receiver is proportional to the distance.
32
Chapter 5: Discussion & Conclusion
Discussion
The overall objective of this project was not met due to arising technical issues throughout the
project duration. The different hardware and software issues encountered along the way did
contribute to a very worthwhile and learning experience. Designing and testing both physical circuits
and software code was challenging and time consuming and turned out to be a difficult aspect of the
project. The distance and angle atesting of both sets of components all lead up to the overall design
of the system.
A number of further development and improvements were suggested for the system through the
project. Initial testing proved the introduction of a max233 voltage driver chip would greatly
increase the system range. A second improvement would the introduction of a display unit to allow
the user to see the calculated distance between transmitter and receiver. An example of this would
be in the three transceivers configuration. Device C receivers the information from device B and
then calculates the distance between itself and device C. The information will then be send on to a
fourth device D and each time it receives new information it will be updated on a PC and available to
be seen by the user.
Problems encountered throughout the project mostly fell on the receiver of the ultrasonic sensor.
The incoming signal could be seen by the receiver but was unable to be amplified to the correct level
for the voltage comparator. The initial proposal on an envelope detector could not be achieved due
to a required time constant been unable to be gotten. A future improvement could be done were an
envelope detector could be achieved using software code. This reduces the amount of circuitry
needed to be designed and built.
33
Conclusion
The objective at the beginning of this project was to experiment to see if an object within a room
could be located using a combination of radio frequency and ultrasonic components. This overall
objective was unsuccessful. The transmission of a modulated PWM and PRBS signal was successful
but the issues were encountered at the receiver end. The included software code generates the
required transmission signal. Although the overall objective was not met, the system configuration I
would have chosen would have been the one transmitter and two receiver’s configuration. At the
time of finishing this report the cross correlation code was not fully completed and is not included in
the report. The full code can be found on my wordpress blog. The range testing of both the radio
frequency and ultrasonic components proved successful in determining the signal strength
decreased with increasing distance. The distance range of the testing was found to be less than
5metres but following testing of the max233 chip this range could be successfully increased with the
addition of the max233.Project management played a key aspect of the project as time keeping and
sticking to deadlines proved to be very important.
34
Appendix A: References 1. GPS Basics
Available http://www.gps-basics.com/faq/q0116.shtml
[Accessed March 2014]
2. W, Mohad Yaakob. W, Bejuri. M Sapri. M Adly Rosly.
Ubiquitous WLAN/Camera Positioning using Inverse Intensity Chromaticity Space-based
feature detection and matching
3. Generation of an Ultrasonic wave
Available http://www.usra.ca/generationofwave.php
[Accessed May 2014]
4. Ultrasonic Technology
Available http://www.hielscher.com/glossary.htm#ultrasound_human
[Accessed March 2014]
5. V, Kamble. D. Makwana. C, Chandramouli. (2007)
Ultrasonic Based Distance Measurement System
EE616 Electronic Design Lab Project Report, EE Dept, IIT Bombay
6. Ultrasonic Applications and Processes
Available http://www.hielscher.com/technolo.htm
[Accessed May 2014]
7. Speed of Sound
Available http://www.physicsclassroom.com/class/sound/Lesson-2/The-Speed-of-Sound
[Accessed March 2014]
8. Speed of Sound through Solids, Liquids and gases
Available https://www.le.ac.uk/se/centres/sci/selfstudy/snd3.htm
[Accessed April 2014]
9. Electromagnetic Radiation
Available http://www.qrg.northwestern.edu/projects/vss/docs/space-environment/2-what-
is-electromagnetic-radiation.html
[Accessed April 2014]
10. Randell, Cliff, and Henk Muller. "Low cost indoor positioning system." Ubicomp 2001:
Ubiquitous Computing. Springer Berlin Heidelberg, 2001.
11. Global Positioning System
Available http://www.gps.ie/
[Accessed April 2014]
35
12. Ibeacon
Available http://meetingofideas.files.wordpress.com/2013/12/ibeacons-bible- 1-0.pdf
[Accessed March 2014]
13. Bat Ultrasonic System
Available http://www.cl.cam.ac.uk/research/dtg/attarchive/bat/
[Accessed March 2014]
14. Pspice
Available http://www.electronics-lab.com/downloads/schematic/013/
[Accessed April 2014]
15. Pulse Width Modulation
Available http://www.embedded.com/electronics-blogs/beginner-s-
corner/4023833/Introduction-to-Pulse-Width-Modulation
[Accessed March 2014]
Appendix B: Software Code
PRBS Generation int a8[]={0,0,0,0,0,0,0,1};
36
int b; int n; int Gen8bitPRBS (); //Generate 8-bit PRBS signal int main(void) { // Configure the PIC configure_pins(); while(1) { for (n=0 ; n<100 ; n++) { b = Gen8bitPRBS();//Output PRBS signal at LATD3 _LATD0 = b; __delay32(100000); // 5000ms delay } printf("%d", b); printf("\n\n"); } return 0; } int Gen8bitPRBS() { int next; next = (a8[0] + a8[1] + a8[5] + a8[7])%2; // Shuffle other elements along to make room a8[0] = a8[1]; a8[1] = a8[2]; a8[2] = a8[3]; a8[3] = a8[4]; a8[4] = a8[5]; a8[5] = a8[6]; a8[6] = a8[7]; a8[7] = next; return next; }
PWM // Configure PWM for free running mode // // PWM period = Tcy * prescale * PTPER = 0.33ns * 1 * PTPER
37
// PWMCON1 = 0x00FF; // Enable all PWM pairs PTCON = 0; _PTCKPS = 0; // prescale=1:1 PTPER = 750; // 33ns *750 = 25us = 40 kHz PDC1 = PTPER; // 50% duty cycle on PWM channel 1 PDC2 = PTPER; // 50% duty cycle on PWM channel 2 PDC3 = PTPER; // 50% duty cycle on PWM channel 3 PTMR = 0; // Clear 15-bit PWM timer counter _PTEN = 1; // Enable PWM time base
38
Appendix C: Circuit Diagram