{'fraction_non_alphanumeric': 0.02696526508226691, 'fraction_numerical': 0.007541133455210238, 'mean_word_length': 4.688474870017331, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Computation calibration on distance measurement in an ultrasonic remote sensing device

Ultrasonic wave is suitable to be used as information carrier in short-range remote sensing practices. When developing a short-range ultrasonic remote sensing device, the object distance measurement routine shall produce an accurate result. In a few-meter or several-meter object detection or imaging, millimeter accuracy is required, therefore, a calibration becomes crucial. This article addresses the process and the result of our research on calibrating the distance between the device and the backscattering object. Our approach consists of investigating potential delay contributors, recognizing the practical delay contributors by analysing the program routine, formulating the calibration equation and applying the calibration equation in the computation.


Introduction
Remote sensing is widely applied for many purposes in different fields. A large number of remote sensing works were carried out using optical waves, including ones reported in [1] and [2]. Massive remote sensing works were also done using microwaves, including ones reported in [3] and [4]. Both optical and microwave remote sensing systems are suitable for long-range and medium-range detection or imaging. As for short-range detection and imaging, acoustic wave -including ultrasonic wave-is more suitable due to its low travel velocity. Compared to long-range and medium-range operations, short-range remote sensing is more sensitive to distance measurement error, e.g. a 5mm error is significant in a 5m-range object detection.

Problem
As ultrasonic wave is found important in certain applications of remote sensing. There have been a number of research works in this type of remote sensing, e.g. the ones reported in [5] and [6]. A problem occurs, that is how to produce an accurate distance measurement in a short-range ultrasonic remote sensing. In this research, we limit the problem to the case of our development of a microcontroller-based ultrasonic remote sensing device.

Solution Approach
To produce accurate distance measurements, calibration shall be done by considering every delay contributor within the system. Before addressing our solution approach, here the physical appearance of the device and the distance measurement setting are shown to give a good visualization of the research work. First, the physical appearance of the device is here depicted by fig. 1. The device physically consists of a microcontroller board and an ultrasonic TX/RX module, and additionally equipped with an echo arrival indicator. Figure 1. The ultrasonic remote sensing proof-of-concept device we are developing. It essentially consists of a microcontroller board (ATmega328P) [7] and a TX/RX module (SR-HC04) [8], and additionally equipped with an echo arrival indicator. Following the theoretical conception, including the distance calibration, the whole algorithm and programming have been done.
Second, the distance measurement setting is depicted by fig. 2. In this figure, the device is placed at the left side whereas the backscattering object is placed at the right side. The distance between the device (more precisely the TX/RX) and the object is computed based on the difference of time instance when the TX starts transmitting the waves and the time instance when RX starts receiving the echo.  Our approach consists of investigating potential delay contributors, recognizing the practical delay contributors by analysing the program routine, formulating the calibration equation and applying the calibration equation in the computation. The investigating potential delay contributors and recognizing the practical delay contributors in our case is discussed in subsection 3.1 and subsection 3.2 respectively whereas applying the calibration equation in the computation is addressed in section 4.

Investigating potential delay contributors
It should be noted that at any computer-based device, several delay events take place during the computation. In the context of ATmega328P, the delay events involved in the process shall be investigated accordingly.
Initially, the very first computer signal i.e. clock is investigated. The clocking mechanism is here shown by fig. 3, letting us know which part of the computer generates clocks and which parts of the computer are driven by the clocks. From this diagram it can be recognized that 5 different oscillatorstimer oscillator, external oscillator, crystal oscillator, low-frequency crystal oscillator and calibrated RC oscillator-drive the AVR Clock Control Unit while the AVR Clock Control Unit itself drives 6 different subsystems namely asynchronous timer / counter, general I/O modules, ADC, CPU core, RAM and Flash and EEPROM.  [7]. From this diagram it can be recognized that the I/O functions are driven by AVR Clock Control Unit while the AVR Clock Control Unit itself is driven by 5 different oscillators.
Second, the amount of delay for a typical instruction is investigated. This investigation is shown by fig. 4. The figure shows an example of one cycle of writing a data. It can be seen that a complete instruction cycle consists of four steps i.e. address fetching, address validation, data fetching and data writing. The beginning of the cycle execution must wait for the earliest next clock; and yet the chip needs some time to respond. The delay occurs in this process is here called one instruction delay (ti). Similar delay is to be expected for other instructions. Then, it is important to understand that another type of delay occurs as the result of sequential execution of command line in the computation. This type of delay is here called discretization delay or t_discr. In the case of our Synthetic Aperture Ultrasonic Remote Sensing (SAURS) device, the scanning principle of Synthetic Aperture Radar [9] is adopted. Whenever an echo is received by the sensor, the computation must wait for the upcoming echo reading instance; this is the meaning of t_discr. The amount of this delay depends on how frequent the echo reading is performed according to the program, and this is one of several parameters that must be properly calculated during the system design, prior to the development. The more frequent the echo reading is performed, the less the waiting time (t_discr) is, however the more time it takes computation resource.

Figure 4.
According to "On-chip RAM Data Access" for ATmega 328P described in [7], here the amount of delay for one typical instruction is investigated. The figure shows an example of one cycle of writing a data. It can be seen that a complete instruction cycle consists of four steps i.e. address fetching, address validation, data fetching and data writing. When fetching the address, the logic gates must wait for the earliest next clock; and yet when the clock comes, the logic gates need some time to respond it, for doing the next step. The delay occurs in this process is here called one instruction delay (ti). Similar delay is to be expected for other instructions.

Recognizing the practical delay contributors
According to subsection 3.1, instruction delay ti and discretization delay t_disc are the potential contributors. Furthermore, it is necessary to investigate how these two types of delay take place and how significant they are. To do so, the following is addressed: (i) analysing the remote sensing routine, (ii) concluding which practical delay contributors take place and transforming them into a distance calibration equation.

Analysing the Remote Sensing Routine.
The computation routine of our ultrasonic remote sensing program is here shown in the form of pseudocode in fig. 5. Vu represents the travel velocity of the ultrasonic wave. The n_max represents the length of the azimuth path of the remote sensing. Pin x and pin y of the microcontroller is connected to the trigger pin and the echo pin of the TX/RX module respectively. The "1" logic of pin x instructs the TX/RX module to transmit ultrasonic waves and its "0" logic instructs it to stop transmitting. This program is assumed to be applied in a Synthetic Aperture Ultrasonic Remote Sensing. The t1 is the ultrasonic transmitting pulse width, t2 is the interval between an echo reading with the next echo reading within a transmitting cycle, and t3 is the interval between a transmitting cycle to the next transmitting cycle. This computation pause of t3 is meant to give time for the remote sensing platform -e.g. a drone-to move to the next position along the azimuth-axis.  Figure 5. Pseudocode of our SAURS device operation without distance calibration. Vu is the travel velocity of the ultrasonic wave. The n_max represents the length of the azimuth path of the remote sensing. Pin x and pin y is connected to the trigger pin and the echo pin of the TX/RX module respectively. The "1" logic of pin x instructs the TX/RX module to transmit ultrasonic waves and its "0" logic instructs it to stop transmitting. This program is assumed to be applied in a Synthetic Aperture Ultrasonic Remote Sensing (SAURS) device. The t1 is the ultrasonic transmitting pulse width, t2 is the interval between an echo reading with the next echo reading within an echo-reading-window, and t3 is the interval between a transmitting cycle to the next transmitting cycle. This t3 pause gives time for the platform, e.g. a drone, to move to the next position along the azimuth-axis. The t3 interval shall be much larger than t1 and t2 whereas t2 can be smaller than t1. Here d(m,n) is the calculated distance (from the device) of m th object detected within an echo-reading-window of the n th azimuth position.

Recognizing the Delay Contributors.
The most relevant part of the routine, i.e. the part from t=0 until t=t_window, is here shown in the form of timing diagram in fig. 6. This figure shows the timing diagram of every task carried out by the microcontroller and the TX/RX module. There is no delay occurs between microcontroller pin and TX/RX pin because both are physically connected though wires. Then, the logic 1 of this trigger pin drives the module to start transmitting ultrasonic waves and there it takes an instruction delay ti. In the same time, the program instructs the microcontroller to start the timer and there it takes an instruction delay ti too. The wave travels, reaches an object then it is reflected back towards the device. After a certain time, this wave echo arrives at the TX/RX module and it drives this module to set logic 1 to its echo pin, there it takes another instruction delay ti. This echo pin then sends the logic 1 directly through wires to the microcontroller's pin y, without any delay. Now this logic 1 waits -as long as t_discr-for the upcoming reading instance, to be read by the processor. When the processor reads this logic 1, it then decides to read the value of timer and store it to an internal memory, and somehow this step takes another instruction delay ti. The magnitude of an individual t_discr is a random value between 0 and t2. As the events take place repeatedly many times, t_discr is then expected to be a half of t2. Figure 6. Timing diagram of an object detection at one azimuth position, with realistic delay contributors. This is a result of a thorough analysis of delays caused by microchip operations and the computation routine. Please note that ti is instruction delay and t_discr is discretization delay as mentioned in subsection 3.1.

Translating the Analysis Result to Calibration Equation.
It is necessary to understand that in practice the echo reading window is much larger than t1 and t2. Whereas t2 is usually smaller than t1; t2 can even be made very small so that the microcontroller can perform pin reading frequently enough, to minimize the t_discr. The amount of t_discr varies between 0 and t2 depends on the instance when the echo arrives at the device's sensor. Thus, in average the amount of t_discr becomes a half of t2. It is expressed as the following: t_discr = 0.5 t2. (1) Whereas from the analysis addressed in subsection 3.2, including the explanation by fig. 6

Applying the Calibration Equation into the Computation
To involve the distance calibration in the device operation, the pseudocode presented in Fig. 5 remains the same, except for the equation of the t_travel. Now it becomes t_travel = timer value -2ti -0.5t2. It is presented in Fig. 7.   Figure 7. Pseudocode of our SAURS device operation with distance calibration. Here the calibration equation "t_travel = timer value -2ti -0.5t2" is applied. The value of ti is assigned in the initial setting.
The value of instruction delay ti shall be determined from experimental measurements. When the value is obtained it can be then assigned into the program, particularly in the initial setting.

Summary
Usage of ultrasonic waves is suitable for short-range remote sensing. Delay contributors in our system have been recognized by analysing the computation routine. A calibration equation has been formulated as travel time = timer value -2ti -t_discr. This calibration should be applied in determining an