0% found this document useful (0 votes)
22 views5 pages

LMS Coding On GNU Radio

The paper discusses the implementation of noise cancellation using the Least Mean Square (LMS) adaptive filter in GNU Radio, a software framework for real-time signal processing. It outlines the significance of adaptive filtering in wireless communication to mitigate noise effects on signals, particularly in ECG signal processing. The authors provide a detailed methodology for implementing the LMS algorithm in GNU Radio, including code snippets and steps for creating custom blocks for noise cancellation applications.

Uploaded by

hgirigaov
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views5 pages

LMS Coding On GNU Radio

The paper discusses the implementation of noise cancellation using the Least Mean Square (LMS) adaptive filter in GNU Radio, a software framework for real-time signal processing. It outlines the significance of adaptive filtering in wireless communication to mitigate noise effects on signals, particularly in ECG signal processing. The authors provide a detailed methodology for implementing the LMS algorithm in GNU Radio, including code snippets and steps for creating custom blocks for noise cancellation applications.

Uploaded by

hgirigaov
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

2017 International Conference on Computer Communication and Informatics (ICCCI -2017), Jan.

05-07, 2017, Coimbatore, INDIA

Implementation of Noise cancellation using Least


Mean Square in GNU Radio
Rohit Kumar K1, Anand R2 Gandhiraj R3
Department of Electronics and Communication Engineering,
Amrita School of Engineering, Coimbatore,
Amrita Vishwa Vidyapeetham,
Amrita University, India-641112.
Emaibkarnenarohitkumar@gmail.com1, anandvimal1@gmail.com2, ,r_gandhiraj@cb.amrita.edu3

Abstract—GNU Radio is open frame work, based on C++ and Bijit Kumar Das et al., [1] have exhibited a Sparse
Python which can be used to develop real time signal processing Adaptive Filtering by an Adaptive Convex Combination of
application, even in low cost credit card sized single board com- the ZA-LMS and the LMS versatile Algorithms. To
puter named Raspberry Pi. Now a days demand for Wireless recognize such frameworks which adjusts progressively to
Communication system design is rapidly increasing. Whenever the meager condition level of the framework and in this
information is transmitting through a wireless channel there is a manner functions admirably both in inadequate and non-
more probability that information is effected by the noise over scanty environments. For profoundly scanty frameworks, the
the channel. We need to cancel that noise in order to achieve the consolidated channel meets to the ZA-LMS calculation.
reliable communication. In this way Noise Cancellation has a
prominent role in Digital communication. In this paper, we II. ADAPTIVE FILTER
implemented Noise Cancellation by using LMS adaptive filter in
GNU radio. In this paper, we analysis and synthesis of signals
The adaptive filter can be defined as, a filter which itself
regulate its switch function according to an some optimizing
has most importance for the detection of cardiac abnormalities.
parameter.The filter coefficients are up-to-date at every
The ECG signals are mixed with random noise from
generation until they converge to long-established
sources.Noises signals are mixed with basic ECG signals are
signal.Centered on the precise signals bought, it makes an
power line interference, baseline wander interference,noises due
attempt to find the most excellent filter design. In a non-
to respirational movements. There are different types of
stationary atmosphere, the filter is anticipated to track time
adaptive filter algorithms have been reduced these noises.In our
versions and range its filter coefficients, accordingly in a
paper we used Least Mean Square algorithm (LMS) is an stationary environment, the filter is anticipated to converge,
adaptive filtering algorithm which is defined as the to the Wiener filter [2].
minimization of the sum of the squares of the difference The operation of adaptive filter involves two processes:
between the original signal and the filter output.
1) The method of adaptive filtering algorithm is out-
Keywords— GNU radio, Raspberry Pi, LMS adaptive filter, lined as the produces the a output signal which is
ECG signals, Noise Cancellation. similar to a input signal.
2) Adaptation system, to regulate the filtering param-
eters (filter switch operate) to the (probably time-
I. INTRODUCTION varying) environment [1] , [3]. As a rule, the (im-
ply) square price of the erro
Our requirement is to design a filter which minimizes the
effect of the noise at the filter output by using some There are some types of adaptive algorithms like
statistical criterion. An optimal solution to this problem is 1) RecursiveLeast Square (RLS) algorithm,
minimizing the mean square value of the error signal. This 2) Least Mean Square (LMS) algorithm.
approach of minimizing error signal to to the stationary input
data is known as Wiener Filter. But this wiener filter is not One of the major applications of adaptive filters is Noise
useful for non-stationary data where we use Kalman Filter in cancellation as shown in figure 1. These figure shows the
such cases. cause of an adaptive noise canceler is to subtract the noise
But the design of wiener filter needs prior information on from a output signal in an adaptively controlled method so as
the signal which cannot be possible at every time. So we to fortify the signal-to-noise ratio [4] . In telephony circuits,
need to find the solution for the filter designing which do not we have to reduce both echo and noise cancellation. General
require any relevant signal information. Thus we go for description for the figure are given below, x(n)-Input signal
Adaptive Filter which meets our requirement. plus Noise, d(n)-Desired signal, e(n)-Error signal, y(n)-
output signal.

978-1-4673-8855-9/17/$31.00 ©2017 IEEE

Authorized licensed use limited to: PES University Bengaluru. Downloaded on August 02,2023 at 05:29:56 UTC from IEEE Xplore. Restrictions apply.
2017 International Conference on Computer Communication and Informatics (ICCCI -2017), Jan. 05-07, 2017, Coimbatore, INDIA

Define the siapal x(n)

Convolution

Generate desired
signal+noise d(n Subtraction

Minimum
Data Updated Error?
A. LMS Algorithm

Least imply square algorithm is a category of adaptive


filter, used to imitate intently a desired filter via finding the
filter coefficients that relate to offer the least mean squares of
the error sign [5] , [6]. The change between the favored and
the actual signal. It's a stochastic gradient descent system in Output
which the filter weights are most effective adapted founded
on the error on the current time. Consistent with this LMS Figure 2: Flow chart for LMS Adaptive filter
algorithm the burden replace equation is given in equation
user can create own blocks for our own applications and its
W ( n + 1) = W(n) + 2 x p x E(n) x X ( n ) (1) applicable both theoretical and practical perspective. For real
time applications, Software Defined Radio (SDR) is used to
Where, transmit a data one place to another place [7].
p - Step Size, Both python language and c++ programming language
W(n)- Weight update, can be write in GNU Radio. But C++ is well suite for GNU
X(n) - Input signal, Radio infrastructure because c++ language is easy to write a
E(n)- Error signal. any program.

i. Flow Chart For LMS adaptive filter. B. GNU Radio Companion


Figure 2 shows the performance of least mean square, the
input signal X(n), and weighted signal W(n), initial weight is The (GRC) GNU Radio Companion is a visualize and
zero, convolution performance is done for the values of X(n) graphical user interface and it is used to implement any
and W(n). The output of the convolution is subtracted from signal processing and communications algorithms. In GRC
desired signal and noise D(n).the minimum error will occur already some important blocks are already fixed so we can
which is moved on to the weighted block and the new use that blocks and we see already existing code also. GNU
weighted is updated. In case if minimum error is zero, the Radio is wide applications algorithms especially Signal pro-
output is obtained directly. cessing and communication perspective. After executes our
Adaptive structures have been used for different appli- GRC file automatically python code is generate and we cam
cations in adaptive filtering such as: Noise cancellation Sys- view also.
tem identification, Adaptive predictor, Equalization, Inverse Both Qt toolkit or the WxWidgets are support in GRC.
modeling, Interference cancellation,
In this article, we are going to implement Noise cancel-
lation using LMS in GNU Radio. C. Plotting and displays

III. GNU RADIO The common plotting in GNU Radio is data visualize data,
Fast Fourier Transform (FFT displays) of our signals,
GNU Radio is a one of the open source software and it is used constellation points, both time and frequency displays and
for real time signal processing algorithms. In these scope sink.

ii
Authorized licensed use limited to: PES University Bengaluru. Downloaded on August 02,2023 at 05:29:56 UTC from IEEE Xplore. Restrictions apply.
2017 International Conference on Computer Communication and Informatics (ICCCI -2017), Jan. 05-07, 2017, Coimbatore, INDIA

IV. RESULTS AND DISCUSSION

A. Implementing in C++ using Turbo C++

Least imply square algorithm is a category of adaptive


filter, used to imitate intently a desired filter via finding the
filter coefficients that relate to offer the least mean squares
of the error sign [5] , [6]. The change between the favored
and the actual signal. It’s a stochastic gradient descent
system in which the filter weights are most effective adapted
founded on the error on the current time. Consistent with
this LMS algorithm the burden replace equation is given in
equation
We designed a system for noise cancellation using LMS
in Turbo C++. Our input signal (x(n)) is some random
signal(eg: sinusoidal signal) and noise signal is Gaussian
Noise or Uniform Noise (N). We can’t judge our system is
uniform so, we have to implement our system. We already
know our input signal and also desired signal then we
compute our system model. If input and output also know
means we easily compute our system model.
The following steps for calculating system model h(n):

• First take FFT(Fast Fourier Transform) of our input


signal (x(n)+ N) and desired signal d(n).

• Divide output by input in frequency domain itself


because both should be same dimensions.

• Then take IFFT (Inverse Fast Fourier Transform) of B. LMS using GNU Radio
h(n).
Our goal is implementing LMS in GNU Radio for Noise
• Store those values in Excel file.
cancellation applications.
So we plotted our desired signal, output signal and error Our own block creation first steps with the out-of-tree
signal by using MS-Excel as shown in figure. The figure modules from on the GNU Radio website.This website may
shows when error signal becomes approximately Zero that use for crating own block using either C++ or Python. The
time our output signal becomes original signal because LMS following steps for creating own blocks in GNU Radio for
take Some microseconds to adapt our output signal. The any applications [8]: This blog is intended to fast-track the
adaptation is depends on Number of Taps we are used. If creation of an out-of-tree module in C++.
taps size is high adaptation time very less. • Add new modtool using add t general lms_ff
• Identify our my module
• use c++/python Language: C++
• Identify Block: LMS
• Add C++ QA code? [y/N] y.
• Adding file LMS impl.h.
• Adding file LMS impl.cc.
• Adding file LMS.h.
• Editing swig/my module swig.i.
• Adding file my module LMS.xml.
• Finally Edit CMake file.

3
Authorized licensed use limited to: PES University Bengaluru. Downloaded on August 02,2023 at 05:29:56 UTC from IEEE Xplore. Restrictions apply.
2017 International Conference on Computer Communication and Informatics (ICCCI -2017), Jan. 05-07, 2017, Coimbatore, INDIA

C. Noise cancellation using LMS in GNU Radio


Basically we created the source files for our block, without matically by using Number of taps. As We know if Number
adding any quality-assurance (QA) code. As an intermediate of tap size increase automatically response is fast. Finally
step, we could add some QA code to perform a unitary test of figure 11 show our required output.
our block but lets just head straight for the programming.
• Now we need to modify lib/lms_ff_mp.cc.
• gr_modtool hints at where you to change code by
adding ++ symbols.
• Lets open the file and modify it accordingly.
• forcast() is a function which tells thw scheduler how
many input items are required to produce nout-
put_items output items.
• Here they are same and hence
- input_items_required[0]=noutput_items.
Figure 6: Noise cancellation using LMS adaptive filter
• The index 0 indicates that this is for the the first port.
• Write our code in this file.
• Now lets build and compile our files using CMake.
• First go to directory gr-LMS and type below com-
mands.
• gr-LMS $ mkdir build.
• gr-LMS $ cd build.
• gr-LMS/build $ cmake ../.
• gr-LMS/build $ make.
• gr-LMS/build $ make test.
• gr-LMS/build $ cd .. Figure 7: Input with noise and filter output
• If everything is fine, then create XML code using
gr_modtool script.
• Go to gr-LMS directory and type below command. V. CONCLUSION AND FUTURE SCOPE

- gr-LMS $ gr_modtool makexml lms_ff. Realization of Noise cancellation using LMS adaptive
• Then go to build and type sudo make install and sudo filter is as we take input as voice signal and Noise signal
ldconfig. which have the Gaussian distribution or Uniform
distribution is added to this and observed Noise canceled
An interesting section of the above code is the definition of the signal at output section with some time delay of
input and output signatures. In our case, we have one input and microseconds due to step size of filter co-efficients. GNU
one output port that allows the float data type [9]. Radio is open frame work, based on C++ and Python which
Then we go for our LMS impl.cc file just do our C++ can be used to develop real time signal processing
algorthim in these and make file in terminal window.If any application, even in low cost credit card sized single board
error is present in our code our make file showing error so we computer named Raspberry Pi. We used LMS algorithm for
must rectifying the error then only we processed next step. We adaptive filtering. But we have few alternates like N-LMS
have to create our XML file for our code and adding all make algorithm, sign LMS, sigma LMS, sigma-sigma LMS and so
file and ldconfig file to gnuradio companion [10]. on. In this way we can extend
Here we are giving a same input for the also and we
computed our output signal, error signal.
For this, We give our original speech signal and mixed
with some random noise like Gaussian and uniform. After
performing our LMS algorithm and find out our original
signal. Figure 7,8,9,10,11 shows how output is adapt auto-

4
Authorized licensed use limited to: PES University Bengaluru. Downloaded on August 02,2023 at 05:29:56 UTC from IEEE Xplore. Restrictions apply.
2017 International Conference on Computer Communication and Informatics (ICCCI -2017), Jan. 05-07, 2017, Coimbatore, INDIA

Figure 10: After 8 seconds

Figure 11: After 10 seconds

our work to further level. We can also implement this on to


hardware by using Software Defined Radio(SDR).

REFERENCES

[1] B. K. Das and M. Chakraborty, “Sparse adaptive filtering by an adaptive [8] R. Gandhiraj and K. Soman, “Modern analog and digital communication
convex combination of the lms and the za-lms algorithms,” Circuits and systems development using gnu radio with usrp,” Telecommunication
Systems I: Regular Papers, IEEE Transactions on, vol. 61, no. 5, pp. Systems, vol. 56, no. 3, pp. 367-381, 2014.
1499-1507, 2014.
[9] R. Anil, R. Danymol, H. Gawande, and R. Gandhiraj, “Machine learning
[2] S. S. Haykin, Adaptive filter theory. Pearson Education India, 2008. plug-ins for gnu radio companion,” in Green Computing Communication
and Electrical Engineering (ICGCCEE), 2014 International Conference
[3] R. L. Das and M. Chakraborty, “Sparse adaptive filters-an overview and on. IEEE, 2014, pp. 1-5.
some new results,” in Circuits and Systems (ISCAS), 2012 IEEE
International Symposium on. IEEE, 2012, pp. 2745-2748. [10] S. Sriram, G. Srivasta, R. Gandhiraj, and K. Soman, “Plug-ins for gnu
radio companion,” International Journal of Computer Applications, vol.
[4] J.-W. Lee and G.-K. Lee, “Design of an adaptive filter with a dynamic 52, no. 16, 2012.
structure for ecg signal processing,” International Journal of Control,
Automation, and Systems, vol. 3, no. 1, pp. 137-142, 2005.
[5] J. Arenas-Garcla, A. R. Figueiras-Vidal, and A. H. Sayed, “Mean- square
performance of a convex combination of two adaptive filters,” Signal
Processing, IEEE Transactions on, vol. 54, no. 3, pp. 10781090, 2006.
[6] G.-O. Glentis, K. Berberidis, and S. Theodoridis, “Efficient least squares
adaptive algorithms for fir transversal filtering,” Signal Processing
Magazine, IEEE, vol. 16, no. 4, pp. 13-41, 1999.
[7] G. Radio, “The gnu software radio,” Available from World Wide Web:
https://gnuradio. org, 2007.

5
Authorized licensed use limited to: PES University Bengaluru. Downloaded on August 02,2023 at 05:29:56 UTC from IEEE Xplore. Restrictions apply.

You might also like