Skip to content

Commit 4dbe9d9

Browse files
committed
both adrv
Signed-off-by: PopPaul2021 <Paul.Pop@analog.com>
1 parent d2158da commit 4dbe9d9

File tree

2 files changed

+137
-49
lines changed

2 files changed

+137
-49
lines changed

examples/adrv9002_example.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
sdr.tx_hardwaregain_chan1 = -10
2323

2424

25-
sdr1 = adi.adrv9002(uri="ip:10.48.65.154")
25+
sdr1 = adi.adrv9002(uri="ip:10.48.65.187")
2626
sdr1.write_stream_profile( "lte_40_lvds_api_68_14_10.stream" ,"lte_40_lvds_api_68_14_10.json")
2727

2828
sdr1.tx0_port_en = "spi"

examples/plot_identification_data.py

+136-48
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,28 @@ def get_cnn_data():
193193
iq_imag = np.int16(np.imag(data) * 2**12-1)
194194
iq = iq_real + 1j * iq_imag
195195

196-
sdr1.tx_destroy_buffer()
197-
sdr1._tx2.tx_destroy_buffer()
198196
sdr.tx_destroy_buffer()
199197
sdr._tx2.tx_destroy_buffer()
198+
sdr.tx(iq)
199+
sdr._tx2.tx(iq)
200200

201+
sdr1.tx_destroy_buffer()
202+
sdr1._tx2.tx_destroy_buffer()
201203
sdr1.tx(iq)
202-
sdr1.tx2(iq)
203-
sdr.tx(iq)
204-
sdr.tx2(iq)
204+
sdr1._tx2.tx(iq)
205205

206-
if get_timestamp(file_path):
206+
sdr2.tx_destroy_buffer()
207+
sdr2._tx2.tx_destroy_buffer()
208+
sdr2.tx(iq)
209+
sdr2._tx2.tx(iq)
207210

208-
truth_vector.append(truth)
211+
sdr3.tx_destroy_buffer()
212+
sdr3._tx2.tx_destroy_buffer()
213+
sdr3.tx(iq)
214+
sdr3._tx2.tx(iq)
215+
216+
time.sleep(0.1)
217+
if get_timestamp(file_path):
209218
with open(file_path, 'r') as file:
210219
lines = file.readlines()
211220
estimated_ch1 = int(lines[1].strip())
@@ -217,6 +226,7 @@ def get_cnn_data():
217226
probability_ch3 = float(lines[7].strip())
218227
probability_ch4 = float(lines[8].strip())
219228

229+
truth_vector.append(truth)
220230
estimated_ch1_vector.append(estimated_ch1)
221231
estimated_ch2_vector.append(estimated_ch2)
222232
estimated_ch3_vector.append(estimated_ch3)
@@ -228,7 +238,7 @@ def get_cnn_data():
228238
probability_ch4_vector.append(probability_ch4)
229239

230240
if get_timestamp1(file_path1):
231-
truth_vector1.append(truth1)
241+
232242
with open(file_path1, 'r') as file:
233243
lines = file.readlines()
234244
estimated_ch5 = int(lines[1].strip())
@@ -239,7 +249,7 @@ def get_cnn_data():
239249
probability_ch6 = float(lines[6].strip())
240250
probability_ch7 = float(lines[7].strip())
241251
probability_ch8 = float(lines[8].strip())
242-
252+
truth_vector1.append(truth1)
243253
estimated_ch5_vector.append(estimated_ch5)
244254
estimated_ch6_vector.append(estimated_ch6)
245255
estimated_ch7_vector.append(estimated_ch7)
@@ -307,7 +317,6 @@ def plot_confusion_matrix():
307317
colorscale='Blues'
308318
))
309319
fig.update_layout(
310-
title=dict(text='Confusion Matrix', x=0.5),
311320
xaxis=dict(title='Estimated Modulation'),
312321
yaxis=dict(title='True Modulation')
313322
)
@@ -321,13 +330,14 @@ def plot_confusion_matrix1():
321330
colorscale='Blues'
322331
))
323332
fig.update_layout(
324-
title=dict(text='Confusion Matrix', x=0.5),
325333
xaxis=dict(title='Estimated Modulation'),
326334
yaxis=dict(title='True Modulation')
327335
)
328336
return fig
329337

330-
table_data = pd.DataFrame(columns=['column-1', 'column-2', 'column-3', 'column-4', 'column-5', 'column-6'], dtype='float64').to_dict('records')
338+
table_data = pd.DataFrame(columns=['column-1', 'column-2', 'column-3', 'column-4', 'column-5', 'column-6'], dtype=np.float64).to_dict('records')
339+
truth_table_data = pd.DataFrame(columns=['column-1', 'column-2', 'column-3'], dtype=pd.StringDtype()).to_dict('records')
340+
truth_table_data1 = pd.DataFrame(columns=['column-1', 'column-2', 'column-3'], dtype=pd.StringDtype()).to_dict('records')
331341

332342
accuracy = 0
333343
precision = 0
@@ -367,54 +377,102 @@ def update_table():
367377
},
368378
]
369379

380+
def update_truth_table():
381+
global truth_table_data
382+
global truth_table_data1
383+
384+
truth_table_data = [
385+
{'column-1': 'Channel 1', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch1)]}'},
386+
{'column-1': 'Channel 2', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch2)]}'},
387+
{'column-1': 'Channel 3', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch3)]}'},
388+
{'column-1': 'Channel 4', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch4)]}'},
389+
]
390+
391+
truth_table_data1 = [
392+
{'column-1': 'Channel 1', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch5)]}'},
393+
{'column-1': 'Channel 2', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch6)]}'},
394+
{'column-1': 'Channel 3', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch7)]}'},
395+
{'column-1': 'Channel 4', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch8)]}'},
396+
]
397+
398+
399+
400+
401+
370402
app.layout = html.Div([
371403
html.Div([
372404
html.Img(src='/assets/ADI_logo.svg', style={'height': '45px', 'margin-right': '16px', 'vertical-align': 'middle'}),
373405
html.H1('High-Performance Analog Meets AI', style={'display': 'inline-block', 'vertical-align': 'middle', 'fontSize': '46px'})
374-
], style={'width': '100%', 'text-align': 'left', 'padding': '5px', 'border-bottom': '1px solid #B7BBC3', 'backgroundColor': '#FFFFFF', 'font-family': 'Barlow', 'display': 'flex', 'align-items': 'center'}),
375-
376-
406+
], style={'width': '100%', 'text-align': 'left', 'padding': '5px', 'border-bottom': '1px solid #B7BBC3', 'backgroundColor': '#FFFFFF', 'font-family': 'Barlow', 'align-items': 'center'}),
377407

378408
html.Div([
379-
html.H2('ADRV9009ZU11EG device 1', style={'text-align': 'center', 'margin-top': '20px', 'font-family': 'Barlow'}),
380-
html.Div(dcc.Graph(id='confusion-matrix'), style={'width': '40%', 'display': 'inline-block', 'margin-left': '5%'}),
381-
html.Div(dcc.Graph(id='modulated-data'), style={'width': '40%', 'display': 'inline-block', 'margin-left': '10%'})
382-
], style={'width': '90%','height': '65%', 'margin-left': '5%', 'margin-top': '1%', 'backgroundColor': 'transparent', 'border-radius': '20px', 'box-shadow': '10px 10px 20px rgba(0, 0, 0, 0.2)', 'font-family': 'Barlow', 'fontSize': '20px'}),
383-
409+
html.H2('ADRV9009ZU11EG device 1', style={'text-align': 'center', 'margin-top': '2%', 'font-family': 'Barlow','height': '10%'}),
410+
html.Div([
411+
dcc.Graph(id='confusion-matrix', style={'width': '40%','height': '100%' ,'display': 'inline-block'}),
412+
dash_table.DataTable(
413+
id='truth-table',
414+
columns=[
415+
{'name': 'Channel', 'id': 'column-1'},
416+
{'name': 'Estimated', 'id': 'column-2'},
417+
{'name': 'Truth', 'id': 'column-3'},
418+
],
419+
data=truth_table_data,
420+
style_cell={'textAlign': 'center', 'fontSize': '20px', 'font-family': 'Barlow'},
421+
style_header={'backgroundColor': '#1E4056', 'color': 'white', 'font-family': 'Barlow', 'fontSize': '25px'},
422+
style_table={'width': '25%','height': '100%', 'display': 'inline-block','margin-top': '50%','vertical-align': 'middle'}
423+
),
424+
dcc.Graph(id='modulated-data', style={'width': '40%','height': '100%' ,'display': 'inline-block'})
425+
], style={'display': 'flex', 'justify-content': 'space-between', 'width': '100%','height': '90%'})],
426+
style={'width': '98%', 'height': '65%', 'margin-left': '1%', 'backgroundColor': 'transparent', 'border-radius': '20px', 'box-shadow': '10px 10px 20px rgba(0, 0, 0, 0.2)', 'font-family': 'Barlow', 'fontSize': '20px'}),
384427
html.Div(
385-
dash_table.DataTable(
386-
id='example-table',
387-
columns=[
388-
{'name': 'Accuracy' , 'id': 'column-1'},
389-
{'name': 'Precision' , 'id': 'column-2'},
390-
{'name': 'Recall' , 'id': 'column-3'},
391-
{'name': 'F1 rate' , 'id': 'column-4'},
392-
{'name': 'MSE rate' , 'id': 'column-5'},
393-
{'name': 'R2 rate' , 'id': 'column-6'}
394-
],
395-
data=table_data,
396-
style_table={'width': '90%', 'margin-left': '5%','margin-top': '2%', 'border-radius': '50px', 'box-shadow': '10px 10px 20px rgba(0, 0, 0, 0.2)', 'font-family': 'Barlow'},
397-
style_cell={'textAlign': 'center', 'fontSize': '20px', 'font-family': 'Barlow'},
398-
style_header={'backgroundColor': '#1E4056', 'color': 'white', 'font-family': 'Barlow', 'fontSize': '20px'}
399-
)
428+
dash_table.DataTable(
429+
id='example-table',
430+
columns=[
431+
{'name': 'Accuracy', 'id': 'column-1'},
432+
{'name': 'Precision', 'id': 'column-2'},
433+
{'name': 'Recall', 'id': 'column-3'},
434+
{'name': 'F1 rate', 'id': 'column-4'},
435+
{'name': 'MSE rate', 'id': 'column-5'},
436+
{'name': 'R2 rate', 'id': 'column-6'}
437+
],
438+
data=table_data,
439+
style_table={'width': '90%', 'margin-left': '5%', 'margin-top': '2%', 'border-radius': '50px', 'box-shadow': '10px 10px 20px rgba(0, 0, 0, 0.2)', 'font-family': 'Barlow'},
440+
style_cell={'textAlign': 'center', 'fontSize': '20px', 'font-family': 'Barlow'},
441+
style_header={'backgroundColor': '#1E4056', 'color': 'white', 'font-family': 'Barlow', 'fontSize': '20px'}
442+
)
400443
),
401444
html.Div([
402-
html.H2('ADRV9009ZU11EG device 2', style={'text-align': 'center', 'margin-top': '20px', 'font-family': 'Barlow'}),
403-
html.Div(dcc.Graph(id='confusion-matrix1'), style={'width': '40%', 'display': 'inline-block', 'margin-left': '5%'}),
404-
html.Div(dcc.Graph(id='modulated-data1'), style={'width': '40%', 'display': 'inline-block', 'margin-left': '10%'})
405-
], style={'width': '90%','height': '65%', 'margin-left': '5%', 'margin-top': '1%', 'backgroundColor': 'transparent', 'border-radius': '10px', 'box-shadow': '10px 10px 20px rgba(0, 0, 0, 0.2)' , 'font-family': 'Barlow', 'fontSize': '20px'}),
406-
407-
dcc.Interval(
408-
id='interval-component',
409-
interval=1*1000, # in milliseconds
410-
n_intervals=0
411-
)
445+
html.H2('ADRV9009ZU11EG device 2', style={'text-align': 'center', 'margin-top': '2%', 'font-family': 'Barlow','height': '10%'}),
446+
html.Div([
447+
dcc.Graph(id='confusion-matrix1', style={'width': '40%','height': '100%' ,'display': 'inline-block'}),
448+
dash_table.DataTable(
449+
id='truth-table1',
450+
columns=[
451+
{'name': 'Channel', 'id': 'column-1'},
452+
{'name': 'Estimated', 'id': 'column-2'},
453+
{'name': 'Truth', 'id': 'column-3'},
454+
],
455+
data=truth_table_data1,
456+
style_cell={'textAlign': 'center', 'fontSize': '20px', 'font-family': 'Barlow'},
457+
style_header={'backgroundColor': '#1E4056', 'color': 'white', 'font-family': 'Barlow', 'fontSize': '25px'},
458+
style_table={'width': '25%','height': '100%', 'display': 'inline-block','margin-top': '50%','vertical-align': 'middle'}
459+
),
460+
dcc.Graph(id='modulated-data1', style={'width': '40%','height': '100%' ,'display': 'inline-block'})
461+
], style={'display': 'flex', 'justify-content': 'space-between', 'width': '100%','height': '90%'})],
462+
style={'width': '98%', 'height': '65%', 'margin-left': '1%', 'backgroundColor': 'transparent', 'border-radius': '20px', 'box-shadow': '10px 10px 20px rgba(0, 0, 0, 0.2)', 'font-family': 'Barlow', 'fontSize': '20px'}),
463+
dcc.Interval(
464+
id='interval-component',
465+
interval=1*1000, # in milliseconds
466+
n_intervals=0
467+
)
412468
], style={'font-family': 'Barlow'})
413469

414470
@app.callback(
415471
[dash.dependencies.Output('confusion-matrix', 'figure'),
416472
dash.dependencies.Output('modulated-data', 'figure'),
417473
dash.dependencies.Output('example-table', 'data'),
474+
dash.dependencies.Output('truth-table', 'data'),
475+
dash.dependencies.Output('truth-table1', 'data'),
418476
dash.dependencies.Output('confusion-matrix1', 'figure'),
419477
dash.dependencies.Output('modulated-data1', 'figure')],
420478
[dash.dependencies.Input('interval-component', 'n_intervals')]
@@ -423,12 +481,13 @@ def update_graph_live(n):
423481
get_cnn_data()
424482
update_confusion_matrix()
425483
update_table()
426-
return plot_confusion_matrix(), plot_modulated_data(), table_data, plot_confusion_matrix1(), plot_modulated_data1()
484+
update_truth_table()
485+
return plot_confusion_matrix(), plot_modulated_data(), table_data, truth_table_data , truth_table_data1, plot_confusion_matrix1(), plot_modulated_data1()
427486

428487
if __name__ == '__main__':
429488

430489
# Code to be executed just once
431-
sdr = adi.adrv9002(uri="ip:10.48.65.203")
490+
sdr = adi.adrv9002(uri="ip:10.48.65.222")
432491
sdr.write_stream_profile( "lte_40_lvds_api_68_14_10.stream" ,"lte_40_lvds_api_68_14_10.json")
433492

434493
sdr.tx0_port_en = "spi"
@@ -442,7 +501,7 @@ def update_graph_live(n):
442501
sdr.tx_hardwaregain_chan1 = -10
443502

444503

445-
sdr1 = adi.adrv9002(uri="ip:10.48.65.154")
504+
sdr1 = adi.adrv9002(uri="ip:10.48.65.187")
446505
sdr1.write_stream_profile( "lte_40_lvds_api_68_14_10.stream" ,"lte_40_lvds_api_68_14_10.json")
447506

448507
sdr1.tx0_port_en = "spi"
@@ -456,4 +515,33 @@ def update_graph_live(n):
456515
sdr1.tx_hardwaregain_chan0 = -10
457516
sdr1.tx_hardwaregain_chan1 = -10
458517

518+
sdr2 = adi.adrv9002(uri="ip:10.48.65.226")
519+
sdr2.write_stream_profile( "lte_40_lvds_api_68_14_10.stream" ,"lte_40_lvds_api_68_14_10.json")
520+
521+
sdr2.tx0_port_en = "spi"
522+
sdr2.tx1_port_en = "spi"
523+
sdr2.tx_ensm_mode_chan0 = "rf_enabled"
524+
sdr2.tx_ensm_mode_chan1 = "rf_enabled"
525+
sdr2.tx_cyclic_buffer = True
526+
sdr2.tx2_cyclic_buffer = True
527+
sdr2.tx0_lo = 2400000000
528+
sdr2.tx1_lo = 2400000000
529+
sdr2.tx_hardwaregain_chan0 = -10
530+
sdr2.tx_hardwaregain_chan1 = -10
531+
532+
533+
sdr3 = adi.adrv9002(uri="ip:10.48.65.203")
534+
sdr3.write_stream_profile( "lte_40_lvds_api_68_14_10.stream" ,"lte_40_lvds_api_68_14_10.json")
535+
536+
sdr3.tx0_port_en = "spi"
537+
sdr3.tx1_port_en = "spi"
538+
sdr3.tx_ensm_mode_chan0 = "rf_enabled"
539+
sdr3.tx_ensm_mode_chan1 = "rf_enabled"
540+
sdr3.tx_cyclic_buffer = True
541+
sdr3.tx2_cyclic_buffer = True
542+
sdr3.tx0_lo = 2400000000
543+
sdr3.tx1_lo = 2400000000
544+
sdr3.tx_hardwaregain_chan0 = -10
545+
sdr3.tx_hardwaregain_chan1 = -10
546+
459547
app.run_server(debug=True)

0 commit comments

Comments
 (0)