Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import pyvisa
  2. import json
  3. import re
  4.  
  5. #Currently setup with a square wave on channel 5.
  6.  
  7. #can't get streaming "WAVEFORM?" to work, so going to save .trc files for later analysis.
  8. #this https://github.com/yetifrisstlama/readTrc/blob/master/readTrc.py may be of value.
  9.  
  10. #https://pyvisa.readthedocs.io/en/1.8/api/resources.html#pyvisa.resources.GPIBInterface
  11. #http://cdn.teledynelecroy.com/files/manuals/maui-remote-control-and-automation-manual.pdf
  12.  
  13.  
  14. def setupScope():
  15. rm = pyvisa.ResourceManager()
  16. print(rm.list_resources())
  17. lecroy = rm.open_resource('USB0::0x05FF::0x1023::3805N01981::INSTR')
  18. print(lecroy.query("*IDN?"))
  19. lecroy.timeout = 5000
  20. print("Connection OK")
  21. return lecroy
  22.  
  23.  
  24. def measurementSetup(lecroy):
  25. #Dummy squarewave setup commands
  26. lecroy.write("TIME_DIV 5E-5")
  27. lecroy.write("COMM_HEADEROFF")
  28.  
  29. #download waveform template
  30. wftmp = open("waveformtemplate.txt","w")
  31. wftmp.write(lecroy.query("TEMPLATE?"))
  32. wftmp.close()
  33.  
  34. #print(lecroy.query("C5:INSPECT? \"SIMPLE\"")) #debugging, will dump until it times out.
  35.  
  36. #lecroy.write("STO C5, FILE")
  37.  
  38. lecroy.write("C5:WAVEFORM?")
  39. sample = open("sampleoutput.txt","w")
  40. sample.write(str(lecroy.read_raw()))
  41. sample.close()
  42.  
  43. if __name__ == "__main__":
  44. lecroy = setupScope()
  45. measurementSetup(lecroy)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement