![]() |
CANopen Slave Protocol Stack
Version 7.08.00
|
This module implements the variables and callback functions for the object dictionary from CiA 404 (analog inputs). The module adds the following objects to the object dictionary:
An example for the module is given inside the file cos404ai_app.c which is located inside the template-cos directory.
The analog input module is initialised for each individual analog input by calling Cos404_AI_DefaultConfiguration() prior to CosMgrStart(). The order of function calls is important because CosMgrStart() may overwrite parameters of the analog input module in case values have been stored in non-volatile memory (refer to object 1010h).
The values for AI status and AI field value are provided to the module by calling Cos404_AI_SetFieldValue().
The field value will be scaled according to the scaling parameters defined via index 6126h and 6127h. Additionally, the user can provide a pointer to a scale handler during initialisation that will be called to scale the field value.
Data Structures | |
| struct | Cos404_AI_Config_s |
| struct | Cos404_AI_FilterParm_s |
| struct | Cos404_AI_ProcessData_s |
Macros | |
| #define | COS_DS404_AI_FV_REAL32_OFF (float)(0.0) |
| #define | COS_DS404_AI_PV_REAL32_OFF (float)(0.0) |
| #define | COS_DS404_AI_FV_INT16_OFF (int16_t)(0) |
| #define | COS_DS404_AI_PV_INT16_OFF (int16_t)(0) |
| #define | COS_DS404_AI_FV_INT32_OFF (int32_t)(0) |
| #define | COS_DS404_AI_PV_INT32_OFF (int32_t)(0) |
| #define | COS_DS404_AI_TARE_SIGNATURE 0x65726174 |
| #define | COS_DS404_AI_FILTER_MOV_AV 0 |
| #define | COS_DS404_AI_FILTER_REP_AV 0 |
Typedefs | |
| typedef uint8_t(* | Cos404AiOpMode_fn) (uint8_t ubChannelV, uint8_t ubModeV) |
| typedef uint8_t(* | Cos404AiSensorType_fn) (uint8_t ubChannelV, uint16_t uwSensorTypeV) |
| typedef int32_t(* | Cos404AiFilter_fn) (uint8_t ubChannelV, int32_t slValueV, uint8_t ubFilterTypeV) |
| typedef uint8_t(* | Cos404AiFilterUpdate_fn) (uint8_t ubChannelV, uint8_t ubFilterTypeV, uint16_t uwFilterConstantV) |
| typedef int32_t(* | Cos404AiLinearisation_fn) (uint8_t ubChannelV, int32_t slValueV, uint16_t uwSensorTypeV) |
| typedef void(* | Cos404AiStatusUpdate_fn) (uint8_t ubChannelV, uint8_t ubStatusV) |
Functions | |
| Cos404_AI_Config_ts * | Cos404_AI_DefaultConfiguration (uint8_t ubChannelV) |
| Cos404_AI_FilterParm_ts * | Cos404_AI_GetFilterParameter (uint8_t ubChannelV) |
| uint8_t | Cos404_AI_GetOperatingMode (uint8_t ubChannelV) |
| uint16_t | Cos404_AI_GetSensorType (uint8_t ubChannelV) |
| Cos404_AI_Status_te | Cos404_AI_Process (uint8_t ubChannelV) |
| uint8_t | Cos404_AI_SetDecimalDigitsPV (uint8_t ubChannelV, uint8_t ubDigitsV) |
| void | Cos404_AI_SetFieldValue (uint8_t ubChannelV, int32_t slFieldValueV, bool_t btStatusV) |
| uint8_t | Cos404_AI_SetPhysicalUnitPV (uint8_t ubChannelV, uint32_t ulPhysicalUnitV) |
| uint8_t | Cos404_AI_SetSensorType (uint8_t ubChannelV, uint16_t uwSensorTypeV) |
Variables | |
| Cos404_AI_ProcessData_ts | atsCos404_AI_ProcessDataG [] |
| #define COS_DS404_AI_FILTER_MOV_AV 0 |
Support of CiA 404 moving average filter.
| #define COS_DS404_AI_FILTER_REP_AV 0 |
Support of CiA 404 repeating average filter.
| #define COS_DS404_AI_FV_INT16_OFF (int16_t)(0) |
Definition for field value of data type int16_t when channel is disabled.
| #define COS_DS404_AI_FV_INT32_OFF (int32_t)(0) |
Definition for field value of data type int32_t when channel is disabled.
| #define COS_DS404_AI_FV_REAL32_OFF (float)(0.0) |
Definition for field value of data type float when channel is disabled.
| #define COS_DS404_AI_PV_INT16_OFF (int16_t)(0) |
Definition for process value of data type int16_t when channel is disabled.
| #define COS_DS404_AI_PV_INT32_OFF (int32_t)(0) |
Definition for process value of data type int32_t when channel is disabled.
| #define COS_DS404_AI_PV_REAL32_OFF (float)(0.0) |
Definition for process value of data type float when channel is disabled.
| #define COS_DS404_AI_TARE_SIGNATURE 0x65726174 |
Define specified 'tare' value for write access to AI tare index 6139h
| typedef int32_t(* Cos404AiFilter_fn) (uint8_t ubChannelV, int32_t slValueV, uint8_t ubFilterTypeV) |
| [in] | ubChannelV | Analog input channel |
| [in] | slValueV | Raw field value to be filtered (int32_t representation) |
| [in] | ubFilterTypeV | Active filter type (value from Cos404_AI_FilterType_e) |
Manufacturer-specific filter callback. When registered via pfnFilterEvent in Cos404_AI_Config_ts, this function is called by Cos404_AI_Process() instead of the built-in filter whenever the active filter type is one of eCOS404_AI_FILTER_TYPE_MANUFACTURER_01 to eCOS404_AI_FILTER_TYPE_MANUFACTURER_04.
The parameter ubChannelV defines the channel number, the first channel starts at eCOS404_CHANNEL_1.
| typedef uint8_t(* Cos404AiFilterUpdate_fn) (uint8_t ubChannelV, uint8_t ubFilterTypeV, uint16_t uwFilterConstantV) |
| [in] | ubChannelV | Analog input channel |
| [in] | ubFilterTypeV | New filter type (value from Cos404_AI_FilterType_e) |
| [in] | uwFilterConstantV | New filter constant (object 61A1h) |
eCosSdo_WRITE_OK on success or any other value from CosSdo_e in case of an errorEvent handler called when the filter type (object 61A0h) or filter constant (object 61A1h) is changed via SDO/USDO write access, and also during initialisation. Register via pfnFilterUpdateEvent in Cos404_AI_Config_ts.
The parameter ubChannelV defines the channel number, the first channel starts at eCOS404_CHANNEL_1.
| typedef int32_t(* Cos404AiLinearisation_fn) (uint8_t ubChannelV, int32_t slValueV, uint16_t uwSensorTypeV) |
| [in] | ubChannelV | Analog input channel |
| [in] | slValueV | Field value to be linearised |
Event handler for manufacturer-specific linearisation of the field value, called by the module during value processing. The handler can be registered during initialisation by Cos404_AI_DefaultConfiguration() for each channel.
The parameter ubChannelV defines the channel number, the first channel starts at eCOS404_CHANNEL_1.
| typedef uint8_t(* Cos404AiOpMode_fn) (uint8_t ubChannelV, uint8_t ubModeV) |
| [in] | ubChannelV | Analog input channel |
| [in] | ubModeV | Requested operating mode |
eCosSdo_WRITE_OK on success or any other value from CosSdo_e in case of an errorEvent handler which is called upon a change of operating mode, defined by parameter ubModeV. The handler can be registered during initialisation by Cos404_AI_DefaultConfiguration() for each channel.
The parameter ubChannelV defines the channel number, the first channel starts at eCOS404_CHANNEL_1.
| typedef uint8_t(* Cos404AiSensorType_fn) (uint8_t ubChannelV, uint16_t uwSensorTypeV) |
| [in] | ubChannelV | Analog input channel |
| [in] | uwSensorTypeV | Requested sensor type value |
eCosSdo_WRITE_OK on success or any other value from CosSdo_e in case of an errorEvent handler which is called upon a change of sensor type, defined by parameter uwSensorTypeV. The handler can be registered during initialisation by Cos404_AI_DefaultConfiguration() for each channel.
The parameter ubChannelV defines the channel number, the first channel starts at eCOS404_CHANNEL_1.
| typedef void(* Cos404AiStatusUpdate_fn) (uint8_t ubChannelV, uint8_t ubStatusV) |
| [in] | ubChannelV | Analog input channel |
| [in] | ubStatusV | New status value (bitmask from Cos404_AI_Status_te) |
Event handler called by Cos404_AI_Process() whenever the channel status (object 6150h) changes. Register via pfnStatusUpdateEvent in Cos404_AI_Config_ts to react to overload, error-limit, or validity transitions without polling the status object.
The parameter ubChannelV defines the channel number, the first channel starts at eCOS404_CHANNEL_1.
Values for AI Filter type from CiA 404, object 61A0h
| Enumerator | |
|---|---|
| eCOS404_AI_FILTER_TYPE_NONE | No filter — field value is passed through unchanged. |
| eCOS404_AI_FILTER_TYPE_MOVING_AVERAGE | Moving average filter. Requires |
| eCOS404_AI_FILTER_TYPE_REPEATING_AVERAGE | Repeating average filter. Requires |
| eCOS404_AI_FILTER_TYPE_MANUFACTURER_01 | Manufacturer-specific filter type 1. Handled by |
| eCOS404_AI_FILTER_TYPE_MANUFACTURER_02 | Manufacturer-specific filter type 2. Handled by |
| eCOS404_AI_FILTER_TYPE_MANUFACTURER_03 | Manufacturer-specific filter type 3. Handled by |
| eCOS404_AI_FILTER_TYPE_MANUFACTURER_04 | Manufacturer-specific filter type 4. Handled by |
| enum Cos404_AI_OpMode_e |
Values for AI Sensor Types corresponding to CiA 404, object 6110
| enum Cos404_AI_Status_te |
Values for AI Status from CiA 404, object 6150h
| Cos404_AI_Config_ts * Cos404_AI_DefaultConfiguration | ( | uint8_t | ubChannelV | ) |
| [in] | ubChannelV | Analog input channel, starting at eCOS404_CHANNEL_1, maximum value is defined by COS_DS404_AI |
This function is called during initialisation of an analog input channel defined by ubChannelV. It returns a pointer to a static default configuration of type Cos404_AI_Config_ts for that channel.
| Cos404_AI_FilterParm_ts * Cos404_AI_GetFilterParameter | ( | uint8_t | ubChannelV | ) |
| [in] | ubChannelV | Analog input channel, starting at eCOS404_CHANNEL_1, maximum value is defined by COS_DS404_AI |
NULL in case of an invalid channel parameter.This function returns a pointer to the filter parameter structure of the analog input channel defined by ubChannelV. The structure provides read access to the active filter type (object 61A0h) and filter constant (object 61A1h), as well as the internal filter state data used by the filter implementation.
This function is only available if COS_DS404_AI_FILTER is greater than 0.
| uint8_t Cos404_AI_GetOperatingMode | ( | uint8_t | ubChannelV | ) |
| [in] | ubChannelV | Analog input channel |
Cos404_AI_OpMode_e enumeration. In case of a wrong channel parameter or a not fully initialised channel the return value is eCOS404_AI_OP_MODE_OFF .This function returns the currently active operating mode of the analog input channel defined by ubChannelV (object 6112h).
| uint16_t Cos404_AI_GetSensorType | ( | uint8_t | ubChannelV | ) |
| [in] | ubChannelV | Analog input channel |
Cos404_AI_SensorType_e enumeration. In case of a wrong channel parameter or a not fully initialised channel the return value is eCOS404_AI_ST_UNKNOWN .This function returns the currently active sensor type of the analog input channel defined by ubChannelV (object 6110h).
| Cos404_AI_Status_te Cos404_AI_Process | ( | uint8_t | ubChannelV | ) |
Execute one analog input processing step for the given channel.
| [in] | ubChannelV | Analog input channel |
Cos404_AI_Status_te)This function runs the complete CiA 404 AI processing pipeline for the channel defined by ubChannelV: linearisation (if pfnLinearisationEvent is registered), filter (object 61A0h), scaling via factor (6126h) and offset (6127h), tare subtraction (object 9138h), and finally span and error-limit checking with status update (object 6150h).
The function must be called from the application after Cos404_AI_SetFieldValue() has provided a new raw field value. Refer to Analog value processing for an example.
| uint8_t Cos404_AI_SetDecimalDigitsPV | ( | uint8_t | ubChannelV, |
| uint8_t | ubDigitsV ) |
| [in] | ubChannelV | Analog input channel |
| [in] | ubDigitsV | Number of decimal digits |
This function should be called by application at change of sensor type to define number of decimal digits of provided process value.
| void Cos404_AI_SetFieldValue | ( | uint8_t | ubChannelV, |
| int32_t | slFieldValueV, | ||
| bool_t | btStatusV ) |
| [in] | ubChannelV | Analog input channel |
| [in] | slFieldValueV | 32 bit value, that represent RAW value for example of an ADC |
| [in] | btStatusV | true if the analog input values are valid (normal operation), false if not valid (sensor error, channel disabled, etc.) |
This function sets the field value (index x100h) slFieldValueV and the input status (index 6150h) ubStatusV for the analog input channel defined by ubChannelV.
The function updates the objects for all supported data types (refer to COS_DS404_DT_INT16, COS_DS404_DT_INT32 and COS_DS404_DT_FLOAT).
Please refer to the section Analog value processing for an example.
| uint8_t Cos404_AI_SetPhysicalUnitPV | ( | uint8_t | ubChannelV, |
| uint32_t | ulPhysicalUnitV ) |
| [in] | ubChannelV | Analog input channel |
| [in] | ulPhysicalUnitV | Physical unit of the process value |
This function should be called by the application when the sensor type changes, to define the corresponding physical unit of the process value.
The cos890.h contains the COS890_PHYSICAL_UNIT() macro and Cos890_SI_Unit_e to set up this value.
| uint8_t Cos404_AI_SetSensorType | ( | uint8_t | ubChannelV, |
| uint16_t | uwSensorTypeV ) |
| [in] | ubChannelV | Analog input channel |
| [in] | uwSensorTypeV | Sensor type |
This function changes the sensor type for the given input channel ubChannelV to the values defined by parameter uwSensorTypeV. Valid values for sensor type are defined by enumeration Cos404_AI_SensorType_e.
|
extern |
This array holds process data values that are accessible via SDO and PDO. It is declared as a global variable to allow PDO mapping.