forked from colinoflynn/pico-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsigGetBuiltIndemo.py
75 lines (51 loc) · 2.05 KB
/
sigGetBuiltIndemo.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""
PS6000 AWG Demo
By: Mark Harfouche
This is a demo of how to use Siggen with the Picoscope 6000
It was tested with the PS6403B USB2.0 version
The system is very simple:
The SigGen is connected to Channel A. No other setup is required
Warning, the picoscope has a bug, that doesn't let you generate a waveform correctly for a while
It means that you need to kick it in place
See http://www.picotech.com/support/topic12969.html
"""
from __future__ import division
from picoscope import ps6000
import pylab as plt
import numpy as np
if __name__ == "__main__":
print(__doc__)
print("Attempting to open Picoscope 6000...")
# see page 13 of the manual to understand how to work this beast
ps = ps6000.PS6000()
print(ps.getAllUnitInfo())
waveform_desired_duration = 1E-3
obs_duration = 10*waveform_desired_duration
sampling_interval = obs_duration/4096
(actualSamplingInterval, nSamples, maxSamples) = ps.setSamplingInterval(sampling_interval, obs_duration)
print("Sampling interval = %f ns"%(actualSamplingInterval*1E9));
print("Taking samples = %d"%nSamples)
print("Maximum samples = %d"%maxSamples)
ps.setChannel('A', 'DC', 5.0, 0.0, True, False)
ps.setSimpleTrigger('A', 0.0, 'Rising', delay=0, timeout_ms=100, enabled=True)
ps.setSigGenBuiltInSimple(offsetVoltage=0, pkToPk=4, waveType="Square", frequency=1/waveform_desired_duration*10, shots=1,
triggerType="Rising", triggerSource="None")
# take the desired waveform
# This measures all the channels that have been enabled
ps.runBlock()
ps.waitReady()
print("Done waiting for trigger")
dataA = ps.getDataV('A', nSamples, returnOverflow=False)
dataTimeAxis = np.arange(nSamples) * actualSamplingInterval
plt.ion()
plt.figure()
plt.hold(True)
plt.plot(dataTimeAxis, dataA, label="Waveform")
plt.grid(True, which='major')
plt.title("Picoscope 6000 waveforms")
plt.ylabel("Voltage (V)")
plt.xlabel("Time (ms)")
plt.legend()
plt.draw()
ps.stop()
ps.close()