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

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

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

 

一、首先要對IVI 有所瞭解,IVI 相關信息可從下面網址得到:http://www.ivifoundation.org/default.aspxsession

  • 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.app

  • IVI 的結構以下圖所示:

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

 

Driver APIide

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.oop

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.

 

二、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 驅動,獲得結果以下圖示:

 

 三、安裝驅動程序,按照驅動幫助文件逐個配置開發環境,添加指定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組件,以及簡單的調用例子,如圖所示:

 

四、編寫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>

 

 

試了一下終於通了。因此記錄一下,做個總結。

相關文章
相關標籤/搜索