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.
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.
Verify correct operation by performing test movements in Profile Velocity Mode using Motion Studio.
After successful testing, disconnect the communication session in Motion Studio.
Copy the Python project to your PC and unzip it. In the "MotionLibrary" Folder, there are the 32-Bit and 64-Bit Libraries.
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 |
[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!