Advertisement
Guest User

Untitled

a guest
Feb 15th, 2022
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. import sys
  2. import redpitaya_scpi as scpi
  3. import matplotlib.pyplot as plt
  4. import numpy as np
  5.  
  6. plt.close("all")
  7.  
  8. #rp_s = scpi.scpi(sys.argv[1])
  9. rp_s = scpi.scpi("192.168.1.100")
  10.  
  11.  
  12.  
  13.  
  14. #New
  15. rp_s.tx_txt("ACQ:RST")
  16. decimation = 1
  17. rp_s.tx_txt(f"ACQ:DEC {str(decimation)}")
  18. rp_s.tx_txt('ACQ:DATA:UNITS VOLTS')
  19.  
  20. rp_s.tx_txt("ACQ:GET:DATA:FORMAT ASCII")
  21. trigLev = 30
  22. rp_s.tx_txt(f"ACQ:TRIG:LEV {trigLev} mV")
  23. rp_s.tx_txt("ACQ:TRIG:DLY 0")
  24.  
  25.  
  26.  
  27. rp_s.tx_txt("ACQ:START")
  28. rp_s.tx_txt("ACQ:TRIG CH1_PE")
  29.  
  30.  
  31.  
  32. while 1:
  33. rp_s.tx_txt('ACQ:TRIG:STAT?')
  34. if rp_s.rx_txt() == 'TD':
  35. break
  36.  
  37.  
  38.  
  39. rp_s.tx_txt('ACQ:SOUR2:DATA?')
  40. buff_string = rp_s.rx_txt()
  41. buff_string = buff_string.strip('{}\n\r').replace(" ", "").split(',')
  42. buff = list(map(float, buff_string))
  43. dati2 = np.array(buff, dtype = np.float32)
  44.  
  45.  
  46. rp_s.tx_txt('ACQ:SOUR1:DATA?')
  47. buff_string = rp_s.rx_txt()
  48. buff_string = buff_string.strip('{}\n\r').replace(" ", "").split(',')
  49. buff = list(map(float, buff_string))
  50. dati1 = np.array(buff, dtype = np.float32)
  51.  
  52.  
  53.  
  54. maxTime = 131.072
  55. vectTempi = np.linspace(0, maxTime * decimation, num = 16384)
  56. metà = maxTime*decimation/2
  57.  
  58.  
  59. """
  60. fig, ax = plt.subplots(2,1, sharex = True)
  61. fig.subplots_adjust(hspace = 0)
  62. ax[0].plot(vectTempi, buff, c = "tab:green")
  63. ax[1].plot(vectTempi, buff, ".g")
  64. for i in ax:
  65. i.set_ylabel("Ampiezza [V]")
  66. i.set_xlabel("Tempo [us]")
  67. i.grid(True)
  68. i.axvline(x = metà, c = "grey", ls = ":")
  69. i.axhline(y = trigLev * 1e-3, c = "grey", ls = ":")
  70.  
  71. plt.show()
  72. """
  73.  
  74. fig, ax = plt.subplots(2,1, sharex = True)
  75. fig.subplots_adjust(hspace = 0)
  76. ax[0].plot(vectTempi, dati1, c = "tab:green")
  77. ax[1].plot(vectTempi, dati2, c = "tab:green")
  78. for i in ax:
  79. i.set_ylabel("Ampiezza [V]")
  80. i.set_xlabel("Tempo [us]")
  81. i.grid(True)
  82. i.axvline(x = metà, c = "grey", ls = ":")
  83. i.axhline(y = trigLev * 1e-3, c = "grey", ls = ":")
  84.  
  85. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement