Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions C#/KCube/KPC101/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
85 changes: 85 additions & 0 deletions C#/KCube/KPC101/KPC101_Example.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D5ED37A5-9897-42C6-8878-DFB422D01E86}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>KPC101_Example</RootNamespace>
<AssemblyName>KPC101_Example</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Thorlabs.MotionControl.DeviceManagerCLI, Version=1.14.59.26708, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\x64\Debug\Thorlabs.MotionControl.DeviceManagerCLI.dll</HintPath>
</Reference>
<Reference Include="Thorlabs.MotionControl.GenericPiezoCLI, Version=1.14.59.26708, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\x64\Debug\Thorlabs.MotionControl.GenericPiezoCLI.dll</HintPath>
</Reference>
<Reference Include="Thorlabs.MotionControl.KCube.PiezoStrainGaugeCLI, Version=1.14.59.26708, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\x64\Debug\Thorlabs.MotionControl.KCube.PiezoStrainGaugeCLI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
156 changes: 156 additions & 0 deletions C#/KCube/KPC101/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// Title: KDC101_Example
// Created Date: 03/05/2026
// Last Modified Date: 03/05/2023
// .NET Framework version: 4.8
// Thorlabs DLL version: 1.14.59
// Example Description:
// This example demonstrates how to set-up the communication for the Thorlabs
// KPC101 controllers.
using System;
using System.Collections.Generic;
using System.Threading;
using Thorlabs.MotionControl.DeviceManagerCLI;
using Thorlabs.MotionControl.GenericPiezoCLI.Piezo;
using Thorlabs.MotionControl.KCube.PiezoStrainGaugeCLI;



namespace KCP_CStest
{
internal class Program
{

static void Main()
{
//SimulationManager.Instance.InitializeSimulations(); Uncomment for simulated device.

// Get the test KPC101 serial number (e.g. 113000123)
string serialNo = "113000001";

try
{
// Tell the device manager to get the list of all devices connected to the computer
DeviceManagerCLI.BuildDeviceList();
}
catch (Exception ex)
{
// An error occurred - see ex for details
Console.WriteLine("Exception raised by BuildDeviceList {0}", ex);
Console.ReadKey();
return;
}

// Get available KCube Piezo Strain Gauge Motors and check our serial number is correct - by using the device prefix
// (i.e. for serial number 113000123, the device prefix is 113)
List<string> serialNumbers = DeviceManagerCLI.GetDeviceList(KCubePiezoStrainGauge.DevicePrefix);
if (!serialNumbers.Contains(serialNo))
{
// The requested serial number is not a KPC101 or is not connected
Console.WriteLine("{0} is not a valid serial number", serialNo);
Console.ReadKey();
return;
}

// Create the KCZ device
KCubePiezoStrainGauge device = KCubePiezoStrainGauge.CreateKCubePiezoStrainGauge(serialNo);
if (device == null)
{
// An error occured
Console.WriteLine("{0} is not a KCubePiezoStrainGauge", serialNo);
Console.ReadKey();
return;
}

// Open a connection to the device.
try
{
Console.WriteLine("Opening device {0}", serialNo);
device.Connect(serialNo);
}
catch (Exception)
{
// Connection failed
Console.WriteLine("Failed to open device {0}", serialNo);
Console.ReadKey();
return;
}

// Wait for the device settings to initialize - timeout 5000ms
if (!device.IsSettingsInitialized())
{
try
{
device.WaitForSettingsInitialized(5000);
}
catch (Exception)
{
Console.WriteLine("Settings failed to initialize");
}
}

// Start the device polling
// The polling loop requests regular status requests to the motor to ensure the program keeps track of the device.
device.StartPolling(250);
// Needs a delay so that the current enabled state can be obtained
Thread.Sleep(500);
// Enable the channel otherwise any move is ignored
device.EnableDevice();
// Needs a delay to give time for the device to be enabled
Thread.Sleep(500);

// Get Piezo configuration
PiezoConfiguration piezoConfiguration = device.GetPiezoConfiguration(serialNo);
// Not used directly in example but illustrates how to obtain device settings
PiezoDeviceSettings currentDeviceSettings = device.PiezoDeviceSettings as PiezoDeviceSettings;

// Display info about device
DeviceInfo deviceInfo = device.GetDeviceInfo();
Console.WriteLine("Device {0} = {1}", deviceInfo.SerialNumber, deviceInfo.Name);

device.SetPositionControlMode(PiezoControlModeTypes.OpenLoop);

// Max voltage - 75
Decimal maxVolts = device.GetMaxOutputVoltage();

Decimal voltage = 1;
// If a voltage is requested
if ((voltage != 0) && (voltage <= maxVolts))
{
// Update voltage if required using real world methods
device.SetOutputVoltage(voltage);

Thread.Sleep(1000);

Decimal newVolts = device.GetOutputVoltage();
Console.WriteLine("Voltage set to {0}", newVolts);
}

Console.WriteLine("Setting Zero");
device.SetZero();
Thread.Sleep(1000);
Console.WriteLine("Voltage:{0}", device.GetOutputVoltage());
Console.WriteLine("Position:{0}", device.GetPosition());

device.SetPositionControlMode(PiezoControlModeTypes.CloseLoop);


//Set position
Decimal setposition = 1.5m;
device.SetPosition(setposition);

Thread.Sleep(1000);

Decimal position = device.GetPosition();
Console.WriteLine("New Position {0}", position);


device.StopPolling();

device.Disconnect(true);
Console.WriteLine("Device disconnected");
//SimulationManager.Instance.UninitializeSimulations(); uncomment for simulated device.

Console.ReadKey();
}
}
}
33 changes: 33 additions & 0 deletions C#/KCube/KPC101/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("KPC101_Example")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("DCHSCCM01")]
[assembly: AssemblyProduct("KPC101_Example")]
[assembly: AssemblyCopyright("Copyright © DCHSCCM01 2026")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]

// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("d5ed37a5-9897-42c6-8878-dfb422d01e86")]

// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
6 changes: 6 additions & 0 deletions C#/KCube/KPC101/bin/x64/Debug/KPC101_Example.exe.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
C:\Users\gboedecker\source\repos\KPC101\KPC101_Example\KPC101_Example\obj\x64\Debug\KPC101_Example.csproj.AssemblyReference.cache
C:\Users\gboedecker\source\repos\KPC101\KPC101_Example\KPC101_Example\obj\x64\Debug\KPC101_Example.csproj.CoreCompileInputs.cache
C:\Users\gboedecker\source\repos\KPC101\KPC101_Example\KPC101_Example\bin\x64\Debug\KPC101_Example.exe.config
C:\Users\gboedecker\source\repos\KPC101\KPC101_Example\KPC101_Example\bin\x64\Debug\KPC101_Example.exe
C:\Users\gboedecker\source\repos\KPC101\KPC101_Example\KPC101_Example\bin\x64\Debug\KPC101_Example.pdb
C:\Users\gboedecker\source\repos\KPC101\KPC101_Example\KPC101_Example\bin\x64\Debug\Thorlabs.MotionControl.PrivateInternal.dll
C:\Users\gboedecker\source\repos\KPC101\KPC101_Example\KPC101_Example\bin\x64\Debug\Thorlabs.MotionControl.Tools.Common.dll
C:\Users\gboedecker\source\repos\KPC101\KPC101_Example\KPC101_Example\bin\x64\Debug\Thorlabs.MotionControl.Tools.Logging.dll
C:\Users\gboedecker\source\repos\KPC101\KPC101_Example\KPC101_Example\bin\x64\Debug\Thorlabs.MotionControl.Tools.WPF.dll
C:\Users\gboedecker\source\repos\KPC101\KPC101_Example\KPC101_Example\obj\x64\Debug\KPC101_E.4EEB1B3A.Up2Date
C:\Users\gboedecker\source\repos\KPC101\KPC101_Example\KPC101_Example\obj\x64\Debug\KPC101_Example.exe
C:\Users\gboedecker\source\repos\KPC101\KPC101_Example\KPC101_Example\obj\x64\Debug\KPC101_Example.pdb
C:\Users\gboedecker\source\repos\KPC101\KPC101_Example\KPC101_Example\obj\x64\Debug\KPC101_Example.exe.config
6 changes: 6 additions & 0 deletions C#/KCube/KPC101/obj/x64/Debug/KPC101_Example.exe.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
6 changes: 6 additions & 0 deletions C#/XA/BBD30X/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
57 changes: 57 additions & 0 deletions C#/XA/BBD30X/BBD30X.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6F6540DC-4ED9-4D48-BE55-32A5AB2A7A1F}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>BBD303</RootNamespace>
<AssemblyName>BBD303</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="tlmc_xa_dotnet">
<HintPath>..\..\..\..\..\..\..\Program Files\Thorlabs XA\SDK\.NET Framework (C#)\Libraries\x64\tlmc_xa_dotnet.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Loading