logo-mobile

ROHM

ROHM
Menu
  • Arduino –
  • Raspberry Pi –
  • Trending –
  • Others –
  • About –
  • Contact –

Arduino

Digital Signal Processing Part 4 – Creating GUI in MATLAB

Tiberia Todeila
Published by Tiberia Todeila at December 7, 2017
Categories
  • Arduino
Tags
  • Arduino
  • digital signal processing
  • dsp
  • matlab
gui in matlab

gui in matlab

This is a continuation of our DSP Arduino series. Last time, we covered the basics of Fourier transform and using MATLAB we learned how to transform a sinusoidal signal from the time domain to the frequency domain. This time, after adding a distortion filter, we will create a simple GUI in MATLAB to record our voice signal!

Hardware

  • Arduino Uno
  • CJMCU-9812 MAX9812L Electret Microphone Amplifier Development Board for Arduino

Software

  • Arduino IDE
  • MATLAB

 

Step 3: Applying the distortion filter

From the previous article, we’ve obtained a signal that had a low-passed filter with a 40th order. For this step, we need to add another filter which distorts the signal. This can be done with the filter function in MATLAB. As you may already know, we’ll also need to add the coefficients shown below.

 

[s,fe2,bits] = wavread(‘s’);
sound(s,fe2);
pause(9)
b = [0.1662, -0.0943, 0.2892, -0.1227, 0.2348, 0.0180, 0.0415, 0.1388, -0.0616, 0.1290, -0.0434, 0.0420, -0.0010, -0.0009, 0.0032, -0.0015, 0.0056] ;
a = [1.0000, -0.7548, 3.4400, -1.6385, 4.8436, -0.8156, 3.2813, 1.2582, 0.6571, 2.1922, -0.4792, 1.4546, -0.2905, 0.4693, -0.0208, 0.0614, 0.0120] ;
x = filter(b,a,s);
figure
plot(t1,s2,t1,x),grid
title(‘The initial signal vs the distorted signal’);
sound(x,fe2);
pause(9)
audiowrite(‘x.wav’,x,fe2);

 

Please note that s is the signal obtained in the previous step when we applied the low-pass filter. In Figure 1, the blue signal represents the original signal, while the green signal represents the distorted signal. The green signal has a lower amplitude compared to the blue one.

gui in matlab

Figure 1: Overlapping signals

To examine further, we are going to use the FFT algorithm.

For a better comparison, the signals were plotted separately. The next two figures will illustrate the difference between the time and frequency domain.


% s si x signals (time-frequency domain)

t1=(0:length(s)-1)/(fe2);
figure
subplot(2,1,1), plot(t1,s),grid
title(‘s signal in time domain(low-pass filter)’);
xlabel(‘Time’)  
ylabel(‘Amplitude’)

t2=(0:length(x)-1)/(fe2);
subplot(2,1,2), plot(t2,x),grid
title(‘x signal in time domain(distorted)’);
xlabel(‘Time’)  
ylabel(‘Amplitude’)

 

gui in matlab

Figure 2: Before and after distortion of the signal in time domain

In the time domain, there is significant modification; s signal has a lower value, even if the visualization of those two pictures would give you the impression that x signal has a higher value. If you are looking at the y-axis scaling, you can observe the difference in amplitude. At this point, maybe you are wondering what kind of filter applied was applied and what kind of modification resulted in those coefficients.

The answer is found in the frequency domain:

 

figure
s1 = abs(fft(s,NS));
subplot(2,1,1), plot((0:(NS-1))/NS*fe2, s1), grid     
title(‘Single-Sided Amplitude Spectrum of s(t)’)
xlabel(‘Frequency (Hz)’)  
ylabel(‘|s(k)|’)

 

x1 = abs(fft(x,NS));
subplot(2,1,2), plot((0:(NS-1))/NS*fe2, x1), grid            
title(‘Single-Sided Amplitude Spectrum of x(t)’)
xlabel(‘Frequency (Hz)’)  
ylabel(‘|X(k)|’)

 

We applied the Fourier transform in order to find the equivalent frequency. As you can see in Figure 3, the point where the y-axis becomes symmetrical is around sampling frequency divided by two.

gui in matlab

Figure 3: Before and after distortion of the signal in frequency domain

Those two signals have different spectrum.

  • In the top
    • Y-axis has values around 800.
    • After value of 2000 Hz, there is no signal shown.
  • In the bottom:
    • Y-axis has values around 40.
    • After value of 2000 Hz, we can observe there is signal.

It’s pretty difficult to examine the plot at this frequency. So let’s make it around 2000 Hz and reevaluate the values.

gui in matlab

Figure 4: A small interval around 2500 Hz

If we look closer to the y-axis, we can observe that the signals have the same shape, even though they didn’t look similar in Figure 3. The problem with that figure was the axis scaling, which resulted in the impression of a dissimilar-looking signal.

On both figures, we observed that the amplitude has been lowered. We still don’t know what the frequency response of the filter is and what other modification this brings to our signal. In this case, we can plot it using Matlab.


[h1,w1] = freqz(b,a,NS,fe2);
figure
plot(w1,abs(h1)), grid   
xlabel(‘Frequency (Hz)’)  
ylabel(‘Frequency response’)  

gui in matlab

Figure 5: A new type of filter

This new type of filter is called band pass filter. Since this is new, let’s go over some of its properties before we proceed further:

  • This can be obtained by connecting together a Low Pass Filter circuit with a High Pass Filter circuit
  • When you apply this filter, the signal in the pass-band filter remains the same, while on the outside of the frequency band the frequency components will be attenuated
  • Components on the high pass band and low pass band are going to be attenuated
    • In our case, this justifies the attenuation of components at frequencies up to 2000 Hz
  • An ideal bandpass filter has flat passband, but in our case, as you can see in Figure 4, we have a gain (it also can have attenuation). We can obtain an ideal filter only in mathematics.
gui in matlab

Figure 6: Band pass filter

You can see that the filter in Figure 6 has similar shape to the filter in Figure 5. Thus, we have obtained the new filter.

1 2
Tiberia Todeila
Tiberia Todeila
Tiberia is currently in her final year of electrical engineering at Politehnica University of Bucharest. She is very passionate about designing and developing Smart Home devices that make our everyday lives easier.

Check us out on Social Media

  • Facebook
  • Twitter

Recommended Posts

  • Digital Signal Processing using MATLAB Part 2Digital Signal Processing using MATLAB Part 2
  • Intro to Digital Signal Processing using MATLAB Part 1Intro to Digital Signal Processing using MATLAB Part 1
  • Digital Signal Processing Part 3 – Fourier TransformDigital Signal Processing Part 3 – Fourier Transform
  • ESP-WROOM-02 Wifi Setup Guide – AT CommandsESP-WROOM-02 Wifi Setup Guide – AT Commands
  • Using ESP-WROOM-02 Wifi Module As Arduino MCUUsing ESP-WROOM-02 Wifi Module As Arduino MCU
  • DIY Guide to Setting Up an LCD with ArduinoDIY Guide to Setting Up an LCD with Arduino
Receive update on new postsPrivacy Policy

Recommended Tutorials

  • How to integrate an RFID module with Raspberry Pi How to integrate an RFID module with Raspberry Pi
  • How to Use the NRF24l01+ Module with Arduino How to Use the NRF24l01+ Module with Arduino
  • How to Run Arduino Sketches on Raspberry Pi How to Run Arduino Sketches on Raspberry Pi
  • Setting Up Raspberry Pi as a Home Media Server Setting Up Raspberry Pi as a Home Media Server

Recommended Trends

  • SewBot Is Revolutionizing the Clothing Manufacturing Industry SewBot Is Revolutionizing the Clothing Manufacturing Industry
  • All About The Sumo Robot Competition And Technology All About The Sumo Robot Competition And Technology
  • 5 Interesting Tips to Calculating the Forward Kinematics of a Robot 5 Interesting Tips to Calculating the Forward Kinematics of a Robot
  • Go Inside the Drones That Are Changing Food Delivery Go Inside the Drones That Are Changing Food Delivery
Menu
  • Arduino –
    Arduino Beginner’s Guide
  • Raspberry Pi –
    Raspberry Pi Beginner's Guide
  • Trending –
    Updates on New Technologies
  • Others –
    Interviews / Events / Others

Check us out on Social Media

  • Facebook
  • Twitter
  • About
  • Company
  • Privacy Policy
  • Terms of Service
  • Contact
  • Japanese
  • 简体中文
  • 繁體中文
Don’t Forget to Follow Us!
© Copyright 2016-2023. Device Plus - Powered by ROHM
© 2023 Device Plus. All Rights Reserved. Muffin group

istanbul escort istanbul escort istanbul escort