Help Icon
Search Results for

    Show / Hide Table of Contents

    Add Reference in LabWindows CVI

    How to perform measurements in LabWindows CVI:

    1. Create a new Project in LabWindows/CVI 2013

    2. Navigate to "Tools -> Create ActiveX Controller"

    3. Click "Next". In the following windows select the AutomationInterface reference.

    4. Again click Next. Select an "Instrument Prefix" in this case "OmicronAI" and Select a "Target .fp File" (Click Browse to create new file, in this example "AutomationInterface.fp").

    5. Click "Next" until the window closes. Now LabWindows/CVI generates a "AutomationInterface.fp", "AutomationInterface.c" and "AutomationInterface.h" file.

    6. Right click the project to add a new File.

    7. Select "Source File", a "File name" and a "File folder".

    8. Click ok. Now you are able to implement your measurement in the generated source file.

    Implement a measurement with the following code:

    // Title:       AutomationInterfaceExample.c
    
    // Include files
    #include "AutomationInterface.h"
    #include <ansi_c.h>
    
    static CAObjHandle automationInterface = 0;
    static OmicronAIObj_BodeDevice bodeHandle = 0;
    static OmicronAIObj_Transmission transmissionHandle = 0; 
    static OmicronAIObj_S21Measurement s21Handle = 0;
    static enum OmicronAIEnum_ExecutionState state = 0;
    static OmicronAIObj_GainResults gainResultHandle = 0;
    static ERRORINFO ErrorInfo;
    
    int main(int argc, char *argv[])
    {
    	HRESULT error = 0;
    	SAFEARRAY* magnitudes;
    	double *arrMagnitudes;
    	int i = 0;   
    	int x = 0;
    	int count = 201;	
    	
    	
    	error = OmicronAI_NewBodeAutomationInterface(NULL, 1, LOCALE_NEUTRAL, 0, &automationInterface);
    
    	error = OmicronAI_BodeAutomationInterfaceConnect(automationInterface, &ErrorInfo, &bodeHandle);
    
    	error = OmicronAI_BodeDeviceGetTransmission(bodeHandle, &ErrorInfo, &transmissionHandle);  
    
    	error = OmicronAI_TransmissionCreateS21Measurement(transmissionHandle, &ErrorInfo, &s21Handle);
    
    	error = OmicronAI_S21MeasurementConfigureSweep(s21Handle, &ErrorInfo, 100, 10000, count, OmicronAIConst_SweepMode_Linear);
    	
    	error = OmicronAI_S21MeasurementSetReceiverBandwidth(s21Handle, &ErrorInfo, OmicronAIConst_ReceiverBandwidth_kHz1); 
    	
    	error = OmicronAI_S21MeasurementExecuteMeasurement(s21Handle, &ErrorInfo, &state); 
    
    	error = OmicronAI_S21MeasurementGetResults(s21Handle, &ErrorInfo, &gainResultHandle);
      
    	error = OmicronAI_GainResultsMagnitude(gainResultHandle, &ErrorInfo, OmicronAIConst_MagnitudeUnit_dB, &magnitudes);
    
    	arrMagnitudes = (double*)magnitudes->pvData;  
    	for(i; i <  count; i++)
    	{
    		printf("Magnitude Value: %f\n", arrMagnitudes[i]);
    	}
    
    	error = OmicronAI_BodeDeviceShutDown(bodeHandle, &ErrorInfo); 
    
    	scanf("Press any key to close: %d",&x);
    }
    
    Note

    OmicronAI_ is the selected Instrument Prefix.

    Note

    Principially it is also possible to create a .NET Controller instead of the previously explained ActiveX Controller. Following that approach one needs to consider:

    1. LabWindows/CVI 2013 is not supported. We tested the basic functionality with LabWindows/CVI 2017.
    2. The Bode Automation Interface assembly "OmicronLab.VectorNetworkAnalysis.AutomationInterface.dll" needs to be specified by path because it is not registered in the Global Assembly Cache.
    3. The function panels will not be generated for all items (because of too long CVI identifiers).
    4. Be sure that all Source-dlls from the Bode Automation Interface installation folder are copied to your CVI project folder.
    In this article
    Back to top Generated by DocFX