User Workspace
The Simulink code generation can be supplied with a user workspace file that identifies objects used by the Simulink model and should be available to the calibration software.
Enumerations and other ginmake directives can appear in this file. These should be specified in comments that begin with %+.
e.g.
Items may have ginmake style comments preceding them. These will be added to the generated externs file (possibly with some translations).
Such comments must begin with %$.
Empty fields in such ginmake comments (e.g. the item name) may be filled in by ginmake using the details in the MATLAB object definition before writing to the externs file.
Items in the user workspace should use the ImportedExtern CoderInfo.StorageClass.
e.g.
1%$ [,speed:rpm,,,r,,,,#.##,]
2MySignal = Simulink.Signal;
3MySignal.CoderInfo.StorageClass = 'ImportedExtern';
4MySignal.DataType = 'single';
5MySignal.Complexity = 'real';
6MySignal.InitialValue = '0.0';Alternative gin object field syntax
It is also possible to specify the fields of an object definition in a more readable way. For example:
1%$ units: speed:rpm
2%$ readonly: true
3%$ axis_param: Flyspd
4%$ scalar: 1
5%$ offset: 0
6%$ reciprocal: false
7%$ category: breakpoints
8%$ format: #.##
9Bpx = Simulink.Breakpoint;
10Bpx.SupportTunableSize = false;
11Bpx.Breakpoints.DataType = 'single';
12Bpx.Breakpoints.Min = [];
13Bpx.Breakpoints.Max = [];
14Bpx.Breakpoints.Unit = '';
15Bpx.Breakpoints.FieldName = 'Bpx';
16Bpx.Breakpoints.Description = '';
17Bpx.Breakpoints.Value = [1 2 3 4 5];
18Bpx.Breakpoints.TunableSizeName = 'N';
19Bpx.CoderInfo.StorageClass = 'ImportedExtern';
20Bpx.CoderInfo.Alias = '';
21Bpx.CoderInfo.Alignment = -1;
22Bpx.StructTypeInfo.Name = '';
23Bpx.StructTypeInfo.DataScope = 'Auto';
24Bpx.StructTypeInfo.HeaderFileName = '';The full list of available fields is as follows:
- name
- units
- format
- category (semicolon separated list allowed)
- optionlist DEPRECATED – use enum instead
- enum (name of enumeration (aka option list), numbers not allowed)
- functiontable (name of function table)
- readonly (true/false or as per ginmake comment read/write field)
- scalar (real values or as per normal ginmake comment)
- offset (real values or as per normal ginmake comment)
- bitmask
- reciprocal (true/false)
- signed (true/false)
- round (true/false)
- axis_param
- axis_steps
- axis_start
- axis_offset
- yaxis_param
- yaxis_steps
- yaxis_start
- yaxis_offset
- description (generates [DESCRIPTION,…] directive)
- min_raw, max_raw: Define limits in internal (raw) values => VIEWRANGE
- min, max: Define limits in physical (real) values => LIMITS
- hardmin, hardmax: Define limits in physical (real) values => HARDLIMITS
- segment: name of segment to place the object in.
Unless stated otherwise, these fields follow those in the parameter/option/table/map definitions. Remember that to create the desired object, you must use the correct number of fields required for that object (unused fields can be left blank).
Examples of how to use limits on raw and real values can be found in VIEWRANGE, LIMITS and HARDLIMITS sections. Note: In Ginmake 2.21+, floating-point objects without limits set will generate a warning. To remove this warning, one of the following needs to be set for the object: Valid range, View range, Limits, Hard Limits.
Segment Placement
By Default, Simulink.Signal objects will be placed in RAM (the segment with semantic:“model_ram”).
All other objects will go into NVM (model_nvm).
It is possible in ginmake 1.91+ to specify the segment NAME in the preceding comment to override this behaviour.
e.g.
Initialization Lists
Items in functions whose names end with _GEMS_Initialize will be added to initialization lists in generated firmware code.