Frequency Input Definition

This MotoHawk™ block allows the frequency of a digital input signal to be monitored.

Block ID

motohawk_frequency_in

Library

MotoHawk_lib/Advanced Digital I/O

Description

Overview

This MotoHawk™ block allows the frequency of a digital input signal to be monitored. The returned frequency is referred to as instantaneous in that is calculated from the last sample period measured from (detect) edge to (detect) edge. It has units of 0.01 Hz. Some resources also support the recovery of average frequency via the Read Average Frequency block.

Average Frequency

MotoHawk™  supports average frequency. This may consume more CPU bandwidth when enabled. Thus while a resource implemented on the eTPU wouldn't suffer from a CPU hit, the same feature implemented on an eMIOS CPU resource would. The application can decide whether this attribute is required or not by setting the associated checkbox in this block. The checkbox will be greyedout if MotoHawk™  detects that this attribute is not supported by the resource. Selecting Frequency Average makes the option available. The Read Average Frequency block must be used to recover the frequency. Using this block without enabling Frequency Average in the definition will result in an error during model update. An error will also result if the block is used and the selected resource does not support that capability.

MotoHawk™  supports two forms of frequency average. These are fixed interval averaging and variable interval averaging.

Fixed interval averaging allows the application to specify the number of periods that should be accumulated before the average is taken. This form of average can smooth out the variability that is observed with instantaneous frequency when monitoring a wheel with inprecise tooth displacement. For example, consider a wheel with two teeth that are displaced about the wheel with +/-1 degree of manufacturing tolerance. The fixed interval average would remain constant (given constant speed of rotation) where the instantaneous frequency would vary.

Variable interval frequency averaging allows the application to measure the average frequency observed overtime. The interval is defined by consecutive reads of frequency by the Read Average Frequency block. For example, to recover the average frequency observed over 5ms the application would place a single Read Average Frequency block in a 5ms trigger. Each access would read the average frequency observed since the last access. So if three periods were observed in the 5ms period then the average period would be the sum of these three instantaneous periods divided by three. The last instantaneous period is returned if a period has not been observed since the last access. This occurs when the signal being monitored has a frequency that is lower than the rate at which it is being read.

Duty Cycle Measurement

The duty cycle measurement is optional. When selected it describes the elapsed time between the occurrence of the non-synchronous edge and the synchronous edge. The synchronous edge is defined by the 'Edge Detect' setting. 4096 represents 100%. The value is instantaneous in that it corresponds to the dutycycle of the last observed period.

Duty cycle measurement may consume additional CPU so the application may select whether the option is required by the application. An additional port is added to the block to allow its recovery.

Alias Protection

Alias protection is a characteristic that protects low frequency inputs from indicating the incorrect frequency when the frequency is very near the low threshold. It may place additional execution burden upon the system because each edge may result in the need to service an interrupt. It does not need to be employed on inputs that consistently sit above the low frequency threshold under normal operation. The low frequency threshold is approximately 1.2 Hz for MPC5xx based modules.

The option will be greyed out unless the feature is available for the selected resource. Typically resources that don't support the feature have implicit support.

Alias protection will provide guaranteed uniform frequency response for all frequencies between 0 Hz and 39000 Hz (for MPC5xx modules). Inputs that support the alias protection attribute, but have it disabled, may report incorrectly when they first start up, when they stop and while their frequency is near the low frequency threshold.

Provide Trigger after N

When enabled the Frequency Input Trigger will be fired after N pulses are observed and the vector of frequency data can be extracted.

Status is a uint8 enumeration. 0 = OK, 1 = Pulse Missed, 2 = Incoherent

Newness Status Output

The optional newness status output that can be requested via the Show Newness Status allows the reported frequency to indicate whether it is a new or stale (old) report. This option is only available when the Provide Trigger after N option is not in use.

Newness is measured relative to the last time the frequency input was accessed. A report is new if at least one new edge was observed by the input since it was last accessed and is stale otherwise. Consider, for example, that this block was being executed periodically at (say) a rate of once every 5ms and that it is monitoring an input that happens to have a constant frequency of 100Hz (10ms period). (Say) the first time it is accessed the input had just observed an edge. The newness status output port would report that the observed frequency of 100Hz is new. Then in 5ms time, when the block executes again, it will still report that the frequency is 100Hz, but it will also report a newness status of stale since there have been no new edges observed since it was last accessed.

Only some resources are capable of detecting whether a report is new or not. Those resources that do not support the function will report unsupported. The motohawk_freqin_newness_status_enum script will allow this status to be enumerated. Its definition is as follows:
    0 = Unsupported
    1 = Stale Report (Old)
    2 = New Report

Block Parameters

Parameter Field Values Comments/Description
Name Alpha-numeric text, single-quote enclosed Enter a unique resource name. This can be the name of the sensor that is being read.  No special characters, such as spaces, dashes or commas (underscore allowed). A name is inherited if no name is given, either from the pin (resource) name or the Calibration Name if calibration of attributes is selected.
Resource Drop-down list Select from available resource listings, as appropriate. Note that the CAM input on MPC5xx modules can't be used if an Encoder Definition block exists in the model.
Perform Duty Cycle Measurement Perform/Do not Perform Choose whether or not to perform duty cycle measurement. Enabling this may consume additional CPU.
Provide Trigger after N Pulses Check box (enable) Select this to enable a trigger signal upon achievement of a set number of signal pulses.
Maximum N Numeric Set a maximum for N number (pulses)
Edge Detect Rising/Falling Select edge of signal to be used for frequency (select best or more consistent edge)
Alias Protection Enable/Disable Enable to allow Alias protection. Will be greyed out if the feature is not supported by the selected resource.
Minimum Frequency Positive numeric Minimum Frequency (Hz) is an advisory attribute indicating the minimum frequency expected to be observed on the input. It allows ControlCore to configure itself optimally. Some implementations may use this attribute as the zero detection threshold and report any frequency lower than this value as zero. The minimum expected frequency to be detected. Values below this frequency may not be seen.
Signal Interface Digital / VR input Signal Interface selects between a simple logic-level digital input such as a hall-effect sensor and a variable-reluctance signal.
Enable Frequency Average Mode Check box Check to indicate that this frequency input is to support Average Frequency calculation. This selection will be greyed out if MotoHawk™  has been able to detect that the resource is not able to support such a frequency calculation.
Average Frequency Mode Drop-down list Select the desired mode of Average Frequency calculation. Only visible when the resource supports the option. The attribute is only editable when the Enable Frequency Average Mode is checked and supported (not greyed out).
Samples in Fixed Interval Average Integer [2-255] Defines how many period samples are used in the fixed interval average. Only applicable when the Fixed Interval average mode is selected.
Allow I/O pin and some attributes to be calibrated Check box Enables the I/O resource and some attributes to be calibrated. This field is only available on Classic modules, see ModuleTypes for help.
Allow some attributes to be calibrated Check box Enables the calibration of some attributes. This field is only available if the module does not support calibrated I/O per the above selection.
Calibration Name Alpha-numeric text, single-quote enclosed Base name that is pre-fixed to the calibrated attributes. Should be unique and C-legal (no special characters such as spaces, dashes or commas (underscore allowed).
Read Access Level 0-8 Sets security level 1 lowest, 8 highest, for user access to read value. A setting of zero indicates unsecured access is allowed.
Write Access Level 0-8 Sets security level 1 lowest, 8 highest, for user access to write value. A setting of zero indicates unsecured access is allowed.
Resource Instrumentation Group Alpha-numeric text, single-quote enclosed Defines the group string that will be applied to resource calibration. Set Folder name and hierarchy of the resource. Use "|" character between folder names to delineate subfolder structure. Only visible if the module supports calibrated I/O.
Parameters Instrumentation Group Alpha-numeric text, single-quote enclosed Defines the group string that will be applied to parameters that support calibration. Set Folder name and hierarchy of attributes that can be calibrated. Use "|" character between folder names to delineate subfolder structure.