MotoHawk:Blocks:Data Storage

From MotoHawk
Jump to navigationJump to search

Data Storage Blocks

The MotoHawk Datastorage Blockset can be used to store data in Non-Volatile or Volatile Memory, and display the data as calibration or a display value. "Vardecs" can be attached to view the data in MotoTune. Data can be written or read in different subsystems of the model as a matrix, vector, or scalar. Vectors must be row vectors.

A brief summary of each block is given below. Additional information on the blockset can be found in our comprehensive online help:

MotoHawk Blockset Help

MotoHawk:Blocks:Data Definition Block

Data Definition Block Help

This MotoHawk® block defines data to be accessed via a MotoHawk Data Read or Data Write block. The 'Data Name' provides a globally unique name, accessible from anywhere in the model. 'Storage Class' identifies the behavior of the data on the target. Volatile data will return to its 'Initial Value' on every startup. NonVolatile data will be saved in EEPROM, and return to the last written value on startup. The initial value is used to specify whether the data is a scalar, vector, or an array and any valid Matlab expression can be used. For example, the initial value can be ones (1, 100) to store a 100 element array. All vectors must be row vectors, and the datatype for the corresponding DataDefinition block, Data Write Block, and Data Read block must match. An additional signal output will be present when 'Output Data Reference' is checked, which is of data type 'reference_T'. This is a pointer to the data, and may be used by the Data Read and Write blocks, to perform pointer-based access to data structures.

Checking 'Attach a VarDec for visibility in MotoTune' will show similar parameters as the Calibration block. If unchecked, the variable will not be available from MotoTune. A Structure Instance can be defined with the data type "struct". A structure name must be provided and must match the structure name specified in a "Structure Declaration" block. MotoTune VarDecs for structures are not specified in this block, but can be specified with the "Create Structure VarDec" block.

MotoHawk:Blocks:Data Read Block

Data Read Block Help

This MotoHawk® block reads a value from data defined by a MotoHawk Data Definition Block. The 'Data Source' may be resolved by name, or by explicitly providing a dynamic reference signal. If "Structure Name" is selected, then the name of the structure instance must be specified along with the name of the field. If "Structure Reference" is selected, then the field is selected and a structure reference is provided as an input. The 'Data Structure' may be a Scalar, Vector, or Matrix. If Vector or Matrix is selected, an option is available to either output the entire data structure as a vector or matrix signal, or to use zero-based index inputs to determine the appropriate item within a larger data structure. The selection for 'Data Structure' and 'Data Type' must match the definition. An error is not given the source is by input reference.

If 'No operation when null reference is input' is checked, an explicit check for a null pointer will be done, and zero will be output from the block. If this is unchecked, null pointers will cause a crash on the target. Note that no type, bounds, or data structure checking is ever provided on the target.

MotoHawk:Blocks:Data Reference

Data Reference Block Help

This MotoHawk® block outputs reference(s) to the given data by name(s), using the signal data type 'reference_T'. It may be used by the MotoHawk Data Read or Data Write blocks, to perform pointer-based access to data structures.

MotoHawk:Blocks:Data Write Block

Data Write Block Help

This MotoHawk® block writes a value to data defined by a MotoHawk Data Definition Block. The 'Data Source' may be resolved by name, or by explicitly providing a dynamic reference signal. No type, bounds, or data structure checking is provided on the target. Such issues can be caught by simulation, with explicit warnings.

If "Structure Name" is selected, then the name of the structure instance must be specified along with the name of the field. If "Structure Reference" is selected, then the field is selected and a structure reference is provided as an input. The 'Data Structure' may be a Scalar, Vector, or Matrix. If Vector or Matrix is selected, an option is available to either output the entire data structure as a vector or matrix signal, or to use zero-based index inputs to determine the appropriate item within a larger data structure. The selection for 'Data Structure' and 'Data Type' must match the definition. An error is given if this does not match when the data source is by name. However, if the source is by input reference, the tool will not provide static error checking.

If 'No operation when null reference is input' is checked, an explicit check for a null pointer will be done, and zero will be output from the block. If this is unchecked, null pointers will cause a crash on the target. Note that no type, bounds, or data structure checking is ever provided on the target. Such issues will be caught by simulation, with explicit warnings.


MotoHawk:Blocks:Fixed NonVolatile Manager

See Fixed NonVolatile Manager block help for additional details on using Fixed NonVolatile Manager.

This MotoHawk® block allows placement of data stores with a known order in the Nonvolatile portion of your controller’s memory. This block may be used when particular variable(s) of the controller software must be maintained, even through various controller software upgrades.


MotoHawk:Blocks:NonVolatile Definition Block

NonVolatile Definition Block Help

This MotoHawk® block configures the behavior of the Non-Volatile data in the module after programming. On shutdown (or when the Store NonVolatile Data block is executed), the RAM copy of Non-Volatile data is stored in Serial EEPROM. On the next startup, the module will use the previously saved values.

What is the Difference between NonVolatile and Fixed NonVolatile Data?

When the module is started the first time after programming with a new .srz, there are two options:

  • Try to use the previously stored values from the previous program
  • Use the factory default values as stored in the .srz file

Note that the previously stored values may only be used if the same NonVolatile variables are available in the new program as in the old one. If the stored NonVolatile variables do not match up with those expected by the new program, they will be restored from factory defaults, regardless of this setting.

Changing the model name, adding or removing any NonVolatile variables, or modifying the name, data type or size of any NonVolatile variables will force reloading from factory defaults. Any other changes to the model will not force reloading from factory defaults, and may therefore be used by the new program.

MotoHawk:Blocks:NonVolatile Status

NonVolatile Status Block Help

This MotoHawk® block outputs the current status of the NonVolatile memory. Note that there is always a Display variable indicating this status available in MotoTune called NonVolatileStatus.

0: NV Currently Loading from Factory FLASH to RAM - This is set while performing the copy from factory defaults in FLASH to the working copy in RAM

1: NV Currently Loading from EEPROM to RAM - This is set while performing the copy from stored EEPROM values to the working copy in RAM

2: NV Currently Storing from RAM to EEPROM - This is set while performing the copy from the working area in RAM to the serial EEPROM

3: NV Loaded Factory FLASH due to change Format ID - This occurs when the stored EEPROM values do not match the structure expected by the model.

4: NV Loaded Factory FLASH due to CRC Failure - This occurs if the last stored values are corrupt, due to a power failure during write or bad memory

5: NV Loaded Factory FLASH due to User Request - This occurs if the user requested that factory defaults be reloaded into RAM, even though the values in EEPROM are OK.

6: NV Loaded Last Stored Values from EEPROM - This normally occurs when the model restarts, and no errors occur

MotoHawk:Blocks:NonVolatile Restore Block

NonVolatile Restore block help

When this MotoHawk® block is triggered, all original NonVolatile definitions are reloaded from FLASH. These are the values provided in the 'Initial Value' field of the MotoHawk Data Definition block.


MotoHawk:Blocks:Size Of Block

SizeOf() Block Help

This MotoHawk® block will return the size of the specified VarDec. It will output either the number of bytes, the total number of elements (rows * columns), number of rows, or the number of columns based on the output format. The output port data type is selected via the output data type parameter.

MotoHawk:Blocks:NonVolatile Store

NonVolatile Store Block Help

When this MotoHawk® block is triggered, all NonVolatile definitions are saved to EEPROM, for later restoration. Note that if your model contains a Main Power Relay block from the Extra Development Blocks library, it will perform this action at controlled shutdown, prior to switching off the relay.


MotoHawk:Blocks:Structure Declaration

This MotoHawk® block defines the fields for a structure, the default values for those fields, and what enumeration should be used for each field.

Concepts behind Structures

Structures The structure declaration describes the format of the data that an application designer is trying to describe. It is composed of fields (or members) and a name. Each field name must be unique and has an associated data type.

Structure declarations do not allocate any memory or define any variables. It is only a definition. Since this is the case, there is no overhead during the code generation process when placing a structure declaration block into an application. To create a structure declaration in MotoHawk, select the MotoHawk Structure Declaration Block from the MotoHawk palette.

Container

A container is how a structure declaration goes from the virtual (the declaration) to the concrete. Essentially, the container declares a dynamically-sized bucket that structure instances can be linked to at the end of the code generation process. The container contains the link to the display/calibration tool. Since the container contains all of the instances, it's data parameter can explicitly set the order of the instances in the VarDec. In the first version of the structure blocks, the container was hidden from the user and the structure declaration name was used instead. However, this placed a requirement that only one container could exist per structure declaration. In addition, all structure instances that used a given structure declaration were required to have the same storage type. These restrictions have been lifted and now the container explicitly specifies all of these parameters. So linking multiple containers to the same structure declaration is now possible. To create a container in MotoHawk, select the MotoHawk Data Definition Block from the MotoHawk palette and select 'struct container' in the data type drop down list.

Structure Instance Definition

The structure instance is the same conceptually as the Fault Definition Block. The application designer scatters structure instance definitions throughout an application and links them to a given container. The instance names and the field names are used to access the data in the container. The container itself is not used directly. The benefit of performing operations in this manner is that one structure instance does not affect another structure instance. In fact, even the structure instances do not affect their container until the end of the code generation process. This allows for more localized models that can be easily componentized. This is a powerful construct when developing applications such as Freeze Frame, Fault Manager, or other dynamically-sized data storage applications. To create a structure instance, select the MotoHawk Data Definition Block from the MotoHawk palette and select 'struct' in the data type drop down list.