Component Blocks: Difference between revisions
(3 intermediate revisions by the same user not shown) | |||
Line 18: | Line 18: | ||
===Component Instance=== | ===Component Instance=== | ||
Provide the filename of a MotoHawk Component file (*.mhc), either as an absolute filename or relative to the current model location. If the component requires a wrapper passphrase or a build passphrase, enter it here | Provide the filename of a MotoHawk Component file (*.mhc), either as an absolute filename or relative to the current model location. If the component requires a wrapper passphrase or a build passphrase, enter it here. If no passphrase is required, use an empty string. | ||
[[Image: ComponentInstanceBlock.JPG]] | [[Image: ComponentInstanceBlock.JPG]] | ||
=== | ===Component Output=== | ||
This | This MotoHawk block provides an output to a parent model from a component. Every output port must have a unique name within a component. The data type and dimensions can be explicitly set or may be set to inherit the driving signal at update time. If left empty, the dimensions are dynamically determined from the signal size. These are then used as constraints in the parent model. The 'Help' and 'Units' fields are also optional but are used in the documentation of the component and are displayed to the component user when using the component in the parent model. | ||
[[Image: ComponentOutputBlock.JPG]] | [[Image: ComponentOutputBlock.JPG]] | ||
==Compiling mex Files== | ==Compiling mex Files== | ||
To work with component blocks you need to install a mex compiler. On most versions of 32 bit | To work with component blocks, you need to install a mex compiler. On most versions of 32-bit MATLAB, that compiler already comes with the software, but it must be selected. To select a mex compiler, or to make sure you have one, type '''mex -setup''' into your MATLAB command line. At that point you will be asked if you want to find and install a mex compiler. If the generic LCC-win32 compiler is already on your machine it will come up as an option. However, if no options come up, you will have to install a compiler. To do so, search MathWorks' website for the compatible compilers for the version of MATLAB you are using. For each version of MATLAB that needs a compiler, they list compatible compilers and give links to download them. If you run into errors while building the component model after the compilers are installed, you might need a MathWorks software patch. This MathWorks page http://www.mathworks.com/support/tech-notes/1600/1605.html is a good starting point for installation and troubleshooting errors. |
Latest revision as of 17:50, 10 March 2023
MotoHawk Component Blocks
The MotoHawk component blocks are a good way to either protect developed code, speed up repeated builds or both. The basic idea of the component block is to precompile part of the code used in a model. Once the code is compiled, you can add it to a parent model. This helps speed up builds if a piece of code is used in many places or if part of the model is finished because the code is precompiled. Using the component blocks can also help protect your code from the user, because the code generated is encrypted, not allowing the user to see it. You can also limit who can use that code by making passwords in the component model.
The component blocks work by setting a MotoHawk model's target definition block to make a component for the family of controllers you will be using. Once that is finished you can create the component model. When finished, you compile it into an *.mhc file, and drop a MotoHawk Component Instance block into a parent model that will use the component. To pass information back and forth from the component, place Component Input and Output blocks in the component model.
Note: When using MotoHawk Components, if you update the component model and rebuild it, you have to recompile the parent code twice to update that model with the new version of the component *.mhc file. The component instance block will tell you which version of the *.mhc file it is using.
Blocks
Component Input
This MotoHawk block provides an input to a component from a parent model. Every input port must have a unique name within a component. The data type and dimensions can be explicitly set or may be set to inherit the driving signal at update-time. If left empty, the dimensions either follow the default value if provided or are dynamically determined from the signal size. These are then used as constraints in the parent model. The default value is optional and is used during simulation of the component. It is available to be used from the parent model, instead of using an explicit input signal or other constant value. The 'Help' and 'Units' fields are also optional but are used in the documentation of the component and are displayed to the component user when using the component in the parent model.
Component Instance
Provide the filename of a MotoHawk Component file (*.mhc), either as an absolute filename or relative to the current model location. If the component requires a wrapper passphrase or a build passphrase, enter it here. If no passphrase is required, use an empty string.
Component Output
This MotoHawk block provides an output to a parent model from a component. Every output port must have a unique name within a component. The data type and dimensions can be explicitly set or may be set to inherit the driving signal at update time. If left empty, the dimensions are dynamically determined from the signal size. These are then used as constraints in the parent model. The 'Help' and 'Units' fields are also optional but are used in the documentation of the component and are displayed to the component user when using the component in the parent model.
Compiling mex Files
To work with component blocks, you need to install a mex compiler. On most versions of 32-bit MATLAB, that compiler already comes with the software, but it must be selected. To select a mex compiler, or to make sure you have one, type mex -setup into your MATLAB command line. At that point you will be asked if you want to find and install a mex compiler. If the generic LCC-win32 compiler is already on your machine it will come up as an option. However, if no options come up, you will have to install a compiler. To do so, search MathWorks' website for the compatible compilers for the version of MATLAB you are using. For each version of MATLAB that needs a compiler, they list compatible compilers and give links to download them. If you run into errors while building the component model after the compilers are installed, you might need a MathWorks software patch. This MathWorks page http://www.mathworks.com/support/tech-notes/1600/1605.html is a good starting point for installation and troubleshooting errors.