A Matlab/Simulink toolbox for working with GOcontroll Moduline controllers, it contains a blockset to access the hardware and a toolchain to compile it.
This is the branch made with Matlab 2023b+, it will not work for 2018b, see the 2018b branch for that version.
Notice: Change the default addon location so it contains no spaces. Make really doesn't like spaces in file paths.
This can be done in the HOME tab of Matlab -> preferences (environment section) -> MATLAB -> Add-Ons.
Change the installation folder to something like "MATLAByour matlab version_addons", do this for all your Matlab installations.
This way it is also easier to maintain version compatibility between toolboxes and Matlab. For more info see the help page.
For Windows users it is especially recommended to change this folder to a shorter path. Windows by default has a 256 character file path limit and there have been issues because of this, it should be fine as long as your username part of the path is shorter than 20 characters.
To update your project to the 2023b+ blockset you can do these steps:
- Copy your project so we have a test version for the new blockset without changing your current version.
- Install the GOcontroll-Simulink blockset through either the mltbx downloaded from the github.com releases page or through the Matlab add-on explorer.
- In your model, right click on an open space and open the 'Model Properties' menu, select the Callbacks tab, in either PreLoadFcn or PostLoadFcn remove the call to 'librarySetup' as this script will now disturb the newly installed toolbox.
- Restart Matlab for good measure, now there are some potential breaking changes to check.
- If you are using any output module monitor blocks, check these as they've had a change in this version, this causes the signals to no longer be attached to the correct outputs of the block.
- Check if the CAN blocks are linked correctly to the library, if there is some issue here check the changelog of V3.4.0.
This blockset contains some new blocks, biggest of which are the UDP blocks and the new CAN blocks. These new blocks have examples included in the library that you can refer to. It is possible to use the new and old CAN blocks together, if one bus only has old or only has new blocks it will be good, mixing old and new blocks on one bus seems to work aswell but it is not recommended.
For licensing reasons one library required for building the model must be dynamically linked in, this means that ./blockset/lib/IIO/libiio.so.0 must be uploaded to the target controller to /usr/lib/
If your controller is running release 0.5.0 or higher you are not affected and can ignore this.
To check what release your controller is running see /etc/controller_update/current-release.txt or run the identify command and look for the repo release field (all on the controller).
To compile the Linux based blockset for GOcontroll Moduline IV/Mini/Display, some initial steps needs to be made:
- To compile some necessary mex files on Windows you may need to install the "MATLAB Support for MinGW-w64 C/C++/Fortran Compiler" add-on from the Matlab add-on explorer.
- To compile some necessary mex files on Mac you need to install and activate some Xcode programs. To install the proper components run
xcode-select --install
anddefaults write com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense 12.0
where 12.0 has to be replaced with your xcode version.
There are two ways to set up a project, using a rolling release or a locked version.
A project set up using the Rolling release method will use the installed version of the blockset.
So when the blockset is updated through the Add-On manager, all projects using this will automatically use the new version.
The locked version method creates a project that is locked to the version of the blockset that is installed at the point of project creation.
This makes sure there will never be a sudden breaking change that has to be dealt with, but makes getting updates much more difficult.
- Install the addon from the Matlab addon explorer
- In the 'HOME' tab of Matlab, from the 'New' dropdown menu, select 'Simulink Model'
- Make a new Simulink model with the 'GOcontroll Linux' template
- Save the model
- Build
- The add-on must be installed through the addon store to install the compilers and such
- In the 'HOME' tab of Matlab, from the 'New' dropdown menu, select 'Project -> From Simulink Template'
- Create the project from the ' GOcontroll-Simulink-Project' template where you want it
- In the 'HOME' tab of Matlab, from the 'New' dropdown menu, select 'Simulink Model'
- Make a new Simulink model with the 'GOcontroll Linux' template
- Save the model in the root of the project folder from before and make sure this folder is also opened in matlab.
- Build
To add your own reusable blocks it is possible to create your own library that will be loaded upon startup.
It is not a good idea to modify the existing GOcontroll libraries, as this will cause major issues when you want to update.
- Create a folder in your project that will contain the library.
- In Matlab on the 'HOME' tab, select 'Simulink Model' from the 'New' dropdown menu. Select the 'Blank Library' option, place your block(s) in here and save it in this new folder
- With the library open, unlock it and then run
set_param('YourLibraryFileName','EnableLBRepository','on');
and then save it - In this folder create a file called 'slblocks.m'
- In this file should be the following with the 2 name fields replaced with relevant values for you:
function blkStruct = slblocks()
Browser.Library = 'YourLibraryFileName'; %no file extension, so 'Library.mdl' would be 'Library'
Browser.Name = 'VisualLibraryName'; %this name will show up in the Library Browser
blkStruct.Browser = Browser;
end
- Add this folder to the path of your project so it gets properly loaded. This is done in the 'PROJECT' tab of Matlab, from this tab select 'Project Path'. Then use either 'Add Folder' or 'Add with Subfolders' to add your new folder to the path
for more info see the Matlab documentation.
Since this blockset is intended to support 2023b and up, it is best to do any development in 2023b.
This way there is no risk of accidentally adding unsupport features. All files like the blockset also need to be saved in the 2023b format.
To develop for this project, fork/clone it, then open the Matlab project in the repo.
This will disable the installed version and allow you to work with the one that is tracked in git.
Never commit +GOcontroll_Simulink_2023b_dev/getInstallationLocation.mlx, in theory this should work out fine, but as it is a binary file it will cause annoying merge conflicts. Revert/discard changes before comitting.
This file will get automatically updated to your local situation everytime the Matlab project is opened.
To force this run git update-index --skip-worktree +GOcontroll_Simulink_2023b_dev/getInstallationLocation.mlx
in the repository.
This will make sure this file doesn't show up in git status
for example.
GOcontrollSimulinkProject.sltx should not contain itself or any mex files, see the guide to updating it.
GOcontroll-Simulink.mltbx should contain GOcontrollSimulinkProject.sltx, but still no mex files.
Please let us know when interface blocks are not working properly. You can contact us at support@gocontroll.com
Or make a pull request with changes to fix issues that you are experiencing.
The changelog can be found in blockset/ert_linux_target_version.m