Main Content

comm.FSKModulator

Modulate using M-ary FSK method

Description

The comm.FSKModulator System object™ modulates a signal using the M-ary frequency shift keying (M-FSK) method. The output is a baseband representation of the modulated signal. For more information, see Algorithms.

To modulate a signal using frequency shift keying:

  1. Create the comm.FSKModulator object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

example

fskmodulator = comm.FSKModulator creates a modulator System object that modulates the input signal using the M-ary frequency shift keying method.

fskmodulator = comm.FSKModulator(Name=Value) creates an FSK modulator object and sets properties using one or more name-value arguments. For example, comm.FSKModulator(BitInput=true) that specifies input values must be binary.

fskmodulator = comm.FSKModulator(M,freqSep,RS,Name=Value) creates an M-FSK modulator object with the ModulationOrder property set to M, the FrequencySeparation property set to freqSep, the SymbolRate property set to RS, and optional name-value arguments.

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Number of frequencies in the modulated signal, specified as a positive integer ≥ 2.

Note

The modulation order, M, must be a power of two, such that M = 2K, where K is a positive integer when you set SymbolMapping to 'Gray' or you set BitInput to true.

Data Types: double

Option to provide input in bits, specified as a numeric or logical 0 (false) or 1 (true).

  • When you set this property to false,the input values must be integers in the range [0, (M – 1)]. If M equals 2, the input vector can be logical values. M represents the value of the ModulationOrder property.

  • When you set this property to true, the input values must be a column vector of bit values. The data type of the input values must be double-precision or logical. The input vector length must be an integer multiple of the number of bits per symbol, log2(M). This vector contains bit representations of integers in the range [0, (M – 1)] and M must be a power of two. Groups of log2(M) bits are mapped onto a symbol, with the first bit representing the MSB and the last bit representing the LSB.

Data Types: logical

Symbol encoding mapping, specified as 'Gray' or 'Binary'. Each integer or group of log2(M) bits corresponds to one symbol. M represents the value of the ModulationOrder property.

  • When you set this property to 'Gray', the object maps symbols to a Gray-encoded ordering.

  • When you set this property to 'Binary', the object maps symbols to a natural binary-encoded ordering.

For either type of mapping, the object maps the lowest frequency to the integer 0 and maps the highest frequency to the integer M – 1. In baseband simulation, the lowest frequency is the negative frequency with the largest absolute value.

Frequency separation between successive tones in the modulated signal in hertz, specified as a positive scalar value. For more information, see Avoid Output Signal Aliasing.

Data Types: double

Phase continuity, specified as a numeric or logical 0 (false) or 1 (true).

  • When you set this property to true, the modulated signal maintains continuous phase, even when its frequency changes.

  • When you set this property to false, the modulated signal comprises portions of M sinusoids of different frequencies. In this case, a change in the input value can cause a discontinuous change in the phase of the modulated signal. M represents the value of the ModulationOrder property.

Data Types: logical

Number of samples per output symbol for each integer or binary word in the input, specified as a positive integer. For more information, see Avoid Output Signal Aliasing.

Data Types: double

Symbol rate in symbols per second, specified as a positive scalar. The symbol duration remains the same, regardless of whether the input signal is bits or integers. For more information, see Avoid Output Signal Aliasing.

Data Types: double

Data type of output, specified as either "double" or "single".

Usage

Description

example

y = fskmodulator(x) modulates the input signal by using the FSK method. The output is the modulated FSK baseband signal.

Input Arguments

expand all

Input signal, specified as an integer or bit-valued column vector with numeric or logical data types. The BitInput property specifies the expected input type and vector length constraints.

Output Arguments

expand all

Modulated output signal, returned as a column vector.

  • When you set BitInput to false, the object returns a column vector with (N × NSPS) elements. N represents the length of the input signal x and NSPS represents the value of the SamplesPerSymbol property.

  • When you set BitInput to true, the object returns a column vector with (N × NSPS) / log2(M) elements. M represents the value of the ModulationOrder property.

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Modulate and demodulate a signal using 8-FSK modulation with a frequency separation of 100 Hz.

Create FSK modulator and demodulator System objects with modulation order 8 and 100 Hz frequency separation.

M = 8;
freqSep = 100;
fskmodulator = comm.FSKModulator(M,freqSep);
fskdemodulator = comm.FSKDemodulator(M,freqSep);

Create an additive white Gaussian noise channel with a signal-to-noise ratio of -2 dB.

awgnchan = comm.AWGNChannel( ...
    NoiseMethod="Signal to noise ratio (SNR)", ...
    SNR=-2);

Create an error rate calculator object.

errRate = comm.ErrorRate;

Transmit one hundred 50-symbol frames using 8-FSK modulation in an AWGN channel.

for counter = 1:100
    data = randi([0 M-1],50,1);
    modSignal = fskmodulator(data);
    noisySignal = awgnchan(modSignal);
    receivedData = fskdemodulator(noisySignal);
    errorStats = errRate(data,receivedData);
end

Display the error statistics.

es1 = 'Error rate = %4.2e\n';
es2 = 'Number of errors = %d\n';
es3 = 'Number of symbols = %d\n';
fprintf([es1 es2 es3],errorStats)
Error rate = 1.40e-02
Number of errors = 70
Number of symbols = 5000

Visualize symbol mapping of an FSK modulated signal with a spectrogram.

Specify 20 samples for each symbol. The symbol 0 maps to -50 kHz (negative phase slope) and the symbol 1 maps to +50 kHz (positive phase slope).

mod = comm.FSKModulator(ModulationOrder=2, ...
    FrequencySeparation=1e5, ...
    SamplesPerSymbol=20, ...
    SymbolRate=1e4);
x = mod([0 1 0 1 0 1]');
figure 
subplot(1,2,1)
plot(unwrap(angle(x)),0:length(x)-1)
grid on
xlabel("Phase")
ylabel("Samples")
subplot(1,2,2)
spectrogram(x,20,0,[], ...
    mod.SymbolRate*mod.SamplesPerSymbol,"centered")

Figure contains 2 axes objects. Axes object 1 contains an object of type line. Axes object 2 contains an object of type image.

The FSK modulator System object can be configured to modulate data input as integer values or as binary values. The FSK demodulator System object can be configured to demodulate symbols and output as integer values or as binary values. Each integer or group of log2(M) bits corresponds to one symbol. M represents the value of the ModulationOrder property. Compute the expected signal lengths for input and output of FSK modulation and demodulation of the integer and binary signals. Display the resulting signal lengths for input and output of the FSK modulated and demodulated integer and binary signals.

Define variable to use when configuring FSK modulator and demodulator objects.

M = 8;         % Modulation order   
freqSep = 100; % Frequency separation
nspf = 21;     % Number of samples per frame
sps = 10;      % Samples per symbol

fskmod_bit = comm.FSKModulator(M,freqSep, ...
    BitInput=true, ...
    SamplesPerSymbol=sps);
fskmod_bif = comm.FSKModulator(M,freqSep, ...
    BitInput=false, ...
    SamplesPerSymbol=sps);
fskdemod_bot = comm.FSKDemodulator(M,freqSep, ...
    BitOutput=true, ...
    SamplesPerSymbol=sps);
fskdemod_bof = comm.FSKDemodulator(M,freqSep, ...
    BitOutput=false, ...
    SamplesPerSymbol=sps);

Generate integer data and modulate data by using an FSK modulator object configured to accept bit data (BitInput=true).

bindata = randi([0 1],nspf*M,1);
modSignal = fskmod_bit(bindata);

Demodulate the data, and then output binary data from the first demodulator object and integer data from the second demodulator. Compute the expected and resulting input and output signal lengths.

rxData_bot = fskdemod_bot(modSignal);
rxData_bof = fskdemod_bof(modSignal);

Compute expected input and output lengths for a binary input signal.

Nbit = length(bindata);
Nsym = sps*length(bindata)/log2(M);
Nbot = (length(modSignal)/sps)*log2(M);
Nbof = length(modSignal)/sps;
expLen = sprintf(' Nbit  Nsym  Nbot  Nbof\n  %d   %d   %d   %d', ...
    length(bindata),length(modSignal), ...
    length(rxData_bot),length(rxData_bof))
expLen = 
    ' Nbit  Nsym  Nbot  Nbof
       168   560   168   56'

Display input and output lengths for a binary input signal.

sigLen = sprintf(' bit   sym   bot   bof\n %d   %d   %d   %d', ...
    length(bindata),length(modSignal), ...
    length(rxData_bot),length(rxData_bof))
sigLen = 
    ' bit   sym   bot   bof
      168   560   168   56'

Generate integer data and modulate data by using an FSK modulator object configured to accept integer data (BitInput=false).

data = randi([0 M-1],nspf,1);
modSignal = fskmod_bif(data);

Because the input length changes, you must release the demodulator objects before reusing them. Demodulate the data, and then output binary data from the first demodulator object and integer data from the second demodulator. Compute the expected and resulting input and output signal lengths.

release(fskdemod_bot)
release(fskdemod_bof)
rxData_bot = fskdemod_bot(modSignal);
rxData_bof = fskdemod_bof(modSignal);

Compute expected input and output lengths for an integer input signal.

Nbif = length(data);
Nsym = sps*length(data);
Nbot = (length(modSignal)/sps)*log2(M);
Nbof = length(modSignal)/sps;
expLen = sprintf('Nbif  Nsym  Nbot  Nbof\n  %d   %d   %d   %d', ...
    length(data),length(modSignal), ...
    length(rxData_bot),length(rxData_bof))
expLen = 
    'Nbif  Nsym  Nbot  Nbof
       21   210   63   21'

Display input and output lengths for an integer input signal.

sigLen = sprintf(' bif  sym  bot  bof\n %d   %d   %d   %d', ...
    length(data),length(modSignal), ...
    length(rxData_bot),length(rxData_bof))
sigLen = 
    ' bif  sym  bot  bof
      21   210   63   21'

More About

expand all

Algorithms

As described in Sklar [1], the general analytical expression for M-FSK modulation is

si(t)=2ETcos(ωit+ϕ)0tTi=1,...,M

  • E is the symbol energy.

  • T is the symbol time duration.

  • ωi is the frequency term that has M discreet values.

  • M is the modulation order and specifies the number of waveforms.

  • ϕ is the phase offset.

References

[1] Sklar, Bernard. Digital Communications: Fundamentals and Applications. 2nd ed. Upper Saddle River, N.J: Prentice-Hall PTR, 2001.

Extended Capabilities

Version History

Introduced in R2012a