Component Blocks: Difference between revisions
No edit summary |
|||
Line 23: | Line 23: | ||
===Compiling mex Files=== | ===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 - | 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”, without the quotes, 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 the option that comes up is none, you will have to install a compiler. To do so search Mathworks website for the compatible compilers for the version of Matlab used. For each version of Matlab that needs a compiler they list compatible compilers, and give links to download them. If you run into errors will 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. |
Revision as of 19:37, 13 December 2011
MotoHawk Component Blocks
The MotoHawk component blocks are a good way to either protect developed code, speedup 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 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 controller 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. A quick 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.
MotoHawk: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, and 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.
MotoHawk:Blocks: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, or use an empty string if no passphrase is required.
MotoHawk:Blocks: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”, without the quotes, 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 the option that comes up is none, you will have to install a compiler. To do so search Mathworks website for the compatible compilers for the version of Matlab used. For each version of Matlab that needs a compiler they list compatible compilers, and give links to download them. If you run into errors will 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.