-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadc-read-simple-plot.py
56 lines (48 loc) · 1.43 KB
/
adc-read-simple-plot.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
ADALM1000
NUM_SAM_PTS beider ADCs auslesen und als Plot darstellen
20.6.2020, S Mack
"""
import numpy as np
import matplotlib.pyplot as plt
from pysmu import Session, Mode
NUM_SAM_PTS = 5000 # Number of sampling points
try:
#if not ('session' in locals()):
session = Session()
if session.devices:
samp_ch_a = []
samp_ch_b = []
dev = session.devices[0]
# Set both channels to high impedance mode.
chan_a = dev.channels['A']
chan_b = dev.channels['B']
chan_a.mode = Mode.HI_Z
chan_b.mode = Mode.HI_Z
samples = dev.get_samples(NUM_SAM_PTS)
for data in samples:
samp_ch_a.append(data[0][0])
samp_ch_b.append(data[1][0])
fig, ax = plt.subplots()
x = np.arange(0, NUM_SAM_PTS, 1)
ax.plot(x,samp_ch_a,'-',label='CH A')
ax.plot(x,samp_ch_b,'-',label='CH B')
ax.set_ylim(-0.1, 5.1)
ax.set_xlim(-50, NUM_SAM_PTS + 50)
ax.grid(linestyle=':')
ax.set(xlabel='Sampling Number', ylabel='Voltage', title='ADALM1000 High Impedance Sampling')
ax.legend(loc='upper right')
plt.show()
else:
print('no devices attached')
except KeyboardInterrupt:
print()
print('Strg + C erkannt...')
finally:
print('Ende.')
#session.cancel()
#session.end()
#del session
pass