
Python Program

This Python program demonstrates how to control a motor using Profile Velocity Mode.

Profile Position Mode is not implemented in this example but can be added and extended by the user.

The project illustrates how to integrate and use the Motion Library (MotionCmd.dll) in Python applications. The example was tested with Python 3.8.2 and Visual Studio Code running on Windows 11.

The current version of the Motion Library is 1.1. If newer versions become available, users should download and update the library from the official maxon website.

The application provides a simple command-line interface and is operated entirely through terminal input.

Note: The program is not compatible with the Python IDLE Shell. Please use a terminal-based environment such as Visual Studio Code, Command Prompt, PowerShell, or Windows Terminal.



Commissioning Procedure
1. Configure and Tune the Drive

Before running the Python application, configure and commission the drive using maxon Motion Studio.

Drive tuning must be completed successfully before commanding the drive via the Motion Library.



2. Perform Test Movements

Verify correct operation by performing test movements in Profile Velocity Mode using Motion Studio.



3. Disconnect Motion Studio

After successful testing, disconnect the communication session in Motion Studio.

Important: If Motion Studio still holds the communication port, the Python application may not be able to establish a connection with the drive.



4. Copy the Example Project

Copy the Python project to your PC and unzip it. In the "MotionLibrary" Folder, there are the 32-Bit and 64-Bit Libraries.

- 32-bit version (MotionCmd.dll)
- 64-bit version (MotionCmd64.dll)


5. Start the Application

Launch Main.py from Visual Studio Code or a Windows Power Shell.

After succesfull startup, the drive will be enabled automatically and the drive LED should turn solid green.

If the LED is solid red, a fault condition is present. In this case, troubleshoot the issue using Motion Studio before proceeding.

Once the application is running, the motor can be controlled using the following keyboard commands:

Key	Function
+	Increase speed by the configured speed step
-	Decrease speed by the configured speed step
s	Toggle Quick Stop (stop and resume motion)
q	Quit the application
Ctrl+C	Terminate the application


Example Terminal Output
Plain Text
[LOG] ----------------------------------------------------------------------
[LOG] maxon - Motion Command Library - 64-Bit / Version: 1.1
[LOG] ----------------------------------------------------------------------
[LOG] Connecting to Interface: b'USB', Port: b'USB0'...
[LOG] ESCON2 connected!
[LOG] Device state: Operation Enabled
 
[LOG] ------------------------- Terminal Interface -------------------------
 
(+) increase by 100 rpm
(-) decrease by 100 rpm
(s) toggle quick stop
(q) quit
 
averaged: 999 rpm / target: 1000 rpm
 
[LOG] Device state: Quick Stop Active
averaged: 0 rpm / target: 1000 rpm QUICK STOP
 
[LOG] Device state: Operation Enabled
averaged: 1002 rpm / target: 1000 rpm
 
[LOG] Quitting - switching power stage off.
 
[LOG] Power stage switched off.
[LOG] ESCON2 disconnected!

Notes
- The displayed averaged speed is a 1-st order filtered velocity actual motor speed measured by the drive.
- The target speed is the commanded velocity set by the user.
- When Quick Stop is activated, the motor is decelerated according to the configured Quick Stop parameters.
- Upon exiting the application, the power stage is disabled and the communication connection is closed.