<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">WJET</journal-id><journal-title-group><journal-title>World Journal of Engineering and Technology</journal-title></journal-title-group><issn pub-type="epub">2331-4222</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/wjet.2024.122022</article-id><article-id pub-id-type="publisher-id">WJET-133083</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Chemistry&amp;Materials Science</subject><subject> Engineering</subject></subj-group></article-categories><title-group><article-title>
 
 
  Ultrasound Ranging with Selective Zone
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Libo</surname><given-names>Deng</given-names></name><xref ref-type="aff" rid="aff1"><sub>1</sub></xref></contrib></contrib-group><aff id="aff1"><label>1</label><addr-line>CCTEG Xi&amp;amp;#8217;an Research Institute, Xi&amp;amp;#8217;an, China</addr-line></aff><pub-date pub-type="epub"><day>28</day><month>03</month><year>2024</year></pub-date><volume>12</volume><issue>02</issue><fpage>339</fpage><lpage>361</lpage><history><date date-type="received"><day>2,</day>	<month>March</month>	<year>2024</year></date><date date-type="rev-recd"><day>10,</day>	<month>May</month>	<year>2024</year>	</date><date date-type="accepted"><day>13,</day>	<month>May</month>	<year>2024</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p>
 
 
  The technology of ultrasonic measurement has been widely applied in many fields in recent years. It has already been researched for almost 40 years and its application in both residential use and military are mature and well-developed. One of the advanced uses is for reversing a car and it is based on sending sound waves through a specific medium and observing the returning echoes to measure the distance from the device to the obstacle. In this report, a simple ultrasonic distance measurement system will be introduced including the design of hardware and software, the simulating results and the final product. This system was built to be cheaper, requires less power and delivers better performance.
 
</p></abstract><kwd-group><kwd>Ultrasound</kwd><kwd> Selective Zone</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>With the rapid development of automobile industry, especially in recent years, the world has begun to step into the era of private cars. As the number of vehicles has increased year by year, the traffic has become increasingly crowded in some places, for example, highways, streets, parking lots and garages. The driver feels worried about the safety of the car and one of the most important saturation is the reversing. Due to the driver cannot know and see clearly the distance from the end of the car to barrier which can be a wall, stone, pedestrian or animal, lots of accidents happen every year. A research shows that there are approximately more than 10,000 traffic accidents per year in reversing-car [<xref ref-type="bibr" rid="scirp.133083-ref1">1</xref>] . This problem has been paid more attention by the society and traffic department.</p><p>To find a way to solve the problem above, the reversing radar was born. This system can help driver to know how far between the object and the car, and reduce the frequency of accident to a large extent. Most vehicles installed in this system have a new name “smart car” [<xref ref-type="bibr" rid="scirp.133083-ref2">2</xref>] . The development of “smart car” requires new sensors that are able to measure distances in the range of a few centimeters to a few meters. Parking aids, as well as intelligent suspensions and headlight leveling, are some examples of features that require a distance measurement to be performed with contactless sensors. Several different physical principles can be employed to measure the distance, but price limits greatly restrict the actual choice.</p><p>An interesting possibility, which has been investigated by several authors, is the use of ultrasonic sensors based on the well-known time of flight technique [<xref ref-type="bibr" rid="scirp.133083-ref3">3</xref>] . Such sensors are reasonably cheap and work for ranges of up to a few meters, even though problems arise regarding both their accuracy and their behavior in noisy open-air conditions.</p><p>In this paper, the author describes a low-cost ultrasonic distance measurement system, which is about design and development of an ultrasound ranging with selective zone. It is concerned with the design of an ultrasound distance measuring system. Two ultrasound transducers will be used to measure the distance from a target, one is for transmit and the other one is for receive. If the measured distance falls with a set range, for example 3.5 - 4 meters, the system will generate an alarm signal and produce an audio signal via a small speaker.</p><sec id="s1_1"><title>1.1. The Aim of This Project</title><p>The objective of this project is that realizing the principle of ultrasound and how to solve the real application using the ultrasound distance measuring system. Indeed, it can be used in a car or alarm when somebody passes or goes through the active range that is set up before. In this project, the microcontroller will be used to control the signal of transmit and receive, also create an alarm signal when the detect distance is lesser than the fixed value which is set by the programming. Consequently, this is a good opportunity to practice the MCU and programming. Moreover, the communicative competence should be improved to a large extent. For example, it is necessary to ask for help from supervisor or classmates in the period of doing the project.</p><p>In another word, by completing this individual project, it is a useful training for the further professional career. The main objective of this project is illustrated as below.</p><p>&#183; Understanding the operating principle and structure function of MCU in detail.</p><p>&#183; Absorb the process of wire arrangement in PCB.</p><p>&#183; Grasp the method for testing and correcting the error of circuit.</p><p>In a word, the ability of putting the theory applies to the practice will be developed at the end of the project. It is meaningful to lay a solid foundation for job in the future.</p></sec><sec id="s1_2"><title>1.2. Summary of the Report Structure</title><p>This report will describe a simple ultrasonic distance measurement system. It is divided into 6 main chapters, including introduction, the review of commercial systems, hardware design and software design, the final results and products, and conclusion, respectively. Specifically, the hardware can be separated by 4 parts which are transmit circuit, receive circuit, display circuit and alarm circuit. Meanwhile, the software is using the C language to program the MCU for control the hardware. And then, according to test the circuit, the simulating result will be given. After that, the picture of final product will be pasted on this report.</p></sec></sec><sec id="s2"><title>2. Individual Design</title><p>To achieve the requirement of this project, a circuit based on 51 series MCU (This component will be introduced on the next chapter) will be introduced in this part. The basic block diagram of this system is shown in <xref ref-type="fig" rid="fig1">Figure 1</xref>.</p><p>The central MCU is for controlling the drive circuit to transmit a 40 KHz sine wave. This signal will arrive in an object, such as a wall or rocks. Then it would return back to another senor, which is for receiving. The period of time will be measured by the MCU and calculated the final distance at the same time. After that, the final distance will be displayed on the 7-segment LED displays. If the distance is lower than the range, which is set before, an alarm signal will be produced by the MCU. In addition, due to the temperature could make a little different to the speed of ultrasonic transmission, the actual temperature will also be provided to figure out the distance by temperature measurement circuit. In a word, all of the specific process will work correctly by programming the MCU.</p><p>The project contains two main modules, which are hardware circuit design and software design. Indeed, a variety of software should be used for circuit design and test in some situation. For example, the principle circuit can be design by the Multisim, the PCB board can be created by the Protel 99, and the Keil uvision 2 can be used to program the MCU. Meanwhile, the hardware includes transmit circuit, receive circuit, display circuit and alarm circuit. All of the software and hardware will be described more specifically in next 2 chapters.</p><sec id="s2_1"><title>2.1. The Basic Brief of This Project</title><p>The Ultrasonic wave propagation velocity in the air is approximately 340 m/s at</p><p>15˚C of air or atmospheric temperature, the same as sonic velocity. To be precise, the ultrasound velocity is governed by the medium and its temperature, hence the velocity in the air is calculated using the formula below.</p><p>V = 340 + 0.6 ( t − 15 ) m / s</p><p>t: temperature, ˚C [<xref ref-type="bibr" rid="scirp.133083-ref4">4</xref>] .</p><p>In this project, a room temperature of 20˚C is assumed, thus the velocity of ultrasound in the air is taken as 343 m/s. Due to the travel distance is very short, the travel time is little affected by temperature. For example, it takes approximately 29.15 μsec for the ultrasound to propagate waves through 1 cm distance [<xref ref-type="bibr" rid="scirp.133083-ref5">5</xref>] . Hence, this system has about 1 cm resolution when measuring the distance.</p><p>The fixed range will be set approximately 1.0 meter by using the MCU. When the real-distance fall within 1 meter, the speaker that is located in alarm circuit module will make a piece of audio. As the real-distance is gradually close, the frequency of sound is increasing continuously. In other words, taking a car-parking as an example, this different frequency indicates the different gap between the obstruction and the vehicle. It is a useful warning for drivers to realize how close the distance is. Without doubt, the MCU determines this fixed range by using its internal timer (This process will be described in the next chapter).</p></sec><sec id="s2_2"><title>2.2. The List of Components</title><p>All the components which have been used in this project are shown as the <xref ref-type="fig" rid="fig2">Figure 2</xref>.</p></sec></sec><sec id="s3"><title>3. Hardware Design</title><p>The detail of the main hardware design would be described in this chapter, including the transmit circuit, receive circuit, display circuit and alarm circuit, respectively. For understanding easily, some components will be introduced if it is necessary. Most of the circuit pictures are picked from the Protel99.</p><sec id="s3_1"><title>3.1. Transmit Circuit</title><p>For generating the transmit ultrasonic signal, the circuit could get a signal waveform by editing the program of MCU and it will work as a driving circuit which is propose to provide a high enough current to drive the ultrasonic wave transmitter. If a hardware circuit will be used to generate this signal, it should be designed as the specified ultrasonic generating circuit with a fixed frequency. This circuit could drive the transmitter directly.</p><p>As the <xref ref-type="fig" rid="fig3">Figure 3</xref> and <xref ref-type="fig" rid="fig4">Figure 4</xref> shows, the way of using software to generate the</p><p>signal has the advantage of higher flexibility. So in this project, the P1.0 of AT89c51 will generate a 40 KHz pulse and then go though the 74HC04 [<xref ref-type="bibr" rid="scirp.133083-ref6">6</xref>] to amplifier the output waveform. The 74HC04 is a high-speed CMOS inverter with amplification, symmetrical propagation delay and transition time. Compared with the LSTTL logic IC, it has low power consumption and the operation voltage is 2 - 6 V. In this circuit, the output waveform is stable by using the 74HC04.</p></sec><sec id="s3_2"><title>3.2. Receive Circuit</title><p>The receiving circuit consists of three parts: the ultrasonic receiver, the simple filter circuit, the amplifier circuit and the waveform converting circuit. The ultrasonic receiver should be matched with the transmitter for they must be sensitive to a same frequency. Otherwise, the effects of receiver will be influenced.</p><p>As the <xref ref-type="fig" rid="fig5">Figure 5</xref> and <xref ref-type="fig" rid="fig6">Figure 6</xref> shows, for the strength of received signal always</p><p>be very week, sometimes the voltage is only around 10 mV, it is quiet easy to be influenced by the interference signal, especially the 40 KHz electrified wire netting signal. So a simple high-pass filter, which has a 40 KHz pass frequency. In addition, the amplification factor could be accessible to control for it must be changed in diver environment.</p><p>A waveform converting circuit is necessary because the received signal is an AC sinusoidal signal while the input of MCU must be a pulse signal. In this situation, The CX20106A [<xref ref-type="bibr" rid="scirp.133083-ref8">8</xref>] is an infrared receiver dedicated chip, commonly used in television infrared remote control. Its carrier frequency is 38 KHZ which is more similar to 40 KHZ. So, the CX20106A should be a center of the receiving circuit.</p></sec><sec id="s3_3"><title>3.3. Display Circuit</title><p>The common anode seven-segment LED will be used in this circuit and controlled by the MCU. The PNP transistor drive the LEDs, (8550 is used in this design). The drive capability of the I/O port is very small and P0 should be pull-up by the external resistor to increase drive capacity. There is one thing should be noticed, when the voltage level is low, it possibly burn microcontroller due to the current flows into the I/O is too large. So the pull-up resistor is generally 600 Ω to 1000 Ω. The experiments show that the digital tube is bright by using this range of value. Its schematic diagram is shown in <xref ref-type="fig" rid="fig7">Figure 7</xref>.</p></sec><sec id="s3_4"><title>3.4. Alarm Circuit</title><p>According to the requirements of the project, the system just needs to provide an alarm audio. So, the PNP transistors should be used in driving the speaker. However, the frequency of the audio signal is controlled by the MCU. It has been described that the frequency of the signal will be rise as the distance is close. The circuit design is shown as <xref ref-type="fig" rid="fig8">Figure 8</xref>.</p></sec><sec id="s3_5"><title>3.5. The Circuit around AT89C51</title><p>The AT89C51 is a low-power, high-performance CMOS 8-bit microcontroller with 4 K bytes of In-System Programmable Flash memory. The device is manufactured using Atmel’s high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with In-System Programmable Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications. <xref ref-type="fig" rid="fig9">Figure 9</xref> shows the AT89C51 on the software.</p><sec id="s3_5_1"><title>3.5.1. The Internal Structure of the Microcontroller</title><p>As the <xref ref-type="fig" rid="fig1">Figure 1</xref>0 shows, the AT89C51 consists of the following components: central processing unit (CPU), oscillation circuit, the internal bus, program memory and data memory, timer/counter, I/O port, serial port and interrupt system.</p></sec><sec id="s3_5_2"><title>3.5.2. Crystal Oscillator Characteristics</title><p>There is a high-gain inverting amplifier used to constitute the internal oscillator. The XTAL1 and XTAL2 are input and output of the inverting amplifier.</p><p>External quartz crystal (12.0 MB) and C1, C2 constitute a parallel oscillating circuit connected to the amplifier feedback loop. Although there are not very stringent requirements on external capacitors C1, and C2, if using a quartz crystal, capacitors should be 30 pF &#177; 10 pF. The circuit is shown in <xref ref-type="fig" rid="fig1">Figure 1</xref>1.</p></sec></sec></sec><sec id="s4"><title>4. Software Design</title><p>In this chapter, some softwares which are used in this system will be described</p><p>and the programming for AT89C51 will be explained. For example, the Protel99 is used in two part, simulation circuit diagram and PCB design.</p><sec id="s4_1"><title>4.1. The Application of Protel99</title><sec id="s4_1_1"><title>4.1.1. Introduction of Protel99</title><p>Protel 99 SE—a complete 32-bit electronic design system for Windows and provides a completely integrated suite of design tools that lets us easily take your designs from concept through to final board layout. Some of the powerful features of Protel 99 SE are used in this project. Not only capturing a schematic and running a transient simulation on the design, but also designing and routing a PCB, all with the integrated tools provided in it [<xref ref-type="bibr" rid="scirp.133083-ref9">9</xref>] .</p><p>With faster logic switching and design clock speeds, the quality of the digital signals becomes more important. Protel 99 SE includes a sophisticated signal integrity analysis tool that can accurately model and analyze your board layout. The signal integrity requirements such as impedance, overshoot, undershoot, and slope are defined as PCB design rules, and then tested during the standard design rule check. If there are nets that you need to analyze in more detail you can select Tools and then Signal Integrity to pass the design to the Signal Integrity Analyzer, where you can perform reflection and cross talk simulations. The results are displayed in an oscilloscope-like waveform analyzer, where you can examine the performance and take measurements directly from the waveforms.</p></sec><sec id="s4_1_2"><title>4.1.2. The Schematic Circuit and the PCB Diagram</title><p><xref ref-type="fig" rid="fig1">Figure 1</xref>2 shows that schematic diagram and final PCB diagram of this project.</p><p>For capturing the correct schematic circuit, 4 basic steps should be finished. Firstly, open the Protel99 SE and create a new schematic sheet. Secondly, set the schematic options. For example, the size is A4. Then, draw the schematic. Finding every component needed in the library and connecting them as the design on the schematic diagram. Finally, check the electrical properties of the circuit. In detail, selecting the tools and clicking the ERC button, it will generate an ERC report from the circuit.</p><p>For achieving the PCB diagram, there are 7 steps should be completed. It will be described in in order, creating a new PCB file, adding the PCB footprint libraries and transferring the design, defining the layer stack and other</p><p>non-electrical layers, setting up new design rules, positioning the components on the PCB, automatically routing the board, verifying your board design, printing to a Windows printing device.</p></sec></sec><sec id="s4_2"><title>4.2. The Programming for AT89C51</title><p>The AT89C51 is programmed by C language in the surrounding of Keil version 4, and then the program is downloaded to the device. In this chapter, the flow chart of program will be listed.</p><disp-formula id="scirp.133083-formula1"><graphic  xlink:href="//html.scirp.org/file/8-1561496x17.png?20240513091541620"  xlink:type="simple"/></disp-formula></sec></sec><sec id="s5"><title>5. Error Analysis and Testing Result</title><p>In the previous chapters, the simulating results of each parts of circuit have been indicate, which is based on a software test. In this part, the practical circuit making process and testing result will be shown in the form of photograph, which is completed in the lab.</p><p>1) The handmade circuit broad (testing) making process (<xref ref-type="fig" rid="fig1">Figure 1</xref>3 and <xref ref-type="fig" rid="fig1">Figure 1</xref>4)</p><p>2) Testing and debugging the hardware and software</p><p>In this system, the design of hardware and software are modularized, which makes the system debugging extremely convenient. Every module should be detected first, then put them together. This can improve the efficiency of debugging to a large extent and accelerate the schedule of the project.</p><p>Hardware debugging can be started from every functional modules of the program, until all of the program work correctly. There are 3 main announcements should be paid more attention.</p><p>&#183; When installing the 2-ultrasonic transducers, they must be parallel and separated by 3 cm.</p><p>&#183; For achieving the suitable sensitivity of receiver and anti-jamming capability, the value of capacitor C4 could be adjusted appropriately.</p><p>&#183; When soldering the component, the temperature should not be too higher. Otherwise, it is easily to damage the device more or less and make the total system paralyzed. In addition, this error cannot be found easily.</p><p>When the hardware circuit was manufactured and detected completely, the program will be edited and tested in the software. After that, the program should download to the MCU and test run it. According to the specific result, correcting the program repeatedly until the result is identical with presumptive purpose. In a word, both software and hardware debugging cannot be separated, because some researches confirm that the error of hardware was found and corrected in general.</p><p>3) Error analysis</p><p><xref ref-type="fig" rid="fig1">Figure 1</xref>5 [<xref ref-type="bibr" rid="scirp.133083-ref10">10</xref>] shows the change in ultrasound sensor readings due to angular deviation of the object surface but in the same distances. Noise in the measurement is another source of error. If an object has a small surface, there will be an angle between two ultrasound headers and the object. In this saturation, the measured distance contains two parts which is a sum of the distance from the transmit header and receive header to the obstacle rather than the real distance. So, the measured distance is a little difference to the real distance. According to test, the smaller measured distance is, the more accuracy it is.</p><p>4) Testing result</p><p>The transmitter was enabled and tested on the oscilloscope shown in <xref ref-type="fig" rid="fig1">Figure 1</xref>6 to get the desired frequency.</p><p>The <xref ref-type="fig" rid="fig1">Figure 1</xref>7 shows the receiver oscilloscope graph. The voltage/division used on this oscilloscope is 2 V/div and the time/division used is 5 ms/div.</p><p>When the measured distance is the range of 0 - 1.0 meter, the system will generator a alarm signal. As the reduction of the distance, the frequency of alarm signal will be more and more quick. The LED should display the real distance all the time. In addition, when the measured distance is far away from 1.0 meter, that will be a safety region and the speaker will not generator the alarm signal. But the real distance is displayed all the time.</p><p>Although some datum is a little different to the actual distance, it is the reasonable error due to the temperature and the angle between the ultrasound header and the object. <xref ref-type="fig" rid="fig1">Figure 1</xref>8 shows the testing distance.</p></sec><sec id="s6"><title>6. The Final Board and Printed Circuit Board (PCB) (<xref ref-type="fig" rid="fig1">Figure 1</xref>9)</title><p>This PCB is manufactured by the stuff in the lab, by using the design that the author provided. Unfortunately, some components were not soldered in time. Without doubt, it should work directly if all the components were soldered correctly (as shown in <xref ref-type="fig" rid="fig2">Figure 2</xref>0 and <xref ref-type="fig" rid="fig2">Figure 2</xref>1).</p></sec><sec id="s7"><title>7. Conclusion and Further Work</title><p>In this report, an ultrasound distance measurement system is described, which is useful for reversing a vehicle. This system contains hardware and software to support it. Two ultrasound headers are used to transmit and receive the signal and a speaker is for generating an audio signal if the measured distance falls in the safety zone. An LED displays the real distance and all the process is controlled by a microcontroller. Although this project is simple and low-cost, the sensor allows resolutions of better than 1 mm to be obtained in quiet conditions. The obtained measurements are accurate enough for giving important information to the driver.</p><p>Some details of this system should be improved in further work. For example, with the change of temperature, the speed of ultrasound is changed to a small extent. If the surface of object is not smooth, this affects the accuracy of this system and leads to a little error on the measurement. By the way, further work could be done on the fusion of the information supplied by the ultrasound that can be utilized for mobile robot navigation in unknown environment rather than reversing a car.</p></sec><sec id="s8"><title>Conflicts of Interest</title><p>The author declares no conflicts of interest regarding the publication of this paper.</p></sec><sec id="s9"><title>Cite this paper</title><p>Deng, L.B. (2024) Ultrasound Ranging with Selective Zone. World Journal of Engineering and Technology, 12, 339-361. https://doi.org/10.4236/wjet.2024.122022</p></sec><sec id="s10"><title>Appendix I: The Program</title><p>#include</p><p>#include</p><p>#define uint unsigned int</p><p>#define uchar unsigned char</p><p>/*define the function*/</p><p>long int time; /*define “time”*/</p><p>bit CLflag; /*define “measuring”*/</p><p>char cshu;</p><p>#define T12us (256-12)</p><p>sbit VOLCK=P1^0;</p><p>sbit S1=P2^1;</p><p>sbit S2=P2^3;</p><p>sbit S3=P2^5;</p><p>sbit S4=P2^7;</p><p>sbit alam=P3^7;</p><p>unsigned char number[<xref ref-type="bibr" rid="scirp.133083-ref5">5</xref>]; /*display data*/</p><p>unsigned char temp_number[<xref ref-type="bibr" rid="scirp.133083-ref5">5</xref>];</p><p>unsigned char fr_alam;</p><p>unsigned char icont; //count the distance</p><p>char code table[<xref ref-type="bibr" rid="scirp.133083-ref"></xref>] ={0x5F,0x44,0x9D,0xD5,0xC6,0xD3,0xDB,0x45,0xDF,0xD7};</p><p>/* 0,1,2,3,4,5,6,7,8,9 */</p><p>/* delay */</p><p>void delay( int j)</p><p>{</p><p>int i;</p><p>for(i=0;i</p><p>}</p><p>void display(void) /* display the data */</p><p>{</p><p>P0=~table[number[<xref ref-type="bibr" rid="scirp.133083-ref4">4</xref>]];</p><p>S1=0;</p><p>delay(200);</p><p>S1=1;</p><p>P0=~(table[number[<xref ref-type="bibr" rid="scirp.133083-ref3">3</xref>]]|0x20);</p><p>S2=0;</p><p>delay(200);</p><p>S2=1;</p><p>P0=~table[number[<xref ref-type="bibr" rid="scirp.133083-ref2">2</xref>]];</p><p>S3=0;</p><p>delay(200);</p><p>S3=1;</p><p>P0=~table[number[<xref ref-type="bibr" rid="scirp.133083-ref1">1</xref>]];</p><p>S4=0;</p><p>delay(200);</p><p>S4=1;</p><p>}</p><p>/* initialize the timer T0、T1 */</p><p>void init_CTC(void )</p><p>{</p><p>TMOD = 0x21;</p><p>ET0 = 0;</p><p>}</p><p>void init_INT( )</p><p>{</p><p>IP=0x01;</p><p>TCON=0;</p><p>}</p><p>//=========The convert of distance and frequency==============</p><p>void Distance_Frequency(void)</p><p>{</p><p>if(number[<xref ref-type="bibr" rid="scirp.133083-ref3">3</xref>]&gt;0) // the distance is more than 1meter, no alarm signal</p><p>icont=0;</p><p>else</p><p>{</p><p>if(number[<xref ref-type="bibr" rid="scirp.133083-ref2">2</xref>]&gt;0)</p><p>{</p><p>switch(number[<xref ref-type="bibr" rid="scirp.133083-ref2">2</xref>])</p><p>{</p><p>case 9: icont=9; break;</p><p>case 8: icont=8; break;</p><p>case 7: icont=7; break;</p><p>case 6: icont=6; break;</p><p>case 5: icont=5; break;</p><p>case 4: icont=4; break;</p><p>case 3: icont=3; break;</p><p>case 2: icont=2; break;</p><p>case 1: icont=1; break;</p><p>default: break;</p><p>}</p><p>}</p><p>else</p><p>{</p><p>if(number[<xref ref-type="bibr" rid="scirp.133083-ref1">1</xref>]&gt;0)</p><p>icont=1;</p><p>else</p><p>icont=0;</p><p>}</p><p>}</p><p>}</p><p>void Timetojuli(void) /* calculate the distance */</p><p>{</p><p>long i;</p><p>i=(long)time*170;</p><p>temp_number[<xref ref-type="bibr" rid="scirp.133083-ref4">4</xref>]=i/10000000; /* 10meters */</p><p>i=i-temp_number[<xref ref-type="bibr" rid="scirp.133083-ref4">4</xref>]*10000000;</p><p>temp_number[<xref ref-type="bibr" rid="scirp.133083-ref3">3</xref>]=i/1000000; /* meters */</p><p>i=i-temp_number[<xref ref-type="bibr" rid="scirp.133083-ref3">3</xref>]*1000000;</p><p>temp_number[<xref ref-type="bibr" rid="scirp.133083-ref2">2</xref>]=i/100000; /* decimeter */</p><p>i=i-temp_number[<xref ref-type="bibr" rid="scirp.133083-ref2">2</xref>]*100000;</p><p>temp_number[<xref ref-type="bibr" rid="scirp.133083-ref1">1</xref>]=i/10000; /* cm */</p><p>i=i-(long)temp_number[<xref ref-type="bibr" rid="scirp.133083-ref1">1</xref>]*10000;</p><p>temp_number[<xref ref-type="bibr" rid="scirp.133083-ref0">0</xref>]=i/1000; /* mm */</p><p>if((temp_number[<xref ref-type="bibr" rid="scirp.133083-ref4">4</xref>]!=0)||(temp_number[<xref ref-type="bibr" rid="scirp.133083-ref3">3</xref>]!=0)||(temp_number[<xref ref-type="bibr" rid="scirp.133083-ref2">2</xref>]!=0)||(temp_number[<xref ref-type="bibr" rid="scirp.133083-ref1">1</xref>]!=0))</p><p>{</p><p>number[<xref ref-type="bibr" rid="scirp.133083-ref4">4</xref>]=temp_number[<xref ref-type="bibr" rid="scirp.133083-ref4">4</xref>];</p><p>number[<xref ref-type="bibr" rid="scirp.133083-ref3">3</xref>]=temp_number[<xref ref-type="bibr" rid="scirp.133083-ref3">3</xref>];</p><p>number[<xref ref-type="bibr" rid="scirp.133083-ref2">2</xref>]=temp_number[<xref ref-type="bibr" rid="scirp.133083-ref2">2</xref>];</p><p>number[<xref ref-type="bibr" rid="scirp.133083-ref1">1</xref>]=temp_number[<xref ref-type="bibr" rid="scirp.133083-ref1">1</xref>];</p><p>number[<xref ref-type="bibr" rid="scirp.133083-ref0">0</xref>]=temp_number[<xref ref-type="bibr" rid="scirp.133083-ref0">0</xref>];</p><p>Distance_Frequency();</p><p>}</p><p>}</p><p>void serve_INT0( ) interrupt 0</p><p>{</p><p>TR0=0; /* switch off the timer 0 */</p><p>EX0=0; /* switch off the interrupt 0 */</p><p>time=(long)TL0;</p><p>time+=(long)TH0*256;</p><p>Timetojuli();</p><p>CLflag=1;</p><p>TH0=0;</p><p>TL0=0;</p><p>}</p><p>void CTC0_INT ( ) interrupt 1</p><p>{</p><p>TR0=0;</p><p>ET0=0;</p><p>}</p><p>void CTC1_INT ( ) interrupt 3</p><p>{</p><p>VOLCK=~VOLCK;</p><p>cshu++;</p><p>}</p><p>/*main*/</p><p>void main()</p><p>{</p><p>init_CTC( ); /* initialize the timer */</p><p>init_INT( ); /* initialize the external interrupt*/</p><p>CLflag=1; /* begin to measure */</p><p>cshu=0;</p><p>IE=0x80;</p><p>ET1=1; ET0=1;</p><p>TR1=0; TR0=0;</p><p>TL1=T12us; TH1=T12us;</p><p>while(1)</p><p>{</p><p>CLflag=0;</p><p>cshu=0;</p><p>EX0=0;</p><p>TH1=T12us;</p><p>TL1=T12us;</p><p>TL0 = 0; TH0 = 0;</p><p>VOLCK=0;</p><p>TR1=1;</p><p>while(cshu&lt;20) ;</p><p>TR1=0;</p><p>TR0=1;</p><p>EX0=1;</p><p>display();</p><p>Distance_Frequency();</p><p>fr_alam++;</p><p>if(icont&gt;0)</p><p>{</p><p>if(fr_alam&gt;=icont)</p><p>{</p><p>fr_alam=0;</p><p>alam=~alam;</p><p>}</p><p>}</p><p>else</p><p>{</p><p>alam=1;</p><p>}</p><p>}</p><p>}</p></sec><sec id="s11"><title>Appendix II: The Circuit Diagram</title><disp-formula id="scirp.133083-formula2"><graphic  xlink:href="//html.scirp.org/file/8-1561496x27.png?20240513091541620"  xlink:type="simple"/></disp-formula></sec></body><back><ref-list><title>References</title><ref id="scirp.133083-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">Swickard, J.E., &lt;i&gt;et al&lt;/i&gt;. (2004) 2003 Accident Review. Business &amp; Commercial Aviation.</mixed-citation></ref><ref id="scirp.133083-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Parvis, A. (2002) An Ultrasonic Sensor for Distance Measurement in Automotive Applications.&lt;i&gt; IEEE Sensors Journal&lt;/i&gt;, 1, 200. &lt;br&gt;https://doi.org/10.1109/JSEN.2001.936931</mixed-citation></ref><ref id="scirp.133083-ref3"><label>3</label><mixed-citation publication-type="other" xlink:type="simple">Parrilla, M., Anaya, J.J. and Fritsch, C. (1991) Digital Signal Processing Techniques for High Accuracy Ultrasonic Range Measurements. &lt;i&gt;IEEE Transactions on Instr&lt;/i&gt;&lt;i&gt;u&lt;/i&gt;&lt;i&gt;mentation and Measurement&lt;/i&gt;, 40, 759-763. &lt;br&gt;https://doi.org/10.1109/19.85348</mixed-citation></ref><ref id="scirp.133083-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Eik-Nes, S.H. (1995) A Review of Epidemiological Studies of Human Exposure to Ultrasound. &lt;i&gt;Ultrasound in Obstetrics &amp; Gynecology&lt;/i&gt;, 6, 293-298. &lt;br&gt;https://doi.org/10.1046/j.1469-0705.1995.06040293.x</mixed-citation></ref><ref id="scirp.133083-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">Zhang, S.Y. (2000) Research of Ultrasonic Distance Measurement Device. Master&amp;#8217;s Thesis, Hohai University, Nanjing.</mixed-citation></ref><ref id="scirp.133083-ref6"><label>6</label><mixed-citation publication-type="other" xlink:type="simple">The Datasheet of CX20106A. &lt;br&gt;https://download.csdn.net/download/xhr131452007/30844728 </mixed-citation></ref><ref id="scirp.133083-ref7"><label>7</label><mixed-citation publication-type="other" xlink:type="simple">Elmer, H., Schweinzer, H. and Magerl, G. (2009) High Resolution Ultrasound Distance Measurement for Long Distances. &lt;i&gt;Annals of Surgery&lt;/i&gt;, 250, 943-949.</mixed-citation></ref><ref id="scirp.133083-ref8"><label>8</label><mixed-citation publication-type="other" xlink:type="simple">Li, X.M. and Qi, R.H. (2003) The Design of Vehicle Navigation Alarm System Based on SB5227 Microprocessor, &lt;i&gt;Technisches Messen&lt;/i&gt;, 70, 173-179. </mixed-citation></ref><ref id="scirp.133083-ref9"><label>9</label><mixed-citation publication-type="other" xlink:type="simple">Datasheet of DS18B20. &lt;br&gt;https://www.renrendoc.com/paper/87231442.html </mixed-citation></ref><ref id="scirp.133083-ref10"><label>10</label><mixed-citation publication-type="other" xlink:type="simple">Weir, R.F. and Childress, D.S. (1997) A New Method of Characterising Gait Using a Portable, Real-Time, and Ultrasound Ranging Device. &lt;i&gt;Proceedings of the &lt;/i&gt;19&lt;i&gt;th A&lt;/i&gt;&lt;i&gt;n&lt;/i&gt;&lt;i&gt;nual I&lt;/i&gt;&lt;i&gt;nternational Conference of the IEEE Engineering in Medicine and Biology S&lt;/i&gt;&lt;i&gt;o&lt;/i&gt;&lt;i&gt;ciety&lt;/i&gt;. &amp;#8216;&lt;i&gt;Magnificent Milestones and Emerging Opportunities in Medical Engineering&lt;/i&gt;&amp;#8217; (&lt;i&gt;Cat. No.&lt;/i&gt;97&lt;i&gt;CH&lt;/i&gt;36136), Chicago, 30 October 1997-2 November 1997, 1810-1812. &lt;br&gt;https://doi.org/10.1109/IEMBS.1997.757080</mixed-citation></ref></ref-list></back></article>