![]() |
CANopen Slave Protocol Stack
Version 7.08.00
|
The purpose of encoders is to detect positions of any kind of machine tools. Encoders detect positions and transmit the position values across the CANopen network. Optionally the encoder may provide speed, acceleration, and jerk values. The encoder may receive configuration information via SDO, e.g. conversion parameters for calculating an - to the application adapted - position value. In the NMT state operational, the position value may be transmitted by synchronous PDO. Additionally, the encoders may transmit asynchronously a PDO scheduled by the elapsing of the event timer.
The CANopen device profile defines two encoder classes, a standard device class 1 (C1) and an extended device class 2 (C2). The standard device C1 specifies basic functionality, which shall be provided by each device. The C2 extended device provides a variety of features with mandatory and optional functions. The mandatory functions of both, C1 and C2, are necessary to ensure non-manufacturer specific operations of a device.
By defining mandatory device characteristics in C1, basic network and encoder operation is guaranteed. By defining extended C2, a degree of defined flexibility may be built in. By leaving hooks for optional and manufacturer-specific functionality, the device developer will not be constrained to an out-of-date standard.
The module adds the following objects to the object dictionary:
| Index | Description | Function / Variable | Configuration Symbol |
|---|---|---|---|
| 6000h | Operating parameters | Cos406_Idx6000() | - |
| 6001h | Measuring units per revolution | Cos406_Idx6001() | COS_DS406 |
| 6002h | Total measuring range in measuring units | Cos406_Idx6002() | - |
| 6003h | Preset value | Cos406_Idx6003() | - |
| 6004h | Position value | ulIdx6004_PosValueG | - |
| 6005h | Linear encoder measuring step settings | Cos406_Idx6005() | - |
| 6030h | Speed value | Cos406_Idx6030() | - |
| 6040h | Acceleration value | Cos406_Idx6040() | - |
| 6050h | Jerk value | Cos406_Idx6050() | - |
| 6200h | Cyclic timer | Cos406_Idx6200() | - |
| 6500h | Operating status | Cos406_Idx6500() | - |
| 6501h | Single-turn resolution / measuring step | Cos406_Idx6501() | - |
| 6502h | Number of distinguishable revolutions | Cos406_Idx6502() | - |
| 6503h | Alarms | Cos406_Idx6503() | - |
| 6504h | Supported alarms | Cos406_Idx6504() | DS406_SUPPORTED_ALARMS |
| 6505h | Warnings | Cos406_Idx6505() | - |
| 6506h | Supported warnings | Cos406_Idx6506() | DS406_SUPPORTED_WARNINGS |
| 6507h | Profile and software version | Cos406_Idx6507() | DS406_PROFILE_VERSION |
| 6508h | Operating time | Cos406_Idx6508() | - |
| 6509h | Offset value | Cos406_Idx6509() | - |
| 650Ah | Module identification | Cos406_Idx650A() | - |
| 650Bh | Serial number | Cos406_Idx650B() | - |
The module is enabled by setting COS_DS406 in the application cos_conf.h:
| Value | Encoder class | Effect |
|---|---|---|
| 1 | Single-turn | Basic position, speed, acceleration, and status objects |
| 2 | Multi-turn | Adds multi-turn position scaling |
Optional tuneable constants:
Macros | |
| #define | DS406_PROFILE_VERSION 0x0400U |
| #define | DS406_SUPPORTED_ALARMS 0x0001U |
| #define | DS406_SUPPORTED_WARNINGS 0x0002U |
| #define | DS406_RESOLUTION_SINGLE_TURN 16384U |
| #define | DS406_RESOLUTION_MULTI_TURN_32 0x01FFFFFFU |
| #define | MAN_OFFSET_VALUE 0x00000000 |
| #define | MAN_MINPOS_VALUE 0x00000000 |
| #define | MAN_MAXPOS_VALUE 0x00003FFF |
| #define | COS_DS406_VERSION_MAJOR 4 |
| #define | COS_DS406_VERSION_MINOR 2 |
Enumerations | |
| enum | DS406_OPER_STATUS_e |
| enum | DS406_ALARM_e |
| enum | DS406_WARN_e |
Functions | |
| void | Cos406_SetAlarms (uint16_t uwAlarmsV) |
| void | Cos406_SetEncoderValue (uint32_t ulSgTurnV, uint32_t ulMtTurnV, uint32_t ulTimeDiffV) |
| void | Cos406_SetOperatingStatus (uint16_t uwStatusV) |
| void | Cos406_SetOperatingTime (uint32_t ulTimeV) |
| void | Cos406_SetWarnings (uint16_t uwWarningsV) |
| enum DS406_ALARM_e |
Alarm bits for object 6503h (CiA 406 Table 144). An alarm indicates a malfunction that may lead to an incorrect position value; the bit stays set until the encoder can again provide a valid position. Bits 0 and 1 are mandatory for class C3 encoders. Use Cos406_SetAlarms() to update the active alarms.
| enum DS406_OPER_STATUS_e |
Operating status bits for object 6500h (CiA 406 Table 137). This object reflects the active encoder configuration as set by object 6000h. Use Cos406_SetOperatingStatus() to update the operating status.
| enum DS406_WARN_e |
Warning bits for object 6505h (CiA 406 Table 150). Warnings indicate that tolerances for internal encoder parameters have been exceeded, but do not imply an incorrect position value. All warning bits clear automatically when the parameter returns to its nominal range, except eWARN_OTLW which is latched until the next power-on. Bits are mandatory for C3, optional for C1 and C2. Use Cos406_SetWarnings() to update active warnings.
| void Cos406_SetAlarms | ( | uint16_t | uwAlarmsV | ) |
| [in] | uwAlarmsV | OR-combination of DS406_ALARM_e bits |
Sets the encoder alarm word returned by SDO read of object 6503h. Call this function whenever an alarm condition is detected or cleared.
| void Cos406_SetEncoderValue | ( | uint32_t | ulSgTurnV, |
| uint32_t | ulMtTurnV, | ||
| uint32_t | ulTimeDiffV ) |
| [in] | ulSgTurnV | current single-turn encoder count |
| [in] | ulMtTurnV | current multi-turn revolution count (ignored for single-turn configuration) |
| [in] | ulTimeDiffV | elapsed time since the previous call, in multiples of 1 ns; pass 0 to update the position without recalculating the speed |
Updates the scaled position value (object 6004h) from the raw encoder counts on every call. The speed value (object 6030h) is recalculated only when ulTimeDiffV > 0; if 0 is passed the speed retains its value from the previous call.
Call this function from the encoder hardware ISR or a periodic task whenever new encoder values are available from the hardware.
| void Cos406_SetOperatingStatus | ( | uint16_t | uwStatusV | ) |
| [in] | uwStatusV | OR-combination of DS406_OPER_STATUS_e bits |
Sets the encoder operating status word returned by SDO read of object 6500h.
| void Cos406_SetOperatingTime | ( | uint32_t | ulTimeV | ) |
| [in] | ulTimeV | accumulated operating time in multiples of 0.1 h; pass 0xFFFFFFFFU if the function is not available |
Sets the encoder operating time counter returned by SDO read of object 6508h. Update this value periodically from a real-time clock or an elapsed-time counter.
| void Cos406_SetWarnings | ( | uint16_t | uwWarningsV | ) |
| [in] | uwWarningsV | OR-combination of DS406_WARN_e bits |
Sets the encoder warning word returned by SDO read of object 6505h. Call this function whenever a warning condition is detected or cleared.