Sei sulla pagina 1di 6

Modulacin ASK-FSK-OOK

ASK, FSK y OOK

The examples here illustrates how to use the Matlab function block in simulink
can be used for implementing ASK, FSK and PSK digital modulation.
Matlab function block can be used whenever you need an output that depends
on the input. That is implementing a function.
To illustrate a simple example here we take an example of digital
communication.
ASK Modulation:

In ASK modulation, you have data in the form of string of binary bits and the
ASK modulator outputs no signal when the data bit is 0 and outputs a
sinusoidal wave when the input bit is 1.
That is if data = 0, then ASK = 0 else ASK = A*sin(wt)
This can be realized as a function block. Data, d is the input which is 0 or 1 and
the output is ASK wave, say y.
Now let's see how we can incorporate this simple example in simulink using the
Matlab Function block.
For the message data, we can use the Bernoulli random bit generator which is
available in the source library of communication system. Then the function
block which is available in the user defined function library and a clock source
which is available in the source library of simulink are required.
Connect them as follows-

When you double click on the function block you should get code in the editor-
function y = fcn(u)
%#codegen

y = u;
Suppose you want to implement ASK modulation. Change the code above to
implement your ASK function or algorithm like the one below-
function y = ask_mod(d, t)
f = 5;

if d == 0;
y = 0;
else
y = sin(2*pi*f*t);

end
In the above code, the inputs are d and t and the output is y, the ASK
modulated wave. d is the data in binary from Bernoulli generator, t is the time
from the clock block. Note that frequencey, f is set to 5(Hz). We could have
another port for specifying the frequency and amplitude. Here amplitude is
taken as unity.
Once you save the function you will get the required two inputs d and t and the
output y labelled. Connect them as shown below-

In the above diagram, names of the blocks have been renamed which is easy
to do.
You may have to change the simulation step size so that you can get smooth
sine wave at the output scope. Go to Simulation > Model Configuration
Parameters and change the Max step size to 0.001 for example.
Change the stop time to 30, 40 or 50 whatever time simulation you want and
run the simulation.

The resulting output ASK waveform is shown below-


FSK modulation:
Next consider the case of FSK signal.

An FSK signal outputs sin(2*pi*f1*t) when data, d is 0 and sin(2*pi*f2*t) when


data d is 1. So we can do this easily by adjusting the above function algorithm.

Take f1 = 5Hz and f2 as 15Hz. Then we can write for FSM modulator.
function y = fsk_mod(d, t)
f1 = 5;
f2= 15;

if d == 0;
y = sin(2*pi*f1*t);
else
y = sin(2*pi*f2*t);

end
The block diagram and the output FSK modulated waveform are shown below-
PSK Modulation:

In PSK modulation, when d is 0 the output is sine wave PSK signal for 0, and
when d is 1 the output is sine wave which is phase shifted by 180 degree.

The code for PSK modulation is below-


function y = qsk_mod(d, t)

f = 5;

if d == 0;
y = sin(2*pi*f*t);
else
y = sin(2*pi*f*t+pi);

end
Notice that the phase shift is pi and not 180 in the above code because the
matlab sin function operates on radian unit. 180 is pi as you might know.

The PSK waveform is shown below,


In this way you can use the function block for digital modulation in matlab. See
more examples in the Matlab tutorial page.

Potrebbero piacerti anche