SOLO now has a block-set library that allows all of our products to be directly controlled or monitored in a powerful Simulink Mathworks environment, this can be a great feature for those in the R&D stages trying to speed up the developments or putting SOLO beside their other blocks in a sophisticated system, our Simulink block-set is capable of communicating with up to 256 SOLO units in a network at the same time.
The model-based design approach of Simulink will enable our users to do things that with conventional coding in programming languages might take months instead of a couple of days in the Simulink environment and that’s why we believe this can be a game-changer for all SOLO users, below we will discuss more on how this library is structured and how to use it.
The Block-set can be downloaded from our Git repository in below link:
Now our Blockset supports two different communication protocols:
UART or USB protocol: The user can directly connect SOLO to their PC using the USB port on SOLO or by using a UART to USB converter
CANopen protocol: The user can communicate with SOLO through KVASER devices on the CAN lines and runing the Simulink Model with Data transferred on the CAN bus, to use the KVASER devices please make sure all the required software libraries and SDKs published by KVASER are installed on your PC.
- 1 Introduction
- 2 Necessary setups for using SOLO Simulink DLL
- 3 The SOLO Simulink block-set Structure
- 4 How to Integerate the SOLO’s C++ dll in Simulink environment
1. Checking MinGW Compiler
For checking if MinGW compiler is installed in your system, you should open command prompt and run the “g++ –version” command. Then, if the following message appeared, you can jump to the next step otherwise you need to install it based on the next section instructions. One more thing is that your compiler version should be sjlj.
Figure 1-1 Message when MinGW is installed
Figure 1-2 Message when MinGW is not installed
1.1. MinGW installation instructions
First you need to download it from this link. You should download the one which is highlighted in the picture.
Figure 1-3 MinGW sjlj Webpage Address
Figure 1-4 Control Panel
Figure 1-5 System Setting window
Figure 1-6 System Setting window
Figure 1-7 System Properties window
Figure 1-8 Add MinGW to System Path
Figure 1-9 Environment Variables window
1.2. Necessary files and Installations
Now as the last step, you will need to make sure all the below required installations and instructions are met
1.2.1 KVASER windows driver intallation
Go to the Kvaser website at https://www.kvaser.com/download/ and download and install the latest version of Kvaser Driver for Windows
1.2.2 Directing the Matlab root to the Blockset folder
Next thing is to make sure is the Matlab root is properly selected to the project’s folder root
1.2.3 Checking Critical files
All these files are necessary and if you lose them, you must download them again.
Our Simulink block-set is built on top of our C++ dll that is designed to support all the UART, USB and CANopen command sets of SOLO in a very efficient and easy-to-use manner, to learn more about these command sets please refer to our USB, UART or CANopen user manuals. Our C++ dll then is called within the S-function structure of Simulink to Call all the Write and Read functions on SOLO.
It worth mentioning that this C++ dll will also enable the SOLO users to use our command sets in Labview environment and soon we will publish some examples for that.
The SOLO’s Simulink Block-set has three main Block types which are explained in below
The Serial Setup Block
The inputs of this block are as followings:
Address: This input defines the Device address of SOLO unit that you want to initialize, to set or change the device address of your unit you can use SOLO Motion Terminal.
COM Port: This defines what COM port is assigned to SOLO unit on your PC, on Windows devices you can check that in Device Manager.
Baud Rate: This defines at what baudrate your SOLO unit operates for UART communications, you can set the baudrate of the UART line in SOLO Motion Terminal.
If you are using the native USB on your SOLO unit, the value of baudrate you put here has no effect and any value will be acceptable as the notion of Baud-rate for the USB-2 protocol on SOLO is non existent.
If you are using SOLO with a UART to USB converter connected to your PC then setting of this Baudrate will be necessary and it’s highly recommended to use the highest baudrates possible ( 937500 bits/s in SOLO UNO and MINI) to have the highest performances.
Timeout: This defines the timeout for commands in terms of milliseconds, if the dll fails to communicate with SOLO within the timeout time, you will receive the timeout error code at the “Result” output.
Trials on Failure: This defines how many times the dll should try automatically sending a failed command to SOLO later when you try to Write or Read some parameters, in case after finishing all the trials the command fails to be sent or received you will receive an error at the “Result” and “Error” outputs in your Write or Read functions.
Result: This output defines if the setup process went successful or if an error occurred during the process.
The Write Blocks
Any Write block will attemp to set the value of a parameter within your SOLO unit, each of these blocks will provide you with some inputs and some outputs that are explained in below.
Note: once you are dealing with Write blocks, you need to make sure you don’t over-use the Write action on the parameters that are stored in the NVM memory (non-volatile memory) of SOLO, this memory can be used for Millions of Writes, however it will be wiser to use it only when necessary, to know more about the NVM memory of SOLO and what commands are stored there please refer to our USB, UART or CANopen user manuals.
Address: This input defines the Device address of SOLO unit that you want to command, in other words, as our Simulink block-set can work with multiple SOLO units at the same time, using this input you will tell to the C++ dll to communicate with what SOLO unit in the network
Value: this is the value that you possibly want to set on your SOLO unit based on the particular action you want to take, for instance for the Write block shown above, this will set the Speed Reference for your SOLO unit with the address of 0.
Result: This output will return a possible result if required after the Write action, in general this output is not used frequently in Write actions except for knowing if the process went right or some errors occurred.
Error: this output will return a possible Error that might occur during the Writing process.
The Read Blocks
Address: This input defines the Device address of SOLO unit that you want to read from, in other words, as our Simulink block-set can work with multiple SOLO units at the same time, using this input you will tell to the C++ dll to communicate with what SOLO unit in the network.
Result: This output will return the request Read value, for instance on the block above, you will receive the Speed Feedback value read or estimated by SOLO.
Error: this output will return a possible Error that might occur during the Reading process.
4. Open the library browser, in the search bar and search for “S-Function” and then add “S-Function Builder” to your Simulink
9. close the window
10. You can make any Write or Read block with the same way as the images below: