Add AI Reference
Add the AI Reference to your Project to connect with SPECTANO 100
To be able to connect to your SPECTANO 100 device you first have to add the Automation Interface reference to your project.
To see other examples visit this page.
The SPECTANO 100 Automation Interface uses the "OmicronLab.MaterialAnalyzer.AutomationInterface.dll" which can be found in the installation directory.
Note
You need to have the correct USB driver installed on your system. The simplest way to install the USB driver is to run our "Spectano Analyzer Suite" installer available for download at OmicronLab
Instruction for adding references to various programming languages:
- Add Reference in C#
- Add Reference in MatLab
- Add Reference in Python
- Add Reference in Excel
- Add Reference in LabWindows CVI
Add Reference in C#
To access the OmicronLab.MaterialAnalyzer.AutomationInterface.dll in C# you need to add the reference to your project.
To install OmicronLab.MaterialAnalyzer.AutomationInterface NuGet package in Visual Studio 2010 or higher,
run the following command in the Package Manager Console
PM> Install-Package OmicronLab.MaterialAnalyzer.AutomationInterface
After successfully adding the reference execute the following code to start a FDS Measurement
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OmicronLab.MaterialAnalyzer.AutomationInterface;
using OmicronLab.MaterialAnalyzer.AutomationInterface.Enumerations;
using OmicronLab.MaterialAnalyzer.AutomationInterface.Interfaces;
namespace FdsMeasurement
{
class Program
{
static void Main(string[] args)
{
// Connect to SPECTANO device and create measurement
SpectanoDevice device = new Spectano100();
// To perform measurements the device needs to be online
var isDeviceOnline = device.IsOnlineDelayed(5000);
var measurement = device.Sweep.CreateFrequencySweepMeasurement();
// Configuring frequency sweep settings
measurement.FrequencySweepSettings.ConfigureFdsFrequencyRange(1000, 100, 3);
// Configuring test cell type
measurement.TestCell.ConfigureOtherTestCell();
// Configuring test cell sample
measurement.TestCellSample.VacuumCapacitance = 0.2;
// Configuring measurement settings
measurement.MeasurementSettings.FdsOutputVoltage = 1;
// Execute measurement
measurement.ExecuteMeasurement();
// Check results
for (int i = 0; i < measurement.Results.Count(ResultType.Fds); i++)
{
Console.Write($"Frequency: {measurement.Results.FrequencyPoints[i]}, Tangent Delta: {measurement.Results.TangentDelta[i]}");
}
// Shutting down SPECTANO device
device.ShutDown(false);
// Console.WriteLine("Press any Key!");
// Console.ReadLine();
}
}
}
Add Reference in MatLab
To add the SPECTANO 100 reference in your MatLab project you have to perform the following steps:
% Connect to SPECTANO device and create measurement
device = actxserver('OmicronLab.MaterialAnalyzer.AutomationInterface');
% To perform measurements the device needs to be online
isDeviceOnline = device.IsOnlineDelayed(5000);
% Configuring frequency sweep settings
measurement = device.Sweep.CreateFrequencySweepMeasurement();
measurement.FrequencySweepSettings.ConfigureFdsFrequencyRange(1000, 100, 3);
% Configuring test cell of type others
measurement.TestCell.ConfigureOtherTestCell()
% Configuring test cell sample
measurement.TestCellSample.VacuumCapacitance = 0.2;
% Configuring measurement settings
measurement.MeasurementSettings.FdsOutputVoltage = 1;
% Execute measurement
state = measurement.ExecuteMeasurement();
% Check results
tanDeltaResult = measurement.Results.TangentDelta;
frequencies = measurement.Results.FrequencyPoints;
for i = 1:measurement.Results.Count('ResultType_Fds')
sprintf('Frequency: %d, Tangent Delta: %d ', frequencies(i), tanDeltaResult(i))
end
% Shutting down SPECTANO device
device.ShutDown(false);
release(device);
Add Reference in Python
To add the SPECTANO 100 reference in your Python project you have to perform the following steps:
import win32com.client
import pythoncom
#Constants
#In Python it is not possible to set Enums as their Name. We have to set them as numbers.
ResultType_Fds = 0;
def InitAIReference():
# Connect to SPECTANO device and create measurement
device = win32com.client.Dispatch("OmicronLab.MaterialAnalyzer.AutomationInterface");
# To perform measurements the device needs to be online
isDeviceOnline = device.IsOnlineDelayed(5000);
# Configuring frequency sweep settings
measurement = device.Sweep.CreateFrequencySweepMeasurement();
measurement.FrequencySweepSettings.ConfigureFdsFrequencyRange(1000, 100, 3);
# Configuring test cell of type others
measurement.TestCell.ConfigureOtherTestCell();
# Configuring test cell sample
measurement.TestCellSample.VacuumCapacitance = 0.2;
# Configuring measurement settings
measurement.MeasurementSettings.FdsOutputVoltage = 1;
# Execute measurement
measurement.ExecuteMeasurement();
# Check results
for i in range(0, measurement.Results.Count(ResultType_Fds)):
print ("Frequency: %f, Tangent Delta: %f " % (measurement.Results.FrequencyPoints[i], measurement.Results.TangentDelta[i]))
# Shutting down SPECTANO device
device.ShutDown(False);
if __name__ == "__main__":
InitAIReference()
Add Reference in Excel
To add the SPECTANO 100 reference in your Excel VBA project be sure that you
- Enabled Macros in Excel
Then navigate through the following pages:
- Open reference dialogue
- Select the AI Reference
- Click OK.
After successfully adding the reference execute following code to gain access to the device.
Sub RunSpectano()
Dim i As Integer
Dim device As SpectanoDevice
Dim measurement As FrequencySweepMeasurement
Dim state As ExecutionState
Dim frequencies() As Double
Dim tanDelta() As Double
Dim isDeviceOnline As Boolean
' Connect to SPECTANO device and create measurement
Set device = New Spectano100
' To perform measurements the device needs to be online
isDeviceOnline = device.IsOnlineDelayed(5000)
' Configuring frequency sweep settings
Set measurement = device.Sweep.CreateFrequencySweepMeasurement
measurement.FrequencySweepSettings.ConfigureFdsFrequencyRange 1000, 100, 3
' Configuring test cell
measurement.TestCell.ConfigureOtherTestCell
' Configuring test cell sample
measurement.TestCellSample.VacuumCapacitance = 0.2
' Configuring measurement settings
measurement.MeasurementSettings.FdsOutputVoltage = 1
' Execute measurement
state = measurement.ExecuteMeasurement
' Check results
frequencies = measurement.Results.FrequencyPoints
tanDelta = measurement.Results.TangentDelta
For i = 0 To measurement.Results.Count(ResultType_Fds) - 1
Cells(i + 1, 1).Value = "Frequency"
Cells(i + 1, 2).Value = frequencies(i)
Cells(i + 1, 3).Value = "Tangent Delta"
Cells(i + 1, 4).Value = tanDelta(i)
Next i
' Shutting down SPECTANO device
device.ShutDown False
End Sub
Add Reference in LabWindows CVI
How to perform measurements in LabWindows CVI:
- Create a new Project in LabWindows/CVI 2013
- Navigate to "Tools -> Create ActiveX Controller"
- Click "Next". In the following windows select the AutomationInterface reference.
- Again click Next. Select an Instrument Prefix in this case "OmicronLabMaterialAnalyzerAI" and Select a "Target .fp File" (Click Browse to create new file, in this example "AutomationInterface.fp").
- Click "Next" until the window closes. Now LabWindows/CVI generates a "AutomationInterface.fp", "AutomationInterface.c" and "AutomationInterface.h" file.
- Right click the project to add a new File.
- Select "Source File", a "File name" and a "File folder". <
- 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 OmicronLabMaterialAnalyzerAIObj_FrequencySweepSettings freqSettings = 0;
static OmicronLabMaterialAnalyzerAIObj_Sweep sweepHandle = 0;
static OmicronLabMaterialAnalyzerAIObj_Results resultsHandle = 0;
static OmicronLabMaterialAnalyzerAIObj_TestCell testCellHandle = 0;
static OmicronLabMaterialAnalyzerAIObj_TestCellSample testCellSampleHandle = 0;
static OmicronLabMaterialAnalyzerAIObj_MeasurementSettings measurementSettingsHandle = 0;
static OmicronLabMaterialAnalyzerAIObj_FrequencySweepMeasurement measurementHandle = 0;
static OmicronLabMaterialAnalyzerAIObj_FdsFrequencySweepSettings frequencySweepSettingsHandle = 0;
static OmicronLabMaterialAnalyzerAIObj_OtherTestCell othersTestCellHandle = 0;
static enum OmicronLabMaterialAnalyzerAIEnum_ExecutionState state;
static ERRORINFO errorInfo;
static VBOOL keepDeviceRunningOnShutdown = VFALSE;
static VBOOL isDeviceOnline = VFALSE;
int main(int argc, char *argv[])
{
int x;
int i = 0;
HRESULT error = 0;
long count;
SAFEARRAY* tangentDelta;
SAFEARRAY* frequencies;
// Connect to SPECTANO device and create measurement
error = OmicronLabMaterialAnalyzerAI_NewSpectanoDevice (NULL, 1, LOCALE_NEUTRAL, 0, &automationInterface);
// To perform measurements the device needs to be online
error = OmicronLabMaterialAnalyzerAI_SpectanoDeviceIsOnlineDelayed (automationInterface, &errorInfo, 5000, &isDeviceOnline);
// Configuring frequency sweep settings
error = OmicronLabMaterialAnalyzerAI_SpectanoDeviceGetSweep (automationInterface, &errorInfo, &sweepHandle);
error = OmicronLabMaterialAnalyzerAI_SweepCreateFrequencySweepMeasurement (sweepHandle,&errorInfo,&measurementHandle);
error = OmicronLabMaterialAnalyzerAI_FrequencySweepMeasurementGetFrequencySweepSettings (measurementHandle, &errorInfo, &freqSettings );
error = OmicronLabMaterialAnalyzerAI_FrequencySweepSettingsConfigureFdsFrequencyRange
(freqSettings, &errorInfo, 1000.0, 100.0, 3, &frequencySweepSettingsHandle);
// Configuring test cell
error = OmicronLabMaterialAnalyzerAI_FrequencySweepMeasurementGetTestCell (measurementHandle, &errorInfo, &testCellHandle);
error = OmicronLabMaterialAnalyzerAI_TestCellConfigureOtherTestCell
(testCellHandle, &errorInfo, &othersTestCellHandle);
// Configuring test cell sample
error = OmicronLabMaterialAnalyzerAI_FrequencySweepMeasurementGetTestCellSample (measurementHandle, &errorInfo, &testCellSampleHandle);
error = OmicronLabMaterialAnalyzerAI_TestCellSampleSetVacuumCapacitance (testCellSampleHandle, &errorInfo, 0.2);
// Configuring measurement settings
error = OmicronLabMaterialAnalyzerAI_FrequencySweepMeasurementGetMeasurementSettings (measurementHandle, &errorInfo, &measurementSettingsHandle);
error = OmicronLabMaterialAnalyzerAI_MeasurementSettingsSetFdsOutputVoltage (measurementSettingsHandle, &errorInfo, 1);
// Execute measurement
error = OmicronLabMaterialAnalyzerAI_FrequencySweepMeasurementExecuteMeasurement (measurementHandle, &errorInfo, &state);
// Check results
error = OmicronLabMaterialAnalyzerAI_FrequencySweepMeasurementGetResults (measurementHandle, &errorInfo, &resultsHandle);
error = OmicronLabMaterialAnalyzerAI_ResultsCount (resultsHandle, &errorInfo, OmicronLabMaterialAnalyzerAIConst_ResultType_Fds, &count);
error = OmicronLabMaterialAnalyzerAI_ResultsGetTangentDelta (resultsHandle, &errorInfo, &tangentDelta);
error = OmicronLabMaterialAnalyzerAI_ResultsGetFrequencyPoints (resultsHandle, &errorInfo, &frequencies);
double *arrTanDelta = (double*)tangentDelta->pvData;
double *arrFrequencies = (double*)frequencies->pvData;
for(i; i < count; i++)
{
printf("Tangent delta Value @ %f: %f\n", arrFrequencies[i], arrTanDelta[i] );
}
// Shutting down SPECTANO device
error = OmicronLabMaterialAnalyzerAI_SpectanoDeviceShutDown(automationInterface, &errorInfo,keepDeviceRunningOnShutdown);
scanf("Press any key to close: %d",&x);
}
Note
OmicronLabMaterialAnalyzerAI_ 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:
- The Spectano Automation Interface assembly "OmicronLab.MaterialAnalyzer.AutomationInterface.dll" needs to be specified by path because it is not registered in the Global Assembly Cache.
- The function panels will not be generated for all items (because of too long CVI identifiers).
- Be sure that all Source-dlls from the Spectano Automation Interface installation folder are copied to your CVI project folder.