This is not (only) a game anymore! From now on you can use your favourite motion platform with MATLAB (R2019 and R2020 version) programming environment. Math, algorithms, signal processing, building and modeling advanced motion systems – all of those can be achieved with the use of the real machine. Size does not matter! All our products are ready to work with the latest version of MATLAB and Simulink applications.

A number of MathWorks products require that you have a third-party compiler installed on your system. The compiler is also required to work with MEX files. Make sure that you have the correct version of compiler installed before you start using ForceSeatDI and/or ForceSeatMI. You can find more information at Mathworks webpage.

ForceSeatDI and ForceSeatMI

As a company we provide two APIs to work with our machines. Both of them can be used with MATLAB and Simulink. It is on your preferences what way would you like to choose. The general idea that stays behind them is the same – to minimize the end user’s effort required to control the motion platform. We strongly believe that our customers time is one of the most important values. That’s why we put a lot of effort to make things as smooth and intuitive as they can be.

Detailed description of our APIs may be found in our Knowledge Base. Now let’s focus on MATLAB and Simulink support for R2019 and R2020 version. Having activated license for used API is a good start point to go. Our development team has created many examples how to use ForceSeatDI and ForceSeatMI with MATLAB and Simulink environments. You can find them in the *.zip package that is provided to you after the license is purchased. They are designed to work out of the box which means no need for sophisticated settings, file copying or other time-consuming stuff. All that needs to be done is to unpack the package, get familiar with the provided README file, and you are ready to go.

We are aware of extraordinary projects that are developed by our customers. It is not easy to keep them up, but we do our best. However, if you do not find our software valid to your needs to not hesitate to contact us. We are here to help you!

Simulink library configuration

Launch MATLAB application and set up path to Simulink compatible plugins provided by our team.

After that you can launch Simulink and create a blank model project.

In the Library Browser you can find all necessary blocks. Simply drag what you need to your project, connect input and outputs, and you are ready to go.

Compilers

ForceSeatMI 2.110+ (and newer) supports MinGW as C/C++ compiler. Older versions require Microsoft Visual Studio C/C++ Compiler (e.g. Build Tools for Visual Studio 2019).

MinGW

MinGW is available via Matlab add-ons mechanism:

  • start Matlab
  • go Home, Add-ons and click Get Add-ons
  • find and install MinGW
  • after installation is finished, MinGW is configured as default compiler for C and C++

Build Tools for Visual Studio 2019

The first step is to download and install Build Tools for Visual Studio 2019 or Visual Studio 2019 Community/Professional/Enterprise. Make sure to select Desktop development with C++ during installation.

Unfortunately Matlab R2020b does not detect Build Tools correctly and two files have to be modified (if you installed Community, Professional or Enterprise edition you can skip below steps):

  • For C++: MATLABROOT\bin\win64\mexopts\msvcpp2019.xml (e.g. C:\Program Files\MATLAB\R2020b\bin\win64\mexopts\msvcpp2019.xml)
  • For C: MATLABROOT\bin\win64\mexopts\msvc2019.xml (e.g. C:\Program Files\MATLAB\R2020b\bin\win64\mexopts\msvc2019.xml)

For both files the procedure is the same:

  • open msvcpp2019.xml or msvc2019.xml in notepad or other text editor
  • find part containing Microsoft.VisualStudio.Product.Community
  • duplicate <and> section and replace Microsoft.VisualStudio.Product.Community with Microsoft.VisualStudio.Product.BuildTools
  • repeat above steps for all entries in file.

For example, below is the section before modification:

<VCVARSALLDIR>
<or>
<and>
<envVarExists name="ProgramFiles(x86)" />
<fileExists name="$$\Microsoft Visual Studio\Installer\vswhere.exe" />
<cmdReturns name="&quot;$$\\vswhere.exe&quot; -version &quot;[16.0,17.0)&quot; -products Microsoft.VisualStudio.Product.Enterprise -property installationPath -format value" />
<fileExists name="$$\VC\Auxiliary\Build\vcvarsall.bat" />
<dirExists name="$$"/>
</and>
<and>
<envVarExists name="ProgramFiles(x86)" />
<fileExists name="$$\Microsoft Visual Studio\Installer\vswhere.exe" />
<cmdReturns name="&quot;$$\\vswhere.exe&quot; -version &quot;[16.0,17.0)&quot; -products Microsoft.VisualStudio.Product.Professional -property installationPath -format value" />
<fileExists name="$$\VC\Auxiliary\Build\vcvarsall.bat" />
<dirExists name="$$"/>
</and>
<and>
<envVarExists name="ProgramFiles(x86)" />
<fileExists name="$$\Microsoft Visual Studio\Installer\vswhere.exe" />
<cmdReturns name="&quot;$$\\vswhere.exe&quot; -version &quot;[16.0,17.0)&quot; -products Microsoft.VisualStudio.Product.Community -property installationPath -format value" />
<fileExists name="$$\VC\Auxiliary\Build\vcvarsall.bat" />
<dirExists name="$$"/>
</and>
</or>
</VCVARSALLDIR>

and after modification:

<VCVARSALLDIR>
<or>
<and>
<envVarExists name="ProgramFiles(x86)" />
<fileExists name="$$\Microsoft Visual Studio\Installer\vswhere.exe" />
<cmdReturns name="&quot;$$\\vswhere.exe&quot; -version &quot;[16.0,17.0)&quot; -products Microsoft.VisualStudio.Product.Enterprise -property installationPath -format value" />
<fileExists name="$$\VC\Auxiliary\Build\vcvarsall.bat" />
<dirExists name="$$"/>
</and>
<and>
<envVarExists name="ProgramFiles(x86)" />
<fileExists name="$$\Microsoft Visual Studio\Installer\vswhere.exe" />
<cmdReturns name="&quot;$$\\vswhere.exe&quot; -version &quot;[16.0,17.0)&quot; -products Microsoft.VisualStudio.Product.Professional -property installationPath -format value" />
<fileExists name="$$\VC\Auxiliary\Build\vcvarsall.bat" />
<dirExists name="$$"/>
</and>
<and>
<envVarExists name="ProgramFiles(x86)" />
<fileExists name="$$\Microsoft Visual Studio\Installer\vswhere.exe" />
<cmdReturns name="&quot;$$\\vswhere.exe&quot; -version &quot;[16.0,17.0)&quot; -products Microsoft.VisualStudio.Product.Community -property installationPath -format value" />
<fileExists name="$$\VC\Auxiliary\Build\vcvarsall.bat" />
<dirExists name="$$"/>
</and>
<and>
<envVarExists name="ProgramFiles(x86)" />
<fileExists name="$$\Microsoft Visual Studio\Installer\vswhere.exe" />
<cmdReturns name="&quot;$$\\vswhere.exe&quot; -version &quot;[16.0,17.0)&quot; -products Microsoft.VisualStudio.Product.BuildTools -property installationPath -format value" />
<fileExists name="$$\VC\Auxiliary\Build\vcvarsall.bat" />
<dirExists name="$$"/>
</and>
</or>
</VCVARSALLDIR>

Alternatively you can download modified files (msvc2019.xml and msvcpp2019.xml) and copy them to MATLABROOT\bin\win64\mexopts\ (e.g. C:\Program Files\MATLAB\R2020b\bin\win64\mexopts\)

Changing default compiler

Once XML files modification is completed, start Matlab and issue: mex -setup cpp

>> mex -setup cpp
MEX configured to use 'MinGW64 Compiler (C++)' for C++ language compilation.

To choose a different C++ compiler, select one from the following:
MinGW64 Compiler (C++) mex -setup:C:\Users\ABC\AppData\Roaming\MathWorks\MATLAB\R2020b\mex_C++_win64.xml C++
Microsoft Visual C++ 2019 mex -setup:'C:\Program Files\MATLAB\R2020b\bin\win64\mexopts\msvcpp2019.xml' C++
>>

Click on Microsoft Visual C++ 2019 link and Matlab will change default C++ compiler. Next perform similar steps for C compiler: mex -setup c

>> mex -setup c
MEX configured to use 'MinGW64 Compiler (C)' for C language compilation.

To choose a different C compiler, select one from the following:
MinGW64 Compiler (C) mex -setup:C:\Users\ABC\AppData\Roaming\MathWorks\MATLAB\R2020b\mex_C_win64.xml C
Microsoft Visual C++ 2019 (C) mex -setup:'C:\Program Files\MATLAB\R2020b\bin\win64\mexopts\msvc2019.xml' C
>>

If everything is configured correctly, there will be following output:

MEX configured to use 'Microsoft Visual C++ 2019 (C)' for C language compilation.
MEX configured to use 'Microsoft Visual C++ 2019' for C++ language compilation.