Comparison of Filtering Methods for Enhanced Reliability of a Train Axle Counter System

This paper presents signal filtering methods that can be effectively applied to train detection systems based on the axle counter systems that are currently in operation for train detection and provide information on the unoccupied status of railway tracks and turnouts. Signals from the wheel detectors contain noise, may be impulsive and time-varying, which means that even for the same train, the signals from the following wheels may be different. A problem appears when already homologated hardware (axle counter system) is working in a harsh environment, exposed to disturbances whose parameters significantly exceed standard thresholds. Despite this, the system must continue to provide reliable information. The authors present research on the application of such filters as median, Savitzkey-Golay, and moving average which can be implemented in the equipment currently in use under specific constraints (e.g., limited computational resources). The research results show that appropriately adjusted filters, for example, in terms of type and window size, increase the signal quality and thereby provide reliable information about passing trains, as well as enhance the availability and safety of the axle counter system performance.


Introduction
Train control systems are crucial components to ensure a safe and efficient operation of railways. Researchers try to enhance the reliability of transportation in a variety of manners, namely by constructing a decision support system for railway traffic management [1], or by developing suitable condition monitoring techniques to ensure early, preventive diagnostics for railway systems [2,3]. In order to make transportation safe, rail inspections should also be done properly. An efficient crack (broken rail) detection system is proposed by Kumar et al. [4] for better diagnostics and inspection.
Research is also carried out in the direction of using obstacle detections systems (study for image processing presented by Yao and colleagues [5]). Nowadays, such systems are commercially used for monitoring lines (e.g., distributed acoustic sensing based on fiber optic technology) and level crossings (e.g., radars).
A study on the need for train detection is presented by Palmer [6]. Authors highlight their crucial role for traffic management and safety. In the past traditional track circuit was used as a system for detecting non-occupancy of sections; in recent year they have been successively replaced by axle counters [6].
An axle counter, which is used for train detection, has currently been one of the most important railway signaling systems, that should provide reliable and safe information for train control purposes. In order to fulfill this task, specific sensors (detectors) are used to confirm the integrity of a train and to indicate if a track section is unoccupied [7]. Other sensors may indicate independent measurements of Sensors 2020, 20, 2754 3 of 18 fixed because of the costs. There are already thousands of detectors installed around the world, for which software upgrade is the only acceptable option for improvement. Any hardware modification (i.e., a replacement of the existing hardware with the new one) is not feasible for financial reasons. Another reason is that such a type of system is subject to validation and a homologation process. A high number of tests (e.g., environmental tests, electromagnetic compatibility tests) and analyses need to be repeated when a hardware platform is changed. Any software modification requires re-testing as well, however test scope can be limited (e.g., failure mode and critical effect analysis (FMCEA), temperature tests, vibration tests, and electromagnetic compatibility (EMC) tests in the scope of radiated and conducted emissions can be skipped when hardware platform and safety assurance methods are not changed). Among various methods of signal processing, filtration is the fundamental one and thus presented in this paper. It needs to be noted however, that the amount of time available for signal processing is highly limited and computational resources are fixed.
The article filtration methods [28,29] are intended to be applied in the double head detector whose operation is based on the amplitude modulation of the signal caused by a passing wheel. As described before, hardware construction is considered fixed and cannot be changed. All implemented methods have to fit to the existing hardware platform with all of its constraints (in this paper the limitation is: 16 kHz sample rate per channel, two channels for processing, fixed point operation, 30 µs of available time for signal processing/3500 of atomic operation within available time).
The input signal, which comes from the wheel detector heads is filtered and demodulated in the hardware part of the detector. Software processing starts just after analog to digital conversion of a demodulated signal (envelope) and ends on the output of a decision module, which provides data about the number of counted axles (wheels) and status, containing information about the state of the detector operation and abnormalities of the input signal. The path of the signal processing is presented in Figure 1.
Sensors 2020, 20, x FOR PEER REVIEW 3 of 18 because of the costs. There are already thousands of detectors installed around the world, for which software upgrade is the only acceptable option for improvement. Any hardware modification (i.e., a replacement of the existing hardware with the new one) is not feasible for financial reasons. Another reason is that such a type of system is subject to validation and a homologation process. A high number of tests (e.g., environmental tests, electromagnetic compatibility tests) and analyses need to be repeated when a hardware platform is changed. Any software modification requires re-testing as well, however test scope can be limited (e.g., failure mode and critical effect analysis (FMCEA), temperature tests, vibration tests, and electromagnetic compatibility (EMC) tests in the scope of radiated and conducted emissions can be skipped when hardware platform and safety assurance methods are not changed). Among various methods of signal processing, filtration is the fundamental one and thus presented in this paper. It needs to be noted however, that the amount of time available for signal processing is highly limited and computational resources are fixed.
The article filtration methods [28,29] are intended to be applied in the double head detector whose operation is based on the amplitude modulation of the signal caused by a passing wheel. As described before, hardware construction is considered fixed and cannot be changed. All implemented methods have to fit to the existing hardware platform with all of its constraints (in this paper the limitation is: 16 kHz sample rate per channel, two channels for processing, fixed point operation, 30 µs of available time for signal processing/3500 of atomic operation within available time).
The input signal, which comes from the wheel detector heads is filtered and demodulated in the hardware part of the detector. Software processing starts just after analog to digital conversion of a demodulated signal (envelope) and ends on the output of a decision module, which provides data about the number of counted axles (wheels) and status, containing information about the state of the detector operation and abnormalities of the input signal. The path of the signal processing is presented in Figure 1. The signals between the following blocks are as follows: u1in(t): analog, input signal, channel 1; u2in(t): analog input signal, channel 2; u1in(n): digital, input signal, channel 1; u2in(n): digital, input signal, channel 2; u1out(n): digital, filter output signal, channel 1; u2out(n): digital, filter output signal, channel 2.
It has to be emphasized that the main goal of the research is application of a different filtration method, which can be implemented inside the "Filters Module".

Wheel Detector Signals
Data (signals) used for testing purposes (i.e., test files containing recorded real signals u1in, u2in that are used as input signals for experimental purposes) were collected from the existing installations of Bombardier's axle counter systems in commercial operation. The data was collected manually (i.e., measured during site visits or recorded automatically by autonomous recorders like signal logging devices) and installed in the wheel detectors in various locations all over the world. Only the files containing signals which caused problems with axle counting in the existing axle counter system (i.e., Telegram: a digital telegram that is sent via a transmission link; AXL: the number of counted axles; ST: status of operation (error codes). The signals between the following blocks are as follows: u 1in (t): analog, input signal, channel 1; u 2in (t): analog input signal, channel 2; u 1in (n): digital, input signal, channel 1; u 2in (n): digital, input signal, channel 2; u 1out (n): digital, filter output signal, channel 1; u 2out (n): digital, filter output signal, channel 2.
It has to be emphasized that the main goal of the research is application of a different filtration method, which can be implemented inside the "Filters Module".

Wheel Detector Signals
Data (signals) used for testing purposes (i.e., test files containing recorded real signals u 1in , u 2in that are used as input signals for experimental purposes) were collected from the existing installations of Bombardier's axle counter systems in commercial operation. The data was collected manually (i.e., measured during site visits or recorded automatically by autonomous recorders like signal logging devices) and installed in the wheel detectors in various locations all over the world. Only the files Sensors 2020, 20, 2754 4 of 18 containing signals which caused problems with axle counting in the existing axle counter system (i.e., disturbed the operation of the wheel detectors) were chosen for the experiments (in the existing system the wheel detectors report errors as they are not able to count axles based on built-in criteria).
The number of axles recorded in each test file is known: directly, for the site measurements performed for certain trains, and generally for all train passages where the type of train is known or indirectly as the number of axles has been identified during the test files analysis performed by Bombardier's signaling specialists (based on review of the recorded signals in relation to information logged in the axle counter evaluation unit black boxes and interlocking system logs, if needed). This information allows to define the criteria for test results.
The input signals u 1in (t) and u 2in (t) are low frequency signals measured on the input of a microprocessor of the trackside electronic unit of the wheel detector. These signals are the outcome of evaluation of wheel detector head signals (sinus, ca. 50 kHz), passing through the analog part of the wheel detector. This path consists of an instrumental amplifier with band limited to 100 kHz, an anti-aliasing filter with band limited to 60 kHz, a band-pass filter with band limited to 2 kHz around the center frequency (in order to protect end low pass switching capacity filter), and a synchronic demodulation unit with a tenth order low pass (switching capacity) filter which limits the band to 300 Hz. This path protects the recorder against aliasing phenomena. In the measured signal there is no higher component present than 300 Hz. The sampling rate of the autonomous recorder used for capturing signals was 3 ksps/channel.

Tests Signals
For experimental purposes, the authors decided to choose tests signals for the following scenarios: (1) signal of train passages in one direction, without stops and returns, strongly disturbed, and (2) signal without train passages, containing only noise/disturbances. In order to evaluate filtration methods, case (1) contains a known number of axles and case (2) contains no axles. The data processing can be performed on signals u 1in (n) and u 2in (n) because the analog to digital converter (A/D) module is fixed and cannot be replaced (homologated hardware platform).
Analysis of the genesis and nature of the disturbances overlapped on the axle signal, chosen for experiments is beyond the scope of the research presented in the paper. However, only the signals influenced by electromagnetic disturbances were considered. The source of some are already known, while others are not yet known. Single spikes are mainly caused by arc on the catenary, which may occur during rising or falling of the pantograph. The shape of a signal during the rising differs from the one which occurs during the falling as the nature of discharge is also different. Such spikes can also be generated during the train passage through a neutral section with full power. Regular spikes have been recorded only in a single application and their source is still unknown. It is suspected that they are generated by an onboard system which can either be in testing mode or is not working correctly because it is faulty. It is already known that vehicles in operation in this location are not equipped with the filters on the power feeding system. Continuous disturbances are caused by the return current flowing through the rails and are produced by traction systems of the vehicles. Some of them (of a similar shape) are caused by the ice accumulating on the catenary (arc and sparks during the train passage). Disturbances existing only in the middle of the bogie are mainly caused by radiated disturbances from the traction units (schematically shown in Figure 2).
Other factors which have an impact on the wheel detectors signal, like extensive sideways movement of a wheel (wheel flange is not located directly over the detector head), small wheels (of small diameter, poor flange, spike wheels, wear and tear), or additional metal equipment mounted into the wheelsets (in the metal free zone) were not taken into consideration for the research on filters. Such signals should be dealt with through an appropriate decision algorithm design.
The electromagnetic compatibility of axle counter systems with rolling stock and infrastructure is presented by Dercosi Persichini and colleagues [30]. Based on the research and work of normative groups a couple of standards addressing this issue have been released (e.g., EN 50121, CLC/TS 50238, Sensors 2020, 20, 2754 5 of 18 EN 50617). Although this is also regulated by European Union (EU) Directives (e.g., 2008/57/EC), improvement and better solutions are still sought. Firstly, this is because not all of the systems in operation on the railway network meet the currently valid requirements, and secondly, the condition of infrastructure and vehicles may vary depending on location and changes over time, thereby generating availability issues.  The following test signals were used in the experiments:    The following test signals were used in the experiments:  The following test signals were used in the experiments:     The following test signals were used in the experiments:     The aforementioned signals are categorized and acquired from various locations. A data processing software which relies on threshold values and duration (time) was designed but does not allow for no error solutions for signals A, B and C.
The goal of the research was to eliminate unwanted components from the input signals A, B and C with minimum impact on the main information carried by the signal (as shown in Figure 5). There should be no impact (or it should be as low as possible) on the shape of the axle signal (e.g., the amplitude should not be decreased, and duration should not be changed). An example of the desired result is shown in Figure 6.

Data Processing
Since the hardware was designed a number of years ago, the hardware constraints (microcontroller, memory, clock, etc.) must be considered. To assess the effectiveness of the filtration method a selected test signal (described in Section 2) was fed to the input of a filtration module (FM), shown in Figure 7. Two additional modules, namely, a decision module (DM) and a statistic description (SD), were introduced to evaluate the results. The idea of the signal flow takes into account the applied filter (FM output signal) which is processed in the decision module (details are described further in Section 3.1). The DM is responsible for the calculation of the number of axles (AXL) and the status of operation (ST) (i.e., error code). The AXL is compared with the known real one (expected value). An error code value equal to 0 is considered as no error. The SD module is described in Section 3.3. In general, however, it mainly compares the quality of the signal based on the standard deviation values (σ) of the raw input signal and the filtered one. The aforementioned signals are categorized and acquired from various locations. A data processing software which relies on threshold values and duration (time) was designed but does not allow for no error solutions for signals A, B and C.
The goal of the research was to eliminate unwanted components from the input signals A, B and C with minimum impact on the main information carried by the signal (as shown in Figure 5). There should be no impact (or it should be as low as possible) on the shape of the axle signal (e.g., the amplitude should not be decreased, and duration should not be changed). An example of the desired result is shown in Figure 6. The aforementioned signals are categorized and acquired from various locations. A data processing software which relies on threshold values and duration (time) was designed but does not allow for no error solutions for signals A, B and C.
The goal of the research was to eliminate unwanted components from the input signals A, B and C with minimum impact on the main information carried by the signal (as shown in Figure 5). There should be no impact (or it should be as low as possible) on the shape of the axle signal (e.g., the amplitude should not be decreased, and duration should not be changed). An example of the desired result is shown in Figure 6.

Data Processing
Since the hardware was designed a number of years ago, the hardware constraints (microcontroller, memory, clock, etc.) must be considered. To assess the effectiveness of the filtration method a selected test signal (described in Section 2) was fed to the input of a filtration module (FM), shown in Figure 7. Two additional modules, namely, a decision module (DM) and a statistic description (SD), were introduced to evaluate the results. The idea of the signal flow takes into account the applied filter (FM output signal) which is processed in the decision module (details are described further in Section 3.1). The DM is responsible for the calculation of the number of axles (AXL) and the status of operation (ST) (i.e., error code). The AXL is compared with the known real one (expected value). An error code value equal to 0 is considered as no error. The SD module is described in Section 3.3. In general, however, it mainly compares the quality of the signal based on the standard deviation values (σ) of the raw input signal and the filtered one.

Data Processing
Since the hardware was designed a number of years ago, the hardware constraints (microcontroller, memory, clock, etc.) must be considered. To assess the effectiveness of the filtration method a selected test signal (described in Section 2) was fed to the input of a filtration module (FM), shown in Figure 7. Two additional modules, namely, a decision module (DM) and a statistic description (SD), were introduced to evaluate the results. The idea of the signal flow takes into account the applied filter (FM output signal) which is processed in the decision module (details are described further in Section 3.1). The DM is responsible for the calculation of the number of axles (AXL) and the status of operation (ST) (i.e., error code). The AXL is compared with the known real one (expected value). An error code value equal to 0 is considered as no error. The SD module is described in Section 3.3. In general, however, it mainly compares the quality of the signal based on the standard deviation values (σ) of the raw input signal and the filtered one.

Decision Module
The decision module (DM) is responsible for providing information about the number of axles (AXL) and the status of operation (ST). In other words, it assesses the filtration effectiveness. For the purpose of acquiring the output information, a state machine was designed. It enables detecting a passage of a wheel as a sequence of two signals that are received from the wheel detector heads. The signals from both heads (shifted by about 20 cm) are then demodulated, filtered, and standardized (digitized) to 0/1 values based on the adjustable threshold level (THR). The THR must be adjustable because it depends on the amplitude which is modulated by the passing wheels (issues are described in . Raw signals go through the synchronic demodulation unit (hardware implemented phase sensitive demodulation method) and can be filtered in the module (FM). The output signal is digitized based on the configured threshold level (three values are applied: 1.6 V, 1.2 V, 0.95 V). Thus, the output vector contains the series of 0/1 samples created by both wheel detector heads. Each pair of samples is processed in the state machine and the number of axles counted, or if an improper sequence is detected, an error is indicated as shown in Figure 8.

State Machine
As mentioned, the state machine (SM) was designed for digitized signals which come from a wheel detector head. The signals from the heads are denoted as x and y, respectively. Thus, xy creates an input vector for a state machine (e.g., xy = 00, 01, 10, 11). The SM can be in one of the seven states, (i.e., Si for i = 0…6.) The following parameters are considered in respect of the state machine operations: • axles: number of axles counted after processing of the input vector xy • errorX: number of occurrences of incorrect transitions (accumulated). X is related to the type of sequence detected (for start-up: error0: 00  11, Figure 9)

Decision Module
The decision module (DM) is responsible for providing information about the number of axles (AXL) and the status of operation (ST). In other words, it assesses the filtration effectiveness. For the purpose of acquiring the output information, a state machine was designed. It enables detecting a passage of a wheel as a sequence of two signals that are received from the wheel detector heads. The signals from both heads (shifted by about 20 cm) are then demodulated, filtered, and standardized (digitized) to 0/1 values based on the adjustable threshold level (THR). The THR must be adjustable because it depends on the amplitude which is modulated by the passing wheels (issues are described in Figures 3-5). Raw signals go through the synchronic demodulation unit (hardware implemented phase sensitive demodulation method) and can be filtered in the module (FM). The output signal is digitized based on the configured threshold level (three values are applied: 1.6 V, 1.2 V, 0.95 V). Thus, the output vector contains the series of 0/1 samples created by both wheel detector heads. Each pair of samples is processed in the state machine and the number of axles counted, or if an improper sequence is detected, an error is indicated as shown in Figure 8.

Decision Module
The decision module (DM) is responsible for providing information about the number of axles (AXL) and the status of operation (ST). In other words, it assesses the filtration effectiveness. For the purpose of acquiring the output information, a state machine was designed. It enables detecting a passage of a wheel as a sequence of two signals that are received from the wheel detector heads. The signals from both heads (shifted by about 20 cm) are then demodulated, filtered, and standardized (digitized) to 0/1 values based on the adjustable threshold level (THR). The THR must be adjustable because it depends on the amplitude which is modulated by the passing wheels (issues are described in Figures 3-5). Raw signals go through the synchronic demodulation unit (hardware implemented phase sensitive demodulation method) and can be filtered in the module (FM). The output signal is digitized based on the configured threshold level (three values are applied: 1.6 V, 1.2 V, 0.95 V). Thus, the output vector contains the series of 0/1 samples created by both wheel detector heads. Each pair of samples is processed in the state machine and the number of axles counted, or if an improper sequence is detected, an error is indicated as shown in Figure 8.

State Machine
As mentioned, the state machine (SM) was designed for digitized signals which come from a wheel detector head. The signals from the heads are denoted as x and y, respectively. Thus, xy creates an input vector for a state machine (e.g., xy = 00, 01, 10, 11). The SM can be in one of the seven states, (i.e., Si for i = 0…6.) The following parameters are considered in respect of the state machine operations: • axles: number of axles counted after processing of the input vector xy • errorX: number of occurrences of incorrect transitions (accumulated). X is related to the type of sequence detected (for start-up: error0: 00  11, Figure 9)

State Machine
As mentioned, the state machine (SM) was designed for digitized signals which come from a wheel detector head. The signals from the heads are denoted as x and y, respectively. Thus, xy creates an input vector for a state machine (e.g., xy = 00, 01, 10, 11). The SM can be in one of the seven states, (i.e., Si for i = 0 . . . 6.) The following parameters are considered in respect of the state machine operations: • axles: number of axles counted after processing of the input vector xy • errorX: number of occurrences of incorrect transitions (accumulated). X is related to the type of sequence detected (for start-up: error0: 00 → 11, Figure 9)          For assessment purposes, the following description can be seen in the diagrams presented in Figures 9 and 10: S0 ÷ S6-state of the state machine. For positive direction: spend1, dpend2, dpend3-counter for returns, error1 ÷ error3-counters for errors, input vector xy sequence: 00, 01, 10, 11.
Negative count (b) transitions (without returns): Once the designed state machine is certified it cannot be changed because it produces a validated outcome. This is one of the reasons that the safety systems (certified once) are very difficult to revise. Therefore, under a validated solution another one can be implemented parallelly (i.e., the output values (axle detection) can be indicated by two or more algorithms).
The simplified designed state machine was utilized for the experiment. This is a solution which is not resistant to noise and can be applied in a system which functions based on disturbance-free signals (hardware is more immune/robust and provides better input). Therefore, such a state machine was used for assessing the filtration effectiveness.

Statistic Description Module
Another criterion used for assessing the filtration method was a standard deviation Equation (1) calculated for the output signal in relation to the input one. This parameter was calculated for all the evaluated signals namely signal A (no train passage), signal B (no train passage), and signal C (train passage). Standard deviations of the signals are calculated separately for each of two channels according to Equation (1).
A separate criterion that must be considered without doubt for the assessment of the filtration method is the implementation costs of the algorithm. In particular, such parameters, like the number of coefficients, number of multiply operations, and memory consumption are taken into consideration for comparison of all filters under analysis.

Filters under Analysis
The main goal of the analysis is to achieve the status when low demand computational resources for filtration are combined with high filtration effectiveness and no false axle counts. The most common approaches to smoothing the real signals with limited resources are presented in other studies (see [31][32][33][34]). The cost of the algorithm is crucial; for example, the outcome decision for fast train passage in specific hardware conditions (limited sampling frequency, microcontroller clock speed) must be taken within a short period of time and filtration cannot change the relationship of signals from both detector heads (neither delay nor amplitude can be unsynchronized). One can notice that the disturbances are located in the band and it is not possible to cut the noise/disturbances out by the high order low-pass filter without affecting the core information. In such a case, the following filtration methods were considered [31]:

Moving Average Arithmetic Filter (MAA)
It is one of the most popular filters in the digital processing world [28], mainly due to its simple implementation. It has low pass amplitude characteristics.
The output sample is calculated as an arithmetic average of the input signal stored in an N-size buffer. For the causal filter, the sum is calculated for input samples before the output point.

Moving Average Arithmetic Square Filter (MAS)
It is a modification of the standard moving average filter, by rising each sample to the power of 2.
The idea of this formula is to increase the signal-to-noise-ratio (SNR), calculated as a mean divided by the standard deviation in comparison to the normal moving average filter [28].

Moving Average Geometric Filter (MAG)
Moving average (geometric) is calculated as a root of the product of the N w -size input buffer.

Median Filter (MF)
The output is calculated as a value, from which half of the population of samples is higher and the rest is lower (Equation (5)). For a sorted buffer of input samples, see below:
C j -polynomial coefficients. For analysis purposes, N wR = 0 (causal filter), and therefore the formula can be rewritten as:

Results
The aforementioned filters were implemented for the purpose of assessment and were tested individually. Signals A, B and C categorized in Section 2 are the filter inputs. The decision module (DM) can be set into one of three thresholds-0.95 V, 1.2 V, and 1.6 V-and analysis of all the cases was performed. The expected number of axles (AXL) is described in the tables below, but it is obvious that the DM cannot (should not) indicate axles for signals A and B. The results of analysis are presented in Tables 1-3 for signals A, B and C, respectively. The first column is a filter type together with window size (N w ). For the Savitzky-Golay filter, apart from the buffer size, the degree of the polynomial is also given.     According to Table 1, a median filter (MF) with window size of 64 is most efficient for signal A since there is no false axle counting (number of counted axles = number of expected axles = 0; lack of incorrect transitions in the state machine ST1 = ST2 = 0 (although disturbance level is very high)). It therefore can be concluded that a median filter is the best solution for filtering impulse noise. Moreover, the best results are not related with the threshold level in the decision module (DM). Such a filter shall be considered for use, however further analysis of its impact on the axle signal is required (discussed in Section 5).
Regarding Table 2, signal B has the best outcomes for moving average (arithmetic) filters of a window size of 64. In this case, there is one important thing which must be taken into account. Simple multiplication of original test signals (to increase the noise level) may lead to false results. As the dc component (offset) of the original signal is 0.6 V, it means that multiplication moves the signal to 1.2 V level (dc). It generates many false transitions in the DM for THR = 1.2 caused by the noise around the threshold level (for simplicity, no hysteresis for THR was implemented for signal standardization according to Figure 8). For THR = 0.95 many false transitions are caused by noise as well by life tests and negative impulses are visible in the signal. Since such effects may lead to the wrong conclusions, the test was repeated for signal B multiplied by factor 2 and shifted back to 0.6 V (being a nominal, static value of the signal). Results are presented in Table 2. It simulates higher noise level without changing the dc component, as it more probable in the real on-site conditions. With respect to such a modified test signal, the best results were achieved for moving average square filter (MAS). In this case a state machine (DM) is a poor quality factor for result assessment, as the whole output signal is kept below THR level and no false transitions are possible. The calculated minimum value of standard deviations proves that the moving average square (MAS) filter increases the signal to noise ratio compared to a typical moving average arithmetic (MAA) filter for the same window size. For signal C (train passage), the highest efficiency was obtained for two filters: moving average arithmetic (MAA) with a window size of 32 and Savitzky-Golay (SG) with a window size of 63 and third order polynomial. The number of counted axles is correct only with respect to these two filters-there was no false counting and no improper transitions-zero errors (ST1 = 0) and a minimal number of false returns (ST2 = 0). However, the best results for signal C were acquired for THR = 1.6 in the decision module. The filtration results that are indicated (in bold) in the tables are depicted in Figure 11.   Figure 11A. It shows that impulses were eliminated completely. This outcome is desired, but the impact of such a filter on the signal must be further verified (discussed in Section 5).
The effect of filtration of signal B (Figure 4) by moving average filter MMA (Nw = 64) is presented in the Figure 11B. The noise level was significantly reduced, although Table 2 shows that MAS filter results were a bit better (i.e., a lower standard deviation of the output signal).  were eliminated completely. This outcome is desired, but the impact of such a filter on the signal must be further verified (discussed in Section 5).
The effect of filtration of signal B (Figure 4) by moving average filter MMA (N w = 64) is presented in the Figure 11B. The noise level was significantly reduced, although Table 2 shows that MAS filter results were a bit better (i.e., a lower standard deviation of the output signal).
It needs to be noted, however, that the life test visible in Figure 11B (i.e., regular negative impulses discussed in more detail in Section 5) may affect the calculation of a standard deviation for noise with level comparable to the modulation depth. The real standard deviation of noise in the output signal is lower than the value presented in the table. It means that the actual quality of the signal after filtration may be better. The effect of filtration of signal C by moving average filter MAA (N w = 32) is shown in the Figure 11C. Similar effects of filtration were achieved for Savitzky-Golay filter SG (N w = 63, third order) and this will be further discussed.

Discussion
Smoothing filtration is a useful method of increasing the quality of signal which is affected by the disturbances within the band. The impact on the core information is however a disadvantage of such filtration. Incorrectly adjusted parameters of filtration (i.e., the length of the filter) may destroy/deform the signal or cut the signal out completely together with disturbances.
One can notice that impulse noise (signal A) is effectively removed by a median filter. However, if the signal comes from a fast-moving wheel, the impulses are short and the final solution (i.e., filter design) must take into account the maximum permitted speed of the train, for which the filter must work safely. Filter length (window size) must be selected carefully. For a real safety-related system, the worst case scenario assumes that the speed of the train is 450 km/h. The wheel detector head sensitivity area for a single channel is ca. 20 cm long. It leads to the duration of the impulse (worst case scenario) from a single wheel of 1.6 ms (for a threshold level THR = 0.95 V). Considering the fixed sampling rate of 16 kHz, it gives roughly 25 samples. In the case of window size of a filter below the doubled amount of collected samples, the impact to the signal is negligible. The output signal is just delayed, not deformed. For window size of 50, the output signal is significantly damped (for an even number of samples for the window size, the output is calculated as the average of adjacent samples) and disappears for a size of 51.
Hence, the median filter can have a significant and sudden impact on the signal. Its parameters, such as window size (buffer length), shall be selected in relation to the maximum speed of a wheel (train) at which a detector must operate reliably. A wheel detector is a safety-related system and it must consider a safety margin (at least 100% margin is usually recommended) to cover deviations resulting from various wheel construction, rail profiles, and way of movement, as all these mentioned factors influence the shape and thus the duration of a signal for a specific speed of a train.
The impact of moving average filter on the signal is not so sudden compared to the impact of a median filter. With respect to selected parameters (i.e., window size), the filter operates correctly at a particular speed of a train, and no risk of malfunction was observed in the case of a set of signals (i.e., a signal does not disappear suddenly when train speed changes so the moving average filter does not cause any hazard in the system). The raw signal (Figure 12 (top)) and the effect of filtration for both filters (MAA and MF) for an assumed window size of 256 is presented in Figure 12 (middle) and (bottom), respectively. It can be seen that the median filter can change (destroy) the signal, if the speed of a train changes. Therefore, the length of the filter buffer for median filter shall be chosen with high safety margins in relation to the maximum permitted train speed (it is defined for each application). signal does not disappear suddenly when train speed changes so the moving average filter does not cause any hazard in the system). The raw signal (Figure 12 (top)) and the effect of filtration for both filters (MAA and MF) for an assumed window size of 256 is presented in Figure 12 (middle) and (bottom), respectively. It can be seen that the median filter can change (destroy) the signal, if the speed of a train changes. Therefore, the length of the filter buffer for median filter shall be chosen with high safety margins in relation to the maximum permitted train speed (it is defined for each application). Savitzky-Golay filter allows for implementing an additional filtration parameter (i.e., the degree of polynomial), which can be used to control how the output signal shall follow the input one. Symmetric impulses are effectively removed, and on the other side, the signal is not dumped like in the case of an arithmetic moving average filter (compare Figure 13 (top) with Figure 13 (bottom)). Moreover, the SG filter is also better for the application, when the signal is modulated due to safety reasons (e.g., a "life test" is performed). Such a modulation is used for checking the correctness of operation of the detector being a subject of the analysis. The "life test" signal (internal test) is shown in Figure 14, where 10-15% amplitude modulation is visible. This change of the signal is also visible in the output signal, otherwise it would cause a failure of the detector. Savitzky-Golay filter allows for implementing an additional filtration parameter (i.e., the degree of polynomial), which can be used to control how the output signal shall follow the input one. Symmetric impulses are effectively removed, and on the other side, the signal is not dumped like in the case of an arithmetic moving average filter (compare Figure 13 (top) with Figure 13 (bottom)). Moreover, the SG filter is also better for the application, when the signal is modulated due to safety reasons (e.g., a "life test" is performed). Such a modulation is used for checking the correctness of operation of the detector being a subject of the analysis. The "life test" signal (internal test) is shown in Figure 14, where 10-15% amplitude modulation is visible. This change of the signal is also visible in the output signal, otherwise it would cause a failure of the detector.    The loss of the modulation depth in the output signal is shown in Figure 15. The modulation depth is almost lost for moving average filter (it is decreased by 50%), while it can be considered as negligible for Savitzky-Golay filter.  The loss of the modulation depth in the output signal is shown in Figure 15. The modulation depth is almost lost for moving average filter (it is decreased by 50%), while it can be considered as negligible for Savitzky-Golay filter.  The loss of the modulation depth in the output signal is shown in Figure 15. The modulation depth is almost lost for moving average filter (it is decreased by 50%), while it can be considered as negligible for Savitzky-Golay filter.  The impact of smoothing filters on the signals can be significant. Each time such a filter is used, its parameters shall be chosen with respect to the maximum speed of the train that is permitted in the application. For a median filter, the safety margin shall be much higher than for moving average filters.

Conclusions
The appropriate filtration of the wheel detector signals has a positive impact on its proper operation. A correctly configured median filter eliminates impulse noise from the signal (e.g., signal A), but the configuration must consider experience and safety conditions for the system because its impact to the signal for the fast moving wheels must be taken into account. Such a signal may be strongly deformed or completely cut out if the length of the filter (window size) is too big. Research has indicated that MF (window size of 64) eliminates impulses, giving clear signal in the output. Signal B is effectively reduced by MAA and MAS filters (window size of 64). Before filtration, signal B was multiplied by factor 2 to implement the worst case scenario ( Figure 4 shows the signal before multiplication). It adds the safety margin and shows that the system can still work correctly and safely (there is no false counting, no errors, and the number of false transitions in the state machine is minimal). Moreover, moving average filter gives the best results with respect to signal C. The output signal is however a bit deformed, but the number of axles is counted correctly for all the thresholds; the Savitzky-Golay filter gives similar results to moving average filter results but in order to achieve the same quality of the signal, the buffer size must be longer. On the other side, the shape of the output signal for axle and test impulse better reflects the input one and thus better reproduces the undisturbed signal. The results of the other filters tested are not better and since their implementation would require more computational resources (power and root calculation), their use is not recommended.
Analysis of the paper filtration methods can be applied to the current installed hardware. Rare but difficult signals can be either eliminated or reduced by the following configuration of filters (as both impulse and continuous disturbances are present in the signal): A median filter and moving average filter (or even moving average square filter for better signal to noise ratio, however more operations are needed). This setup reduces impulse noise and continuous, but the shape of the signal will be deformed. It can be applied in the systems when the shape itself does not carry out important information. For high speeds, the duration of wheel impulse will be affected after passing through the filters.
A median filter and a polynomial smoothing filter are recommended for cases when a signal carries specific important information in its shape. Such a combination will reproduce the original signal to a greater degree and will maintain the data carried.
Another very important aspect is connected with the implementation of smoothing filters which are not complex and do not consume much of the processing time. Moving average can be calculated in a cumulative way, thereby decreasing the minimum number of operations executed for each new sample to a minimum.
The impact of a filter on a signal shall be taken into consideration with respect to all the filter types. Wrongly configured median filter can completely cut out the signal of wheels, therefore information about the constraints shall be clearly defined in the Safety Related Application Conditions and Application Guidelines for such types of systems. Filter parameters shall be treated as safety critical data and appropriately protected. The filtering functions shall also be implemented and executed in the regime for SIL-4 safety integrity level.
The presented research is an important first stage for evaluation of the method of improving the operation of an axle counter system on a software level. This stage is a kind of preprocessing of the signals which are further analyzed in other software modules.
Moreover, the use of digital filters, that are applied as software modules opens up the possibility of further improvement. It is a possibility of adapting filter parameters so that they could be controlled by a decision module and thereby improve train detection system availability.

Conflicts of Interest:
The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript, or in the decision to publish the results.