-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_app.py
More file actions
67 lines (52 loc) · 2.42 KB
/
test_app.py
File metadata and controls
67 lines (52 loc) · 2.42 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
import os
import sys
import serial.tools.list_ports
abs_path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(abs_path + '/fpga_uart_pc_software/')
ports = serial.tools.list_ports.comports()
for port, desc, hwid in sorted(ports):
print("{}: {} [{}]".format(port, desc, hwid))
comport = str(sys.argv[1])
plot_title = str(sys.argv[2])
from uart_communication_functions import *
uart = uart_link(comport, 5e6)
print("test reading data from hvhdl example interconnect")
print("this should be 44252 : ", uart.request_data_from_address(99))
print("now write 37 to the same address with write_data_to_address(99,37)")
uart.write_data_to_address(99,37)
print("the register should now read 37 : ", uart.request_data_from_address(99))
print("we will now write back 44252 with with write_data_to_address(99,44252)")
uart.write_data_to_address(99,44252)
print("this should be again 44252 : ", uart.request_data_from_address(99))
uart.write_data_to_address(111,8)
print("requested filter index : ", uart.request_data_from_address(111))
print("now we will get 200 000 data point stream which correspond to clean sine and noisy sine which is fixed and floating point filered")
number_of_points = 50000
noisy_sine = uart.stream_data_from_address(103, number_of_points);
# fixed_point_filtered_data = uart.stream_data_from_address(104, number_of_points);
floating_point_filtered_data = uart.stream_data_from_address(108, number_of_points);
# microprocessor_filtered_data = uart.stream_data_from_address(110, number_of_points);
#
(fig, ax) = pyplot.subplots(3, 2)
# ax[0][0].subplot(2, 2, 1)
ax[0][0].plot(noisy_sine)
ax[0][0].set_title('noisy sine')
uart.write_data_to_address(111,9)
ax[0][1].plot(uart.stream_data_from_address(108, number_of_points))
ax[0][1].set_title('gain 0.10')
uart.write_data_to_address(111,6)
ax[1][0].plot(uart.stream_data_from_address(110, number_of_points))
ax[1][0].set_title('gain 0.07')
uart.write_data_to_address(111,3)
ax[1][1].plot(uart.stream_data_from_address(110, number_of_points))
ax[1][1].set_title('gain 0.04')
fig.suptitle(plot_title, fontsize=15)
uart.write_data_to_address(111,1)
ax[2][0].plot(uart.stream_data_from_address(110, number_of_points))
ax[2][0].set_title('gain 0.02')
fig.suptitle(plot_title, fontsize=15)
uart.write_data_to_address(111,0)
ax[2][1].plot(uart.stream_data_from_address(110, number_of_points))
ax[2][1].set_title('index 0.01')
fig.suptitle(plot_title, fontsize=15)
pyplot.show()