Commanding Maxon Motors EPOS2 Motor Controller from MATLAB

Version 2.0 (226 KB) by Eugenio
These are some files for commanding a Maxon Motors EPOS2 motor controller from MATLAB


Updated 15 Jan 2019

View License

Sometimes is desired to control inside MATLAB a Maxon Motor connected to a EPOS 2 motor controller. It is possible to do that with this files, and the submitted tool differs from other in that it uses USB bus. This tool is primary targeted to the study and research in Robotics, where it is wanted to move a custom robot using inverse kinematics without worrying about low level communication and real time performance.
1) For proper use, first download and install the EPOS2 libraries,

In Linux:
- Download and install in the system the libraries: and

In Windows:
- Download and install EPOS2 USB driver following the link,
- Download and copy to directory "Epos2Windows" the files,
EposCmd.dll, EposCmd.lib
EposCmd64.dll, EposCmd64.lib
vxlapi.dll, vxlapi64.dll

2) Next, compile the files calling the script "Make". The script requires that "mex" was properly setting up.

Example of use:

Files "test_epos.m" and "test_epos2.m" contain some example of controlling EPOS2 Motor Controller.



From "test_epos.m",

>> a = OpenCommunication;

Connecting to node 1

>> b = GetErrorState(a, 1);
>> ClearErrorState(a);
>> EnableNode(a, 1);

Setting Node 1 to "Profile Position" type >> help SetOperationMode for further information

>> SetOperationMode(a, 1, 6);

Profile veloctiy of 300 rpm and profile acceleration of 300 rpm/s

>> SetProfilePositionData(a, 1, 3000, 3000);

Move 132000 quadrature pulse in absolute position

>> MoveToPosition(a, 1, 132000, 1);


>> QuickStop(a, 1);


>> CloseCommunication(a);

From file "test_epos2.m",

Motor1 = Epos2(1);
If (Motor1.IsInErrorState)
Motor1.SetOperationMode( OperationModes.ProfilePositionMode );
Motor1.MotionInPosition( 132000 );
Motor1.MotionInPosition( -132000, 4000, 6000, 1);

delete Motor1

Cite As

Eugenio (2023). Commanding Maxon Motors EPOS2 Motor Controller from MATLAB (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2013b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Added Win2Linux.h and manuals in spanish