File syn_cia402.h¶
FileList > proto > syn_cia402.h
Go to the source code of this file
CANopen CiA 402 Device Profile for Drives and Motion Control. More...
#include "../common/syn_defs.h"#include "syn_canopen.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_CIA402_Axis CiA 402 Axis Instance. |
| struct | SYN_CIA402_Config CiA 402 axis configuration parameters. |
| struct | SYN_CIA402_Setpoints CiA 402 motion controller setpoint outputs for motor loop / FOC. |
Public Types¶
| Type | Name |
|---|---|
| enum | SYN_CIA402_Mode CiA 402 operation modes. |
| enum | SYN_CIA402_State CiA 402 Finite State Machine state enumeration. |
| typedef SYN_CIA402_Config | SYN_CiA402Config |
| typedef SYN_CIA402_Axis | SYN_CiA402Drive |
| typedef SYN_CIA402_State | SYN_CiA402State |
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_cia402_feed_feedback (SYN_CIA402_Axis * axis, int32_t pos_actual, int32_t vel_actual, int16_t torque_actual) Feed measured actual values (encoder position, velocity, torque) to axis. |
| uint16_t | syn_cia402_get_controlword (const SYN_CIA402_Axis * axis) Read current Controlword (Index 0x6040). |
| int8_t | syn_cia402_get_mode (const SYN_CIA402_Axis * axis) Get requested Mode of Operation (Index 0x6060). |
| int8_t | syn_cia402_get_mode_display (const SYN_CIA402_Axis * axis) Get active Mode of Operation Display (Index 0x6061). |
| SYN_CIA402_State | syn_cia402_get_state (const SYN_CIA402_Axis * axis) Get current FSM state. |
| uint16_t | syn_cia402_get_statusword (const SYN_CIA402_Axis * axis) Read current Statusword (Index 0x6041). |
| SYN_Status | syn_cia402_init (SYN_CIA402_Axis * axis, const SYN_CIA402_Config * cfg) Initialize CiA 402 Axis controller. |
| size_t | syn_cia402_populate_od (SYN_CANOpenODEntry * od_table, size_t max_entries, SYN_CIA402_Axis * axis) Populate a CANopen Object Dictionary table with standard CiA 402 objects. |
| SYN_Status | syn_cia402_report_actuals (SYN_CIA402_Axis * axis, int32_t pos_actual, int32_t vel_actual, int16_t torque_actual) Feed measured actual values alias for compatibility. |
| SYN_Status | syn_cia402_set_controlword (SYN_CIA402_Axis * axis, uint16_t cw) Set Controlword (Index 0x6040) from master / RPDO / SDO. |
| SYN_Status | syn_cia402_set_mode (SYN_CIA402_Axis * axis, int8_t mode) Request Mode of Operation (Index 0x6060). |
| SYN_Status | syn_cia402_set_target_position (SYN_CIA402_Axis * axis, int32_t pos) Set target position (Index 0x607A). |
| SYN_Status | syn_cia402_set_target_torque (SYN_CIA402_Axis * axis, int16_t torque) Set target torque (Index 0x6071). |
| SYN_Status | syn_cia402_set_target_velocity (SYN_CIA402_Axis * axis, int32_t vel) Set target velocity (Index 0x60FF). |
| SYN_Status | syn_cia402_step (SYN_CIA402_Axis * axis, uint32_t dt_us, SYN_CIA402_Setpoints * out_setpoints) Execute periodic CiA 402 control loop step in microseconds. |
| SYN_Status | syn_cia402_trigger_fault (SYN_CIA402_Axis * axis, uint16_t error_code) Trigger a drive fault and enter FAULT_REACTION_ACTIVE / FAULT state. |
| SYN_Status | syn_cia402_update (SYN_CIA402_Axis * axis, uint32_t dt_ms) Periodic motion update in milliseconds. |
Macros¶
Detailed Description¶
Implements a zero-heap, deterministic CiA 402 Drive Finite State Machine (Controlword 0x6040 / Statusword 0x6041), Motion Modes of Operation (PP, PV, PT, HM, CSP, CSV, CST), trapezoidal trajectory generation, following error supervision, and standard CANopen Object Dictionary binding.
Public Types Documentation¶
enum SYN_CIA402_Mode¶
CiA 402 operation modes.
enum SYN_CIA402_Mode {
SYN_CIA402_MODE_NO_MODE = 0,
SYN_CIA402_MODE_PROFILE_POSITION = 1,
SYN_CIA402_MODE_PP = 1,
SYN_CIA402_MODE_PROFILE_VELOCITY = 3,
SYN_CIA402_MODE_PV = 3,
SYN_CIA402_MODE_PROFILE_TORQUE = 4,
SYN_CIA402_MODE_PT = 4,
SYN_CIA402_MODE_HOMING = 6,
SYN_CIA402_MODE_HM = 6,
SYN_CIA402_MODE_CYCLIC_SYNC_POSITION = 8,
SYN_CIA402_MODE_CSP = 8,
SYN_CIA402_MODE_CYCLIC_SYNC_VELOCITY = 9,
SYN_CIA402_MODE_CSV = 9,
SYN_CIA402_MODE_CYCLIC_SYNC_TORQUE = 10,
SYN_CIA402_MODE_CST = 10
};
enum SYN_CIA402_State¶
CiA 402 Finite State Machine state enumeration.
enum SYN_CIA402_State {
SYN_CIA402_STATE_NOT_READY_TO_SWITCH_ON = 0,
SYN_CIA402_STATE_NOT_READY = 0,
SYN_CIA402_STATE_SWITCH_ON_DISABLED = 1,
SYN_CIA402_STATE_READY_TO_SWITCH_ON = 2,
SYN_CIA402_STATE_SWITCHED_ON = 3,
SYN_CIA402_STATE_OPERATION_ENABLED = 4,
SYN_CIA402_STATE_QUICK_STOP_ACTIVE = 5,
SYN_CIA402_STATE_FAULT_REACTION_ACTIVE = 6,
SYN_CIA402_STATE_FAULT = 7
};
typedef SYN_CiA402Config¶
Alias for SYN_CIA402_Config for backwards-compatibility.
typedef SYN_CiA402Drive¶
Alias for SYN_CIA402_Axis for backwards-compatibility.
typedef SYN_CiA402State¶
Alias for SYN_CIA402_State for backwards-compatibility.
Public Functions Documentation¶
function syn_cia402_feed_feedback¶
Feed measured actual values (encoder position, velocity, torque) to axis.
SYN_Status syn_cia402_feed_feedback (
SYN_CIA402_Axis * axis,
int32_t pos_actual,
int32_t vel_actual,
int16_t torque_actual
)
Parameters:
axisAxis instance.pos_actualActual position (counts).vel_actualActual velocity (counts/s).torque_actualActual torque (0.1% rated).
Returns:
SYN_OK on success, SYN_INVALID_PARAM on NULL.
function syn_cia402_get_controlword¶
Read current Controlword (Index 0x6040).
Parameters:
axisAxis instance.
Returns:
Controlword value (0 on NULL).
function syn_cia402_get_mode¶
Get requested Mode of Operation (Index 0x6060).
Parameters:
axisAxis instance.
Returns:
Mode of operation.
function syn_cia402_get_mode_display¶
Get active Mode of Operation Display (Index 0x6061).
Parameters:
axisAxis instance.
Returns:
Mode of operation display.
function syn_cia402_get_state¶
Get current FSM state.
Parameters:
axisAxis instance.
Returns:
Current FSM state.
function syn_cia402_get_statusword¶
Read current Statusword (Index 0x6041).
Parameters:
axisAxis instance.
Returns:
Statusword value (0 on NULL).
function syn_cia402_init¶
Initialize CiA 402 Axis controller.
Parameters:
axisAxis instance.cfgInitial configuration parameters.
Returns:
SYN_OK on success, SYN_INVALID_PARAM on NULL parameters.
function syn_cia402_populate_od¶
Populate a CANopen Object Dictionary table with standard CiA 402 objects.
size_t syn_cia402_populate_od (
SYN_CANOpenODEntry * od_table,
size_t max_entries,
SYN_CIA402_Axis * axis
)
Binds 0x6040 (Controlword), 0x6041 (Statusword), 0x6060..0x60FF objects directly to the live fields of the given axis instance.
Parameters:
od_tableDestination array of Object Dictionary entries.max_entriesSize of od_table.axisAxis instance to bind.
Returns:
Number of entries populated (0 on error or insufficient capacity).
function syn_cia402_report_actuals¶
Feed measured actual values alias for compatibility.
SYN_Status syn_cia402_report_actuals (
SYN_CIA402_Axis * axis,
int32_t pos_actual,
int32_t vel_actual,
int16_t torque_actual
)
Parameters:
axisAxis instance.pos_actualActual position (counts).vel_actualActual velocity (counts/s).torque_actualActual torque (0.1% rated).
Returns:
SYN_OK on success, SYN_INVALID_PARAM on NULL.
function syn_cia402_set_controlword¶
Set Controlword (Index 0x6040) from master / RPDO / SDO.
Parameters:
axisAxis instance.cwControlword value.
Returns:
SYN_OK on success, SYN_INVALID_PARAM on NULL.
function syn_cia402_set_mode¶
Request Mode of Operation (Index 0x6060).
Parameters:
axisAxis instance.modeRequested mode (SYN_CIA402_MODE_*).
Returns:
SYN_OK on success, SYN_INVALID_PARAM on invalid mode.
function syn_cia402_set_target_position¶
Set target position (Index 0x607A).
Parameters:
axisAxis instance.posTarget position in counts.
Returns:
SYN_OK on success, SYN_INVALID_PARAM on NULL.
function syn_cia402_set_target_torque¶
Set target torque (Index 0x6071).
Parameters:
axisAxis instance.torqueTarget torque in 0.1% rated torque.
Returns:
SYN_OK on success, SYN_INVALID_PARAM on NULL.
function syn_cia402_set_target_velocity¶
Set target velocity (Index 0x60FF).
Parameters:
axisAxis instance.velTarget velocity in counts/s.
Returns:
SYN_OK on success, SYN_INVALID_PARAM on NULL.
function syn_cia402_step¶
Execute periodic CiA 402 control loop step in microseconds.
SYN_Status syn_cia402_step (
SYN_CIA402_Axis * axis,
uint32_t dt_us,
SYN_CIA402_Setpoints * out_setpoints
)
Evaluates state machine transitions, computes motion ramps, performs following error supervision, updates Statusword, and outputs motor setpoints.
Parameters:
axisAxis instance.dt_usTime elapsed since last step in microseconds.out_setpointsOutput setpoint commands (may be NULL if not needed).
Returns:
SYN_OK on success, error code on failure.
function syn_cia402_trigger_fault¶
Trigger a drive fault and enter FAULT_REACTION_ACTIVE / FAULT state.
Parameters:
axisAxis instance.error_codeFault error code (e.g. overcurrent, limit tripped, tracking error).
Returns:
SYN_OK on success, SYN_INVALID_PARAM on NULL.
function syn_cia402_update¶
Periodic motion update in milliseconds.
Parameters:
axisAxis instance.dt_msTime delta in milliseconds.
Returns:
SYN_OK on success, SYN_INVALID_PARAM on NULL.
Macro Definition Documentation¶
define SYN_CIA402_CW_CHANGE_IMMEDIATELY¶
Bit 5: Change Set-point Immediately (PP) \
define SYN_CIA402_CW_CHANGE_ON_SETPOINT¶
Bit 9: Change on Set-point (PP)
define SYN_CIA402_CW_ENABLE_OPERATION¶
Bit 3: Enable Operation
define SYN_CIA402_CW_ENABLE_VOLTAGE¶
Bit 1: Enable Voltage
define SYN_CIA402_CW_FAULT_RESET¶
Bit 7: Fault Reset (0 -> 1 rising edge)
define SYN_CIA402_CW_HALT¶
Bit 8: Halt axis
define SYN_CIA402_CW_NEW_SETPOINT¶
Bit 4: New Set-point (PP) / Start Homing (HM)
define SYN_CIA402_CW_QUICK_STOP¶
Bit 2: Quick Stop (active low: 0=stop)
define SYN_CIA402_CW_RELATIVE¶
Bit 6: Relative Positioning (PP: 0=Abs, 1=Rel)
define SYN_CIA402_CW_SWITCH_ON¶
Bit 0: Switch On
define SYN_CIA402_OD_CONTROLWORD¶
Controlword (U16)
define SYN_CIA402_OD_FOLLOWING_ERROR_WINDOW¶
Following Error Window (U32)
define SYN_CIA402_OD_HOMING_ACCELERATION¶
Homing Acceleration (U32)
define SYN_CIA402_OD_HOMING_METHOD¶
Homing Method (I8)
define SYN_CIA402_OD_HOMING_SPEED_FAST¶
Homing Speed Switch (U32)
define SYN_CIA402_OD_HOMING_SPEED_SLOW¶
Homing Speed Zero (U32)
define SYN_CIA402_OD_MAX_TORQUE¶
Max Torque (U16, 0.1% rated)
define SYN_CIA402_OD_MODES_OF_OPERATION¶
Modes of Operation (I8)
define SYN_CIA402_OD_MODES_OF_OPERATION_DISPLAY¶
Modes of Operation Display (I8)
define SYN_CIA402_OD_POSITION_ACTUAL_VALUE¶
Position Actual Value (I32)
define SYN_CIA402_OD_POSITION_DEMAND_VALUE¶
Position Demand Value (I32)
define SYN_CIA402_OD_POSITION_WINDOW¶
Position Window (U32)
define SYN_CIA402_OD_PROFILE_ACCELERATION¶
Profile Acceleration (U32)
define SYN_CIA402_OD_PROFILE_DECELERATION¶
Profile Deceleration (U32)
define SYN_CIA402_OD_PROFILE_VELOCITY¶
Profile Velocity (U32)
define SYN_CIA402_OD_QUICK_STOP_DECELERATION¶
Quick Stop Deceleration (U32)
define SYN_CIA402_OD_QUICK_STOP_OPTION¶
Quick Stop Option Code (I16)
define SYN_CIA402_OD_SOFTWARE_POS_LIMIT_MAX¶
Software Position Limit Max (I32)
define SYN_CIA402_OD_SOFTWARE_POS_LIMIT_MIN¶
Software Position Limit Min (I32)
define SYN_CIA402_OD_STATUSWORD¶
Statusword (U16)
define SYN_CIA402_OD_TARGET_POSITION¶
Target Position (I32)
define SYN_CIA402_OD_TARGET_TORQUE¶
Target Torque (I16, 0.1% rated)
define SYN_CIA402_OD_TARGET_VELOCITY¶
Target Velocity (I32)
define SYN_CIA402_OD_TORQUE_ACTUAL_VALUE¶
Torque Actual Value (I16)
define SYN_CIA402_OD_TORQUE_SLOPE¶
Torque Slope (U32, units/s)
define SYN_CIA402_OD_VELOCITY_ACTUAL_VALUE¶
Velocity Actual Value (I32)
define SYN_CIA402_SW_FAULT¶
Bit 3: Fault Active
define SYN_CIA402_SW_FOLLOWING_ERROR¶
Bit 13: Following Error Active (PP)
define SYN_CIA402_SW_HOMING_ATTAINED¶
Bit 12: Homing Attained (HM)
define SYN_CIA402_SW_HOMING_ERROR¶
Bit 13: Homing Error (HM)
define SYN_CIA402_SW_INTERNAL_LIMIT¶
Bit 11: Internal / Software Limit Active
define SYN_CIA402_SW_MANUFACTURER_8¶
Bit 8: Manufacturer Specific
define SYN_CIA402_SW_OPERATION_ENABLED¶
Bit 2: Operation Enabled
define SYN_CIA402_SW_QUICK_STOP¶
Bit 5: Quick Stop Inactive (1=normal, 0=quick stop)
define SYN_CIA402_SW_READY_TO_SWITCH_ON¶
Bit 0: Ready to Switch On
define SYN_CIA402_SW_REMOTE¶
Bit 9: Remote Control Active
define SYN_CIA402_SW_SETPOINT_ACK¶
Bit 12: Setpoint Acknowledge (PP)
define SYN_CIA402_SW_SPEED_ZERO¶
Bit 12: Speed 0 (PV)
define SYN_CIA402_SW_SWITCHED_ON¶
Bit 1: Switched On
define SYN_CIA402_SW_SWITCH_ON_DISABLED¶
Bit 6: Switch On Disabled
define SYN_CIA402_SW_TARGET_REACHED¶
Bit 10: Target Position / Velocity Reached
define SYN_CIA402_SW_VOLTAGE_ENABLED¶
Bit 4: Power Stage Voltage Enabled
define SYN_CIA402_SW_WARNING¶
Bit 7: Drive Warning
The documentation for this class was generated from the following file src/syntropic/proto/syn_cia402.h