## 4 Vehicle Detection Using Ultrasonic Sensors
### Analysis with a Single Vehicle  
First, to simplify our analysis, we consider a single vehicle on a single-lane road, as illustrated in Figure 4. We assume the vehicle has length \(l_{\
u}\) and is traveling at constant speed \(v_{\
u}\) on a straight path along a lane of width \(l_{l}\). The ultrasonic sensor is placed at a distance of \(l_{g}\) from the roadside. The ultrasonic wave spreads at constant speed \(v_{u}\) and with angle \(\theta\). The width of the ultrasonic wave \(l_{d}\) is \(2l_{u}\tan\frac{\theta}{2}\), where \(l_{u}\) is the distance from the sensor to the detection point. The detection point is the side of the vehicle owing to the mount position of an ultrasonic sensor. Vehicles are detected using a number of distance data collected from the ultrasonic sensors. This requires the ultrasonic sensors to have detection intervals that can collect sufficient distance data for reliable vehicle detection. The detection interval of an ultrasonic sensor is given by:  
\[\frac{\text{detectable period of a vehicle}}{\text{number of distance data necessary for vehicle detection}}\]  
In Figure 4, the detectable period of the vehicle can be calculated as \(\frac{l_{\
u}}{v_{\
u}}\) when the vehicle passes the ultrasonic sensor. However, as the ultrasonic wave has a width of \(l_{d}\) at detection distance \(l_{l}\), the detectable period of the vehicle is \(\frac{l_{\
u}+l_{d}}{v_{\
u}}\). Thus, if we know how many distance measurements are needed, we can calculate the detection interval. However, this is not simple. We must examine the system design to determine the necessary number of distance data. Generally, raw signal data collected from the sensors should be filtered for noise before being input to a specific algorithm. To avoid useful signals being filtered out, the volume of data should be larger than some minimum amount required by the noise filter. This minimum varies depending on the type of noise filter. The most appropriate noise filter is determined by the characteristics of ultrasonic sensors. Figure 4: Analysis model. Ultrasonic sensors generate distance data by measuring the time taken to receive reflected ultrasonic waves. The time is directly proportional to the distance between the ultrasonic sensor and the detection object. Owing to the slow speed of ultrasonic waves, the sampling rate is much lower than in other sensors, e.g., acoustic and magnetic sensors. Moreover, if the noise filter is implemented in a software package, its complexity must be suitable for the low computing power of WSN-based systems. Considering these two restrictions, we analyzed various filters. A median filter has been selected for the proposed system, because it combines appropriate performance with a low sampling rate. The required number of data for a median filter is \(\left\lceil\frac{m}{2}\right\rceil\), where \(m\) is the mask size of the filter. Thus, the detection interval of an ultrasonic sensor using a median filter is given by Equation (2), which means the maximum detection interval. If the detection interval is longer than that given by Equation (2), the data will be filtered out:  
\[\text{Maximum detection interval}=\frac{l_{v}+l_{d}}{v_{v}\left\lceil\frac{m}{2}\right\rceil} \tag{2}\]  
Previously, the maximum detection interval for an ultrasonic sensor was derived based on the model in Figure 4. If more frequent data are needed, a shorter detection interval can be applied. However, the detection interval cannot be shortened indefinitely, owing to the slow speed of ultrasonic waves. If a new ultrasonic wave is emitted before the previous wave has been received, a detection error will occur. Thus, the ultrasonic sensor should wait until the previous wave has arrived. In Figure 4, the maximum detection distance is \(l_{l}+l_{g}\). Because the ultrasonic wave makes a round trip, the maximum total distance traveled by the ultrasonic wave is \(2(l_{l}+l_{g})\). If a road has \(n\) lanes, this distance will be \(2(nl_{l}+l_{g})\).