forked from prometheus-science/red2pmic
-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.py
43 lines (34 loc) · 1.67 KB
/
test.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
# import pyrpl library
from pyrpl import Pyrpl
configFile = "/home/andre/pyrpl_user_dir/test1.yml"
# create an interface to the Red Pitaya
#r = pyrpl.Pyrpl(configFile).redpitaya
p = Pyrpl(hostname='10.42.0.60',config=configFile)
print(p)
p.rp.hk.led = 0b10101010 # change led pattern
# measure a few signal values
print("Voltage at analog input1: %.3f" % p.rp.sampler.in1)
print("Voltage at analog output2: %.3f" % p.rp.sampler.out2)
print("Voltage at the digital filter's output: %.3f" % p.rp.sampler.iir)
# output a function U(t) = 0.5 V * sin(2 pi * 10 MHz * t) to output2
p.rp.asg0.setup(waveform='sin',
amplitude=0.5,
frequency=10e6,
output_direct='out2')
# demodulate the output signal from the arbitrary signal generator
r.iq0.setup(input='asg0', # demodulate the signal from asg0
frequency=10e6, # demodulaltion at 10 MHz
bandwidth=1e5) # demodulation bandwidth of 100 kHz
# set up a PID controller on the demodulated signal and add result to out2
r.pid0.setup(input='iq0',
output_direct='out2', # add pid signal to output 2
setpoint=0.05, # pid setpoint of 50 mV
p=0.1, # proportional gain factor of 0.1
i=100, # integrator unity-gain-frequency of 100 Hz
input_filter = [3e3, 10e3]) # add 2 low-passes (3 and 10 kHz)
# modify some parameters in real-time
r.iq0.frequency += 2.3 # add 2.3 Hz to demodulation frequency
r.pid0.i *= 2 # double the integrator unity-gain-frequency
# take oscilloscope traces of the demodulated and pid signal
data = r.scope.curve(input1='iq0', input2='pid0',
duration=1.0, trigger_source='immediately')