-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrbs_Example_Gen_lib.m
More file actions
137 lines (117 loc) · 3.84 KB
/
Copy pathPrbs_Example_Gen_lib.m
File metadata and controls
137 lines (117 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
clear;
close all;
clear variables;
clear global;
clc;
%%
% Load Library
myLib = TEProteusLib();
%%
% Define IP Address for Target Proteus device descriptor
% VISA "Socket-Based" TCP-IP Device. Socket# = 5025
myLib.ip_addr = '127.0.0.1'; % '127.0.0.1' = Local Host, your IP address here
myLib.pxi_slot = 3; % Set 0 to select slot from attached modules
myLib.com_ifc = myLib.COMM_IFC_LAN; %"LAN" = VISA or "DLL" = PXI
myLib.paranoia_level = 2; % 0, 1 or 2
%%
% Instrument setup
% Open session
[inst, idnstr, slotNumber, serial] = myLib.ConnecToProteus();
% Report model
fprintf('Connected to: %s, slot: %d\n', idnstr(1), slotNumber(1));
% Reset AWG
inst.SendScpi('*CLS;*RST');
%%
% DATA CONFIG
prbs_seq = myLib.PRBS_13;
% DATA_TYPE_BILVL_NRZ
% DATA_TYPE_BILVL_RZ
% DATA_TYPE_PAM4
% DATA_TYPE_PAM8
data_wfm_type = myLib.DATA_TYPE_BILVL_NRZ;
baud_rate = 10E6;
clk_div = 1;
% PULSE_EDGE_LINEAR
% PULSE_EDGE_GAUSSIAN
edge_shape = myLib.PULSE_EDGE_LINEAR;
rise_time = 0.100E-9;
%%
% Channel configuration
data_ch = 1;
data_segm = 1;
% AWG Parameters
sample_rate = 1.25E+9;
interp_factor = 1;
signal_ampl = 0.50;
granularity = 32;
dac_resolution = 16;
%%
seed = [1,zeros(1, prbs_seq -1)];
num_of_bits = clk_div * (2^prbs_seq - 1); % Even number for perfect clock
num_of_bits = num_of_bits * myLib.GetSerialBitsPerSymbol(data_wfm_type);
% Sample Rate and DAC mode must be made consistent
if sample_rate / interp_factor > 2.5E9
interp_factor = 1;
dac_resolution = 8;
granularity = 64;
end
%%
% % Create AWG Setup Variable
awg_setup = myLib.CreateDefaultAwgSetup();
% Create Pulse Setup Variable
pulse_setup = myLib.CreateDefaultPulseSetup();
% AWG Parameters
awg_setup.sampling_rate = sample_rate;
awg_setup.interpol = interp_factor;
awg_setup.dac_resolution = dac_resolution;
awg_setup.volt = signal_ampl;
awg_setup.mode = myLib.AWG_MODE_DIRECT;
% Basic Pulse Parameters
pulse_setup.prbs_seq = prbs_seq;
pulse_setup.data_wfm_type = data_wfm_type;
pulse_setup.pulse_type = myLib.PULSE_TYPE_SQUARE;
pulse_setup.edge_shape = edge_shape;
pulse_setup.pulse_width = 1 / baud_rate; % 1 / Baud Rate
pulse_setup.rise_time = rise_time;
pulse_setup.sampling_rate = awg_setup.sampling_rate / awg_setup.interpol;
pulse_setup.granul = 1;
pulse_setup.quality = 2;
prbs_data = myLib.GetStdPrbsData( pulse_setup.prbs_seq,...
seed,...
num_of_bits);
toc;
fprintf('\nGetting Serial Data Waveform\n');
tic;
%%
% Waveform is calculated as a superposition of pulses for "1" bits in the
% data sequence
[ data_wfm_out,...
sample_rate_out] = myLib.GetSerialDataWfm( prbs_data,...
pulse_setup);
toc;
% Calculate final DAC's sample rate to keep accurate timing
awg_setup.sampling_rate = sample_rate_out * awg_setup.interpol;
fprintf('\nAdapting Waveform for downloading\n');
% The full DAC range is used
% The base waveform is repeated as many times as required so the overall
% number of samples is a multiple of the granularity
tic;
data_wfm_out = myLib.NormalizeFull(data_wfm_out);
[data_wfm_out, num_reps] = myLib.WfmAppendGranularity(data_wfm_out, granularity);
toc;
%%
% Waveform Downloading
% ********************
fprintf(1, '\nDOWNLOADING DATA WAVEFORM FOR CH%d\n', data_ch);
awg_setup.channel = data_ch;
awg_setup.segment = data_segm;
myLib.SendWfmToProteus( awg_setup,...
data_wfm_out,...
true);
%%
% Disconnect, close VISA handle and destroy handle
myLib.DisconnectFromProteus();
fprintf('END\n');
clear myLib;
clear inst;
%close all;