|
CANopen Slave Documentation
Version 7.00.02
|
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:
| Index | Description | Function / Variable | Configuration Symbol |
|---|---|---|---|
| 6100h | AI input FV (float) | Cos404_AI_SetFV_Real32() | COS_DS404_DT_FLOAT |
| 6110h | AI sensor type | Cos404_AI_Init() | - |
| 6112h | AI operating mode | Cos404_AI_Init() | - |
| 6126h | AI scaling factor | - | COS_DS404_AI_SCALING |
| 6127h | AI scaling offset | - | COS_DS404_AI_SCALING |
| 6130h | AI input PV (float) | Cos404_AI_SetFV_Real32() | COS_DS404_DT_FLOAT |
| 6131h | AI physical unit PV | Cos404_AI_SetPhysicalUnitPV() | - |
| 6132h | AI decimal digits PV | Cos404_AI_SetDecimalDigitsPV() | - |
| 6150h | AI status | Cos404_AI_SetFV_Int16() | - |
| 61A0h | AI filter type | #Cos404_AI_FilterParm_ts | COS_DS404_AI_FILTER |
| 61A1h | AI filter constant | Cos404_AI_FilterParm_ts | COS_DS404_AI_FILTER |
| 7100h | AI input FV (int16_t) | Cos404_AI_SetFV_Int16() | COS_DS404_DT_INT16 |
| 7130h | AI input PV (int16_t) | Cos404_AI_SetFV_Int16() | COS_DS404_DT_INT16 |
| 9100h | AI input FV (int32_t) | Cos404_AI_SetFV_Int32() | COS_DS404_DT_INT32 |
| 9130h | AI input PV (int32_t) | Cos404_AI_SetFV_Int32() | COS_DS404_DT_INT32 |
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 initialized for each individual analog input by calling by calling Cos404_AI_Init() prior to CosMgrStart(). The order of function calls is important because CosMgrStart() may overwrite parameters of the analog input module in case a values have been stored in non-volatile memory (refer to object 1010h).
The values for AI status, Ai field value and AI process value are provided to the module by calling Cos404_AI_SetFV_Int16() or the corresponding function for data type int32_t or float.
Include dependency graph for cos404ai.h:Data Structures | |
| struct | Cos404_AI_Config_s |
| struct | Cos404_AI_ProcessData_s |
Typedefs | |
| typedef void(* | Cos404AiEvent_fn) (uint8_t ubChannelV) |
| typedef uint8_t(* | Cos404AiHandler_fn) (uint8_t ubInputV, void *pvdDataV) |
Functions | |
| uint8_t | Cos404_AI_GetOperatingMode (uint8_t ubChannelV) |
| uint16_t | Cos404_AI_GetSensorType (uint8_t ubChannelV) |
| void | Cos404_AI_Init (uint8_t ubChannelV, Cos404_AI_Config_ts *ptsConfigurationV) |
| uint8_t | Cos404_AI_SetDecimalDigitsPV (uint8_t ubChannelV, uint8_t ubDigitsV) |
| uint8_t | Cos404_AI_SetPhysicalUnitPV (uint8_t ubChannelV, uint32_t ulPhysicalUnitV) |
| void | Cos404_AI_SetFV_Int16 (uint8_t ubChannelV, uint8_t ubStatusV, int16_t swFieldValueV, int16_t swProcessValueV) |
| void | Cos404_AI_SetFV_Int32 (uint8_t ubChannelV, uint8_t ubStatusV, int32_t slFieldValueV, int32_t slProcessValueV) |
| void | Cos404_AI_SetFV_Real32 (uint8_t ubChannelV, uint8_t ubStatusV, int32_t slFieldValueV, float ftProcessValueV) |
Variables | |
| Cos404_AI_ProcessData_ts | atsCos404_AI_ProcessDataG [] |
| typedef void(* Cos404AiEvent_fn) (uint8_t ubChannelV) |
| [in] | ubChannelV | Analog input channel |
An event handler can be registered during initialization by Cos404_AI_Init() for each channel. Supported events are:
The parameter ubChannelV defines the channel number, the first channel starts at eCOS404_CHANNEL_1.
| typedef uint8_t(* Cos404AiHandler_fn) (uint8_t ubInputV, void *pvdDataV) |
| [in] | ubChannelV | Analog input channel |
| [in] | pvdDataV | Pointer to handler specific data |
eCosSdo_WRITE_OK on success or any other value from CosSdo_e in case of an errorA data handler can be registered during initialization by Cos404_AI_Init() for each channel. Supported handlers are:
The parameter ubChannelV defines the channel number, the first channel starts at eCOS404_CHANNEL_1. The data contents of pointer pvdDataV is specific for every handler.
| enum Cos404_AI_OpMode_e |
Values for AI Sensor Types corresponding to CiA 404, object 6110
| enum Cos404_AI_Status_e |
Values for AI Status from CiA 404, object 6150h
| uint8_t Cos404_AI_GetOperatingMode | ( | uint8_t | ubChannelV | ) |
Get pending operating mode of a channel.
| [in] | ubChannelV | Analog input channel |
Cos404_AI_OpMode_e enumeration. In case of wrong channel parameter or not fully initialised channel the return value is eCOS404_AI_OP_MODE_OFF . | uint16_t Cos404_AI_GetSensorType | ( | uint8_t | ubChannelV | ) |
Get pending sensor type of a channel.
| [in] | ubChannelV | Analog input channel |
Cos404_AI_SensorType_e enumeration. In case of wrong channel parameter or not fully initialised channel the return value is eCOS404_AI_ST_UNKNOWN . | void Cos404_AI_Init | ( | uint8_t | ubChannelV, |
| Cos404_AI_Config_ts * | ptsConfigurationV ) |
| [in] | ubChannelV | Analog input channel |
| [in] | ptsConfigurationV | Pointer to memory with configuration data of struct Cos404_AI_Config_ts |
This function performs an initialization of the analog input channel defined by ubChannelV, the value for the parameter starts at eCOS404_CHANNEL_1 and is limited by the definition of COS_DS404_AI. The parameter ptsConfigurationV is a pointer to the configuration structure Cos404_AI_Config_ts.
Please refer to the section Module Initialization for an example.
CosMgrStart() function. | 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_SetFV_Int16 | ( | uint8_t | ubChannelV, |
| uint8_t | ubStatusV, | ||
| int16_t | swFieldValueV, | ||
| int16_t | swProcessValueV ) |
| [in] | ubChannelV | Analog input channel |
| [in] | ubStatusV | Status of analog input values, provided by Cos404_AI_Status_e |
| [in] | swFieldValueV | 16-bit field value |
| [in] | swProcessValueV | 16-bit process value |
This function converts the field value swFieldValueV and process value swProcessValueV to a float representation and calls Cos404_AI_SetFV_Real32().
| void Cos404_AI_SetFV_Int32 | ( | uint8_t | ubChannelV, |
| uint8_t | ubStatusV, | ||
| int32_t | slFieldValueV, | ||
| int32_t | slProcessValueV ) |
| [in] | ubChannelV | Analog input channel |
| [in] | ubStatusV | Status of analog input values, provided by Cos404_AI_Status_e |
| [in] | slFieldValueV | 32-bit field value |
| [in] | slProcessValueV | 32-bit process value |
This function converts the field value slFieldValueV and process value slProcessValueV to a float representation and calls Cos404_AI_SetFV_Real32().
| void Cos404_AI_SetFV_Real32 | ( | uint8_t | ubChannelV, |
| uint8_t | ubStatusV, | ||
| int32_t | slFieldValueV, | ||
| float | ftProcessValueV ) |
| [in] | ubChannelV | Analog input channel |
| [in] | ubStatusV | Status of analog input values, provided by Cos404_AI_Status_e |
| [in] | slFieldValueV | 32 bit value, that represent RAW value for example of an ADC |
| [in] | ftProcessValueV | float process value, scaled value representing a physical quantity |
This function sets the field value (index x100h) slFieldValueV, the process value (index x130h) ftProcessValueV 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 application at change of sensor type to define corresponding physical unit of provided process value.
The cos303.h contains the COS303_PHYSICAL_UNIT() macro and Cos303_SI_Unit_e to setup this value.
|
extern |
This array holds processing values that can are accessed SDO and PDO. The access via PDO and possibility to map values is the reason why it is declared as a global variable.