# Integrated System for Official Vehicles with Online Reservation and Moving Path Monitoring
## 2 System Architecture
### Set-Top-Box (STB)
#### 2.1.2 Control System  
It contains a microcontroller (MCU), GPS receiver, micro-SD card device, and 3-axis altitude and gyroscope. 1. The MCU has a dual-core CPU with a working clock of 160/240 MHz, 448 KB of ROM, and 520 KB of SRAM. It supports 802.11 b/g/n transmission protocol. It has a total of 34 GPIOs externally, and multiple communication interfaces such as SPI, I2C, and UART enable communication with multiple different sensors or devices. 2. The GPS receiver uses the interface protocol developed by NMEA for three specifications: 0180, 0182, and 0183. The NMEA-0183 protocol is used in detectors, sonars, anemometers, GPS receivers, and other devices. The transmission data are encoded in ASCII code, and its communication format is shown in Table 1. Each statement has a different length, and the longest bit is up to 82 bits. In this study, the sentence at the beginning of GPRMC is used for analysis. Thus, the content of each sentence group such as the current latitude and longitude, hemisphere, and UTC is separated by commas. A sentence starts with $, and the CR and LF codes of ASCII are used as the end code of the sentence. The code is stored in the micro-SD memory card after processing the character strings. The motion of the vehicle in driving is divided into three: straight moving, stopping and turning. To obtain the exact GPS position and reduce sampling points, a 3-axis accelerometer and a gyroscope are used with GPS. As the STB is placed in front of the driver's seat, the three-axis acceleration is defined, as shown in Figure 3.  
When a vehicle is moving straight, its motions are in acceleration, constant velocity, or deceleration. As shown in Figure 4, the distance between points is calculated by using Equation (1) [12; 13]. \[\mathrm{d}=\mathrm{R}\times\mathrm{cos}^{-1}\left(\mathrm{sin}\Phi_{1}\mathrm{ sin}\Phi_{2}+\mathrm{cos}\Phi_{1}\mathrm{cos}\Phi_{2}\mathrm{cos}(\Delta\lambda)\right) \tag{1}\]  
where R is the radius of the earth (\(\cong\)6371 km), P (\(\lambda_{1}\), \(\Phi_{1}\)) and Q (\(\lambda_{2}\), \(\Phi_{2}\)) are the longitudinal and latitudinal coordinates of two points on the sphere, \(\Delta\lambda\) is the difference in the longitude \begin{table}
\begin{tabular}{c c} \hline \hline
**Messages** & **Meaning** \\ \hline GGA & Time (UTC), Latitude, N or S (North or South), Longitude, E or W (East or West), GPS Quality Indicator, Number of satellites in view, Horizontal Dilution of precision, Antenna Altitude above/below mean-sea-level, Units of antenna altitude, etc. \\ \hline GLL & Latitude, N or S (North or South), Longitude, E or W (East or West), Time (UTC), Status A-Data Valid, V - Data Invalid, Checksum. \\ \hline GSA & Selection mode, PDOP, HDOP, VDOP, the ID of 1 st satellite used for the fix, etc. \\ \hline GSV & A total number of messages, Message number, satellite in view, Satellite \\  & number, Elevation in degrees, Azimuth in degrees to true, SNR, Checksum. \\ \hline RMA & Latitude, N or S, Longitude, E or W, Time Difference, Magnetic Variation, \\  & Speed Over Ground, etc. \\ \hline RMC & Time (UTC), Status, Latitude, N or S, Longitude, E or W, Speed over ground, \\  & Track degrees, Date, Magnetic Variation, Checksum. \\ \hline VTG & Track Degrees, Speed Knots, Speed Kilometers Per Hour, Checksum, etc. \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Contents of various sentences in NMEA. (radii) of the two points (absolute value), and d is the straight-line distance between P and Q on the ground. When the vehicle is accelerated or decelerated (B and D in Figure 5), the sensed acceleration (ax > 0 or ax < 0) is recorded in the micro-SD card. When the vehicle moves at a constant speed (ax \(\approx\) 0) and the angular velocity w detected by the gyroscope is close to a constant value (\(\theta\) = constant) (at C), the GPS data are not recorded on the SD card. When the vehicle stops (at A in Figure 5), the acceleration is zero (ax = 0) with a fixed angular velocity w (\(\theta\) = constant).