📄 write_waveform_to_esg.m.bak
字号:
%Parameters:
% esg_gpib_addr - configured gpib address of the ESG. May not be
% applicable to all setups.
% filename - name of the file when stored on the ESG
% input_bits - array of bits of the waveform to be stored.
% slot_setup - configuration of the data with respect to the 2 slots:
% 0 = NULL data in Slot 1 and Slot 2
% 1 = Input Data in Slot 1 and NULL data in Slot 2
% 2 = NULL Data in Slot 1 and Input Data in Slot 2
% 3 = Input Data in Slot 1 and Slot 2
function write_waveform_to_esg(esg_gpib_addr, filename, input_bits, slot_setup);
% New filter to save trouble
%clear all;
%clc;
N = 121; % Length of filter in samples
Fs = 48000; % Sampling rate
%Fs = 384000; % Sampling rate
Fb = 4800; % Symbol rate
I = Fs/Fb; % upsampling factor
modulation_h = 0.25;
% This is the time vector for the filter samples, such that plot(t,h) plots the filter coefficients
% against time. The offset by 0.5/Fs is to ensure an even length filter.
t = -(N/2)/Fs+0.5/Fs:1/Fs:(N/2)/Fs-0.5/Fs;
M = length(t);
t = t((M-N)/2+1:end-(M-N)/2);
alpha = 0.2 + 1E-8; % Filter excess bandwidth
h = rrc(t, alpha, 1/Fb); % Generate filter
h = h/(10^(20.04/20));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% START HERE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NULL24 = zeros(1,24); %NULL array to balance input waveform
NULLslot = zeros(1,size(input_bits,2)); %NULL array to replace the input_bits for a given slot
%Based upon the slot_setup input, configure the final waveform for Slots 1 and 2.
switch slot_setup
case 0,
input_bits = [NULL24 NULLslot NULL24 NULLslot];
case 1,
input_bits = [NULL24 input_bits NULL24 NULLslot];
case 2,
input_bits = [NULL24 NULLslot NULL24 input_bits];
case 3,
input_bits = [NULL24 input_bits NULL24 input_bits];
otherwise,
input_bits = [NULL24 input_bits NULL24 input_bits];
end
%#######################################
% MAKE THE ULTIMATE SEQUENCE
%#######################################
input_symbols = bit2ESGsymbolmapping(input_bits)';
input_symbols = input_symbols*50/3;
input_sym1 = repmat(input_symbols,5,1); % replicate frame 5 times
baseband_samples1 = conv(h, I*upsample(input_sym1, I));
baseband_samples1 = baseband_samples1(61:end-60); % remove the filter delays to get a clean-cut signal
% slice off the center of the filtered waveform to get a proper wraparound signal
% take the 4th block
fourth_block = baseband_samples1(3*size(input_symbols,1)*I+1:3*size(input_symbols,1)*I+size(input_symbols,1)*I);
third_block = baseband_samples1(2*size(input_symbols,1)*I+1:2*size(input_symbols,1)*I+size(input_symbols,1)*I);
diff1 = fourth_block - third_block;
%-------------------------------------------------------
% if the difference between 3rd and 4th block is zero
% that means the block is perfectly fine to be
% wrapped around.
%------------------------------------------------------
wrap_sig = fourth_block; % grab either the 3rd or the 4th block.
carrier_phase = pi * modulation_h/I * cumsum(wrap_sig);
THE_SIGNAL = exp(j * (carrier_phase));
scale = 1;
esg_arb(esg_gpib_addr, filename, THE_SIGNAL, scale);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -