How do i generate pulse waveform of random binary sequence in MATLAB?

27 vues (au cours des 30 derniers jours)
Basmah Ahmad
Basmah Ahmad le 8 Jan 2024
I want to transmit random binary sequence through radar. But for this i have to first convert it into pulse waveform using parameters like PRF, bandwidth, sampling frequency, Pulse width etc. Then after transmission and reception, i will generate range dopple map.
Please guide me how can i do this

Réponses (1)

Hassaan
Hassaan le 8 Jan 2024
Modifié(e) : Hassaan le 8 Jan 2024
% Define Parameters
N = 1000; % Number of bits
PW = 1e-6; % Pulse width in seconds
PRF = 1e3; % Pulse Repetition Frequency in Hz
Fs = 10e6; % Sampling frequency in Hz
numPulses = 128; % Number of pulses to simulate
target_velocity = 30; % Target velocity in m/s (example value)
% Generate a random binary sequence
binarySequence = randi([0, 1], 1, N);
% Create a pulse waveform
waveform = phased.RectangularWaveform('PulseWidth', PW, 'PRF', PRF, 'SampleRate', Fs);
% Generate a pulse train based on the binary sequence
pulseTrain = repmat(waveform(), 1, N); % Repeat the pulse for each bit
% Reshape the binary sequence to match the pulse train
binarySequenceRepeated = repelem(binarySequence, length(pulseTrain) / N);
% Modulate the pulse train with the binary sequence using BPSK
modulatedPulseTrain = pskmod(binarySequenceRepeated, 2, pi); % Binary Phase Shift Keying
% Set up transmitter and receiver
tx = phased.Transmitter('Gain',20);
rx = phased.ReceiverPreamp('Gain',20,'NoiseFigure',10);
% Simulate Transmitting and Receiving multiple pulses
received = zeros(length(modulatedPulseTrain), numPulses);
for p = 1:numPulses
% Each pulse in the train is transmitted separately
transmitted = tx(modulatedPulseTrain(:, p));
received(:, p) = rx(transmitted);
% Add Doppler shift to simulate target movement
doppler_shift = 2*(target_velocity/physconst('LightSpeed'))*waveform.PRF;
received(:, p) = received(:, p) .* exp(1j*2*pi*doppler_shift*(0:length(received(:, p))-1)/Fs).';
end
% Range-Doppler processing
rdmap = phased.RangeDopplerResponse('RangeMethod','FFT','DopplerOutput','Speed',...
'OperatingFrequency',300e6,'SampleRate',Fs,'DopplerFFTLengthSource','Property',...
'DopplerFFTLength',numPulses,'RangeFFTLengthSource','Property',...
'RangeFFTLength',length(modulatedPulseTrain));
% Generate and plot the Range-Doppler map
[resp, range_grid, speed_grid] = rdmap(received);
resp = abs(resp);
resp = 10*log10(resp/max(resp(:)));
imagesc(speed_grid, range_grid*physconst('LightSpeed')/2, resp, [-40 0]);
colorbar;
xlabel('Speed (m/s)');
ylabel('Range (m)');
title('Range-Doppler Map');
  • Simulating Multiple Pulses: The code loops over numPulses to simulate the transmission and reception of multiple pulses. This creates a matrix where each column represents a different pulse.
  • Doppler Shift: It applies a Doppler shift to each pulse to simulate the effect of a moving target over time.
  • Range-Doppler Processing: The phased.RangeDopplerResponse function is used to process the 2D matrix (multiple pulses) and generate the Range-Doppler map.
Note
Assumes that each bit in the binary sequence modulates a single pulse of the radar signal. Depending on your specific requirements, the method of creating the pulse train and applying the modulation may vary. Ensure that the length of the modulatedPulseTrain and the dimensions of the received matrix match your system's needs. Additionally, make sure that the number of pulses simulated (in the numPulses variable) correctly reflects the design of your radar system.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.
  3 commentaires
Hassaan
Hassaan le 8 Jan 2024
@Basmah Ahmad Updated my previous answer. Thank you.
Basmah Ahmad
Basmah Ahmad le 8 Jan 2024
Modifié(e) : Basmah Ahmad le 8 Jan 2024
@Muhammad Hassaan Shah Thanks again for answering. I picked your generated pulsed waveform and put it into my code with the specific parameters. Code is very much similar to your code. But i am encountering an error. Can you solve it? This is my code and error:
Error using coder.internal.assert (line 33)
Expected input X to be a non-empty column vector.
Error in coder.internal.errorIf (line 7)
coder.internal.assert(~cond, msgID, varargin{:});
Error in phased.Transmitter/validateInputsImpl (line 204)
coder.internal.errorIf(cond, ...
Error in Untitled31 (line 75)
[txsig,txstatus] = transmitter(sig);
c = physconst('LightSpeed');
fc = 2.4e9;
pri = 2e-05;
fs = 100e+06;
Numtgts = 3;
tgtpos = zeros(Numtgts);
tgtpos(1,:) = [500 530 750];
tgtvel = zeros(3,Numtgts);
tgtvel(1,:) = [-60 20 40];
tgtrcs = db2pow(10)*[1 1 1];
tgtmotion = phased.Platform(tgtpos,tgtvel);
target = phased.RadarTarget('PropagationSpeed',c,'OperatingFrequency',fc, ...
'MeanRCS',tgtrcs);
radarpos = [0;0;0];
radarvel = [0;0;0];
radarmotion = phased.Platform(radarpos,radarvel);
txantenna = phased.IsotropicAntennaElement;
rxantenna = clone(txantenna);
h = phased.RectangularWaveform;
h.SampleRate = 100000000;
h.PulseWidth = 2e-08;
h.PRF = 50000;
h.NumPulses = 1;
binarySequence = randi([0, 1], 1, 63);
% Generate a pulse train based on the binary sequence
pulseTrain = repmat(h(), 1, 63); % Repeat the pulse for each bit
% Reshape the binary sequence to match the pulse train
binarySequenceRepeated = repelem(binarySequence, ceil(length(pulseTrain) / 63));
% Modulate the pulse train with the binary sequence using BPSK
waveform = pskmod(binarySequenceRepeated, 2, pi); % Binary Phase Shift Keying
sig = waveform(:);
Nr = length(sig)
bwrmss = bandwidth(waveform)/sqrt(12);
rngrms = c/bwrmss;
peakpower = 11e+03;
txgain = 20.0;
transmitter = phased.Transmitter( ...
'PeakPower',peakpower, ...
'Gain',txgain, ...
'InUseOutputPort',true);
radiator = phased.Radiator( ...
'Sensor',txantenna,...
'PropagationSpeed',c,...
'OperatingFrequency',fc);
channel = phased.FreeSpace( ...
'SampleRate',fs, ...
'PropagationSpeed',c, ...
'OperatingFrequency',fc, ...
'TwoWayPropagation',true);
collector = phased.Collector( ...
'Sensor',rxantenna, ...
'PropagationSpeed',c, ...
'OperatingFrequency',fc);
rxgain = 42.0;
noisefig = 1;
receiver = phased.ReceiverPreamp( ...
'SampleRate',fs, ...
'Gain',rxgain, ...
'NoiseFigure',noisefig);
Np = 128;
dt = pri;
cube = zeros(Nr,Np);
for n = 1:Np
[sensorpos,sensorvel] = radarmotion(dt);
[tgtpos,tgtvel] = tgtmotion(dt);
[tgtrng,tgtang] = rangeangle(tgtpos,sensorpos);
sig = waveform();
[txsig,txstatus] = transmitter(sig);
txsig = radiator(txsig,tgtang);
txsig = channel(txsig,sensorpos,tgtpos,sensorvel,tgtvel);
tgtsig = target(txsig);
rxcol = collector(tgtsig,tgtang);
rxsig = receiver(rxcol);
cube(:,n) = rxsig;
end
imagesc([0:(Np-1)]*pri*1e6,[0:(Nr-1)]/fs*1e6,abs(cube))
xlabel('Slow Time {\mu}s')
ylabel('Fast Time {\mu}s')
axis xy
ndop = 128;
rangedopresp = phased.RangeDopplerResponse('SampleRate',fs, ...
'PropagationSpeed',c,'DopplerFFTLengthSource','Property', ...
'DopplerFFTLength',ndop,'DopplerOutput','Speed', ...
'OperatingFrequency',fc);
matchingcoeff = getMatchedFilter(waveform);
[rngdopresp,rnggrid,dopgrid] = rangedopresp(cube,matchingcoeff);
imagesc(dopgrid,rnggrid,10*log10(abs(rngdopresp)))
xlabel('Closing Speed (m/s)')
ylabel('Range (m)')
axis xy
mfgain = matchingcoeff'*matchingcoeff;
dopgain = Np;
noisebw = fs;
noisepower = noisepow(noisebw,receiver.NoiseFigure,receiver.ReferenceTemperature);
noisepowerprc = mfgain*dopgain*noisepower;
noise = noisepowerprc*ones(size(rngdopresp));
rangeestimator = phased.RangeEstimator('NumEstimatesSource','Auto', ...
'VarianceOutputPort',true,'NoisePowerSource','Input port', ...
'RMSResolution',rngrms);
dopestimator = phased.DopplerEstimator('VarianceOutputPort',true, ...
'NoisePowerSource','Input port','NumPulses',Np);
detidx = NaN(2,Numtgts);
tgtrng = rangeangle(tgtpos,radarpos);
tgtspd = radialspeed(tgtpos,tgtvel,radarpos,radarvel);
tgtdop = 2*speed2dop(tgtspd,c/fc);
for m = 1:numel(tgtrng)
[~,iMin] = min(abs(rnggrid-tgtrng(m)));
detidx(1,m) = iMin;
[~,iMin] = min(abs(dopgrid-tgtspd(m)));
detidx(2,m) = iMin;
end
%Find the noise power at the detection locations.
ind = sub2ind(size(noise),detidx(1,:),detidx(2,:))
%Estimate the range and range variance at the detection locations. The estimated ranges agree with the postulated ranges.
[rngest,rngvar] = rangeestimator(rngdopresp,rnggrid,detidx,noise(ind))
%Estimate the speed and speed variance at the detection locations. The estimated speeds agree with the predicted speeds.
[spdest,spdvar] = dopestimator(rngdopresp,dopgrid,detidx,noise(ind))

Connectez-vous pour commenter.

Catégories

En savoir plus sur Detection, Range and Doppler Estimation dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by