Research and design of LED indoor positioning system

. According to indoor positioning requirements, the light intensity sensing circuit is designed with LED as the light source. The function relationship between light intensity and distance is obtained by fitting the experimental data. The distance from the light source to the node to be located is calculated. The coordinate position of the node to be measured on the two-dimensional plane is obtained through the trilateral measurement and positioning algorithm. The experimental results of this system show that the absolute position error is less than 10cm, which can meet the needs of a large number of indoor positioning applications.


Introduction
In large-scale complexes, sports halls, underground parking lots and other indoor environments, GPS-based positioning technology has the disadvantages of weak signals and poor accuracy. The lighting conditions of these indoor environments are its essential elements. LED is the mainstream technology of indoor environment lighting at present. The use of visible light communication technology to achieve indoor positioning has wide applicability [1][2][3] .
2 System composition and principle LED indoor positioning system consists of anchor nodes and nodes to be located. The anchor node is set on the ceiling, each LED flashes at different frequencies, and the flashing frequency is higher than the perception range of human eyes, so as not to cause discomfort to indoor personnel. The node to be located, by receiving the LED light synthesized by different frequencies, completes the coordinate positioning of its own ground. In order to discuss the principle of the system, the system is simplified as a system consisting of 3 LED anchor nodes and nodes to be located. The system structure is shown in Figure 1 [40,40,0] are the projections of the anchor nodes on the ground, h1, h2, h3 are the height of the anchor node to the ground 80, d1, d2, and d3 are the projection distances of the node to be located to the anchor node, L1, L2, L3 are the distances from the node to be located to the anchor node. The principle of LED indoor positioning system is: By designing the light intensity sensing circuit and combining the algorithm to obtain the distance values of L1, L2, L3, Given the coordinates of P1, P2, P3 and P1', P2', P3' and the heights of h1, h2, h3, The distance values of d1, d2, and d3 are obtained through the operation of formula (1). Then through formulas (2) The Trilateration positioning algorithm [4][5][6] was used and modified in this design. Adjust the real coordinate system to the coordinate system shown in Figure 2, Let the coordinates of P1', P2', and P3' be [0,0], [d, 0], and [i, j], respectively. Under the condition that the distances between these three coordinates and d1, d2, and d3 are known, using the formulas (2) and (3), the node coordinates [x0, y0] are obtained.

Design of light intensity sensing circuit
In terms of controlling the lighting of anchor nodes, Three LED lamps P1, P2 and P3 are driven by a square wave with a duty cycle of 80% and flash at the frequency of 128Hz, 256Hz and 512Hz respectively, Avoiding 50Hz power frequency interference will neither affect the lighting nor cause discomfort [7] . In order to obtain node spacing L1, L2, L3, the designed light intensity sensing circuit is shown in Figure 3, D1 in the picture is the photodiode 2CU2B, It converts changes in the received light into changes in current, Photocurrent > 30uA; U2 in the picture is the LF356N integrated operational amplifier. Double power supply ± 12VDC is adopted, and the magnification is designed to be about 20 times; In order to cooperate with the laterA / D acquisition, R4, R5 and R6 are used to form a voltage dividing circuit to raise the output AC voltage signal of LF356N by 1.5V, so that the output voltage signal is between 0-3.3v.

Part of anchor node
Timer interrupt mode is adopted in program design. In the main program. The first step is initialization, which includes: defining three I / O pins (Freq_Low_PIN ,  Freq_Mid_PIN ,Freq_High_PIN); declaring to use Timer1; defining an integer variable (My_Counter32), as counter; defining three Boolean variables (Freq_Low_Val,Freq_Mid_Val ,Freq_High_Val). The second step is to set the Timer1, which includes: setting cycle equal to 1 / 1024 second. The third step is to set the interrupt, which includes: turn on timer interrupt and turn on global interrupt.
In the interrupt service program part, every time an interrupt occurs, the My_Counter32'value is increased by 1, from 0 to 31, and then it is reset to zero and recalculated. If the My_Counter32'value can be divided by 1, the Freq_High_PIN will output the current Freq_High_Val, then reverse the current Freq_High_Val, and assign it to Freq_High_Val, so as to prepare for the next assignment when entering the interrupt service program.Similarly, if the My_Counter32'value can be divided by 2 or 4, the same operation will be performed for the Freq_Mid_PIN and Freq_Low_PIN . The program flow chart is shown in Figure 4.

Part of node to be located
First, the output signal of the light intensity sensing circuit is analog-to-digital converted, and then the FFT fast Fourier transform [8][9] is performed for the conversion result according to formula (4), and then the spectrum represented by the real part and the virtual part is converted into the spectrum represented by the amplitude and phase,The amplitude corresponding to three frequency points is extracted, and multiple sets of data are recorded for curve fitting, so as to obtain the functional relationship between light intensity and distance.
During the test, calibrate a reference position every 4 units along the x-axis of the ground coordinate, measure and record the FFT amplitude of 128Hz, 256Hz, 512Hz frequency points [F_L,F_M,F_H], some data are shown in Table 1. Use MATLAB to make curve fitting between the amplitude of three frequency points and the theoretical distance L [10] . In order to simplify the design, the linear model f (x) = α * x + β is selected. After fitting, the function relationship between light intensity and distance is shown in formula (5), and the fitting effect corresponding to 512Hz signal is shown in Figure 5. The measurement results show that the functional relationship between the amplitude and distance of the three frequency points is slightly different, which may be due to the attenuation of the system frequency domain.
The program design flow of LED indoor positioning system is shown in Figure 6. The system uses Arduino 2560 as the controller. In the initialization stage, A0 channel of Arduino 2560 is set, which supports A/D conversion with 10bit precision; Set the number of FFT sampling points N = 128, sampling frequency fs = 2048Hz, and select Hamming window as the window function type; Define the coordinates of anchor node projection P1 ', P2', P3 '; Define h1, h2, h3 height values. In the A/D acquisition phase, 128 data points are continuously converted. Next, the 128 point FFT algorithm is executed to obtain the 128 point amplitude frequency characteristic value stored in double word data type, The data of point 8, 16 and 32 correspond to the amplitude of 128Hz, 256Hz and 512Hz respectively. In the phase of amplitude conversion to distance, according to formula (5), obtain the distance L1, L2, L3 from the undetermined node x to the three anchor nodes P1, P2, P3. In the algorithm stage of Pythagorean theorem, the values of d1, d2 and d3 are calculated according to formula (1). At the stage of the Trilateration positioning algorithm, according to formulas (2) and (3)

Experimental result
The indoor ground coordinate selection is shown in Figure 7, and five areas of A,B,C,D,E are divided. Three anchor nodes P1, P2 and P3 are directly above the ground. The LED indoor positioning system can accurately identify the location of the node to be located through actual measurement, and the area identification code is shown in Figure 8. According to formula (6), the absolute error of position is calculated to be ≤ 6.5cm.

Conclusion
LED indoor positioning system places anchor nodes on the ceiling, establishes coordinate system and divides areas according to indoor environment. When the node moves indoors, the system can accurately obtain its location and coordinate information.