V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
wzw
V2EX  ›  问与答

有人熟悉 安捷伦 agilent 和 罗德与施瓦茨 Rohde & Schwarz 等测试设备的开发吗? (SCPI 如何入门?)

  •  1
     
  •   wzw · 2018-06-04 21:38:44 +08:00 · 1727 次点击
    这是一个创建于 2156 天前的主题,其中的信息可能已经有所发展或是发生改变。

    问题:

    1. SCPI 感觉有点难理解, 如何入门?
    2. 我用用程序控制这些设备,进行测试. 那我应该如何完成最简单的一个测试步骤?(帮助理解 SCPI 流程)

    1 目前看懂了 hello world 的例子, 连上了设备. 这个代码跑通

    import visa
    
    rm = visa.ResourceManager()
    scope = rm.open_resource("TCPIP::192.168.2.2::5025::SOCKET")
    
    # All these three settings are required for SOCKET and Serial connection
    scope.write_termination = '\n'
    scope.set_visa_attribute(visa.constants.VI_ATTR_TERMCHAR, 10)
    scope.set_visa_attribute(visa.constants.VI_ATTR_TERMCHAR_EN, True)
    
    scope.clear()  # Clear instrument io buffers and status
    idn_response = scope.query('*IDN?')  # Query the Identification string
    
    print 'Hello, I am ' + idn_response
    

    2 但是开始测试的 SCPI 命令就有点难上手的感觉了. (这段卡不太懂了. 恶补中)

     RTO/RTE Oscilloscope example for Python using PyVISA
    
    import visa
    import VISAresourceExtentions
    
    # -----------------------------------------------------------
    # Initialization
    # -----------------------------------------------------------
    rm = visa.ResourceManager()
    scope = rm.open_resource('TCPIP::10.85.0.119::INSTR')
    
    # try block to catch any InstrumentErrorException() or InstrumentTimeoutException()
    try:
        scope.write_termination = ''
        # Some instruments require LF at the end of each command. In that case, use:
        # scope.write_termination = '\n'
        scope.ext_clear_status()  # Clear instrument io buffers and status
        scope.write('*RST;*CLS;:SYST:DISP:UPD ON')  # Reset the instrument
        scope.write('*ESE 1')  # Event Status Enable OPC bit - one time setting after *RST
        scope.ext_error_checking()  # Error Checking
    
        # -----------------------------------------------------------
        # Settings all in one string:
        # -----------------------------------------------------------
        scope.write('ACQ:POIN:AUTO RECL;:TIM:RANG 2.0;:ACQ:POIN 1002;:CHAN1:STAT ON;:TRIG1:MODE AUTO')
        scope.ext_error_checking()  # Error Checking
    
        # -----------------------------------------------------------
        # Acquisition:
        # -----------------------------------------------------------
        print '\nAcquisition started...'
        scope.ext_write_with_srq_sync('SING', 6000)
        print 'Acquisition finished'
        # -----------------------------------------------------------
        # Selftest:
        # -----------------------------------------------------------
        print '\nSelftest started...'
        scope.ext_query_with_srq_sync('*TST?', 120000)
        scope.ext_error_checking()  # Error Checking
        print 'Selftest finished...'
    
        print 'Finished'
    
    except VISAresourceExtentions.InstrumentErrorException, e:
        # Catching instrument error exception and showing its content
        print 'Instrument error(s) occurred:\n' + e.message
    
    except VISAresourceExtentions.InstrumentTimeoutException, e:
        # Catching instrument error exception and showing its content
        print 'Timeout error(s) occurred:\n' + e.message
    
    

    有没有这方面入门经验的分享一下, 感觉 SCPI 命令好难懂.

    谢谢

    4 条回复    2018-06-05 14:42:58 +08:00
    v2byy
        1
    v2byy  
       2018-06-04 22:52:58 +08:00 via iPhone
    看开发手册啊,做自动化测试吗
    wzw
        2
    wzw  
    OP
       2018-06-04 23:02:10 +08:00
    @v2byy #1 很多测试只能半自动吧. 正在看手册... 感觉有点怪怪的. 不如 python node js php .net C 好理解. 也可能我刚开始
    wzw
        3
    wzw  
    OP
       2018-06-05 07:01:28 +08:00 via iPhone
    一个回复,三个收藏+++
    fsdafsag
        4
    fsdafsag  
       2018-06-05 14:42:58 +08:00
    只会用 labview 控制,一般都有范例可以改或者 DLL 可以调用, 再不济也可以根据通讯协议通过 scpi 模块来通讯。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3881 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 05:20 · PVG 13:20 · LAX 22:20 · JFK 01:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.