Maxon EPOS2 Driver C++ Class using USB-CAN Gateway for Multiple Motor Actuation

I am sharing a C++ Class for multiple Maxon motor actuation by EPOS2 via USB-Can gateway.

The source code is written for two motors, but it is possible to modify easily to actuate multiple motors.

<Download>

If you want to see a simpler version for one motor actuation, see this article. 

I hope this article makes your life easier.

-Mok-

12 thoughts on “Maxon EPOS2 Driver C++ Class using USB-CAN Gateway for Multiple Motor Actuation

  1. Pingback: Minimal c++ class for Maxon EPOS2 - Youngmok Yun: Roboticist in The Univ. of Texas at Austin

  2. Kamil ORMAN

    Hi, Thanks for this very useful work.
    Can you help me about: Maxon EPOS2 driver (MATLAB class) using USB-CAN for two maxon motor.
    i’m very happy if you have some code and send me,
    Best wishes

    Kamil ORMAN (PhD Student)

    Reply
    1. admin Post author

      HI, Kamil. Have you tried to use the attached file? It includes a class for Maxon EPOS2 and a demo program. If you have a problem to use this, please let me know.

      Reply
  3. Kamil ORMAN

    Hi Youngmok,
    I tried to test this code but I didn’t succeed. I’m very new at GNU licensed code.
    I know that bother you, but I’ll be very happy if you help me.
    I’m working on the system as follows: 2*maxon EC motors and 2*EPOS2 50/5 (AGV). I want to control this system with MATLAB.

    ->node1 connected to the computer via USB and node2 connected to node1 via CANopen. I tried this connection via Epos studio and i run both nodes. now I want to run in the MATLAB (real-time) or I can try with visual c++ 2010 express. (I haven’t tried yet the RS232 interface)

    if you send this code (you share it here) to me as Matlab code or as visual c++ project, I would be very pleased.

    Best wishes

    Kamil,

    Reply
    1. admin Post author

      Sorry I do not have visual studio, and MATLAB is completely different…. As long as I know, you may download some example files for those platform from Maxon website.

      Reply
  4. Esa

    Hi ,

    Can you please describe the setup for this code to work?

    Does the computer link to one EPOS controller via USB ?

    Do you then you have a secondary EPOS controller connected to the first EPOS controller via the CAN interface connector ? J7 or J8 ?

    I am using the EPOS2 70/10

    Do we need to put these controllers in a specific mode/settings to get this code working ?

    Cheers
    Esa

    Reply
  5. Esa

    I also find this confusing

    PortName_MCP = “USB0”;
    PortName_PIP = “USB1”;

    nodeId_MCP = 1;
    nodeId_PIP = 1;

    ErrorCode = 0x00;

    Does that mean that the Computer is connected to both EPOS2 controller via 2 separate USB cables ?

    what does MCP and PIP stand for ? why do they have the same value?

    I managed get the simpler version of the code you posted (for one motor actuation) working without any issues.

    Any help would be much appreciated

    Cheers

    Reply
  6. stex2005

    Hello Mok,

    does this library use CANopen PDO or SDO or neither?
    Is is possible to implement Cyclic Synchronous Position Mode on multi-axis without much delay ?
    Thanks
    Stex

    Reply
    1. admin Post author

      Hi, stex2005. The code is using an USB library which is very slow. After long development time of motor control systems, I decided to commercialize motor drivers. Please see https:/esmacat.com Here you can see EtherCAT based motor drivers and others.

      Reply
  7. Evelyn

    Dear Dr. Yun,

    Hi, firstly thank you for your kindness sharing the code to us, which really helps a lot!

    I am a graduate student currently using EPOS2 motors to move a remote car. In our design we need to use ProfileVelocityMode to control it. So I modified the “cmaxonmotor.h” and what I did was simply changed all “VCS” commands related with “ProfilePosition” to the ones related with “ProfileVelocity” , including but not limited to “VCS_ActivateProfileVelocityMode”, “VCS_MoveWithVelocity” and all that part from “Definition.h” under “Profile Velocity Mode”.

    However, the motor won’t move with the new moving command in our “ProfileVelocityMode”. I suspect there should be something wrong in main function, since we used the same “for-loop” method you used in”position mode”. We also tried to remove the “for-loop” and directly use “motor.moveWithVelocity()” command but the motor did not move, either. The error message shows a code”872415239″, which cannot be referred to any error code in “command library book” provided by Maxon.

    I am not sure what’s the difference in driving motors between “velocity mode” and “position mode”. Could you please provide us with some suggestions?

    Looking forward to your reply soon! Thank you again for your kindness sharing your work and experiences!

    Reply

Leave a Reply