[digital signal] GUI based virtual signal generator (various waveforms) [matlab phase 271]

Keywords: MATLAB

1, Case introduction

1 application background
The traditional desktop function signal generator has the disadvantages of huge volume, inflexible interface, fixed waveform and high price. In view of this current situation, a simple digital signal generator is completed according to the homework assigned by the teacher, which can produce white noise, sine wave, sawtooth wave and square wave with different amplitude and frequency. The tool selection is matlab, which has powerful data analysis function and data processing function. Its own library function brings great convenience to the generation of signal waveform. This paper introduces in detail the basic principle of how to complete the virtual digital signal generator through the computer sound card and the specific functions needed to realize the waveform.

2 topic introduction
This paper mainly introduces the basic principle and implementation steps of using computer programming tool matlab to realize virtual digital signal generator through computer sound card; Aiming at the shortcomings of traditional digital signal generator, the design of virtual digital signal generator is completed to realize the generation of simple digital signals such as triangular wave, sawtooth wave, square wave, white noise and so on.

3 technical route
Sound card is a kind of hardware to realize the mutual conversion of sound wave / digital signal. In the commonly used PC configuration sound card, soybean provides two interfaces: microphone input and speaker output. They integrate the analog-to-digital converter (ADC) and digital to analog converter (DAC) required by signal io. Therefore, we only need to lead out the generated digital signal through the audio line to obtain the sound output.
All waveforms are drawn by the functions in matlab, and the connection between waveform and sound card is completed through fixed interface functions, so as to realize the conversion between waveform and audio signal.

2, Partial source code

function varargout = signal_prodoce_comlpete(varargin)
% SIGNAL_PRODOCE_COMLPETE M-file for signal_prodoce_comlpete.fig
%      SIGNAL_PRODOCE_COMLPETE, by itself, creates a new SIGNAL_PRODOCE_COMLPETE or raises the existing
%      singleton*.
%
%      H = SIGNAL_PRODOCE_COMLPETE returns the handle to a new SIGNAL_PRODOCE_COMLPETE or the handle to
%      the existing singleton*.
%
%      SIGNAL_PRODOCE_COMLPETE('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in SIGNAL_PRODOCE_COMLPETE.M with the given input arguments.
%
%      SIGNAL_PRODOCE_COMLPETE('Property','Value',...) creates a new SIGNAL_PRODOCE_COMLPETE or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before signal_prodoce_comlpete_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to signal_prodoce_comlpete_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help signal_prodoce_comlpete

% Last Modified by GUIDE v2.5 22-Sep-2009 21:56:54

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @signal_prodoce_comlpete_OpeningFcn, ...
                   'gui_OutputFcn',  @signal_prodoce_comlpete_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% --- Executes just before signal_prodoce_comlpete is made visible.
function signal_prodoce_comlpete_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to signal_prodoce_comlpete (see VARARGIN)

% Choose default command line output for signal_prodoce_comlpete
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes signal_prodoce_comlpete wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = signal_prodoce_comlpete_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

3, Operation results




4, matlab version and references

1 matlab version
2014a

2 references
[1] Shen Zaiyang. Proficient in MATLAB signal processing [M]. Tsinghua University Press, 2015
[2] Gao Baojian, Peng Jinye, Wang Lin, pan Jianshou. Signal and system -- Analysis and implementation using MATLAB [M]. Tsinghua University Press, 2020
[3] Wang Wenguang, Wei Shaoming, Ren Xin. MATLAB implementation of signal processing and system analysis [M]. Electronic Industry Press, 2018

Posted by twistisking on Mon, 20 Sep 2021 21:19:54 -0700