Python Automation of a Power Meter and Rotation Mount (Viewer Inspired) | Thorlabs Insights @thorlabs
Python Automation of a Power Meter and Rotation Mount (Viewer Inspired) | Thorlabs Insights  @thorlabs
Uploaded July 2022 | Updated September 2026, 27 minutes ago
A Python script that automates control of a Kinesis® K-Cube® motor controller and a power meter is written using Visual Studio® Code. The program acquires optical power measurements from the power meter as the rotation mount's angle sweeps through 180°, which is required to characterize a variable optical attenuator. Since this code uses libraries developed using the .NET framework, running this code requires Python.NET to be installed.

This tutorial implements the code specific to the K-Cube motor controller first, followed by the code for the power meter. The packages and classes required by both devices are identified, and the steps required to initialize and complete shutdown for both devices are shown. In addition, an approach is described for acquiring power readings and checking controller status while the motor is moving. The Python script is executed once after the K-Cube section of the code is complete, and a second time after the program is finished.

The K-Cube motor controller and power meter were automated in order to characterize the optical power transmitted through a pair of fixed, crossed linear polarizers when a rotating half-wave plate is located between them. As the half-wave plate rotates, the polarization orientation of the light transmitted by the output polarizer remains constant, while the transmitted power varies sinusoidally. Measurements of this transmitted optical power, as well as the corresponding rotation angles of the mount in which the half-wave plate is secured, are provided by the program.

The Python code demonstrated during this video can be downloaded from Thorlabs' official GitHub account: github.com/Thorlabs/Motion_Control_Examples/tree/main/Python/KCube

00:00 Introduction
00:35 Variable Optical Attenuator Overview
01:45 Brief Discussion of Project Setup
02:21 Packages and Classes for K-Cube
03:51 Initialize K-Cube Motor Controller
07:20 Home the Rotation Mount
07:46 Move the Rotation Mount
09:38 Controller Shutdown
10:00 Test Run of Rotation Mount Code
10:28 Packages and Classes for Power Meter
11:50 Initialize Power Meter
14:10 Acquire and Display Power Readings
16:37 Execute Complete Program

Components used in this demonstration include:
- Thorlabs' software download page: thorlabs.com/software_pages/ViewSoftwarePage.cfm?Code=Motion_Control&YVI=24
- KDC101 K-Cube Brushed DC Servo Motor Controller: thorlabs.com/newgrouppage9.cfm?objectgroup_id=2419&pn=KDC101&YVI=24
- PRM1Z8 Motorized Rotation Stage: thorlabs.com/newgrouppage9.cfm?objectgroup_id=2875&pn=PRM1Z8&YVI=24
- PL202 Compact Laser Module: thorlabs.com/newgrouppage9.cfm?objectgroup_id=12994&pn=PL202&YVI=24
- AD11F Adapter (Laser to Mount): thorlabs.com/newgrouppage9.cfm?objectgroup_id=219&pn=AD11F&YVI=24
- KM100T Threaded Kinematic Mount: thorlabs.com/newgrouppage9.cfm?objectgroup_id=1492&pn=KM100T&YVI=24
- PRM1 Manual Rotation Mount: thorlabs.com/newgrouppage9.cfm?objectgroup_id=990&pn=PRM1&YVI=24
- Linear Polarizers: thorlabs.com/navigation.cfm?guide_id=2459&YVI=24
- Wave Plates: thorlabs.com/navigation.cfm?guide_id=23&YVI=24
- S121C Photodiode Power Sensor: thorlabs.com/newgrouppage9.cfm?objectgroup_id=3328&pn=S121C&YVI=24
- PM400 Optical Power Meter: thorlabs.com/newgrouppage9.cfm?objectgroup_id=10562&pn=PM400&YVI=24
- 1" Diameter Lens Tubes: thorlabs.com/newgrouppage9.cfm?objectgroup_id=3307&YVI=24
- SM1RC Slip-Ring Mount for SM1 Lens Tubes: thorlabs.com/newgrouppage9.cfm?objectgroup_id=1533&pn=SM1RC&YVI=24
- BA2 Mounting Base: thorlabs.com/newgrouppage9.cfm?objectgroup_id=47&pn=BA2&YVI=24
- FSR3 Fiber Storage Reel: thorlabs.com/newgrouppage9.cfm?objectgroup_id=2685&pn=FSR3&YVI=24

For more photonics how-to videos, visit thorlabs.com/newgrouppage9.cfm?objectgroup_id=14062&YVI=24
Python Automation of a Power Meter and Rotation Mount (Viewer Inspired) | Thorlabs InsightsWhat Is Spherical Aberration? | Optics ExplainedThe Nature Conservancy of New Jersey | Thorlabs and Our CommunityHitting the Road with the Thorlabs Mobile Photonics Lab! VLOG Ep. 1Optomech Basics: Optical Post Mounting ConsiderationsDay in the Life of an Optics Production ManagerComb Lasers for Optical CommunicationsThorlabs Mobile Photonics Lab Experience @ SCCCDistinguish the Fast and Slow Axes of a Quarter-Wave Plate | Thorlabs InsightsThorlabs FFS2000 Workstations: Setup, Power Up, and Power DownWhats Coming to Thorlabs?Laser Scanning Techniques and Applications
Thorlabs |

Python Automation of a Power Meter and Rotation Mount (Viewer Inspired) | Thorlabs Insights

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER