Capture the display of a Rigol DS1000Z series oscilloscope by LAN using LXI SCPI commands
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Rigol_functions.py 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. __author__ = 'RoGeorge'
  2. import time
  3. import pip
  4. import sys
  5. def print_running_Python_versions():
  6. print "Running Python version:"
  7. print (sys.version) # parentheses necessary in python 3.
  8. print sys.version_info
  9. print
  10. installed_packages = pip.get_installed_distributions()
  11. installed_packages_list = sorted(["%s==%s" % (i.key, i.version) for i in installed_packages])
  12. print "Installed Python modules:"
  13. print(installed_packages_list)
  14. print
  15. def get_memory_depth(tn):
  16. # Define number of horizontal grid divisions for DS1054Z
  17. h_grid = 12
  18. # ACQuire:MDEPth
  19. tn.write("ACQ:MDEP?")
  20. mdep = tn.read_until("\n", 1)
  21. # if mdep is "AUTO"
  22. if mdep == "AUTO\n":
  23. # ACQuire:SRATe
  24. tn.write("ACQ:SRAT?")
  25. srate = tn.read_until("\n", 1)
  26. # TIMebase[:MAIN]:SCALe
  27. tn.write("TIM:SCAL?")
  28. scal = tn.read_until("\n", 1)
  29. # mdep = h_grid * scal * srate
  30. mdep = h_grid * float(scal) * float(srate)
  31. # return mdep
  32. return float(mdep)
  33. # return maximum achieved stop point, or 0 for wrong input parameters
  34. # if achieved == requested, then set the start and stop waveform as n1_d and n2_d
  35. def is_waveform_from_to(tn, n1_d, n2_d):
  36. # read current
  37. # WAVeform:STARt
  38. tn.write("WAV:STAR?")
  39. n1_c = float(tn.read_until("\n", 1))
  40. # WAVeform:STOP
  41. tn.write("WAV:STOP?")
  42. n2_c = float(tn.read_until("\n", 1))
  43. if (n1_d > n2_d) or (n1_d < 1) or (n2_d < 1):
  44. # wrong parameters
  45. return 0
  46. elif n2_d < n1_c:
  47. # first set n1_d then set n2_d
  48. tn.write("WAV:STAR " + str(n1_d))
  49. time.sleep(1)
  50. tn.write("WAV:STOP " + str(n2_d))
  51. time.sleep(1)
  52. else:
  53. # first set n2_d then set n1_d
  54. tn.write("WAV:STOP " + str(n2_d))
  55. time.sleep(1)
  56. tn.write("WAV:STAR " + str(n1_d))
  57. time.sleep(1)
  58. # read achieved n2
  59. tn.write("WAV:STOP?")
  60. n2_a = float(tn.read_until("\n", 1))
  61. if n2_a < n2_d:
  62. # restore n1_c, n2_c
  63. is_waveform_from_to(tn, n1_c, n2_c)
  64. # return n2_a
  65. return n2_a