65
GPIB GPIB 儀器控制之概念及軟硬體介紹 儀器控制之概念及軟硬體介紹 研華股份有限公司 工業自動化事業群

Advantech in 2001advdownload.advantech.com/productfile/Downloadfile2/EI-2... · 2017-09-26 · GPIB History General Purpose Interface Bus z由HP於1975年提出–HPIB作為自家各種儀器間的連接

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

  • GPIB GPIB 儀器控制之概念及軟硬體介紹儀器控制之概念及軟硬體介紹

    研華股份有限公司

    工業自動化事業群

  • OutlineOutline

    1. Introduction to Adavntech GPIB Card 2. Introduction to IEEE 488.13. Introduction to IEEE 488.2 & SCPI

  • GPIB HistoryGPIB HistoryGeneral Purpose Interface BusGeneral Purpose Interface Bus

    由HP於1975年提出 – HPIB作為自家各種儀器間的連接介面.

    IEEE於1975年修訂為IEEE-488-1975(Define Connector & Cable 之電氣特性及機械特性及資料傳輸Handshanking模式).

    於1978年再修訂為IEEE-488.1-1987針對統一定義軔體程式.

    IEEE-488.2-1987統一建立標準碼, 格式協定共同命令(Standard Code,Format,Protocols,Comm Commands)為IEEE488軟體標準.

    SCPI (Stand Command Protocols Interface)

  • GPIBGPIB特色特色

    可同時將十五台儀器(0~31位址可用)連接到電腦(控制器),電腦負責控制Bus上的通訊

    8bit平行傳輸,可達8Mbit/s通訊速度

    控制器到儀器可長20m(儀器間2m)

    多使用純文字(7bit data)指令(易於判別)

    使用3控制線於交握(handshake),確認資料正確傳輸

    除資料BUS外還有其他控制線:SRQ, IFC, EOI, ATN等

  • Introduction to Advantech Introduction to Advantech PCIPCI--1670 GPIB Card1670 GPIB Card

  • SpecificationSpecification

    Supports Windows 95/98/Me/NT40/2000/XP and DOS OS.Provides NI-like driver & function libraries.Supports Visual C++、Borland C++ Builder、Labwindows、Visual Basic、Delphi and Labview…etc.Provides interactive control utility.– GPIBTool.exe

    IEEE 488 bus transfer rates up to 1.5M bytes/sec.– ( Actual rates depend on instrument

    capabilities )

  • PCIPCI--1670 Linking many GPIB 1670 Linking many GPIB 儀器儀器......示波器 信號產生器

    數位電錶 交換器

  • Advantech PCIAdvantech PCI--1670 GPIB 1670 GPIB Interface Card & GPIB cableInterface Card & GPIB cable

  • Explain Installing filesExplain Installing filesSee computerSee computer

  • Introduction to GPIBToolIntroduction to GPIBToolinteractive GPIB window interface.– GPIBTool.exe

    Test Program– GPIBTest.exe

  • GPIB Bus Auto scan UtilityGPIB Bus Auto scan Utility

  • GPIBTool Utility Command FunctionGPIBTool Utility Command Function

  • Operating GPIBTool.exeOperating GPIBTool.exe

  • Bus Timeout periodBus Timeout period

  • CommandsCommandsOpen:– Open a new device ibdev– Online/offline ibonl– Close the interface ibclose

    Configure:– Set primary address ibpad– Set secondary address ibsad– Set timeout value ibeot– Set ending byte of streamstring ibeos– Enable/disable EIO line ibeot– Software structure of a device ibconfig

  • CommandsCommandsRead/Write:– Read data ibrd– Write commands ibwrt

    Operations:– Check whether a device is – on GPIB connecting barline– (online) or not ibln– Clear a device ibclr– Trigger a device ibtrg– Return to local operation mode ibloc– Transfer power control ibpct– Sequential pollingSerial polling ibrsp– Configure parallel pollingparallel polling

    ibppc– Parallel pollingParallel polling ibrpp– Wait for event to occur ibwait

  • Examples of various languagesExamples of various languagesVisual C++Borland C++ BuilderLabwindowsVisual BasicDelphiLabview Turbo C.. etc.

  • Turbo C program ExampleTurbo C program Example1. if ( (lcr = ibdev(0,21,96,T10s,1,0)) < 0 )

    report_errorr(lcr,"Device Open ERRor"); 2. ibln(lcr,21,97,&data1);3. ibwrt(lcr,"syst:err?",35);

    if ( ibsta & ERR )report_errorr(lcr,"Device Write ERRor");

    4. ibrd(lcr,parser_buf,40);if ( ibsta & ERR )

    report_errorr(lcr,"Device Read ERRor");else{parser_buf[ibcntl-1]=0;printf("GPIB read(%d) : %s\n\r",ibcntl,parser_buf); }

    5. ibwrt(lcr,"*sre 16",35);if ( ibsta & ERR )

    report_errorr(lcr,"Device Write ERRor");6. ibwrt(lcr,"*idn?",35);

    if ( ibsta & ERR )report_errorr(lcr,"Device Write ERRor");

  • 7. ibwait(lcr,RQS|TIMO);8. ibrsp(lcr,&spr);

    printf("spr =%x,ibsta=%x\n\r",spr,ibsta);9. ibrd(lcr,parser_buf,10);

    if ( ibsta & ERR )report_errorr(lcr,"Device Read ERRor");

    else{parser_buf[ibcntl-1]=0;printf("GPIB read(%d) : %s\n\r",ibcntl,parser_buf); }

    10. ibwrt(lcr,"*sre 0",35);if ( ibsta & ERR )

    report_errorr(lcr,"Device Write ERRor");11. ibppc(lcr,0);

    if ( ibsta & ERR )report_errorr(lcr,"PPC ERRor");

    12. ibrpp(lcr,&spr);printf("PPR =%x\n\r",spr);

    Turbo C program ExampleTurbo C program Example

  • Introduce to the IEEE 488.1Introduce to the IEEE 488.1

  • GPIBGPIB的使用的使用GPIB使用目標 用電腦同時整合多台儀器的控制動作或資料收集

    十分適合於量測或測試系統架設

    一般而言高級儀器(>3萬元) 支援GPIB低價儀器 支援RS232

    雖然儀器傳輸速度只有8Mbit/s,但大部分儀器都夠用 仍然通用

    2%高速資料傳輸儀器

    Ethernet TCP/IP 100M~1Gbit/s Or USB 2.0 480bit/s

  • 1.1.基本結構基本結構

    IEEE 488 訊號線

    三線交握程序

    *Controllers:控制訊號接收發送秩序(可當Talker or listener),

    *Talker:發命令或送資料者

    *Listeners:接收資料或接受命令者界面上只可以有一個System controller,同時,只有一個Talker,但可以有多個Listener

    GPIB共有16條訊號線(及八條接地線) 使用獨特的雙面(一公一母)24Pin接頭,接線的特色是,把儀器與電腦通通連起來便可以了

  • IEEE 488IEEE 488 訊號線訊號線16條訊號線是共用的(接在一起):

    8 資料線data line(資料線)

    5 介面管理線interface manage line

    3 交握線handshaking line

  • 123456789101112

    131415161718192021222324

    DIO5DIO6DIO7DIO8RENGNDGNDGNDGNDGNDGNDSIGNAL GROUND

    DIO1DIO2DIO3DIO4EOI

    DAVNRFDNDAC

    IFCSRQATN

    SHIELD

    Fig. GPIB Connector and Pin Assignments

  • 資料線資料線

    DIO1 - DIO8

    攜帶資料和命令訊息於GPIB上

    幾乎所有資料和命令訊息使用7-bit ASCII code set.

  • 管理線管理線

    介面清除(IFC)

    Attention (ATN)

    遠程致能(REN)

    End-or-Identify (EOI)

    服務要求(SRQ)

  • 介面清除介面清除(IFC)(IFC)

    將所有裝置至於靜止狀態.

    Is asserted by system controller.

    100uS

  • Attention (ATN)Attention (ATN)區分裝置資料的型態

    –ATN asserted, 命令訊息.

    –ATN unasserted, 資料訊息 .

    Is asserted by Controller.

  • ATN

    命 令 模 式 資 料 模 式

    a e

    DIOb c d f g

    LSN5

    TLK10

    UNL

    結束位元

    啟始資料

    Fig. IEEE 488 command and data transfer mode

  • 遠程致能遠程致能(REN)(REN)

    致能裝置於可遙控狀態

    Is asserted by system controller.

  • EndEnd--oror--IndentifyIndentify (EOI)(EOI)

    資料結束訊號

    Parallel Poll 執行訊號

    Is asserted by current Talker.

  • 服務要求服務要求(SRQ)(SRQ)通知控制器需要服務

    The SRQ line remains asserted until the device is serial polled.

    Is asserted by Non-Controller.

  • 交握線交握線

    Not Ready For Data (NRFD)

    –用來指示裝置是否準備好接收資料

    Not data Accepted (NDAC)

    –用來指示裝置是否已接收到資料

    Data Valid (DAV)

    –用來指示在資料線上之資料為正確如此裝置才可正確接收資料

  • GPIB 3GPIB 3--wire wire HankshakingHankshaking資料傳送資料傳送*表示在此的高電位表示false

    Not Data Accepted

    Not Ready for DataListener

    Talker

    TalkerController

    1.Talker要送資料了

    2.等大家全準備接收

    3.資料放上去

    4.資料傳好了

    5.等大家全接到了

    Data Vadid

    Data line

  • DIO

    DAV

    NRFD

    NDAC

    控制器或

    發話者

    裝 置或

    收聽者

    a

    b

    c

    d

    e

    f

    g

    a

    b

    三線交握程序三線交握程序

  • Introduce to the IEEE 488.2Introduce to the IEEE 488.2

  • 內容內容

    簡介

    IEEE 488.2 程式表頭IEEE 488.2程式資料IEEE 488.2 回應資料共同命令

    狀態回報結構

  • What is IEEE 488.2What is IEEE 488.2創立於創立於1987.1987.

    Named ANSI/IEEE Std 488.2Named ANSI/IEEE Std 488.2--1987.1987.

    IEEE Standard Codes, Formats, Protocols, and IEEE Standard Codes, Formats, Protocols, and Common Commands.Common Commands.

    與與ANSI/IEEE Std 488.1ANSI/IEEE Std 488.1--19871987共同使用共同使用

  • IEEE 488.2 IEEE 488.2 程式表頭程式表頭命令程式表頭

    –簡單命令程式表頭

    –複合命令程式表頭

    –共同命令程式表頭

    查詢程式表頭

    –簡單查詢程式表頭

    –複合查詢程式表頭

    –共同查詢程式表頭

  • (root)

    INPut ROUTe SENSe TRIGer

    FREQuence POWer VOLTage CURRent

    RANGe REFerence AC

    ATTenuationAPERture

    AUTO

  • IEEE 488.2 IEEE 488.2 程式資料程式資料

    – MAX,MIN,NAN,UP,DOWN

    –100, 100., -1.23,4.56e3, .....

    –#b0101, #Q71, #HFA,

    –15V, 20KHz,

    –`this is a string',“this is also a string"

  • IEEE 488.2 IEEE 488.2 程式資料程式資料

    – #3004– #0

    – scan (@ 1,2,6:9)– RANG (600/20)

  • IEEE 488.2 IEEE 488.2 回應資料回應資料

    – ON,DEFAULT

    – -12, 1234

    – -12.34, 56.78

    – -12.34e-5

    – #HA0B3

  • IEEE 488.2 IEEE 488.2 回應資料回應資料

    – #Q173

    – #B1010

    – “this is a string”

    8.7.11.2 NL ^END

  • 什麼是什麼是SCPI ?SCPI ?. Standard Commands for Programmable Instruments

    HP-SL ( HP System Language )

    TMSL ( Test and Measurement System Language )

    SCPI ( Hp TMSL + Tek ADID(Analog Data Interchange Format) )

  • SCPISCPI水平相容性水平相容性

    Controller

    D.S.O Counter D.M.M

    TRIG* *

  • SCPISCPI垂直相容性垂直相容性

    D.M.M(1990 version)

    D.M.M(1994 version)

    Controller

    MEAS* *

  • SCPI SCPI 和和 GPIBGPIB間之關係間之關係

    SCPI

    IEEE-488.2

    IEEE-488.1

    1987Defined Codes, Formats, Protocols,and Common Commands

    1975Defined BusDefined Bus Handshake

    1989DefinedStandardCommands

  • 49

    Format of SCPI CommandFormat of SCPI Command

    Hierarchical StructureCommand Separator– SENSe:RANGe:UPPer 10.0

    Abbreviated Commands– RANG=RANGE=rang=ranG= .....

    Numeric Suffix– OUTPut:TTLTrg:STATe ON

  • 50

    Format of SCPI CommandFormat of SCPI Command

    Implied Command– ex. INITiate

    : CONTinuous ON|OFF[: IMMediate]

    – INIT:IMM or INIT

  • 51

    INPut ROUTe SENSe TRIGer

    (root)

    FREQuence POWer VOLTage

    RANGe REFerence AC

    ATTenuationAPERture

    CURRent

    AUTO

  • 52

    Format of SCPI ParameterFormat of SCPI ParameterParameters defined by SCPI– distinguished by ‘< >‘

    Optional Parameter– FORMAT:DATA [,]

    OR Parameter – CALibration:SOURce INTernal|EXTernal

    Repeated Parameter– :VOLT {,}

  • 53

    Type of SCPI parametersType of SCPI parametersNumeric – 123,-123,1.23e-2,- - - -– MAX,MIN,INFinity,DEFault– #H7B,#Q173,#B1111011

    Boolean ON,OFF,1,0Character-Enumerated CURRent|VOLTageCharacter Data – < character data> ex. BALanced ,UNBalanced

    Channel List (@1,3,5:8)Unit Suffixes KHZ,WArbitrary Block Data

  • 54

    Linking CommandsLinking Commands

    • Linking IEEE-488.2 Common Commands with SCPI Commands

    ex. *RST;OUTP:TTLT3 ON•Linking Multiple complete SCPI Commands

    ex. OUTP:TTLT2 ON;:TRIG:SOUR EXT•Linking a complete SCPI Commands with other keywords

    from the same branch and levelex. FUNC:RES 10000,(@100:107) and FUNC:VOLT

    (@116,123)as FUNC:RES 10000,(@100:107) ;VOLT (@116,123)

  • 55

    INPut SubsystemINPut Subsystem

    INPut:COUPling AC|DC|GROundINPut:COUPling?INPut:FILTer[:LPASs][:STATe] INPut:FILTer[:LPASs][:STATe]?

  • 56

    SENSe SubsystemSENSe Subsystem[SENSe]:VOLTage[:DC]:RANGe[:UPPer]

    [SENSe]:SWEep:OFFSet:POINts [SENSe:]ACQUire:TYPE NORMal|RANDom[SENSe:]AVERage:TYPE ENVelop|SCALar[SENSe:]FUNCtion[:ON] {,}

  • How to find GPIB device How to find GPIB device command ?command ?

    See HP 34401A is a 6 1/2-digit, high-performance digital multimeter User manual .

  • How to find GPIB device How to find GPIB device command ?command ?

    See HP 33120A is a Function/Arbitrary Waveform Generator User manual .

  • DA&C & GPIB Example DA&C & GPIB Example for LabVIEW for LabVIEW LanguangeLanguange

  • DA&C & GPIB Example DA&C & GPIB Example for LabVIEW for LabVIEW LanguangeLanguange

  • DA&C & GPIB Example DA&C & GPIB Example for LabVIEW for LabVIEW LanguangeLanguange

  • GPIB Example for VB ProgramGPIB Example for VB Program

  • GPIB Example for LabWindows/CVIGPIB Example for LabWindows/CVI

  • 程式開發與測試程式開發與測試

    運用兩台IPC (內含PCI-1670 GPIB Crad ), 分別設定為Master , Slave mode .Master IPC 指令控制台,Slave IPC 內含PCI卡片PCI-1710HG(AI),PCI-1760(Relay),PCI-1721(AO),PCI-1240(Contiune Drive)運用程式技巧將Slave IPC 內部所有卡片依據其特定功能建立專屬之GPIB 控制指令.由Master IPC 下GPIB指令給Salve IPC , 讓各卡片作不同功能量測.

  • Advantech IPC Instrument Advantech IPC Instrument Application Application

    GPIB 儀器控制之概念及軟硬體介紹OutlineGPIB History General Purpose Interface BusGPIB特色Introduction to Advantech PCI-1670 GPIB CardSpecificationPCI-1670 Linking many GPIB 儀器...Advantech PCI-1670 GPIB Interface Card & GPIB cableExplain Installing filesIntroduction to GPIBToolGPIB Bus Auto scan UtilityGPIBTool Utility Command FunctionOperating GPIBTool.exeBus Timeout periodCommandsCommandsExamples of various languagesTurbo C program ExampleTurbo C program ExampleIntroduce to the IEEE 488.1GPIB的使用1.基本結構IEEE 488 訊號線資料線管理線介面清除(IFC)Attention (ATN)遠程致能(REN)End-or-Indentify (EOI)服務要求(SRQ)交握線Introduce to the IEEE 488.2內容What is IEEE 488.2IEEE 488.2 程式表頭IEEE 488.2 程式資料IEEE 488.2 程式資料IEEE 488.2 回應資料IEEE 488.2 回應資料Format of SCPI CommandFormat of SCPI CommandFormat of SCPI ParameterType of SCPI parametersINPut SubsystemSENSe SubsystemHow to find GPIB device command ?How to find GPIB device command ?DA&C & GPIB Example for LabVIEW LanguangeDA&C & GPIB Example for LabVIEW LanguangeDA&C & GPIB Example for LabVIEW LanguangeGPIB Example for VB ProgramGPIB Example for LabWindows/CVI程式開發與測試Advantech IPC Instrument Application