Documente Academic
Documente Profesional
Documente Cultură
BY
CHOR CIK HAH
2017/2018
ACKNOWLEDGEMENTS
I would like to express my appreciation to those who have given valuable aid and support
throughout the process of my project.
I would also like to thank my friends, Sing Hah and Wai Tong, for giving me fresh
ideas, valuable suggestions and always being there to support me throughout the whole
process of my project
Special thanks also to my family members for being so supportive and patient with
me. Without them, this project may not have been completed is such a short period of time.
ii
ABSTRACT
iii
TABLE OF CONTENTS
ACKNOWLEDGEMENTS ................................................................................................................. ii
ABSTRACT..................................................................................................................................... iii
TABLE OF CONTENTS .................................................................................................................... iv
1.0 INTRODUCTION .......................................................................................................................1
1.1 Background ..........................................................................................................................1
1.2 Problem definition: ..............................................................................................................3
1.3 Project aims .........................................................................................................................4
1.4 Project objectives .................................................................................................................4
1.5 Report Outline......................................................................................................................5
2.0 PROJECT HARDWARE...............................................................................................................5
2.1 Circuit Drawing.....................................................................................................................5
2.2 Receiver Circuit ....................................................................................................................5
2.2.1 Signal amplification circuit .............................................................................................5
2.2.2 Detection circuit ............................................................................................................7
2.2.3 Signal detector...............................................................................................................8
2.2.4 Signal holding circuit......................................................................................................8
2.3 Transmitter Circuit ...............................................................................................................9
2.4 7-segment LED display circuit ...............................................................................................9
2.5 Temperature revision voltage generating circuit................................................................. 10
2.6 Resonator........................................................................................................................... 11
2.7 Power supply circuit ........................................................................................................... 11
3.0 PROJECT SOFTWARE .............................................................................................................. 12
3.1 Range Meter Operation ...................................................................................................... 12
3.2 Ultrasonic Pulse Sending Out Process ................................................................................. 12
3.3 Capture interruption process .............................................................................................. 14
4.0 TESTS, RESULTS AND DISCUSSION ......................................................................................... 14
4.1 Detection operation confirmation ...................................................................................... 15
4.2 Measuring range ................................................................................................................ 16
4.3 Temperature calibration feature ........................................................................................ 16
5.0 CONCLUSIONS AND RECOMMMENDATIONS ......................................................................... 17
5.1 Conclusions ........................................................................................................................ 17
5.2 Recommendations ............................................................................................................. 17
iv
REFERENCES ................................................................................................................................ 18
APPENDIX A: Source code file of Ultrasonic Range Meter ........................................................... 18
Appendix B – Student-Supervisor Log-Book ............................................................................... 25
v
1.0 INTRODUCTION
1.1 Background
Optical Triangulation is one of the oldest forms of distance measurement. All that is
required is that the angle between a single point on an object and two separate views can
be measured together with distance between the two view-points as shown in Figure 1.0.
For the light stripe method, several hundred 2-D measurements of an object surface are
produced up to sixty times per second. A light stripe system uses a 2-D CCD sensor and a
light stripe generator as shown in Figure 1.1. The image formed of the projected light
stripe will reveal the shape of the surface if viewed from an angle. The shape of the imaged
stripe vary depending on distance each point on the surface is away from the instrument.
1
Photogrammetry is a non-contact multiple point measuring tool that is capable of high
accuracy measurement of 10 to more than 1000 points simultaneously. It typically provides
high accuracy results between 1 part in 5000 to 1 part in 150,000 of the largest dimension
of the object being measured. Photogrammetry uses images of an object taken from a
variety of directions as shown in Figure 1.2.
Time of flight services use the time taken for light or sound to travel to a surface and
return. The biggest advantage of these systems over triangulation systems is the sent and
returned light rays are usually co-axial. Ultrasonic rangefinders use sound to measure
distance with an accuracy of a few centimeters, over a range of a few meters, at a rate of
milliseconds to several seconds per sample. Sound waves propagate from the transmitter
and bounce off objects, returning an echo to the receiver as shown in Figure 1.3.
2
Interference measuring techniques that use interference usually provide relative
measurements rather than absolute, The distance to an object can only be known relative to
another by zeroing the counter to a reference position. Laser trackers as shown in Figure
1.4 provide a relatively fast, precise and intuitive method of measuring large objects in
industrial environments.
The features of ultrasonic ranging which makes it suitable for mobile robot navigation in
various terrains include the ability to work with almost any surface type, resistant to
vibration, radiation, background light and noise, largely unaffected by dust or dirt and long
distance measurements of up to 10 meters.
3
1.3 Project aims
4
1.5 Report Outline
The report consists of five chapters: (i) Introduction, (ii) Project hardware, (iii) Project
software, (iv) Tests, results, and discussion, and (v) Conclusions and recommendations.
Chapter 1 provides an overview of the project background, problem definition, aims, and
objectives. Chapter 2 discusses the hardware involved in terms of the circuits and parts
used. Chapter 3 discusses the program and processing used while chapter 4 explains the
performance testing. Chapter 5 concludes on the project work carried out.
Figure 2.1 shows the circuit drawing of the developed ultrasonic range meter system. The
circuit consists of six parts, namely: (i) receiver circuit, (ii) transmitter circuit, (iii) 7-
segment LED display circuit, (iv) temperature revision voltage generating circuit, (v)
resonator, and (vi) power supply circuit. Figure 2.2 shows the pattern drawing for the
ultrasonic range meter. Figure 2.3 shows the developed prototype.
The receiver circuit consists of four subcircuits: (i) signal amplification circuit, (ii)
detection circuit, (iii) signal detector, and (iv) signal holding circuit.
The ultrasonic signal which was received with the reception sensor is amplified by 1000
times(60dB) of voltage with the operational amplifier with two stages as shown in Figure
2.4. It is 100 times at the first stage (40dB) and 10 times (20dB) at the next stage.
5
Figure 2.1: Circuit diagram of overall ultrasonic range meter system
Figure 2.2: PCB pattern drawing for the ultrasonic range meter.
6
Figure 2.3: Ultrasonic range meter prototype.
Generally, the positive and negative power supply are used for the opamp. The circuit this
time works with the single power supply of +9 V. Therefore, for the positive input of the
operational amplifiers, the half of the power supply voltage is appied as the bias voltage.
Then the alternating current signal can be amplified on 4.5V central voltage. When using
the operational amplifier with the negative feedback, the voltage of the positive input
terminal and the voltage of the negative input terminal become equal approximately. This
is called virtual grounding. So, by this bias voltage, the side of the positive and the side of
the negative of the alternating current signal can be equally amplified. When not using this
bias voltage, the distortion causes the alternating current signal. This technique is often
used when using the opamp which needs two kinds of powers in the single power.
The detection is done to detect the received ultrasonic signal. This is the half-wave
rectification circuit with Shottky barrier diodes as shown in Figure 2.5. The DC voltage
according to the level of the detection signal is output to the capacitor behind the diode.
The Shottky barrier diodes are used because the high frequency characteristic is good.
7
2.2.3 Signal detector
The signal detector circuit as shown in Figure 2.6 is the circuit which detects the ultrasonic
which returns from the measurement object. The output of the detection circuit is detected
using the comparator. At the circuit this time, the operational amplifier of the single power
supply is used instead of the comparator. The operational amplifier amplifies and outputs
the difference between the positive input and the negative input.
In case of the operational amplifier which doesn't have the negative feedback, the output
becomes the saturation state by a little input voltage. Generally, the operational amplifier
has over 10000 times of mu factors. So, when the positive input becomes higher a little
than the negative input, the difference is tens of thousands of times amplified and the
output becomes the same as the power supply almost.(It is the saturation state) Oppositely,
when the positive input becomes lower a little than the negative input, the difference is tens
of thousands of times amplified and the output becomes 0 V almost.(It is in the OFF
condition) This operation is the same as the operation of the comparator. However,
because the inner circuit of the comparator is different from the operational amplifier, the
comparator can not be used as the operational amplifier.
The signal holding circuit of Figure 2.7 is the holding circuit of detected signal. SR ( Set
and Reset ) flip-flop is used. The detector is made to be not operate in the constant
time(About 1.5 milliseconds) after sending out a transmission pulse to prevent from the
wrong detection which is due to the influence of the transmission pulse. This operation is
controlled with the software of PIC.
When using the capture feature of PIC, this circuit isn't indispensable. Capture operation is
done by the change of the capture input in the once. The reason for using this circuit is to
confirm signal detection operation within the reflected signal detection time(About 65
milliseconds). When sending out next ultrasonic pulse, the output of this circuit is checked.
And when the output is L level, an error display is done because the reflected signal could
not be detected.
8
Figure 2.6: Signal detector circuit.
Figure 2.7: Signal holding circuit
The inverter in Figure 2.8 is used for the drive of the ultrasonic sensor. The two inverters
are connected in parallel because of the transmission electric power increase. The phase
with the voltage to apply to the positive terminal and the negative terminal of the sensor
has been 180 degrees shifted. Because it is cutting the direct current with the capacitor,
about twice of voltage of the inverter output are appied to the sensor.
The power supply voltage of this drive circuit is +9V. It is converting voltage with the
transistor to make control at the operating voltage of PIC(+5V). Because C-MOS inverters
are used, it is possible to do ON/OFF at high speed comparatively.
Three 7 segment LEDs are used for 3-digit display as shown in Figure 2.9. As for the
lighting-up of the LED, 1 digit is displayed in the order with the software of PIC. At the
circuit this time, The LEDs light up it when the terminal of PIC is L level. So, ANODE
COMMON type is used as the LED. The anode common type is the type which the side of
the positive(Anode) of the LED is connected inside. It lights up when grounding(L level) a
cathode in the segment to want to make light up.
9
Figure 2.8: Transmitter Circuit Figure 2.9: 7-segment LED display
circuit
The temperature revision voltage generating circuit is as shown in Figure 2.10. The sound
wave propagation speed in air is changed by the temperature. At 0°C, it is 331.5m/sec. At
40°C, it is 355.5m/sec. This range meter calculates a distance by dividing the propagation
time which was measured by the capture feature.
The time which the sound wave takes to go and return is 2m/331.5m/sec = 0.006033
seconds = 6.033 milliseconds. The contents of the counter by the capture feature is 6033
within 1 microsecond. For the conversion of this to distance (cm), it divides by 60. It is
6033/60=100.55. The following of the decimal point is cut off. It becomes a measurement
error. This conversion value (60) depends on the temperature. It isn't related with the
distance to measure. In case of 9 m, it is 54298/60=904.9. The conversion error becomes
big when the distance becomes long. This is because it isn't possible to do conversion
10
below the decimal point. In case of 40°C, it is 2m/355.5m/sec = 5625 microseconds and
the conversion value is 56. The conversion value should be changed by the ambient
temperature. At this range meter, a conversion value is generated using the A/D conversion
feature. The A/D converter converts input voltage into the 10-bit digital data. Using upper
3 bits, the A/D conversion result from 0V to 5V is the value from 0 to 7. And 54 is added
to this value. Then, the conversion value range is from 54 to 61.
2.6 Resonator
A 4-MHz resonator is used in the relation of the timer in the count time as shown in Figure
2.11. When using 4-MHz clock, it is 1 microsecond per count for the counter count up
time. Timer1 to use for capture is a maximum of 65535 counts(16 bits). So, a maximum of
65.535 milliseconds count is made. The propagation speed of the sound in air is 343
m/second in case of 20°C. In the time which goes and returns in the 10-m distance, it is
20m/343m/sec = 0.0583 seconds (58.3 milliseconds). As the range meter this time, it is an
exactly good value.
The voltage of +5V and +9V are made with +12V power supply using the 3 terminal
regulator as shown in Figure 2.12. +9V are used for the transmitter and the receiver. 100-
mA type is used because few needed electric currents.
In other circuit, +5V is used. +5V voltage is used for the lighting-up of LEDs, because they
are controlled by PIC. The about 10-mA electric current per segment flows through the
LED. So, it becomes about 80 mA when all segments(eight) light up.
11
3.0 PROJECT SOFTWARE
The range meter detects a reflected wave from the object after sending out a ultrasonic
pulse. By measuring the time which returns after emitting a sound wave, a distance to the
object is measured. The operation as shown in Figure 3.1 is repeatedly executed. LED
display processing is executed in parallel with this operation.
12
(iii) Stop the reflected wave detector
Immediately after letting out a transmission pulse, the influence occurs to the receiver
circuit and there is possibility of wrong detection. To prevent this, the operation of the
reflected wave detector is stopped. RA4 is an open type and an external resistor is needed.
13
3.3 Capture interruption process
The following tests were performed to test the performance of the Ultrasonic Range Meter:
(i) Detection operation confirmation
(ii) Measuring range
(iii) Temperature calibration feature
14
4.1 Detection operation confirmation
The photograph shown in Figure 4.1 is the one to have observed the signal when
measuring a 2.36m distance. Observation points are shown below.
(1) is 1st pin of IC1 ( It is a signal after the amplification with the operational amplifier. )
(2) is 8th pin of IC3 ( It is a detection holding circuit gate signal by PIC. )
(3) is 11th pin of IC3 ( It is an output signal of the detection holding circuit. )
When (2) is an L level, the detector stops. You can find that a malfunction by the
transmission pulse is prevented. The prevention time of this circuit is about 1.5
milliseconds. There is possibility to malfunction when short any more.
Some feeble reflection signals are received until it detects a reception pulse. Because the
threshold voltage of the signal detector of IC2 is working effectively, those feeble signals
are not detected.
The signal of (3) changes to H level from L level when detecting a reception pulse. This
signal is detected by the capture feature of PIC and the propagation time of the ultrasonic is
measured.
15
4.2 Measuring range
The ultrasonic transmission time of this Meter is 0.5 milliseconds. So, it isn't possible to do
long-range measurement.
Most short : 29 cm
distance This distance is decided by the time to prevent from an influence by
the transmission pulse. When measuring a long distance, the sending-
out time of the transmission pulse must be expanded. In this case, it is
necessary to expand in the prevention time, too, and the shortest
measurement distance becomes long.
Most long distance : 3.6 m
This distance is decided by the length of the transmission pulse. The
ultrasonic energy becomes big when the transmission time is long and
the long-range measurement is possible. However, as the explaining
at the most short distance, the shortest measurement distance becomes
long.
The test was conducted for a distance measurement of 1 m as shown in Figure 4.2. The
temperature to display 1.00 is a calculation value. At this equipment, it isn't possible to do
an adjustment with detailed calibration value. It is 8 steps. So, it is a reference value. To
change a calibration range, the change of the software processing by the value which A/D
converted is needed.
When doing this confirmation, the opposite connection of the calibration resistor was
erroneous. The connection in the center is right but the connection in the both edges is
opposite. It was intended to turn to the right when the ambient temperature was high.
However, the actual operation is opposite. Because it is not in the problem in case of
practical use, it was therefore not changes. A schematic and a pattern drawing are
corrected.
16
Dial Temperature
Display
condition for displaying 1.00
Full turn
to right 0.98 8.6°C
Full turn
to left 1.11 83.0°C
5.1 Conclusions
5.2 Recommendations
17
REFERENCES
[1] Clarke, T. and Williams, M. (1999), Buyers Guide to Six Non-contact Distance
Measuring Techniques. Retrieved May 12, 2012, from http://www.optical-metrology-
centre.com: http://www.optical-metrology-
centre.com/Downloads/Papers/Quality%20Today%201999%20Buyers%20Guide.pdf
list p=pic16f873
include p16f873.inc
__config _hs_osc & _wdt_off & _pwrte_on & _lvp_off
18
seg7a ;Pattern A set adr
seg7b ;Pattern B set adr
endc
19
movwf digit_cnt ;Set digit counter
movlw seg70 ;Set 7seg head address
movwf seg7_ha ;Save 7seg head address
movlw seg7_0 ;Set 7segment pattern 0
movwf seg70 ;Save pattern 0
movlw seg7_1 ;Set 7segment pattern 1
movwf seg71 ;Save pattern 1
movlw seg7_2 ;Set 7segment pattern 2
movwf seg72 ;Save pattern 2
movlw seg7_3 ;Set 7segment pattern 3
movwf seg73 ;Save pattern 3
movlw seg7_4 ;Set 7segment pattern 4
movwf seg74 ;Save pattern 4
movlw seg7_5 ;Set 7segment pattern 5
movwf seg75 ;Save pattern 5
movlw seg7_6 ;Set 7segment pattern 6
movwf seg76 ;Save pattern 6
movlw seg7_7 ;Set 7segment pattern 7
movwf seg77 ;Save pattern 7
movlw seg7_8 ;Set 7segment pattern 8
movwf seg78 ;Save pattern 8
movlw seg7_9 ;Set 7segment pattern 9
movwf seg79 ;Save pattern 9
movlw seg7_a ;Set 7segment pattern A
movwf seg7a ;Save pattern A
movlw seg7_b ;Set 7segment pattern B
movwf seg7b ;Save pattern B
movlw b'00011110' ;OPS=1:4,T2=ON,EPS=1:16
movwf t2con ;Set T2CON register
bsf status,rp0 ;Change to Bank1
movlw d'157' ;157x64=10048usec
movwf pr2 ;Set PR2 register
bsf pie1,tmr2ie ;TMR2IE=ON
bcf status,rp0 ;Change to Bank0
wait
goto $ ;Interruption wait
20
retfie
21
goto g_loop1 ;No. Continue
goto int_end
division
movfw s_adj ;Read adjustment data
subwf ccpr1l,f ;Capture - adjust
btfsc status,z ;Result = 0 ?
goto division2 ;Yes. "R = 0"
btfsc status,c ;Result < 0 ?
goto division1 ;No. "R > 0"
goto division3 ;Yes."R < 0"
division1 ;( R > 0 )
movlw d'1' ;Set increment value
addwf p_countl,f ;Increment L count
btfss status,c ;Overflow ?
goto division ;No. Continue
incf p_counth,f ;Increment H count
goto division ;Jump next
division2 ;( R = 0 )
movfw ccpr1h ;Read CCPR1H
btfss status,z ;CCPR1H = 0 ?
goto division1 ;No. Next
movlw d'1' ;Set increment value
addwf p_countl,f ;Increment L count
btfss status,c ;Overflow ?
goto digit_set ;Jump to digit set
incf p_counth,f ;Increment H count
goto digit_set ;Jump to digit set
division3 ;( R < 0 )
movfw ccpr1h ;Read CCPR1H
btfss status,z ;CCPR1H = 0 ?
goto division4 ;No. Borrow process
goto digit_set ;Jump to digit set
22
division4
decf ccpr1h,f ;CCPR1H - 1
movlw d'255' ;Borrow value
addwf ccpr1l,f ;CCPR1L + 255
incf ccpr1l,f ;CCPR1L + 1
goto division1 ;Next
digit_h1 ;( R > 0 )
incf disp_h,f ;Increment 100th count
goto digit_h ;Jump next
digit_h2 ;( R = 0 )
movfw p_counth ;Read H counter
btfss status,z ;H counter = 0 ?
goto digit_h1 ;No. Next
incf disp_h,f ;Increment 100th count
goto digit_t ;Jump to 10th digit pro
digit_h3 ;( R < 0 )
movfw p_counth ;Read H counter
btfss status,z ;H counter = 0 ?
goto digit_h4 ;No. Borrow process
movlw d'100' ;Divide value
addwf p_countl,f ;Return over sub value
goto digit_t ;Jump to 10th digit pro
digit_h4
decf p_counth,f ;H counter - 1
movlw d'255' ;Borrow value
addwf p_countl,f ;L counter + 255
incf p_countl,f ;L counter + 1
goto digit_h1 ;Next
digit_t0
movlw d'10' ;Divide value
23
subwf p_countl,f ;Digit - divide
btfsc status,z ;Result = 0 ?
goto digit_t1 ;Yes. "R = 0"
btfsc status,c ;Result < 0 ?
goto digit_t1 ;No. "R > 0"
goto digit_t2 ;Yes."R < 0"
digit_t1 ;( R >= 0 )
incf disp_t,f ;Increment 10th count
goto digit_t ;Jump next
digit_t2 ;( R < 0 )
movlw d'10' ;Divide value
addwf p_countl,f ;Return over sub value
goto digit_u ;Jump to 1st digit pro
goto int_end
c_digit
decf digit_cnt,w ;Digit count - 1
addwf disp_ha,w ;Digit H.Adr + count
movwf fsr ;Set FSR register
movfw indf ;Read digit
addwf seg7_ha,w ;Seg7 H.Adr + digit
movwf fsr ;Set FSR register
movfw indf ;Read seg7 data
movwf portb ;Write LED data
;********************************************************
; END of Ultrasonic Range Meter
;********************************************************
en
24
Appendix B – Student-Supervisor Log-Book
8am,
1. 24/9
C300 Determined the project, ultrasonic range meter, and required resources none, progress achieved
8am,
2. 1/10
C300 submission of draft proposal Did not state the project schedule, please indicate project schedule.
8am,
3. 8/10
C300 Resubmission of proposal none, progress achieved
8am, Construct minimal microcontroller circuitry and verify operation, develop interfacing
4. 15/10
C300 circuitry to 7-segment displays, verify operation,
none, progress achieved
8am, Develop interfacing circuitry to ultrasonic transducers and verify operation using
5. 22/10
C300 oscilloscope.
circuit problem, need to troubleshoot
25
Appendix B – Student-Supervisor Log-Book
8am,
7. 5/11
C300 Develop an application to transmit and detect ultrasonic pulses. none, progress achieved
8am,
8. 12/11
C300 Develop an application for distance measurement using ultrasonic pulses. inaccurate results, check temperature effect
8am,
10. 26/11
C300 System integration, testing and verification
none, progress achieved
26
Appendix B – Student-Supervisor Log-Book
8am,
12. 10/12
C300 Report submission
minor modifications and corrections.
8am,
14. 24/12
C300 Presentation
none, progress achieved
27