IVI 技術在自動測試系統中的應用研究


最近在做一個項目,關於TR組件自動測試系統,其中對測試系統儀器的設置,想底層用IVI 來實現,新的儀器大多支持lan口,廠家都自帶IVI 驅動程序,只要按指定步驟就能實現多個廠家的IVI 儀器設置,實現同類儀器的可互換性。

本項目中用到示波器、頻譜儀、寬帶信號源、微波信號源等儀器。下面講一下開發IVI 步驟:

 

1、首先要對IVI 有所了解,IVI 相關信息可從下面網址獲得:http://www.ivifoundation.org/default.aspx

  • overview 中大家可以學習IVI 的定義,了解IVI 的好處。

The IVI standards define an open driver architecture, a set of instrument classes, and shared software components. Together these provide critical elements needed for instrument interchangeability.

  • IVI 的結構如下圖所示:

IVI 驅動類型有IVI-C 、IVI-COM的,驅動程序通過I/O庫和硬件通信,兩種支持的上層開發語言不太一樣,本人用C#開發因此項目中所有IVI 驅動都選擇IVI-COM類型的。

 

Driver API

To support all popular programming languages and development environments, IVI drivers provide either a IVI-C or an IVI-COM API. Driver developers may provide both interfaces, as well as wrapper interfaces optimized for specific development environments.

Instrument I/O

All IVI drivers communicate to the instrumentation hardware through an I/O Library. The VISA library is used for the GPIB and VXI buses, while other buses can either utilize VISA or another library.

Shared Components

IVI Foundation members have cooperated to provide common software components, called IVI shared components, that ensure multi-vendor system compatibility. These components provide services to drivers and driver clients that need to be common to all drivers. For instance, the IVI Configuration Server enables administration of system-wide configuration.

 

2、IVI 驅動程序下載

上面是目前IVI 支持的幾種IVI儀器類。

IVI shared components 在該網站是可以下載的,對於大家平時用的儀器應該是安捷倫的比較多,安捷倫的網站上軟件下載可下載

IO Libraries Suite 16.3 Update 2

http://www.home.agilent.com/agilent/software.jspx?cc=CN&lc=chi&nid=-33330.977662&id=2175637 

該IO庫中下載安裝后會自動安裝IVI Shared Component 組件。

IVI Shared Component主要支持多廠家的儀器的一致性。安裝完I/O庫后,就需要安裝各個儀器的IVI 驅動程序了。大家可能會問:我怎么知道我用的儀器是否支持IVI 呢?有IVI 驅動嗎? 這個大家可以從http://www.ivifoundation.org/default.aspx 網站的"Driver Registry" 頁面去查看,但凡支持IVI的廠商儀器的IVI 驅動都會列出來,只要從這個列表里查找是否有你要的IVI-C 或IVI-COM 驅動,再點擊鏈接進入相關廠商官網去下載對應驅動程序。

    例如查找泰克的AWG7122C 的IVI 驅動,得到結果如下圖示:

 

 3、安裝驅動程序,按照驅動幫助文件逐個配置開發環境,添加指定COM 引用,進入開發調用,此項目用C#開發,都以C# 為例。

記住安裝軟件的順序:

先安裝IO Libraries Suite 庫,再安裝單個儀器的IVI 驅動,已經下載了泰克AWG7122C 的IVI 驅動,安裝后大家可以打開C:\Documents and Settings\All Users\Application Data\IVI Foundation\IVI\IviConfigurationStore.xml  ,IviConfigurationStore文件中會看到相應驅動信息

 

並且相應IVI 安裝路徑下也會驅動安裝文件和幫助信息:C:\Program Files\IVI Foundation\IVI\Drivers\TekFgen

該目錄下有幫助文件打開之后會有詳細介紹驅動程序開發步驟,需要引入的COM組件,以及簡單的調用例子,如圖所示:

 

4、編寫IVI IviConfigurationStore.xml 文件

參考幫助文檔基本上就能開始編寫調用IVI 驅動接口的程序了,在寫程序中你會發現,在介紹可互換編程時,例子里面提到 "MyLogicalName",這個很重要,需要我們提前做好的一步,就是還需要編寫上面提到的:IviConfigurationStore.xml 文件。

// If true, this will query the instrument model and fail initialization
// if the model is not supported by the driver
bool idQuery = false;

// If true, the instrument is reset at initialization
bool reset = false;

// Setup IVI-defined initialization options
string standardInitOptions =
  "Cache=true, InterchangeCheck=false, QueryInstrStatus=true, RangeCheck=true, RecordCoercions=false, Simulate=false";

// Setup driver-specific initialization options
string driverSetupOptions =
  "DriverSetup= Model=AWG7052, Trace=false";

fgen.Initialize("MyLogicalName", idQuery, reset, standardInitOptions + "," + driverSetupOptions)

 

在調用每個驅動時都要傳入一個logicName ,它是寫在配置文件IviConfigurationStore中,調用過程會從這個文件讀取相關設備物理地址,使用的驅動信息等。

下面是簡單的調用泰克AWG7122C 的C# 程序和配置文件例子:

 

C# 程序調用:(初始化實例,並且調用產生一個正弦波形)

IIviSessionFactory factory = new IviSessionFactoryClass();
            ;
            IIviFgen siggen = (IIviFgen)factory.CreateDriver("AWG7122C");//logicName ----AWG7122C

            try
            {
                siggen.Initialize("AWG7122C", false, false, "");
                // Get a string property


                string description = siggen.Identity.Description;

                siggen.InitiateGeneration();
                siggen.Arbitrary.Waveform.Configure("Ch1,", 0x00000001, 0.1, 0.2);//配置通道1 輸出波形, 0x00000001----波形數字
                siggen.Arbitrary.SampleRate = 24;
                siggen.Trigger.InternalRate = 0.3;
                siggen.Output.set_OperationMode("Ch1", IviFgenOperationModeEnum.IviFgenOperationModeContinuous);
                siggen.Output.set_Enabled("Ch1", true);
               
                siggen.Trigger.SendSoftwareTrigger();
                // Close the session
                siggen.Close();
                return true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return false;
            }

 

 

對應配置文件設置:HardwareAssets、 DriverSessions、LogicalNames這幾部分是需要自己手動添加的項,IOResourceDescriptor 是指通過 Aglient Connection Expert 所發現的VISA String。至於相關信息的細節解釋大家可以參考http://www.ivifoundation.org/default.aspx 上的Specifications 頁面中的

IVI Specifications 文檔。

 <HardwareAssets>
  <IviHardwareAsset id="p179">
   <Name>AWG7122C</Name>
   <Description>Resource Name for Arbitrary Waveform Generators</Description>
   <DataComponents/>
   <IOResourceDescriptor>TCPIP0::AWG-3289382193::inst0::INSTR</IOResourceDescriptor>
  </IviHardwareAsset>
   </HardwareAssets>
 <DriverSessions>
  <IviDriverSession id="p183">
   <Name>AWG7122C</Name>
   <Description>Logic Name for Arbitrary Waveform Generators</Description>
   <DataComponents/>
   <IviHardwareAsset idref="p179"/>
   <IviSoftwareModuleRef idref="p176"/>
   <VirtualNames/>
   <SoftwareModuleName>AWG7122C</SoftwareModuleName>
   <Cache>0</Cache>
   <DriverSetup/>
   <InterchangeCheck>0</InterchangeCheck>
   <QueryInstrStatus>0</QueryInstrStatus>
   <RangeCheck>0</RangeCheck>
   <RecordCoercions>0</RecordCoercions>
   <Simulate>0</Simulate>
  </IviDriverSession>

 </DriverSessions>
  <LogicalNames>
  <IviLogicalName id="p187">
   <Name>AWG7122C</Name>
   <Description>Logic Name for Arbitrary Waveform Generators</Description>
   <IviDriverSession idref="p183"/>
  </IviLogicalName>

</LogicalNames>

 

 

試了一下終於通了。所以記錄一下,作個總結。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM