<<

applied sciences

Article A Robust Real-Time Automatic Recognition Prototype for Maritime Optical Morse-Based Communication Employing Modified Clustering Algorithm

, Xiaozheng Wang †, Minglun Zhang * †, Hongyu Zhou, Xinglong Lin and Xiaomin Ren State Key Laboratory of Information Photonics and Optical Communications, Beijing University of Posts and , Beijing 100876, China; [email protected] (X.W.); [email protected] (H.Z.); [email protected] (X.L.); [email protected] (X.R.) * Correspondence: [email protected] These authors contributed equally. †  Received: 31 December 2019; Accepted: 7 February 2020; Published: 12 February 2020 

Abstract: In maritime communications, the ubiquitous Morse lamp on ships plays a significant role as one of the most common backups to or satellites just in case. Despite the advantages of its simplicity and efficiency, the requirement of trained operators proficient in and maintaining stable sending speed pose a key challenge to this traditional manual signaling manner. To overcome these problems, an automatic system is needed to provide a partial substitute for human effort. However, few works have focused on studying an automatic recognition scheme of maritime manually sent-like optical Morse signals. To this end, this paper makes the first attempt to design and implement a robust real-time automatic recognition prototype for onboard Morse lamps. A modified k-means clustering algorithm of machine learning is proposed to optimize the decision threshold and identify elements in Morse light signals. A systematic framework and detailed recognition algorithm procedure are presented. The feasibility of the proposed system is verified via experimental tests using a light-emitting diode (LED) array, self-designed receiver module, and microcontroller unit (MCU). Experimental results indicate that over 99% of real-time recognition accuracy is realized with a signal-to-noise ratio (SNR) greater than 5 dB, and the system can achieve good robustness under conditions with low SNR.

Keywords: automatic recognition; Morse code; k-means clustering; machine learning; maritime communication; real-time; free space

1. Introduction Free space optical (FSO) communication has attracted widespread attention from both academia and industry. It has been demonstrated as a promising technology as a complementary solution to conventional radio frequency (RF), fiber optics, and microwave communications, particularly for applications with size, weight, and power restrictions. The potential advantages of FSO communication including eye safety, no spectrum licensing issues, smaller and lighter payloads, low probability of intercept, and immunity from jamming make it a natural candidate for maritime long-range communication scenarios [1–4]. Among the various modulation schemes, Morse code is still widely used as a common language between maritime vessels due to its simplicity, efficiency, and small costs. Traditionally, the ubiquitously deployed Morse lamp with LEDs, particularly on naval ships, is operated by a signalman translating the message into Morse code (dots and dashes) and manually turning the lamp “on” and “off” in the correct sequence (on–off keying), to transmit a light signal. On the recipient ship, the blinking

Appl. Sci. 2020, 10, 1227; doi:10.3390/app10041227 www.mdpi.com/journal/applsci Appl. Sci. 2020, 10, 1227 2 of 16 light signal is visually observed and directly interpreted by persons trained in the skill. However, there remains several outstanding issues to this kind of manual signaling method nowadays [5,6]. First, it would require a long training period for a skilled recipient on shipboard. In practice, Morse code relies on precise time intervals between elements while operators have difficulties in maintaining an absolutely stable sending pace, the data length may vary even if it is operated by the same person, and, thus, the reliability of communication cannot be guaranteed [7]. Moreover, as it is long-term and repetitive work, the recognition accuracy is susceptible to the physical and psychological conditions of the human body, which can make them unwieldy in an emergency as well [8]. To cope with the aforementioned issues, research efforts have been made for Morse code automatic recognition in communications. Previous related works are mostly based on signal processing tools, such as Kalman filters, phase-locked loops, and time–frequency analysis [8–11]. Wei et al. [9] proposed an automatic method to lock the frequency of Morse code based on the phase-locked loop circuit. Xiao et al. [10] presented an automatic reception approach for high-frequency (HF) continue-wave (CW) telegrams. A Kalman filtering algorithm combined with the support vector machine (SVM) is utilized to extract the time-domain characteristics of CW signals and deal with unstable code speed. The authors of [11] adopted the Cooley–Tukey Fast Fourier Transform (FFT) algorithm to analyze the spectrogram of a noisy audio Morse signal, and implemented a real-time decoder based on a digital signal processor. In [12], a wavelet transform-based automatic decoding method was proposed for multiplexed Morse telegraph recognition, and the feasibility of this method was analyzed via experiments. With the further advances of computers and embedded technologies, various high-performance microcontrollers have come out, facilitating the implementation of automated process control, signal recognition, data processing, and algorithm verification. Furthermore, motivated by the remarkable achievements of machine learning, some machine learning (ML)-based approaches have been proposed to model Morse signals and enhance the system robustness in a time-varying noisy environment. Wei et al. [13] provided a machine-learning method for automatic Morse signal detection. An SVM classifier, named HSVM, was proposed to be trained, based on graphical features extracted from the Morse spectrum. The authors of [14] combined signal processing and the deep learning method to construct a Morse identification system, an improved feature extraction algorithm was proposed, and the experimental results indicated a better result. Yuan et al. [15] proposed a deep learning framework on blind Morse signal detection in the wideband spectrum and achieved state-of-art performance using real-world datasets. In [16], a k-means clustering algorithm was introduced to differentiate the elements in Morse signals after parameter extraction of the time–frequency image, and the suitability of the proposed method was investigated by simulation under different signal-to-noise ratio (SNR) conditions. In addition, Qu et al. [17] used this k-means clustering algorithm for dynamic threshold and Morse code recognition in a noisy environment. However, existing works have focused on Morse telegraph signals recognition in RF wireless communications, and, to the best of our knowledge, no reported work has tried to present an automatic recognition scheme and performance analysis for maritime manually sent-like Morse light signals. Besides, the ML-based k-means algorithms have not been well studied in this case as well, and there is no related real-time experimental measurement yet. To address these issues, we first propose and experimentally demonstrate an automatic recognition framework of Morse light signals in maritime optical communications by an ML-based clustering approach. Specifically, we implement a flexible FSO hardware prototype to collect real-measured Morse light signals in the physical environment for the recognition algorithm test. A modified k-means clustering is designed to compute the decision threshold for binarization and identify elements including dot–dash and space recognition in Morse light signals. To improve the decoding efficiency, we make modifications to the classical k-means algorithm, and a selection sorting-assisted method has been adopted. To tackle with the emerging glitches in the binarization waveform, resulting from strong noise channels, a novel error correction scheme is presented to enhance the robustness to ambient light noises. The proposed recognition approach is implemented in a microcontroller unit (MCU), and the Appl. Sci. 2020, 10, x FOR PEER REVIEW 3 of 17

Morse code recognition in a noisy environment. However, existing works have focused on Morse telegraph signals recognition in RF wireless communications, and, to the best of our knowledge, no reported work has tried to present an automatic recognition scheme and performance analysis for maritime manually sent-like Morse light signals. Besides, the ML- based k-means algorithms have not been well studied in this case as well, and there is no related real-time experimental measurement yet. To address these issues, we first propose and experimentally demonstrate an automatic recognition framework of Morse light signals in maritime optical communications by an ML-based clustering approach. Specifically, we implement a flexible FSO hardware prototype to collect real-measured Morse light signals in the physical environment for the recognition algorithm test. A modified k-means clustering is designed to compute the decision threshold for binarization and identify elements including dot–dash and space recognition in Morse light signals. To improve the decoding efficiency, we make modifications to the classical k-means algorithm, and a selection sorting-assisted method has been adopted. To tackle with the emerging glitches in the binarization waveform, resulting from strong noise channels, a novel error correction scheme is presented to enhance the robustness to ambient light noises. The proposed recognition approach is implemented in a microcontroller unit (MCU), and the performance of the prototype is analyzed in terms of recognition accuracy and system robustness via real-time decoding results derived from the MCU. Appl. Sci. 2020, 10, 1227 3 of 16 2. Principle performance of the prototype is analyzed in terms of recognition accuracy and system robustness via real-time2.1. Optical decoding Morse resultsSignal derivedCharacterization from the MCU.

2. PrincipleMorse code is a classical encoding scheme in telecommunications composed of a unique sequence of short–long dots, dashes, and spaces to represent different letters of the alphabet, 2.1.numbers Optical, and Morse procedural Signal Characterization notations. It is usually transmitted by on–off radio, light, or tones [18].Morse code is a classical encoding scheme in telecommunications composed of a unique sequence of short–long dots, dashes, and spaces to represent different letters of the alphabet, numbers, and While using light as a transmitting medium, the dots and dashes are represented as procedural notations. It is usually transmitted by on–off radio, light, or tones [18]. highWhile level using(light lighton), asand a transmitting the spaces or medium, pauses the refer dots to and low dashes level are(light represented off). In addition, as high level the (lightMorse on), code and depends the spaces on or accurate pauses refer time to lowintervals, level (light which off). correspond In addition, theto the Morse pulse code width depends in the on accuratesignal waveform. time intervals, The which duration correspond of a dot to is the regarded pulse width as a in basic the signal unit, waveform.and the dash The duration duration ofis athree dot is times regarded that. as aThe basic spaces unit, and or the time dash intervals duration between is three times dot– that.dash Thees, spaces between or time letters, intervals and between dot–dashes,words are 1, between 3, and letters,5 units, and respectively between words [19]. As are illustrated 1, 3, and 5 in units, Figure respectively 1, it is more [19]. Aslike illustrated the Return in- Figureto-Zero1, it OOK is more (RZ like-OOK the Return-to-Zero) scheme in optical OOK (RZ-OOK)wireless communications. scheme in optical wireless Unlike communications.RF, the optical Morse Unlike-encoded RF, the optical signal Morse-encoded should be real signal and should non-negative be real and due non-negative to the intensity due to themodulation/direct detection/direct detection(IM/DD) (IMmechanism/DD) mechanism [20]. [20].

Figure 1. WWaveformaveform of opticaloptical Morse signalsignal interpretinginterpreting “SOS.”“SOS.”

As mentionedmentioned above, above, the t recognitionhe recognition is achieved is achieved based onbased the dionff erentthe different time intervals timeand intervals signal amplitudeand signal to amplitude distinguish to di distinguishfferent elements. different However, elements the.automatic However, recognition the automatic of manually recognition sent Morseof manually light signals sent Morse in the real light world signals is facing in the two real obvious world challenges. is facing two One obvious is that the challenges unstable typing. One pace can lead to variations in different elements durations, and the other is the amplitude fluctuation resulting from ambient light noise. Assume the time intervals of dots, dashes, and spaces in unstable Morse light signals are distributed in a nearly normal fashion [21]. Let us denote D1 and D2 as the dot and dash durations samples, respectively; then, the probability density function (PDF) is expressed as

2 1 (D µ) f (D) = exp( − ), (1) √2π − 2σ2

2 2 where D1 ~ N (µ, σ ), D2 ~ N (3µ, σ ), µ denotes the means, and σ is the scale parameter. By controlling proper µ and σ2, it is able to generate manually sent-like Morse light signals based on the Morse encoding rules as the data source to verify the designed algorithm later. A histogram of the distribution of different element durations is shown in Figure2, and it can be clearly seen that the duration ratio changes. Generally, the durations of different elements in the two figures nearly follow a ratio of 1:3 and 1:3:5:7, respectively. In addition, additive white Gaussian noise (AWGN) is considered to be added to the raw Morse data. Figure3 plots the signal waveform in the time domain with /without noise. It is observed that the noise will cause amplitude fluctuation, but not affect the duration of different elements. In addition, these duration and amplitude variations can lead to errors for recognition. Appl. Sci. 2020, 10, x FOR PEER REVIEW 4 of 17 is that the unstable typing pace can lead to variations in different elements durations, and the other is the amplitude fluctuation resulting from ambient light noise. Assume the time intervals of dots, dashes, and spaces in unstable Morse light signals are distributed in a nearly normal fashion [21]. Let us denote D1 and D2 as the dot and dash durations samples, respectively; then, the probability density function (PDF) is expressed as

2 1 (D   ) , fD( ) exp(2 ) , (1) 2 2 2

2 2 where D1 ~ N (휇, 휎 ), D2 ~ N (3휇, 휎 ), 휇 denotes the means, and 휎 is the scale parameter. By 2 controlling proper 휇 and 휎2, it is able to generate manually sent-like Morse light signals based on the Morse encoding rules as the data source to verify the designed algorithm later. A histogram of the distribution of different element durations is shown in Figure 2, and it can be clearly seen that the duration ratio changes. Generally, the durations of different elements in the two figures nearly follow a ratio of 1:3 and 1:3:5:7, respectively. In addition, additive white Gaussian noise (AWGN) is considered to be added to the raw Morse data. Figure 3 plots the signal waveform in the time domain with/without noise. It is observed that the noise will cause amplitude fluctuation, but not affect the duration of different Appl.elements. Sci. 2020 ,In10 , 1227 addition, these duration and amplitude variations can lead to errors4 of for 16 recognition.

(a) (b)

Figure 2. Histogram of ( a) space and ( b) dot dot–dash–dash duration distribution distributions.s.

Figure 3. TimeTime domain of optical Morse signal with additive white Gaussian noise (AWGN).(AWGN).

2.2. Modified K-Means Clustering Algorithm The k-means algorithm is one of the most commonly used clustering methods due to its simplicity and efficiency. The basic idea is to partition data samples into k clusters based on the calculated distance between each element and centroid [22–24]. As the practical FSO channels suffer from many factors such as ambient light noise and multi-path dispersion [20], this method is able to optimize the decision threshold of the time-varying received signal and reduce the error rate in this noisy environment. Furthermore, as analyzed in Section 2.1, a notable clustering feature is observed in terms of the element distribution of optical Morse signals, which can be effectively differentiated using the k-means clustering algorithm. The detailed procedure in this case is as follows: Let X denote the sampled voltage data set, and initialize k cluster centroids C = [C1, C2, ... Ck,] randomly from X, compute the Euclidean distance between each voltage sample and centroid to find the positions of the clusters’ centroids minimizing the cost function [21], and then assign each sample to its closest cluster centroid, defined as

2 j = arg(min X Ci(m) ), (2) 1 i k k − k ≤ ≤ Appl. Sci. 2020, 10, 1227 5 of 16 where represents the Euclidean distance, C (m) is the i-th cluster centroid during the m-th iteration, k•k i X S (m), and S (m) denotes the cluster with the centroid of C (m). Then, update the centroid of each ∈ j j j cluster by calculating the mean as follows:

1 X Ci(m + 1) = X, (i = 1, 2, ... , k), (3) ni X S (m) ∈ i where Ci(m + 1) is the i-th cluster centroid during the (m + 1)-th iteration, ni stands for the number of data samples in the i-th cluster, Sj(m) denotes the cluster with the centroid of Ci(m), and X represents all the data samples in cluster Sj(m). If the updated centroids remain the same, it indicates that convergence is reached and then stops, described as

abs ([C (m + 1) C (m)]) < abs([C (m) C (m 1)]) 2%, (i = 1, 2, ... , k). (4) i − i i − i − × Otherwise, repeat the step until it reaches convergence. It is noted that there are also another enhanced clustering method and modified version of the Euclidean distance that yield good performance for high-dimensional datasets [25–27]. The data to be processed by the proposed automatic recognition algorithm include voltage value and level duration, both of which are one-dimensional datasets. Thus, for the ease of implementation in the embedded system, the simplest k-means method and Euclidean distance are chosen in this work, which can also effectively meet the requirement. In order to adapt this algorithm to the application scenario, we propose several modifications to the clustering process to improve the recognition accuracy. The optimization of the k-means clustering algorithm is as follows: 1. Cluster Centroid Initialization: The digital filter will cause an amplitude level hopping effect in the head and tail of the passing signal, leading to significant deviation. Thus, this part of the signal is designed to be abandoned in this case while selecting the cluster centroid during the iteration. 2. Selection Sort-Assisted (Figure4): It can be easily known that the obtained k cluster centroids are in an unordered state. As the purpose of cluster analysis is to distinguish the signals with different durations in the Morse decoding, it is necessary to sort the final k centroids so that the Appl. Sci. 2020, 10, x FOR PEER REVIEW 6 of 17 device can effectively identify different clusters. Considering the small quantity of centroids and easythe implementation small quantity in of this centroids case, we and exploit easy the implementation widely used selection in this sort case, algorithm we exploit to rearrange the thewidely centroids used in selection a certain sort order algorithm [28]. to rearrange the centroids in a certain order [28].

7 3 5 9 8 2 1

1 3 5 9 8 2 7

1 2 5 9 8 3 7

1 2 3 9 8 5 7

1 2 3 5 8 9 7

1 2 3 5 7 9 8

1 2 3 5 7 8 9

FigureFigure 4.4. Selection sort sort process process..

3. System Overview

A schematic diagram of the proposed system is shown in Figure 5, composed of a source computer, arbitrary waveform generator (AWG), LED driver, LED source, lens, receiver module, analog–digital converter (ADC), and MCU. First, the information bits are encoded by a PC into an unstable Morse code set and converted to an analog signal by AWG. Then, the signal is amplified and modulated to drive the LED via the driver circuit for transmitting visible light signals. At the receiver side, the incoming light signal is received by a photodetector (PD) for photoelectric conversion and amplified by a transimpedance amplifier (TIA). Then, the ADC is used to convert the electrical analog signal into a digital signal. Afterward, the digital signal is fed to the MCU for further processing.

Figure 5. Block diagram of hardware setup.

Appl. Sci. 2020, 10, x FOR PEER REVIEW 6 of 17

the small quantity of centroids and easy implementation in this case, we exploit the widely used selection sort algorithm to rearrange the centroids in a certain order [28].

7 3 5 9 8 2 1

1 3 5 9 8 2 7

1 2 5 9 8 3 7

1 2 3 9 8 5 7

1 2 3 5 8 9 7

1 2 3 5 7 9 8

1 2 3 5 7 8 9

Figure 4. Selection sort process. Appl. Sci. 2020, 10, 1227 6 of 16 3. System Overview

3. SystemA schematic Overview diagram of the proposed system is shown in Figure 5, composed of a source computer, arbitrary waveform generator (AWG), LED driver, LED source, lens, receiver A schematic diagram of the proposed system is shown in Figure5, composed of a source computer, arbitrarymodule, waveformanalog–digital generator converter (AWG), (ADC) LED driver,, and LEDMCU source,. First, lens, the information receiver module, bits analog–digital are encoded converterby a PC into (ADC), an unstable and MCU. Morse First, thecode information set and converted bits are encoded to an analog by a PC signal into an by unstable AWG. MorseThen, codethe signal set and is amplified converted toand an modulated analog signal to bydrive AWG. the Then,LED via the the signal driver is amplified circuit for and transmitting modulated tovisible drive thelight LED signals. via the At driver the circuit receiver for transmitting side, the incoming visible light light signals. signal At the is receiver received side, by the a incomingphotodetector light signal (PD) is for received photoelectric by a photodetector conversion (PD) forand photoelectric amplified conversion by a transimpedance and amplified byamplifier a transimpedance (TIA). Then amplifier, the ADC (TIA). is Then, used the to ADCconvert is used the toelectrical convert theanalog electrical signal analog into signal a digital into asignal. digital Afterward, signal. Afterward, the digital the digital signal signal is fed is to fed the to MCU the MCU for forfurther further processing. processing.

Figure 5. Block d diagramiagram of h hardwareardware setup.setup.

The Cortex M4-based MCU STM32 is the core part of this whole hardware system, which has a rich peripheral interface with high integration, composed of a serial peripheral interface (SPI), finite impulse response (FIR) filter, timers (TIM), universal synchronous/asynchronous receiver transmitters (USART), and a decode module. The control signal and sampled data stream are transmitted between the MCU chip and ADC using a SPI. After FIR denoising, the sampled signal is further processed by the decode module, where the recognition algorithm is implemented. Then, the USART module is used for the interaction between the automatic recognition system and the host computer, including the transmission of control commands and return of the decoding results. In addition, the TIM module provides a working clock for the entire system to ensure that each functional component can run in an orderly manner. As indicated in Figure6, the implementation of our proposed recognition algorithm contains three stages: Signal pretreatment, Morse decoding, and accuracy analysis. The input sampled signal is filtered first by the FIR module to reduce the effects of noise on the subsequent process. Then, the threshold between the high level and low level is determined to classify all the voltage samples into two levels (0 and 1) in the stage of binarization. As there still exist some irregular hopping points after FIR denoising, which will affect the automatic decoding, resulting in the decline of recognition accuracy, the error correction stage is designed as a necessary complement to address this issue by eliminating the spikes in the signal. Afterward, a relatively pure and stable Morse code signal is obtained and classified according to the characteristics of the dot, dash, and space code. After utilizing the dot–dash and space recognition algorithm, the identified Morse code set is able to be interpreted Appl. Sci. 2020, 10, x FOR PEER REVIEW 7 of 17

The Cortex M4-based MCU STM32 is the core part of this whole hardware system, which has a rich peripheral interface with high integration, composed of a serial peripheral interface (SPI), finite impulse response (FIR) filter, timers (TIM), universal synchronous/asynchronous receiver transmitters (USART), and a decode module. The control signal and sampled data stream are transmitted between the MCU chip and ADC using a SPI. After FIR denoising, the sampled signal is further processed by the decode module, where the recognition algorithm is implemented. Then, the USART module is used for the interaction between the automatic recognition system and the host computer, including the transmission of control commands and return of the decoding results. In addition, the TIM module provides a working clock for the entire system to ensure that each functional component can run in an orderly manner. As indicated in Figure 6, the implementation of our proposed recognition algorithm contains three stages: Signal pretreatment, Morse decoding, and accuracy analysis. The input sampled signal is filtered first by the FIR module to reduce the effects of noise on the subsequent process. Then, the threshold between the high level and low level is determined to classify all the voltage samples into two levels (0 and 1) in the stage of binarization. As there still exist some irregular hopping points after FIR denoising, which will affect the automatic decoding, resulting in the decline of recognition accuracy, the error correction stage is designed as a necessary complement to address this issue by eliminating the spikes in the signal. Afterward, a relatively pure and stable Morse code signal is obtained and Appl. Sci. 2020, 10, 1227 7 of 16 classified according to the characteristics of the dot, dash, and space code. After utilizing the dot–dash and space recognition algorithm, the identified Morse code set is able to be interpretedinto a string messageinto a string sequence message by table sequence lookup decoding, by table andlookup is then decoding, finally output and tois thethen computer finally outputfor accuracy to the computation. computer for accuracy computation.

Figure 6. FlowchartFlowchart of of o opticalptical Morse Morse s signalignal p processing.rocessing.

4. Signal PretreatmentPretreatment The pretreatment stage includes digital filtering, binarization, and hopping points correction. The Appl. TheSci. 20 20 pretreatment, 10, x FOR PEER stageREVIEW includes digital filtering, binarization, and hopping points8 of 17 purpose of this stage is to provide a pure and stable Morse code signal for the subsequent decoding correction. The purpose of this stage is to provide a pure and stable Morse code signal for process. Detailed signal processing is provided in the following subsections. the4.1. subsequentDigital Filter decoding Denoising process. Detailed signal processing is provided in the following subsections.4.1. DigitalConsidering Filter Denoising that low-frequency components dominate in the frequency domain of the opticalConsidering Morse signal that low-frequency(Figure 7) , we components adopt a FIR dominate low-pass in filter the frequency with a cutoff domain frequency of the optical of 40 MorseHz using signal the (Figure Hamming7), we adopt window a FIR low-pass to mitigate filter the with noise a cuto effect,ff frequency and of for 40 theHz using ease theof Hammingimplementation window in to the mitigate MCU the as noisewell. e ffect, and for the ease of implementation in the MCU as well.

Figure 7.7. Frequency domain of optical Morse signal.signal.

4.2.4.2. BinarizationBinarization In this stage, the proposed modified k-means clustering algorithm is utilized to compute a In this stage, the proposed modified k-means clustering algorithm is utilized to classification voltage threshold VT and partition the voltage samples into two levels, representing “1” (i.e.,compute high level)a classification and “0” (i.e., voltage low level), threshold respectively. VT and The partition specific steps the ofvoltage this process samples are as into follows: two levels, representing “1” (i.e., high level) and “0” (i.e., low level), respectively. The specific 1.steps Initialize of this process a similarity are valueas follows:s, to quantify how similar two clusters are to one another; 2. Perform the mk-means algorithm to classify all the voltage data samples into two sets with the 1. Initialize a similarity value s, to quantify how similar two clusters are to one another; cluster centroids of CV1 and CV2; 2. Perform the mk-means algorithm to classify all the voltage data samples into two sets with the cluster centroids of CV1 and CV2; 3. Calculate the distance between two centroids by d = abs (CV2 − CV1). If d < s, it means that two clusters are similar. At this time, all sampling values are divided into high or low level. Then, set VT = 0; otherwise, set VT = (CV2 + CV1)/2; 4. Iterate over all data samples; a value above the obtained threshold in step (3) indicates “1;” meanwhile, a value below indicates “0.”

4.3. Error Correction In many cases, there exist multiple unexpected glitches in signals after binarization due to the noise effects. As Figure 6 shows, the red circle marks in the block binarization indicate hopping points. Thus, we design the error correction algorithm to eliminate these abnormal hopping voltages and guarantee an accurate subsequent decoding process. The first step is to compute a threshold of durations for the purpose of localizing the emerging glitch positions. By using the algorithm in Section 2.2, duration data corresponding to each level can be partitioned into three clusters with three centroids in an ascending sort order, denoted by Cd = [Cd1, Cd2, Cd3]. Then, if Cd2/Cd1 > 3.5, it means that data samples clustered around Cd1 are from the glitches, and the basic dot duration unit is given by D0 = Cd2. Otherwise, it means the waveform is good, no jump level exists, and D0 = Cd1. Then, the duration threshold can be obtained as DT = e1*D0, where e1 denotes an adjustable parameter. In addition, we assume e1 = 0.3 at this time. The ratio 3.5 and e1 = 0.3 are established based on the experimental dataset observations for the optimal decoding result.

Appl. Sci. 2020, 10, 1227 8 of 16

3. Calculate the distance between two centroids by d = abs (C C ). If d < s, it means that two V2 − V1 clusters are similar. At this time, all sampling values are divided into high or low level. Then, set VT = 0; otherwise, set VT = (CV2 + CV1)/2; 4. Iterate over all data samples; a value above the obtained threshold in step (3) indicates “1;” meanwhile, a value below indicates “0.”

4.3. Error Correction In many cases, there exist multiple unexpected glitches in signals after binarization due to the noise effects. As Figure6 shows, the red circle marks in the block binarization indicate hopping points. Thus, we design the error correction algorithm to eliminate these abnormal hopping voltages and guarantee an accurate subsequent decoding process. The first step is to compute a threshold of durations for the purpose of localizing the emerging glitch positions. By using the algorithm in Section 2.2, duration data corresponding to each level can be partitioned into three clusters with three centroids in an ascending sort order, denoted by Cd = [Cd1, Cd2, Cd3]. Then, if Cd2/Cd1 > 3.5, it means that data samples clustered around Cd1 are from the glitches, and the basic dot duration unit is given by D0 = Cd2. Otherwise, it means the waveform is good, no jump level exists, and D0 = Cd1. Then, the duration threshold can be obtained as DT = e1*D0, where e1 denotes an adjustable parameter. In addition, we assume e1 = 0.3 at this time. The ratio 3.5 and e1 = 0.3 are established based on the experimental dataset observations for the optimal decoding result. To increase the identifying accuracy, we introduce the average voltage amplitude as the second judgement criteria beyond the duration data. The average voltage amplitude refers to the statistical average of all sampled voltage values during a period of one level (“0” or “1”). Assume two new voltage thresholds, described as VTH = VT + Vpp e × 2 (5) VTL = VT Vpp e − × 2 where VT is the binarization voltage threshold computed in Section 4.2, VPP denotes the peak–peak voltage value, and e2 represents another adjustable parameter; it is also established based on the experimental dataset observations and is set at 0.25 in this case for the optimal decoding result. In addition, using a different value may lead to erratic performance in our experiment. Let us denote Dc and Vac to the current duration and average voltage value during one level, respectively; then, the glitches can be localized under the following constraint:

Dc < DT VTL < Vac < VT VT < Vac < VTH. (6) k k After marking the hopping glitches, it is time to identify their position relations to the normal voltage level. To be precise, there should be six different statuses of the emerging voltage spikes, which can represent all potential situations. In addition, the voltage spike can be either low or high. As long as the duration of a level is less than the computed duration threshold, it is considered as a voltage spike and merging is performed until meeting a complete voltage level (duration higher than threshold). These six cases are distinguished according to whether the transition part can form a complete level and its adjacent level condition (high or low). As the Figure8 shows: (a) If several consecutive spikes can form a complete level after merging their duration (no longer a spike) and its adjacent level is low, then the combined one is set at high, denoted by the red line; (b) similar to (a), if the adjacent is high, then the combined one is set at low; (c) if the combined spike is still a spike after merging their duration and its adjacent level is low, then change it to low level, denoted by the red line; (d) similar to (c), if the adjacent level is high, change it to low level; (e) and (f) if the combined spike still cannot form a complete level after merging their duration, and its previous and next complete levels are of different types (one high and one low), then superimpose half of its duration time to the preceding and succeeding complete levels, respectively. Appl. Sci. 2020, 10, x FOR PEER REVIEW 9 of 17

To increase the identifying accuracy, we introduce the average voltage amplitude as the second judgement criteria beyond the duration data. The average voltage amplitude refers to the statistical average of all sampled voltage values during a period of one level (“0” or “1”). Assume two new voltage thresholds, described as

VTH V T  V pp  e2 , (5) VTL V T  V pp  e2 where VT is the binarization voltage threshold computed in Section 3.2, VPP denotes the peak–peak voltage value, and e2 represents another adjustable parameter; it is also established based on the experimental dataset observations and is set at 0.25 in this case for the optimal decoding result. In addition, using a different value may lead to erratic performance in our experiment. Let us denote Dc and Vac to the current duration and average voltage value during one level, respectively; then, the glitches can be localized under the following constraint:

Dc < DT ∥ VTL < Vac < VT ∥ VT < Vac < VTH. (6) After marking the hopping glitches, it is time to identify their position relations to the normal voltage level. To be precise, there should be six different statuses of the emerging voltage spikes, which can represent all potential situations. In addition, the voltage spike can be either low or high. As long as the duration of a level is less than the computed duration threshold, it is considered as a voltage spike and merging is performed until meeting a complete voltage level (duration higher than threshold). These six cases are distinguished according to whether the transition part can form a complete level and its adjacent level condition (high or low). As the Figure 8 shows: (a) If several consecutive spikes can form a complete level after merging their duration (no longer a spike) and its adjacent level is low, then the combined one is set at high, denoted by the red line; (b) similar to (a), if the adjacent is high, then the combined one is set at low; (c) if the combined spike is still a spike after merging their duration and its adjacent level is low, then change it to low level, denoted by the red line; (d) similar to (c), if the adjacent level is high, change it to low level; (e) and (f) if the combined spike still cannot form a complete level after merging their duration, and its previous and Appl.next Sci.complete2020, 10, 1227 levels are of different types (one high and one low), then superimpose half9 of o 16f its duration time to the preceding and succeeding complete levels, respectively.

(a) (b) (c) (d) (e) (f)

Figure 8. Error correction cases cases..

Take the the string string “SOS” “SOS” as an a example;s an example Figure9 ;presents Figure its 9 corresponding presents its signal corresponding waveform during signal waveformtheAppl. whole Sci. 2020 pretreatment , 10 during, x FOR PEER the process. REVIEWwhole pretreatment In addition, some process. of the errorIn addition, cases mentioned some of above the error are marked 10 cases of 17 mentionedby the vertical above red lines. are It marked can be clearly by the seen vertical that the red emerging lines. voltageIt can spikes be clearly after binarization seen that the are emergingeaff pureectively and eliminatedvoltage stable spikesMorse using after-encoded this binar method, signalization and interpreting are a pure effectively and stable “SOS” eliminated Morse-encoded is derived using after signalthis themethod, interpreting designed and “SOS”pretreatment is derived stage. after the designed pretreatment stage.

Figure 9. Pretreatment of Morse signal interpreting “SOS”.“SOS.”

5. Morse Code Decoding 5. Morse Code Decoding Considering that we have obtained a relatively stable Morse-encoded signal after the pretreatment stage,Considering it is easy to identifythat we the have elements obtained using a relatively the k-means stable algorithm Morse and-encoded derive thesignal decoded after datathe basedpretreatment on the Morse stage, code it is table. easy This to identify stage includes the elements dot–dash using recognition, the k-means space recognition, algorithm and and accuracyderive the computation. decoded data based on the Morse code table. This stage includes dot–dash recognition, space recognition, and accuracy computation. 5.1. Dot–Dash Recognition 5.1. DotConsidering–Dash Recognition that both dots and dashes are represented by “1” (high level) according to Morse encodingConsidering rules, the onlythat dibothfference dots between and dash themes are is the represented time duration. by The“1” dot (high duration level) is according the basic unit to of time measurement in code transmission, while the dash duration is three units. As the time duration Morse encoding rules, the only difference between them is the time duration. The dot of the voltage level changes after pretreatment, it is necessary to recalculate the dot, as well as the duration is the basic unit of time measurement in code transmission, while the dash duration is three units. As the time duration of the voltage level changes after pretreatment, it is necessary to recalculate the dot, as well as the dash, duration thresholds. Thus, the mk- means clustering algorithm is performed to accomplish the classification of different high- level samples and dot–dash recognition. Figure 10a shows a flowchart of our dot–dash recognition algorithm: 1. Extract the high-level samples output after signal pretreatment, stored in an array; 2. Perform the mk-means method to partition these data samples into two clusters, and store the classification results in a new array HA; 3. Sort the two cluster centroids in ascending order, stored in an array CH, and ensure that CH(0) is less than CH(1). If the order of the cluster centroids changes, then update the centroid index stored in HA; 4. Assume the basic dot duration computed above is D0 and s = CH(1)/CH(0). If s < 2, it indicates that the two clusters belong to one common category. At this point, if

Appl. Sci. 2020, 10, 1227 10 of 16 dash, duration thresholds. Thus, the mk-means clustering algorithm is performed to accomplish the classification of different high-level samples and dot–dash recognition. Figure 10a shows a flowchart of our dot–dash recognition algorithm:

1. Extract the high-level samples output after signal pretreatment, stored in an array; 2. Perform the mk-means method to partition these data samples into two clusters, and store the classification results in a new array HA; 3. Sort the two cluster centroids in ascending order, stored in an array CH, and ensure that CH(0) is less than CH(1). If the order of the cluster centroids changes, then update the centroid index stored in HA; Appl. Sci. 2020, 10, x FOR PEER REVIEW 11 of 17 4. Assume the basic dot duration computed above is D0 and s = CH(1)/CH(0). If s < 2, it indicates that the two clusters belong to one common category. At this point, if CH(1)/D0 2, then it means CH(1)/D0 ≤ 2, then it means all the samples in HA denote “dot,” and all≤ indexes in the all the samples in HA denote “dot,” and all indexes in the array need to be updated to 0; else, if array need to be updated to 0; else, if CH(1)/D0 > 2, then it means HA represents “dash,” CH(1)/D > 2, then it means HA represents “dash,” and the indexes should be updated to 1. and the0 indexes should be updated to 1.

START START

High-Level Low-Level Samples Samples Extraction Extraction

Perform K-Means Algorithm value=dataLow(i)/Dn

Sort the two centroids value<2? Y

N LA(i)=1 Centroids order change ? Y

Update HA N value<4? Y

N LA(i)=3 CH(1)/CH(0) N <2? value<6? Y Y

N LA(i)=5

CH(1)/D0 N >2? LA(i)=7

Y

N Update HA to 1 Update HA to 0 Iterarion Over?

Y

END END (a) (b)

FigureFigure 10.10. Flowchart ofof (aa)) dot–dash,dot–dash, andand ((bb)) spacespace recognitionrecognition algorithms.algorithms.

5.2.5.2. SpaceSpace Recognition Recognition In Morse coding rules, space refers to a period of signal absence following each dot or dash, which In Morse coding rules, space refers to a period of signal absence following each dot or represents 0 (low level) in binary optical signals. Spaces between adjacent dots and dashes, two letters, words,dash, which and sentences represents are 1, 0 3,(low 5, and level) 7 units in binary long, respectively. optical signals. Therefore, Spaces a similar between concept adjacent is used dots to classifyand dashes, all the two low-level letters, samples words, into and these sentences four statuses are by1, calculating3, 5, and 7 the units time long, duration respectively. threshold. AssumeTherefore,Dn = a CH(0) similaris theconcept new computed is used to basic classify duration, all the used low to- initializelevel samples the threshold, into these and four it is notedstatuses that by while calculating two clusters the time both duration indicate “dash” threshold. at the Assume same time, Dn =D CH(0)n is supposed is the new to be computed 1/3 of the smallerbasic duration cluster centroid, used to value. initial Asize illustrated the threshold, in Figure and 10b, it the is noted space recognitionthat while resultstwo clusters are stored both in indicate “dash” at the same time, Dn is supposed to be 1/3 of the smaller cluster centroid value. As illustrated in Figure 10b, the space recognition results are stored in an array LA, where the element value indicates the exact time duration units. For example, 3 denotes 3 units, representing spaces between adjacent letters.

5.3. Accuracy Computation

To quantify the accuracy of our recognition algorithm, the Levenshtein distance (edit distance) is used by counting the minimum number of edit operations required to transform one string into the other. The modification operations include: (a) Insert a character; (b) delete one character; and (c) replace one character with another. Let us denote R = [r1 r2…ri] and D = [d1 d2…dj] as the raw data string and the decoded data string, respectively. m[i,j]

Appl. Sci. 2020, 10, 1227 11 of 16 an array LA, where the element value indicates the exact time duration units. For example, 3 denotes 3 units, representing spaces between adjacent letters.

5.3. Accuracy Computation To quantify the accuracy of our recognition algorithm, the Levenshtein distance (edit distance) is used by counting the minimum number of edit operations required to transform one string into the other. The modification operations include: (a) Insert a character; (b) delete one character; and (c) replace one character with another. Let us denote R = [r1 r2 ... ri] and D = [d1 d2 ... dj] as the raw data string and the decoded data string, respectively. m[i,j] represents the edit distance between the first i characters of R and the first j characters of D, and is expressed as [29]   0 i = 0, j = 0    j i = 0, j > 0 m(i, j) =  , (7)  i i > 0, j = 0   min(m(i 1, j) + 1, m(i, j 1) + 1, m(i 1, j 1) + f lag) i > 0, j > 0 − − − − where the flag variable is the indicator function equal to 0 when R[i] = D[j], and equal to 1 otherwise. Then, we have the recognition accuracy,

m(i, j) A = 1 , (8) − max( R , D ) | | | | where |R| and |D| represent the length of the raw and decoded data string, respectively. In addition, the procedure of this dynamic programming algorithm to derive the edit distance is shown in Algorithm 1:

Algorithm 1 String similarity algorithm 1: procedure Levenshtein Distance (R, D) 2: int m[i,j] = 0 3: for each i 1 to |R| do ← 4: m[i,0] = i 5: end for 6: for each j 1 to |D| do ← 7: m[0, j] = j 8: end for 9: for each i 1 to |R| do ← 10: for each j 1 to |D| do ← 11: t if (R[i] = D[j]) then 0 else if 1 ← 12: m[i,j] = min{ m[i 1,j 1] + t, m[i 1,j] + 1, m[i,j 1] + 1} − − − − 13: end for 14: end for 15: return m[|R|, |D|] 16: end procedure

6. Experimental Validation

6.1. Experimental Setup The experimental testbed for our proposed system prototype is shown in Figure 11; we use this prototype to generate a real optical Morse encoded signal and verify the feasibility of our proposed automatic recognition approach. Appl. Sci. 2020, 10, x FOR PEER REVIEW 12 of 17

represents the edit distance between the first i characters of R and the first j characters of D, and is expressed as [29]  00,0ij==   j ij=>0, 0 mi(, j )= ,  >= (7)  iij0, 0 min((1,)1,(,1)1,(1,1)mi−+ j mi j −+−−+ mi j flag ) i >> 0,0 j where the flag variable is the indicator function equal to 0 when R[i] = D[j], and equal to 1 otherwise. Then, we have the recognition accuracy, mi(, j ) A =−1 , (8) max(RD , )

where |R| and |D| represent the length of the raw and decoded data string, respectively. In addition, the procedure of this dynamic programming algorithm to derive the edit distance is shown in Algorithm 1: Algorithm 1 String similarity algorithm 1: procedure Levenshtein Distance (R, D) 2: int m[i,j] = 0 3: for each i ←1 to |R| do 4: m[i,0] = i 5: end for 6: for each j ←1 to |D| do 7: m[0 , j] = j 8: end for 9: for each i ←1 to |R| do 10: for each j ←1 to |D| do 11: t ← if (R[i] = D[j]) then 0 else if 1 12: m[i,j] = min{ m[i-1,j-1] + t, m[i-1,j] + 1, m[i,j-1] + 1} 13: end for 14: end for 15: return m[|R|, |D|] 16: end procedure

6. Experimental Validation

6.1. Experimental Setup

The experimental testbed for our proposed system prototype is shown in Figure 11; we Appl.use this Sci. 2020 prototype, 10, 1227 to generate a real optical Morse encoded signal and verify the feasibility12 of 16 of our proposed automatic recognition approach.

(a) (b)

Figure 11. Demonstration of proposed free space optical (FSO) prototype: (a) Transmitter side, (b) receiver side.

At Tx, an unstable Morse encoded signal is first produced by an arbitrary waveform generator (AWG 7051). Then, it is modulated to the LED (XLamp® XP-L2) driven by the self-designed driving circuit packed inside the lamp. Note that a signal lamp consisting of LED arrays is employed in our system for the purpose of simulating the maritime optical communication scenarios. At Rx, we use an optical lens (ZLKC-KM5012MP8) with a focal length of 50 mm to narrow the field-of view (FOV) of the receiver, thereby mitigating the incoming ambient light noise. The emitted light signal is captured by a self-designed optical receiving module including an avalanche photo-diode (S8664-50K) and a transimpedance amplifier (LTC6268-10) with a high gain factor of 2 million times. Then, after analog–digital conversion by ADS8866 (16-bit resolution), the signal is applied to the STM32F446 embedded system [30] and processed based on our proposed approach. The sampling period is Ts = 2.7 ms, and the sampling rate of the ADC is set at Fs = 375 Hz to guarantee that there are at least 20 C30 samples during the period of a basic dot unit. Finally, the output recognition results are analyzed on the computer in real time using the algorithm mentioned in Section 4.3, and the accuracy performance is determined. The key parameters of the devices used in this system are listed in Table1.

Table 1. System configuration parameters.

Device Manufacturer Model AWG Tektronix AWG 7051 LED Cree Inc XLamp® XP-L2 Lens ZhiSai Technology ZLKC-KM5012MP8 APD Hamamatsu Photonics S8664-50K TIA Linear Technology LTC6268-10 ADC Texas Instruments ADS 8866 MCU STMicroelectronics STM32F446

6.2. Recognition Accuracy Evaluation In the experiments, a Morse-encoded signal interpreting the string “hello world” is generated on the computer with MATLAB using the method in Section 2.1, and the durations and amplitude fluctuation are considered by controlling the µ and σ2 and adding AWGN, respectively. We first investigate the offline performance. Figure 12 shows the off-line pretreatment results based on the mk-means clustering algorithm. One can observe that the obtained waveform is just the same as the original signal, which indicates that our method works well. Appl.Appl. Sci. 20202020, ,1010, ,x 1227 FOR PEER REVIEW 14 of 1713 of 16 Appl. Sci. 2020, 10, x FOR PEER REVIEW 14 of 17 M orse signal with noises 80 60 40 20 M orse signal with noises 080 (mV) (mV)

Amplitude Amplitude -2060 40 200123456789 0

(mV) (mV) Time (s)

Amplitude Amplitude -20 After FIR Denoising 0123456789 40 Time (s) 20 After FIR Denoising

(mV) (mV) 040 Amplitude Amplitude 0123456789 20 Time (s)

(mV) (mV) 0

Amplitude Amplitude A fte r B in a riza tio n 1 0123456789 Time (s) 0.5 A fte r B in a riza tio n 0 Amplitude 1 0123456789 0.5 Time (s) 0 Amplitude A fte r E rro r C o rre c tio n 1 0123456789 0.5 Time (s) 0

Amplitude A fte r E rro r C o rre c tio n 01234567891 Time (s) 0.5 0 Raw Morse Data Amplitude 1 0123456789 0.5 Time (s)

Amplitude 0 Raw Morse Data 01234567891 Time (s) 0.5

Amplitude 0 0123456789Figure 12. Simulation results of Morse signal interpreting “hello world.” Time (s) Then, the prototypeFigureFigure 12.12. is Simulation used to test resultsresults the ofof real MorseMorse-time signalsign decodingal interpretinginterpreting accuracy. “hello“hello world.”Theworld.” optical signal emitted from LED arrays is received by the photo detector and then processed in the Then, the prototype is used to test the real-time decoding accuracy. The optical signal emitted embeddedThen, system;the prototype the translation is used toresults test theare realobta-timeined bydecoding the serial accuracy. port software The optical on the signal from LED arrays is received by the photo detector and then processed in the embedded system; the translationcomputer.emitted from resultsFigure LED are13 arrays obtaineddisplays is by receivedthe the real-time serial by port thre softwareecognition photo ondetector results the computer. inand the then FigureSerial processed Assistant13 displays in the real-timesoftwareembedded recognitionderived system; from resultsthe STM32. translation in the It Serialis also results Assistant obse rvedare software obtathat inedthe derived decoding by the from serial results STM32. port are It softwareexactly is also observedthe on the thatsamecomputer. the as decodingthe rawFigure string results 13 “hello displays are exactly world.” the the It real-timeis same wort ash thenoticing re rawcognition stringthat the “helloresults transceiver world.” in the was It isSerial originally worth Assistant noticing thatdesignedsoftware the transceiver derivedfor the wasfromlong-range originally STM32. outdoor designedIt is also foren obsevironment therved long-range that and the outdoor candecoding support environment results 4.8 andarekm canexactlyFSO support the 4.8communicationsame km as FSO the communication raw [31]. string The “hello transmitter [31]. world.” The transmitter consists It is wort of consists moreh noticing than of more 30 that LEDs, than the 30 eachtransceiver LEDs, at eacha DC atwas forward a DC originally forward currentcurrentdesigned ofof 1500 1500for mA mAthe and andlong-range a correspondinga corresponding outdoor electrical electric en powervironmental power of 4.35 of W,and 4.35 which canW, iswhichsupport enough is enough for 4.8 indoor km for optical FSO wirelessindoorcommunication optical communication. wireless [31]. The communication. Thus, transmitter the received consistsThus, optical th eof received power more maintainsthan optical 30 LEDs,power a high eachmaintains level at in a the DCa high laboratory forward level in the laboratory environment, and the recognition accuracy also remains the same environment,current of 1500 and mA the recognition and a corresponding accuracy also electric remainsal the power same afterof 4.35 increasing W, which the distanceis enough from for 1 toafter 6 m. increasing the distance from 1 to 6 m. indoor optical wireless communication. Thus, the received optical power maintains a high level in the laboratory environment, and the recognition accuracy also remains the same after increasing the distance from 1 to 6 m.

FigureFigure 13. 13. Real-timeReal-time optical optical Morse Morse code code recognition recognition results. results.

6.3. System Robustness Evaluation 6.3. System Robustness Evaluation To evaluate the performance and robustness of our system, we investigate the recognition accuracy To evaluate the Figureperformance 13. Real-time and opticalrobustness Morse codeof ourrecognition system, results. we investigate the under different signal-to-noise ratio (SNR) conditions. Considering that it is difficult to accurately recognition accuracy under different signal-to-noise ratio (SNR) conditions. Considering control the SNR of the input signal over the optical path, the experiment is conducted between the that6.3. Systemit is difficult Robustness to accurately Evaluation control the SNR of the input signal over the optical path, the PC and STM32 through the serial port. During the test, two English texts containing 2196 characters experiment is conducted between the PC and STM32 through the serial port. During the wereTo selected evaluate as the rawthe data,performance and each characterand robustness appeared randomly.of our system, Note that we the transmittinginvestigate datathe test, two English texts containing 2196 characters were selected as the raw data, and each volumerecognition is far moreaccuracy than thatunder of usualdifferent use in signal-t our consideredo-noise realratio maritime (SNR) scenario.conditions. Considering that Theit is specificdifficult test to accurately procedure iscontrol as follows: the SNR First, of the the input raw data signal of lengthover the 2196 optical characters path, arethe Morse-encoded and superimposed with noise in MATLAB. By controlling the proportion of noise experiment is conducted between the PC and STM32 through the serial port. During the samples, the Morse-encoded signal data with different SNRs ( 3–6 dB) is generated on the PC and test, two English texts containing 2196 characters were selected− as the raw data, and each

Appl. Sci. 2020, 10, x FOR PEER REVIEW 15 of 17

character appeared randomly. Note that the transmitting data volume is far more than that of usual use in our considered real maritime scenario. The specific test procedure is as follows: First, the raw data of length 2196 characters are Morse-encoded and superimposed with noise in MATLAB. By controlling the proportion of noise samples, the Morse-encoded signal data with different SNRs (–3–6 dB) Appl.is generated Sci. 2020, 10 ,on 1227 the PC and then transmitted to the STM32-embedded system through14 ofthe 16 serial port; secondly, STM32 stores and decodes the received data and returns the thenrecognition transmitted results to the back STM32-embedded to the host computer. system through Finally, the in serialthe host port; computer, secondly, STM32the original stores and and decodesdecoded the data received file are data examined, and returns and the the recognition decoding results accuracy back tois thestatistically host computer. analyzed. Finally, The in thestatistical host computer, decoding the results original during and decoded the experiment data file are examined,listed in Table and the2. decoding accuracy is statistically analyzed. The statistical decoding results during the experiment are listed in Table2. Table 2. Recognition results under different signal-to-noise ratios (SNRs). Table 2. Recognition results under different signal-to-noise ratios (SNRs). SNR (dB) Total Characters Correct Characters Accuracy SNR− (dB)3 Total Characters2196 Correct Characters 1979 Accuracy90.1% 3−1 21962196 1979 2003 90.1%91.2% − 11 21962196 2003 2038 91.2%92.8% − 13 21962196 2038 2102 92.8%95.7% 35 21962196 2102 2128 95.7%96.9% 5 2196 2128 96.9% 66 21962196 2176 2176 99.1% The curve of recognition accuracy versus SNR derived from Table 2 is plotted in Figure 14. ItThe is curvenoticed of recognitionthat the decoding accuracy versusaccuracy SNR increases derived from with Table the2 growthis plotted of in the Figure SNR. 14. Our It is noticedproposed that approach the decoding can accuracy achieve increases an average with theautomatic growth ofrecognition the SNR. Our accuracy proposed of approach more than can achieve90% when an average the SNR automatic of the recognitioninput signal accuracy is greater of more than than −3 90%dB. whenFurthermore, the SNR of an the accuracy input signal of isover greater 95% than is observed3 dB. Furthermore, with an SNR an accuracygreater than of over 3 dB. 95% In is the observed case that with the an noise SNR greater is relatively than 3 − dB.strong In the with case an that SNR the of noise −3 dB, is relatively the system strong can with still an achieve SNR of a3 good dB, the accuracy system canof 90.1%. still achieve Thus, a − goodwe conclude accuracy ofthat, 90.1%. in the Thus, presence we conclude of ambien that, int thelight presence noise, of the ambient proposed light noise,mk-means the proposed based mk-meansrecognition based system recognition still performs system still well performs in terms well of inthe terms decoding of the decoding accuracy accuracy performance. performance.

Recognition accuracy under different SNR 99.10% 100.00% 96.90% 95.70% 95.00% 92.80% 91.20% 90.10% 90.00% Accuracy

85.00% -3-11356 SNR (dB)

Figure 14. Recognition accuracy under different different SNRs. 7. Conclusions 7. Conclusions In conclusion, we proposed an automatic recognition scheme for maritime optical Morse lamps basedIn on conclusion, a modified k-means we proposed clustering an algorithm. automatic A flexible recognition FSO communication scheme for prototypemaritime consisted optical ofMorse LED arrays,lamps and based an MCU on wasa constructedmodified k-means for real data clustering collection andalgorithm. real-time decoding.A flexible We FSO also investigatedcommunication the performance prototype consisted of the proposed of LED approach arrays, includingand an MCU recognition was constructed accuracy, as for well real as systemdata collection robustness. and Real-time real-time recognition decoding. results We derived also investigated from the MCU the indicate performance that the accuracy of the increasesproposed with approach the growth including of the SNR,recognition and can accuracy, reach more as than well 99%. as system It is worth robustness. mentioning Real-time that our proposedrecognition modified results k-means derived clustering from the algorithm MCU indi can alsocate bethat applied the accuracy in other digital increases communication with the systemsgrowth of for the decision SNR, and threshold can reach optimization more than and 99%. is adaptive It is worth to dimentioningfferent channel that our characteristics. proposed In the future, we will further investigate the recognition performance based on other ML-based clustering algorithms.

Author Contributions: Conceptualization, X.W. and M.Z.; methodology, X.W. and M.Z.; software, X.W., M.Z., H.Z. and X.L.; validation, X.L.; formal analysis, X.W. and M.Z.; investigation, X.W. and M.Z.; resources, H.Z. and X.L.; data curation, X.W. and M.Z.; writing—original draft preparation, X.W.; writing—review and editing, M.Z.; visualization, X.W., H.Z. and X.L.; supervision, M.Z. and X.R.; project administration, M.Z. All authors have read and agreed to the published version of the manuscript. Appl. Sci. 2020, 10, 1227 15 of 16

Funding: This research received no external funding. Conflicts of Interest: The authors declare no conflict of interest.

References

1. Khalighi, M.A.; Uysal, M. Survey on free space optical communication: A communication theory perspective. IEEE Commun. Surv. Tutor. 2014, 16, 2231–2258. [CrossRef] 2. Grant, K.J.; Mudge, K.A.; Clare, B.A.; Perejma, A.S.; Martinsen, W.M. Maritime Laser Communications Trial 98152-19703, DSTO; Endinburgh: South Australia, Australia, 2012. 3. Sluz, J.E.; Riggins, J., II; Juarez, J.C.; Sova, R.M.; Young, D.W.; Nelson, C. Characterization of data transmission through a maritime free-space optical channel with a custom bit error rate tester. Proc. Spie 2010, 7700, 77000D. 4. Yu, J.; Li, Q.; Li, H.; Wang, Q.; Zhou, G.; He, D.; Xu, S.; Xia, Y.; Huang, Y. High-Precision Light Spot Position Detection in Low SNR Condition Based on Quadrant Detector. Appl. Sci. 2019, 9, 1299. [CrossRef] 5. New Atlas. Available online: https://newatlas.com/us-navy-signal-lamps-fltc-texting/50523/ (accessed on 10 October 2019). 6. Sapaico, L.R.; Sato, M. Analysis of vision-based text entry using Morse code generated by tongue gestures. In Proceedings of the 2011 4th International Conference on Human System Interactions (HSI), Yokohama, Japan, 19–21 May 2011; pp. 158–164. 7. Hsieh, M.C.; Luo, C.H.; Mao, C.W. Unstable Morse code recognition with adaptive variable-ratio threshold prediction for physically disabled persons. IEEE Trans. Rehabil. Eng. 2000, 8, 405–413. [CrossRef][PubMed] 8. Popular Mechanics. Available online: https://www.popularmechanics.com/military/navy-ships/a27391/us- navy-Morse-code-software/ (accessed on 10 October 2019). 9. Ma, W.; Zhang, J.; Wang, H. Automatic Decoding System of Morse Code. O.I. Autom. 2007, 26, 51–52. 10. Xiao-Na, Z.; Guo-Jun, L.; Yong, J.; Li, Z. Automatic reception of High-frequency CW telegraph with Support Vector Machine. In Proceedings of the 2nd IEEE International Conference on Future Computer and Communication, Wuhan, China, 21–24 May 2010; pp. 335–338. 11. Zahradnik, P.; Šimák, B. Implementation of Morse decoder on the TMS320C6748 DSP development kit. In Proceedings of the 2014 6th IEEE European Embedded Design in Education and Research Conference, Milan, Italy, 11–12 September 2014; pp. 128–131. 12. Xiao, S.; Gao, Y. Multiplexed Morse Telegraph Automatic Decoding Based on Wavelet Transform. Comput. Digit. Eng. 2017, 45, 632–636. 13. Wei, Z.; Jia, K.; Sun, Z. An Automatic Detection Method for Morse Signal Based on Machine Learning. In Proceedings of the 12th International Conference on Intelligent Information Hiding and Multimedia Signal, Matsue, Japan, 12–15 August 2017; pp. 185–191. 14. Wang, X.; Zhao, Q.; Ma, C.; Xiong, J. Automatic Morse Code Recognition Under Low SNR. In Proceedings of the 2018 International Conference on Mechanical, Electronic, Control and Automation Engineering, Manila, Philippines, 5–7 January 2018. 15. Yuan, Y.; Sun, Z.; Wei, Z.; Jia, K. DeepMorse: A Deep Convolutional Learning Method for Blind Morse Signal Detection in Wideband Wireless Spectrum. IEEE Access 2019, 7, 80577–80587. [CrossRef] 16. Wang, Y.; Sun, Z.; Jia, K. An Automatic Decoding Method for Morse Signal based on Clustering Algorithm. In Proceedings of the 12th International Conference on Intelligent Information Hiding and Multimedia Signal Processing, Kaohsiung, China, 21–23 November 2016; pp. 235–242. 17. Qu, S.; Liu, H.; Zhang, X. Morse Recognition Algorithm Based on K-means. In Proceedings of the 2019 IEEE Cross Strait Quad-Regional Radio Science and Wireless Technology Conference, Taiyuan, China, 19–22 July 2019; pp. 1–2. 18. Lee, C.T.; Shen, T.C.; Lee, W.D. A Novel Optical Morse Code-Based Electronic Lock Using the Ambient Light Sensor and Fuzzy Controller. Appl. Sci. 2017, 7, 140. [CrossRef] 19. Bilal, M.; Liu, S.; Qiao, G.; Wan, L.; Tao, Y. Bionic Morse Coding Mimicking Humpback Whale Song for Covert Underwater Communication. Appl. Sci. 2020, 10, 186. [CrossRef] 20. Ma, S.; Dai, J.; Lu, S.; Li, H.; Zhang, H.; Du, C.; Li, S. Signal Demodulation with Machine Learning Methods for Physical Layer Visible Light Communications: Prototype Platform, Open Dataset, and Algorithms. IEEE Access 2019, 7, 30588–30598. [CrossRef] Appl. Sci. 2020, 10, 1227 16 of 16

21. Zhang, X. The Distinction of Ship’s Communication Signals. J. Jimei. Navig. Inst. 1996, 14, 19–25. 22. Zhang, J.; Chen, W.; Gao, M.; Shen, G. K-means-clustering-based fiber nonlinearity equalization techniques for 64-QAM coherent optical communication system. Opt. Express 2017, 25, 27570–27580. [CrossRef] [PubMed] 23. Peng, Y.; Liu, X.; Shen, C.; Huang, H.; Zhao, D.; Cao, H.; Guo, X. An Improved Optical Flow Algorithm Based on Mask-R-CNN and K-Means for Velocity Calculation. Appl. Sci. 2019, 9, 2808. [CrossRef] 24. Hou, X. An Improved K-means Clustering Algorithm Based on Hadoop Platform. In Proceedings of the International Conference on Cyber Security Intelligence and Analytics, Shenyang, China, 21–22 February 2019; pp. 1101–1109. 25. Cardarilli, G.C.; Di Nunzio, L.; Fazzolari, R.; Re, M.; Spanó, S. AW-SOM, an algorithm for high-speed learning in hardware self-organizing maps. IEEE Trans. Circuits Syst. IiExp. Briefs 2019, 67, 380–384. [CrossRef] 26. Cardarilli, G.C.; Di Nunzio, L.; Fazzolari, R.; Nannarelli, A.; Re, M.; Spanò, S. N-Dimensional Approximation of Euclidean Distance. IEEE Trans. Circuits Syst. IiExp. Briefs 2019, 55, 161. [CrossRef] 27. Tolentino, J.A.; Gerardo, B.D.; Medina, R.P. Enhanced Manhattan-Based Clustering Using Fuzzy C-Means Algorithm. In Proceedings of the International Conference on Computing and Information Technology, Chiangmai, Thailand, 5–6 July 2018; pp. 126–134. 28. Heineman, G.T.; Pollice, G.; Selkow, S. Algorithms in a Nutshell: A Practical Guide, 2rd ed.; O’Reilly Media, Inc.: Sebastopol, CA, USA, 2016; pp. 53–89. 29. Zhao, Z.; Yin, Z.; Wang, Q.; Xu, X.; Jiang, H. An improved algorithm of Levenshtein Distance and its application in data processing. J. Comput. Applicat. 2009, 29, 424–426. [CrossRef] 30. STMicroelectronics 32-bit Arm Cortex MCUs. Available online: https://www.st.com/en/microcontrollers- microprocessors/stm32f446.html (accessed on 26 January 2020). 31. Zhou, H.; Zhang, M.; Wang, X.; Ren, X. Implementation of High Gain Optical Receiver with the Large Photosensitive Area in Visible Light Communication. In Proceedings of the Asia Communications and Photonics Conference, Chengdu, China, 2–5 November 2019; pp. 99–101.

© 2020 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).