Capture the display of a Rigol DS1000Z series oscilloscope by LAN using LXI SCPI commands
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Rigol_functions.py 1.4KB

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