Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import redpitaya_scpi as scpi
- import matplotlib.pyplot as plt
- import numpy as np
- plt.close("all")
- #rp_s = scpi.scpi(sys.argv[1])
- rp_s = scpi.scpi("192.168.1.100")
- #New
- rp_s.tx_txt("ACQ:RST")
- decimation = 1
- rp_s.tx_txt(f"ACQ:DEC {str(decimation)}")
- rp_s.tx_txt('ACQ:DATA:UNITS VOLTS')
- rp_s.tx_txt("ACQ:GET:DATA:FORMAT ASCII")
- trigLev = 30
- rp_s.tx_txt(f"ACQ:TRIG:LEV {trigLev} mV")
- rp_s.tx_txt("ACQ:TRIG:DLY 0")
- rp_s.tx_txt("ACQ:START")
- rp_s.tx_txt("ACQ:TRIG CH1_PE")
- while 1:
- rp_s.tx_txt('ACQ:TRIG:STAT?')
- if rp_s.rx_txt() == 'TD':
- break
- rp_s.tx_txt('ACQ:SOUR2:DATA?')
- buff_string = rp_s.rx_txt()
- buff_string = buff_string.strip('{}\n\r').replace(" ", "").split(',')
- buff = list(map(float, buff_string))
- dati2 = np.array(buff, dtype = np.float32)
- rp_s.tx_txt('ACQ:SOUR1:DATA?')
- buff_string = rp_s.rx_txt()
- buff_string = buff_string.strip('{}\n\r').replace(" ", "").split(',')
- buff = list(map(float, buff_string))
- dati1 = np.array(buff, dtype = np.float32)
- maxTime = 131.072
- vectTempi = np.linspace(0, maxTime * decimation, num = 16384)
- metà = maxTime*decimation/2
- """
- fig, ax = plt.subplots(2,1, sharex = True)
- fig.subplots_adjust(hspace = 0)
- ax[0].plot(vectTempi, buff, c = "tab:green")
- ax[1].plot(vectTempi, buff, ".g")
- for i in ax:
- i.set_ylabel("Ampiezza [V]")
- i.set_xlabel("Tempo [us]")
- i.grid(True)
- i.axvline(x = metà, c = "grey", ls = ":")
- i.axhline(y = trigLev * 1e-3, c = "grey", ls = ":")
- plt.show()
- """
- fig, ax = plt.subplots(2,1, sharex = True)
- fig.subplots_adjust(hspace = 0)
- ax[0].plot(vectTempi, dati1, c = "tab:green")
- ax[1].plot(vectTempi, dati2, c = "tab:green")
- for i in ax:
- i.set_ylabel("Ampiezza [V]")
- i.set_xlabel("Tempo [us]")
- i.grid(True)
- i.axvline(x = metà, c = "grey", ls = ":")
- i.axhline(y = trigLev * 1e-3, c = "grey", ls = ":")
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement