<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">OPJ</journal-id><journal-title-group><journal-title>Optics and Photonics Journal</journal-title></journal-title-group><issn pub-type="epub">2160-8881</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/opj.2021.118018</article-id><article-id pub-id-type="publisher-id">OPJ-111025</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Chemistry&amp;Materials Science</subject><subject> Engineering</subject><subject> Physics&amp;Mathematics</subject></subj-group></article-categories><title-group><article-title>
 
 
  Design and Implementation of Indoor Visible Light Positioning System Based on MiniSTM32
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Shuxuan</surname><given-names>Zhou</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Weisong</surname><given-names>He</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Yuan</surname><given-names>Qin</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Qian</surname><given-names>Wu</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib></contrib-group><aff id="aff1"><addr-line>Liangjiang International College, Chongqing University of Technology, Chongqing, China</addr-line></aff><pub-date pub-type="epub"><day>03</day><month>08</month><year>2021</year></pub-date><volume>11</volume><issue>08</issue><fpage>284</fpage><lpage>293</lpage><history><date date-type="received"><day>6,</day>	<month>November</month>	<year>2020</year></date><date date-type="rev-recd"><day>31,</day>	<month>July</month>	<year>2021</year>	</date><date date-type="accepted"><day>3,</day>	<month>August</month>	<year>2021</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p>
 
 
  
    Aiming at the problems of LED-based visible light positioning system such as unstable illumination, Lambertian model transmission limitation, large positioning error, etc., it is proposed to use PWM to drive the LED, use the curve fitting method to obtain the ranging model, and estimate the target position according to the trilateral algorithm. A positioning system platform based on the microcontroller MiniSTM32 was built to test the performance of the transceiver circuit. The experimental results showed that the positioning error of less than 3 cm was achieved in a space of 80 cm &#215; 80 cm &#215; 80 cm. 
  
 
</p></abstract><kwd-group><kwd>Light Positioning</kwd><kwd> Curve Fitting</kwd><kwd> MiniSTM32</kwd><kwd> Trilateral</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>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. [<xref ref-type="bibr" rid="scirp.111025-ref1">1</xref>]. 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.</p><p>More and more scholars at home and abroad are studying indoor positioning based on visible light communication. Literature [<xref ref-type="bibr" rid="scirp.111025-ref2">2</xref>] 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 [<xref ref-type="bibr" rid="scirp.111025-ref3">3</xref>] 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 &#215; 5 m &#215; 3 m A positioning error of 18 cm is obtained in the space area. Literature [<xref ref-type="bibr" rid="scirp.111025-ref4">4</xref>] uses multiple LED lights to improve positioning accuracy, and this method can effectively solve the problem of occlusion in visible light indoor positioning. Literature [<xref ref-type="bibr" rid="scirp.111025-ref5">5</xref>] proposed two hybrid positioning methods RSS and AOA, RSS and TDOA to improve positioning accuracy.</p><p>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.</p></sec><sec id="s2"><title>2. The Positioning Principle of Indoor Positioning System</title><sec id="s2_1"><title>2.1. Trilateral Positioning</title><p>Given that the bottom projection coordinates of the three LEDs are A(x<sub>1</sub>, y<sub>1</sub>), B(x<sub>2</sub>, y<sub>2</sub>), and C(x<sub>3</sub>, y<sub>3</sub>), the coordinate of receiver is O(x, y). The distances from the receiver to the projection points are d<sub>1</sub>, d<sub>2</sub>, and d<sub>3</sub> 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:</p><p>{ ( x − x 1 ) 2 + ( y − y 1 ) 2 = d 1 2 ( x − x 2 ) 2 + ( y − y 2 ) 2 = d 2 2 ( x − x 3 ) 2 + ( y − y 3 ) 2 = d 3 2 (1)</p><p>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</p><p>{ x = d 1 2 − d 2 2 + 6400 160 y = d 1 2 + d 2 2 − 2 d 3 2 + 9600 320 (2)</p></sec><sec id="s2_2"><title>2.2. Curve Fitting</title><p>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.</p></sec></sec><sec id="s3"><title>3. Circuit Design and Analysis</title><sec id="s3_1"><title>3.1. The Overall Structure of the Circuit</title><p>The structural design of the visible light positioning system is shown in <xref ref-type="fig" rid="fig1">Figure 1</xref>, 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.</p></sec><sec id="s3_2"><title>3.2. Transmitter Design</title><sec id="s3_2_1"><title>3.2.1. Transmitter Hardware Design</title><p>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 <xref ref-type="fig" rid="fig2">Figure 2</xref>. 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.</p><p>The physical diagram of the construction is shown in <xref ref-type="fig" rid="fig3">Figure 3</xref>. 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.</p></sec><sec id="s3_2_2"><title>3.2.2. Transmitter Program Design</title><p>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.</p></sec></sec><sec id="s3_3"><title>3.3. Receiver Design</title><sec id="s3_3_1"><title>3.3.1. Receiver Circuit Design</title><p>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 <xref ref-type="fig" rid="fig4">Figure 4</xref>. 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</p><p>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 <xref ref-type="fig" rid="fig5">Figure 5</xref>. The physical picture of the whole receiving circuit is shown in <xref ref-type="fig" rid="fig6">Figure 6</xref>.</p></sec><sec id="s3_3_2"><title>3.3.2. Receiver Programming</title><p>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</p><p>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.</p><p>The flowchart of the positioning system receiving program is shown in <xref ref-type="fig" rid="fig1">Figure 1</xref>. 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.</p></sec></sec><sec id="s3_4"><title>3.4. Circuit Test and Analysis</title><p>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 <xref ref-type="fig" rid="fig7">Figure 7</xref>. 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.</p></sec></sec><sec id="s4"><title>4. Experiment and Result Analysis</title><p>The experimental positioning scene is shown in <xref ref-type="fig" rid="fig8">Figure 8</xref>. The space size of the positioning model is 80 cm &#215; 80 cm &#215; 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.</p><p>The area of the calibration board at the bottom of the lamp holder is 80 cm &#215; 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 <xref ref-type="fig" rid="fig9">Figure 9</xref>.</p><p>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 <xref ref-type="fig" rid="fig1">Figure 1</xref>0, 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.</p><p>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 σ(x<sub>e</sub>, y<sub>e</sub>)</p><p>σ ( x e , y e ) = ( x − x e ) 2 + ( y − y e ) 2 (3)</p><p>Randomly select some points for testing, and the experimental results are shown in <xref ref-type="table" rid="table1">Table 1</xref>.</p><table-wrap id="table1" ><label><xref ref-type="table" rid="table1">Table 1</xref></label><caption><title> Experiment result</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Actual coordinates</th><th align="center" valign="middle" >Output coordinates</th><th align="center" valign="middle" >Error function</th></tr></thead><tr><td align="center" valign="middle" >(10, 10)</td><td align="center" valign="middle" >(10.206, 11.905)</td><td align="center" valign="middle" >1.918</td></tr><tr><td align="center" valign="middle" >(10, 50)</td><td align="center" valign="middle" >(12.197, 51.821)</td><td align="center" valign="middle" >2.853</td></tr><tr><td align="center" valign="middle" >(30, 30)</td><td align="center" valign="middle" >(31.281, 30.924)</td><td align="center" valign="middle" >1.579</td></tr><tr><td align="center" valign="middle" >(50, 50)</td><td align="center" valign="middle" >(48.791, 52.121)</td><td align="center" valign="middle" >2.441</td></tr><tr><td align="center" valign="middle" >(70, 70)</td><td align="center" valign="middle" >(72.129, 71.190)</td><td align="center" valign="middle" >2.439</td></tr><tr><td align="center" valign="middle" >(20, 40)</td><td align="center" valign="middle" >(18.971, 41.692)</td><td align="center" valign="middle" >1.980</td></tr><tr><td align="center" valign="middle" >(40, 40)</td><td align="center" valign="middle" >(41.071, 42.219)</td><td align="center" valign="middle" >2.464</td></tr><tr><td align="center" valign="middle" >(60, 20)</td><td align="center" valign="middle" >(62.137, 21.961)</td><td align="center" valign="middle" >2.900</td></tr><tr><td align="center" valign="middle" >(60, 60)</td><td align="center" valign="middle" >(59.562, 62.107)</td><td align="center" valign="middle" >2.152</td></tr><tr><td align="center" valign="middle" >(70, 40)</td><td align="center" valign="middle" >(71.152, 38.183)</td><td align="center" valign="middle" >2.151</td></tr></tbody></table></table-wrap><p>It can be seen from the test results that in the positioning space of 80 cm &#215; 80 cm &#215; 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.</p></sec><sec id="s5"><title>5. Conclusion</title><p>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.</p></sec><sec id="s6"><title>Acknowledgements</title><p>This article is supported by the general project of Chongqing Natural Science Foundation.</p></sec><sec id="s7"><title>Conflicts of Interest</title><p>The authors declare no conflicts of interest regarding the publication of this paper.</p></sec><sec id="s8"><title>Cite this paper</title><p>Zhou, S.X., He, W.S., Qin, Y. and Wu, Q. (2021) Design and Implementation of Indoor Visible Light Positioning System Based on MiniSTM32. Optics and Photonics Journal, 11, 284-293. https://doi.org/10.4236/opj.2021.118018</p></sec></body><back><ref-list><title>References</title><ref id="scirp.111025-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">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</mixed-citation></ref><ref id="scirp.111025-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">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</mixed-citation></ref><ref id="scirp.111025-ref3"><label>3</label><mixed-citation publication-type="other" xlink:type="simple">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</mixed-citation></ref><ref id="scirp.111025-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Cossu, G., Presi, M., Corsini, R., et al. (2011) A Visible Light Localization Aided Optical Wireless system. IEEE GLOBECOM Workshops, 802-807.  
https://doi.org/10.1109/GLOCOMW.2011.6162565</mixed-citation></ref><ref id="scirp.111025-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">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</mixed-citation></ref></ref-list></back></article>