GPS cannot be applied to indoor positioning, and people's demand for indoor positioning is increasing. An indoor positioning technology that can be applied to indoor environments has become an important research direction. At present, the commonly used technologies for indoor positioning include infrared (IR), Ultrasound, radio frequency identification (RFID), wireless local area network (WLAN), Bluetooth (Bluetooth), etc. . LED provides a new choice for indoor positioning technology due to its rich spectrum resources, low cost, low power consumption, long life, energy saving and environmental protection.
More and more scholars at home and abroad are studying indoor positioning based on visible light communication. Literature  proposed that a trilateral positioning algorithm based on received signal strength can achieve indoor positioning, thus verifying the feasibility of indoor positioning in visible light communication. In reference to the small positioning area of the trilateral positioning algorithm, the literature  proposed 4 LED weighted positioning algorithms, and considering the actual LED layout, the transmission distance information was introduced as a weighting factor into the positioning algorithm, in the 5 m × 5 m × 3 m A positioning error of 18 cm is obtained in the space area. Literature  uses multiple LED lights to improve positioning accuracy, and this method can effectively solve the problem of occlusion in visible light indoor positioning. Literature  proposed two hybrid positioning methods RSS and AOA, RSS and TDOA to improve positioning accuracy.
This article builds an LED-based visible light positioning system, using MiniSTM32 as the system control center, the transmitter uses 3 LEDs to send light signals of different frequencies, the receiver photodetector outputs electrical signals, and MiniSTM32 performs A/D sampling on the signals. According to the trilateral positioning algorithm, the distance relationship between the receiving and sending ends is obtained, and the position coordinates are obtained.
2. The Positioning Principle of Indoor Positioning System
2.1. Trilateral Positioning
Given that the bottom projection coordinates of the three LEDs are A(x1, y1), B(x2, y2), and C(x3, y3), the coordinate of receiver is O(x, y). The distances from the receiver to the projection points are d1, d2, and d3 respectively. Therefore, three equations for the projection circle on the bottom surface are established, and the solution of the equation is the position coordinates of the receiver. The equations are:
If the coordinates of the 3 LEDs in the positioning system model are A (0, 0, 80), B (80, 0, 80), (40, 80, 80), then the node O(x, y) to be determined can be further reduced to
2.2. Curve Fitting
The curve fitting method is to obtain discrete data through experiments, and then fit the discrete data into a continuous function. The transmitter part of the visible light positioning system model built in this article only uses 3 LED lamp beads with a power of 3 W, and a single LED lamp bead cannot meet the lighting needs of a large space. The radiation model of the LED lamp is not an ideal Lambertian radiation model. If the intensity-based distance estimation method is used, a larger positioning error will occur. Therefore, the relationship between the photovoltage value of the receiving end and the node to be measured can be obtained by curve fitting.
3. Circuit Design and Analysis
3.1. The Overall Structure of the Circuit
The structural design of the visible light positioning system is shown in Figure 1, which is mainly divided into the hardware and software design of the transmitter part, and the hardware and software design of the receiver part. The transmitter part includes a micro control system STM32 Series and an LED drive circuit; the receiver part includes a photodetector, amplify circuit, A/D sampling, curve fitting, and position coordinate output modules.
3.2. Transmitter Design
3.2.1. Transmitter Hardware Design
In the positioning system, the light signal carrying position information sent by the transmitter LED to the receiver, the change in the intensity of the light signal will affect the accuracy of the positioning result. In order to drive the LED to emit sufficient light intensity, it is necessary to design the drive circuit of LED. We choose L298N as the driver chip of the transmitting circuit. L298N is a constant voltage and constant current bridge driver chip, which has the characteristics of high working voltage and large output current. The driving circuit of the transmitter LED is shown in Figure 2. The driving circuit is connected to the three output ports of the microcontroller MiniSTM32. Press the key module of the microcontroller, and the microcontroller port can generate the corresponding PWM wave. Set the PWM wave duty cycle to 50% square wave, and the frequency of the 3 LED lights are 0.5 KHz, 2 KHz, 3 KHz.
Figure 1. Indoor visible light positioning system frame.
Figure 2. The circuit of transmitter.
The physical diagram of the construction is shown in Figure 3. The transmitter uses a timer to reverse the pin voltage 0 and 1. The high voltage is 1 output. At this time, the L298N works normally, the circuit is turned on, and there is current in the circuit, and the LED lamp is on; the low voltage is 0 output, when the circuit is open, the LED lamp bead is off. The on-off process of the LED lamp bead is the process of converting the electrical signal into an optical signal, so the length of the lamp bead’s on-off time can be controlled by changing the duty ratio of the PWM wave to realize the modulation of the light signal.
3.2.2. Transmitter Program Design
The program of the transmitter of the system mainly initializes the 3 LED circuits and clocks, configures the input and output ports, initializes the timer, sets the value of the register, and the prescaler (PSC)value of the timer, automatic reload value (ARR) can encode 3 LEDs, and then send the data to the drive circuit of the transmitter.
3.3. Receiver Design
3.3.1. Receiver Circuit Design
The photodiode can convert the light signal into an electrical signal after receiving the signal from the LED. The current signal at this time is very weak, about a few hundred nanoamperes-several microamperes, so the I/V conversion amplifier circuit is mainly composed of a cascade circuit composed of operational amplifier AD825 and operational amplifier LF353 as shown in Figure 4. The operational amplifier AD825 is a high-speed, low-cost, and super-optimized operational amplifier with DC parameters. It is widely used in signal conditioning and data acquisition applications. The operational amplifier LF353 is a high-speed, low-cost, JFET input operational amplifier with extremely low input offset voltage. It requires low supply current while maintaining a large gain bandwidth product. In addition, matched high-voltage JFET inputs provide extremely low input bias and offset currents. LF353 is generally used for high-speed integrators, analog-to-digital converters, sampling and protection circuits and many other
Figure 3. Physical picture of the transmitter circuit.
Figure 4. I/V conversion signal acquisition front-end module.
circuits. In addition, two capacitors are connected in parallel with the +5 V power supply and the −5 V power supply of the circuit, one is a 0.1 uF ceramic capacitor and the other is a 10uF electrolytic capacitor. Two capacitors are connected in parallel with the +5 V power supply of the circuit and the −5 V power supply, one is a 0.1 uF ceramic capacitor, and the other is a 10 uF electrolytic capacitor. These two capacitors are used for power supply filtering, which can filter out AC waves generated by power supply rectification and high frequency waves in the filter circuit. The power supply filter circuit is shown in Figure 5. The physical picture of the whole receiving circuit is shown in Figure 6.
3.3.2. Receiver Programming
The signal received by the receiving end of the positioning system is a voltage signal. In order to facilitate data processing, we need to perform digital signal processing to convert analog signals into digital signals, that is, convert analog
Figure 5. Power filter circuit diagram.
Figure 6. Hardware physical diagram of the receiving end circuit.
voltage signals into digital voltage signals. This conversion process can be sampled by A/D. When finished, the ADC module of the microcontroller can complete the A/D sampling process. The output value of the ADC module is a digital quantity without a unit. The maximum digital quantity of a 12-bit ADC is 4096, so the ADC output value can only be between 0 - 4096. In order to convert the digital quantity to a value with a unit, use a reference Voltage to calculate. Knowing that the reference voltage of the one-chip computer is 3.3 V, this system uses mV as the voltage unit, so set temp/adcx = 3300/9600 in the program. In order to reduce the positioning error, when the AD acquisition system has 3 channels at the transmitting end, the next round of sampling is performed after a delay of 100 ms, which can ensure the stable output light signal of the LED light source. ADC channel 1, the acquisition time is 0.021 ms, 100 acquisitions require 2.1 ms, the average is taken after 100 acquisitions, and then the next ADC channel cycle is performed. This cycle process can improve the positioning accuracy of the system.
The flowchart of the positioning system receiving program is shown in Figure 1. The PA1 port of the microcontroller MinSTM32 is connected to the output port of the receiving circuit. The signal sent by the LED is first detected, and the A/D sampling model is used to read the voltage value corresponding to the positioning node. Convert the voltage to the distance relationship, then bring into the three-side positioning algorithm, and finally use the serial port to print the coordinates to complete the positioning process.
3.4. Circuit Test and Analysis
We use an oscilloscope to test the actual performance of the circuit. The oscilloscope detects the signal waveforms of the amplifying circuit of the 3 LED lights at the transmitter and the output waveform at the receiver as shown in Figure 7. The first, second, and third channels of the oscilloscope correspond to the output signals of the 3 LEDs at the transmitting end, and the fourth channel is the output signal of the receiving end. Compared with the waveform of the transmitting end, the output waveform of the receiving end has more high-order harmonic signals, which are caused by noise, which includes interference from background light and interference in the circuit.
4. Experiment and Result Analysis
The experimental positioning scene is shown in Figure 8. The space size of the positioning model is 80 cm × 80 cm × 80 cm, the light source at the transmitting end is 3 LED lamp beads with a power of 3 W, and the receiving end is composed of a silicon photodiode and an amplifier circuit. In order to reduce the positioning error caused by the interference of the external background light, a shading curtain is used for shading treatment, and the bottom of the lamp holder is a calibration plate.
Figure 7. Circuit test results.
Figure 8. Experimental positioning scene.
The area of the calibration board at the bottom of the lamp holder is 80 cm × 80 cm. The point where the LEDA is projected onto the calibration board is the origin (0, 0), the coordinates of the X axis are 0 to 80 cm, and the coordinates of the Y axis are 0 to 80 cm, evenly spaced at 10 cm. Divide the calibration board into 81 points at this time, and mark them one by one, as shown in Figure 9.
Next, in order to obtain the relationship between the photovoltage value at the receiving end and the node to be measured, we take the LEDC with a frequency of 3 KHz as an example. First, the point where the LEDC is projected onto the plane and the node to be measured are collected at 10 cm from each other, and a single-chip microcomputer is used to collect a data point, that is, to measure the voltage value of the point, and a total of 8 points of data are measured. Then, MATLAB can be used to fit the distance measurement function model of the light source. As shown in Figure 10, the X axis represents the distance d between the LED projection onto the plane and the receiving end, and the Y axis represents the voltage amplitude U(x, y) measured at this point.
According to the ranging function model, it is only necessary to bring the corresponding photovoltage value of the point to be tested into the fitted ranging function model to obtain the distance d. In order to verify the performance of the positioning system designed in this paper, define the error function σ(xe, ye)
Randomly select some points for testing, and the experimental results are shown in Table 1.
Figure 9. Distribution of test points on the receiving plane.
Figure 10. Ranging function model.
Table 1. Experiment result.
It can be seen from the test results that in the positioning space of 80 cm × 80 cm × 80 cm, the error of the positioning test node using the curve fitting method is within 3cm, which shows that the measurement result is more accurate. The curve fitting method does not require too much theoretical formula derivation, and can be quickly built in a visible light positioning environment, and a certain positioning accuracy can be obtained. But the shortcomings are also very significant. The measurement accuracy is affected by the number of experimental measurement data. Although increasing the number of experimental measurement data can improve the positioning accuracy to a certain extent, the difficulty of system construction is also increased accordingly.
In this paper, we have designed the transmitter drive circuit and the receiver circuit of the visible light positioning system. The LED drive circuit is driven by the L298N chip. The receiving end circuit is composed of an I/V conversion amplifier circuit and a filter circuit. An oscilloscope was used to analyze and test the circuit performance of the transceiver, and the test results show that the transceiver is working normally. The core processor of the positioning system is the microcontroller MiniSTM32. The transmitter transmits signals of different frequencies, and the receiver is connected to the ADC of the microcontroller to convert the output analog signal into a digital signal. In the programming of the single-chip microcomputer, the stable output of the light source can be ensured by increasing the number of data acquisitions and then taking the average method. Using the curve fitting method, the relationship between distance and voltage can be obtained. Finally, the serial port of the single-chip microcomputer was used to print out the coordinates, and the positioning accuracy was 3cm to verify the feasibility of the visible light positioning system.
This article is supported by the general project of Chongqing Natural Science Foundation.
 Wu, C., Zhu, M. and Zhang, Y. (2017) The Design and Implementation of an Infrared Indoor Positioning and Lighting System. 2017 IEEE 2nd Advanced Information Technology, Electronic and Automation Control Conference (IAEAC). https://doi.org/10.1109/IAEAC.2017.8054394
 Wang, W., Liu, X., Li, M., et al. (2019) Optimizing Node Localization in Wireless Sensor Networks Based on Received Signal Strength Indicator. IEEE Access, 7, 73880-73889. https://doi.org/10.1109/ACCESS.2019.2920279
 Hara, S. and Anzai, D. (2018) Experimental Performance Comparison of RSSI-and TDOA-Based Location Estimation Methods. VTC Spring IEEE Vehicular Technology Conference, 2651-2655. https://doi.org/10.1109/VETECS.2008.581
 Mazuelas, S., Lago, F.A., Gonzalez, D., et al. (2008) Dynamic Estimation of Optimum Path Loss Model in a RSS Positioning System. IEEE/ION Position, Location and Navigation Symposium. https://doi.org/10.1109/PLANS.2008.4569988