Analog Input

This block provides access to the value of the A/D converter channel associated with the selected module resource (pin). The output value is the width of the selected type and represents the ratio of the voltage level of the analog resource to the Reference Voltage (usually 5V).

Block ID

motohawk_ain

Library

MotoHawk_lib/Analog I/O Blocks

Description

The Analog Input block abstracts analog input channels that are connected to a module's Analog to Digital Converter (ADC, A/D or A-to-D) hardware. This hardware converts an analog signal into a digital signal. A conversion is typically a fractional representation of the reference voltage, which is typically 5V. The number of bits defines the resolution and thus the range. Thus a 10bit conversion can have a value between 0 and 1023 where as a 12bit conversion has a value between 0 and 4095.

The conversion is a fraction of the reference. Thus if the input signal was 2.5V, the reference was 5V and a 10bit ADC converter was in use then the native result would be 512 [ (2.5V x 1023) / 5V = 512]. The block allows the number of bits (Output Width in Bits) of the result to be specified so a native conversion can be standardized. Thus selecting 12bits would give a result of 2048, for the example above, even if the underlying ADC was only a 10bit converter.

The Output Width in Bits allows standardization of the result, irrespective of the number of bits supported by the underlying ADC that is in use. The following are some examples:

ADC Configured Resolution (bits) Scale (bits) Raw ADC Raw ADC (binary) Scaled ADC Scaled ADC (binary)
10 11 513 1000000001 1026 10000000010
10 13 513 1000000001 4104 1000000001000
12 11 789 1100010101 394 110001010
8 7 250 11111010 125 1111101

Zeros added for padding are highlighted in red.

Some modules support alternate references. Classic modules expose this functionality via a Reference drop down. Other modules have more flexibility and can select different references based upon the selected resource. The mask will highlight what references are supported for a given resource. It is possible that a selected resource doesn't support any alternate references.

The developer can select an alternate reference that is not supported. Alternatively an external mechanism may lead to the resource's ability to support the selection to change (different target or external modification of the resource). In either case, the default internal reference will be used by the model when it detects that the selected alternate reference is not supported by the hardware. The block also supports the On unsupported alternate reference dropdown that defines how the block should behave when unsupported selection is detected during Simulink Update check (CTRL-D). For example, the developer could consider selecting an unsupported reference as an error, which would terminate the build.

Output Creation Status will add an optional uint16 output that provides the ControlCore error status. 0 means OK, and any other number is an error. This is generally only useful for Classic modules. Please type 'help motohawk_error_enum' for more information. This can be useful for disabling diagnostics or strategies based on different I/O calibrations.

'motohawk_creation_status_enum' is a script that returns a cell array with that enumeration. It can be used in the Enumeration field of a probe to decode the return value of this block.

Block Parameters

Parameter Field Values Comments/Description
Name Alpha-numeric text, single-quote enclosed Name assigned to the Analog Input. Should be unique and C-legal (no special characters, such as spaces, dashes or commas (underscore allowed). When empty the name inherits from the Resource name, or the listed Calibration name if the I/O pin calibration option is selected.
Resource Drop-down list The analog input resource described by this block.
Reference 5V/2.7V Select Reference voltage level for selected input. This is supported by the ECM-563, GCM-563, and HCM-563 targets. This parameter is ignored if not implemented for the current target module and is only visible for Classic targets.
Data Type Drop-down list Assign Data Type: int8, uint8, uint16, etc.
Output Width in Bits 7-16 Specify the number of bits used to represent the output value. Ensure that this fits within the range of the Data Type selected (e.g. 7 for int8, avoiding the sign bit).
Output creation status Check box (enable) Enabling "Output Creation Status" adds an optional uint16 output that provides the ControlCore error status. 0 means OK, and any other number is an error. This can be useful for disabling diagnostics or strategies based on different I/O calibrations. "motohawk_creation_status_enum" is a script that returns a cell array with that enumeration. It can be used in the Enumeration field of a probe to decode the return value of this block.
Allow I/O pin to be calibrated. Check box (enable) Name, Access Levels and Instrumentation Group Strings fields are available. This field is only available on Classic modules, see ModuleTypes.
Calibration Name Alpha-numeric text, single-quote enclosed Name exposed to Instrumentation. 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.
Instrumentation Group Alpha-numeric text Defines Folder name and hierarchy for use by Instrumentation. Use "|" character between folder names to delineate subfolder structure.
Use Alternate Reference Checkbox Associates an alternate voltage reference with the input when checked. Only visible for MotoCoder targets.
On unsupported alternate reference Dropdown Specify how the block should behave when an unsupported alternate reference is selected.

The most common cause for a reference to become unsupported occurs when the target is changed, which can impact the selected resource and/or what reference(s) the selected resource supports on the new target.

Only visible when Use Alternate Reference is visible.
On unsupported alternate reference Edit A value of 'Ignore', 'Warn' or 'Error'. Typically used when a workspace variable is to supply the setting. Only visible when "Specify via Edit Dialog" has been selected by the On unsupported alternate reference drop down.
XDRP1 Checkbox Check to select that this analog resource use "XDRP1" as its ADC voltage reference. Will display (Unsupported) if the selected resource does not support the selection.

Only visible when Use Alternate Reference is visible.
XDRP2, XDRP3, ... Checkbox Other resources may exist. The list is driven by what possible resources MotoHawk is aware of.

Only visible when Use Alternate Reference is visible.