Search code examples
cmatlabevalmexmingw-w64

Commanding Maxon Motors EPOS2 Motor Controller from MATLAB


I want to communicate with EPOS2 Maxon Driver. Here is what I found on File Exchange to do it.

  • Download the link and create Epos2Windows as a empty folder in \Version2 where Make.m exist.
  • Add MinGW-w64 toMatlab.
  • Install EPOS2 USB driver .
  • Download EPOS-Windows-DLL-En.
  • copy Definitions.h, EposCmd.lib, EposCmd64.lib, vxlapi.dll, vxlapi64.dll from \EPOS-Windows-DLL-En\Microsoft Visual C++\Definition Files to Epos2Windowsfolder.

Finally when I use Make command, there are lots of errors starting with Error using mex and ...

I started to find out what the problem is. So I ran Make.m code line by line. I found the problem in eval( char(strcmd) ). Now I have no idea to handle it.

Any help would be appreciated.

errors1 errors2

Win10, MATLAB R2017b


Solution

  • Here is the way that I solved the problem in Win10_LTSC, Matlab_2019a: Install MinGW64 Compiler with Windows 10 SDK or later (C++) for Mex of Matlab. there are some commands in the files that need to be compiled by the cpp compiler. mex changes it compiler as see filetype so change all of 25 files with type .c to .cpp in the folder and Make.m.

    to avoid the error of invalid conversion from 'void*' to 'real_T*, change real_T *y = ssGetOutputPortSignal(S,0); [line 274 in sfun_maxon.cpp] to real_T *y = (real_T *)ssGetOutputPortSignal(S,0);.

    open test_epos.m and set the true value of NodeId then run the code.