Skip to content

File syn_cia402.h

FileList > proto > syn_cia402.h

Go to the source code of this file

CANopen CiA 402 Servo Drive & Motion Control Profile Engine. More...

  • #include "../common/syn_defs.h"
  • #include "../util/syn_scurve.h"
  • #include "syn_canopen.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_CiA402Config
Configuration parameters for CiA 402 Drive.
struct SYN_CiA402Drive
CiA 402 Drive Handle.

Public Types

Type Name
enum SYN_CiA402Mode
CiA 402 Modes of Operation (0x6060 / 0x6061)
enum SYN_CiA402State
CiA 402 Drive State Machine States.

Public Functions

Type Name
uint16_t syn_cia402_get_statusword (const SYN_CiA402Drive * drive)
Retrieve current 16-bit Statusword value.
SYN_Status syn_cia402_init (SYN_CiA402Drive * drive, const SYN_CiA402Config * cfg)
Initialize a CiA 402 Drive instance.
size_t syn_cia402_populate_od (SYN_CANOpenODEntry * entries, size_t max_entries, SYN_CiA402Drive * drive)
Populate a standard CANopen Object Dictionary array with CiA 402 drive objects.
SYN_Status syn_cia402_report_actuals (SYN_CiA402Drive * drive, int32_t actual_pos, int32_t actual_vel, int16_t actual_torque)
Report actual motor feedback (position, velocity, torque).
SYN_Status syn_cia402_set_controlword (SYN_CiA402Drive * drive, uint16_t controlword)
Process new Controlword command and update drive state machine.
SYN_Status syn_cia402_set_mode (SYN_CiA402Drive * drive, int8_t mode)
Set requested Mode of Operation.
SYN_Status syn_cia402_set_target_position (SYN_CiA402Drive * drive, int32_t target_pos)
Set target position for PP or CSP mode.
SYN_Status syn_cia402_set_target_torque (SYN_CiA402Drive * drive, int16_t target_torque)
Set target torque for PT or CST mode.
SYN_Status syn_cia402_set_target_velocity (SYN_CiA402Drive * drive, int32_t target_vel)
Set target velocity for PV or CSV mode.
SYN_Status syn_cia402_trigger_fault (SYN_CiA402Drive * drive, uint16_t error_code)
Trigger a fault state in the drive.
SYN_Status syn_cia402_update (SYN_CiA402Drive * drive, uint32_t dt_ms)
Periodic motion control update step.

Macros

Type Name
define SYN_CIA402_CW_ABS_REL (1U &lt;&lt; 6)
define SYN_CIA402_CW_CHANGE_IMMED (1U &lt;&lt; 5)
define SYN_CIA402_CW_ENABLE_OP (1U &lt;&lt; 3)
define SYN_CIA402_CW_ENABLE_VOLTAGE (1U &lt;&lt; 1)
define SYN_CIA402_CW_FAULT_RESET (1U &lt;&lt; 7)
define SYN_CIA402_CW_HALT (1U &lt;&lt; 8)
define SYN_CIA402_CW_NEW_SETPOINT (1U &lt;&lt; 4)
define SYN_CIA402_CW_QUICK_STOP (1U &lt;&lt; 2)
define SYN_CIA402_CW_SWITCH_ON (1U &lt;&lt; 0)
define SYN_CIA402_SW_FAULT (1U &lt;&lt; 3)
define SYN_CIA402_SW_INTERNAL_LIMIT (1U &lt;&lt; 11)
define SYN_CIA402_SW_OPERATION_ENABLED (1U &lt;&lt; 2)
define SYN_CIA402_SW_QUICK_STOP (1U &lt;&lt; 5)
define SYN_CIA402_SW_READY_TO_SWITCH_ON (1U &lt;&lt; 0)
define SYN_CIA402_SW_SETPOINT_ACK (1U &lt;&lt; 12)
define SYN_CIA402_SW_SWITCHED_ON (1U &lt;&lt; 1)
define SYN_CIA402_SW_SWITCH_ON_DISABLED (1U &lt;&lt; 6)
define SYN_CIA402_SW_TARGET_REACHED (1U &lt;&lt; 10)
define SYN_CIA402_SW_VOLTAGE_ENABLED (1U &lt;&lt; 4)
define SYN_CIA402_SW_WARNING (1U &lt;&lt; 7)

Detailed Description

Implements the standard CiA 402 power drive state machine, Controlword (0x6040) processing, Statusword (0x6041) status reporting, and motion modes of operation (Profile Position, Profile Velocity, Profile Torque, Homing, and Cyclic Synchronous Position/Velocity).

Designed to bind directly into syn_canopen Object Dictionary tables.

Public Types Documentation

enum SYN_CiA402Mode

CiA 402 Modes of Operation (0x6060 / 0x6061)

enum SYN_CiA402Mode {
    SYN_CIA402_MODE_NO_MODE = 0,
    SYN_CIA402_MODE_PP = 1,
    SYN_CIA402_MODE_PV = 3,
    SYN_CIA402_MODE_PT = 4,
    SYN_CIA402_MODE_HM = 6,
    SYN_CIA402_MODE_CSP = 8,
    SYN_CIA402_MODE_CSV = 9,
    SYN_CIA402_MODE_CST = 10
};


enum SYN_CiA402State

CiA 402 Drive State Machine States.

enum SYN_CiA402State {
    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 = 6,
    SYN_CIA402_STATE_FAULT = 7
};


Public Functions Documentation

function syn_cia402_get_statusword

Retrieve current 16-bit Statusword value.

uint16_t syn_cia402_get_statusword (
    const SYN_CiA402Drive * drive
) 

Parameters:

  • drive Pointer to drive handle.

Returns:

16-bit Statusword (0x6041), or 0 if drive is NULL.


function syn_cia402_init

Initialize a CiA 402 Drive instance.

SYN_Status syn_cia402_init (
    SYN_CiA402Drive * drive,
    const SYN_CiA402Config * cfg
) 

Parameters:

  • drive Pointer to drive handle.
  • cfg Pointer to drive configuration.

Returns:

SYN_OK on success, SYN_INVALID_PARAM if pointers are NULL.


function syn_cia402_populate_od

Populate a standard CANopen Object Dictionary array with CiA 402 drive objects.

size_t syn_cia402_populate_od (
    SYN_CANOpenODEntry * entries,
    size_t max_entries,
    SYN_CiA402Drive * drive
) 

Creates entries for 0x6040, 0x6041, 0x6060, 0x6061, 0x6064, 0x606C, 0x6071, 0x6077, 0x607A, 0x60FF.

Parameters:

  • entries Output array of SYN_CANOpenODEntry elements.
  • max_entries Maximum capacity of entries array (must be >= 10).
  • drive Pointer to drive handle.

Returns:

Number of entries populated, or 0 on error.


function syn_cia402_report_actuals

Report actual motor feedback (position, velocity, torque).

SYN_Status syn_cia402_report_actuals (
    SYN_CiA402Drive * drive,
    int32_t actual_pos,
    int32_t actual_vel,
    int16_t actual_torque
) 

Parameters:

  • drive Pointer to drive handle.
  • actual_pos Actual measured position (0x6064).
  • actual_vel Actual measured velocity (0x606C).
  • actual_torque Actual measured torque (0x6077).

Returns:

SYN_OK on success, SYN_INVALID_PARAM if drive is NULL.


function syn_cia402_set_controlword

Process new Controlword command and update drive state machine.

SYN_Status syn_cia402_set_controlword (
    SYN_CiA402Drive * drive,
    uint16_t controlword
) 

Parameters:

  • drive Pointer to drive handle.
  • controlword Received 16-bit Controlword (0x6040).

Returns:

SYN_OK on success, SYN_INVALID_PARAM if drive is NULL.


function syn_cia402_set_mode

Set requested Mode of Operation.

SYN_Status syn_cia402_set_mode (
    SYN_CiA402Drive * drive,
    int8_t mode
) 

Parameters:

  • drive Pointer to drive handle.
  • mode Target mode (SYN_CIA402_MODE_*).

Returns:

SYN_OK on success, SYN_INVALID_PARAM on invalid inputs.


function syn_cia402_set_target_position

Set target position for PP or CSP mode.

SYN_Status syn_cia402_set_target_position (
    SYN_CiA402Drive * drive,
    int32_t target_pos
) 

Parameters:

  • drive Pointer to drive handle.
  • target_pos Target position value (0x607A).

Returns:

SYN_OK on success, SYN_INVALID_PARAM if drive is NULL.


function syn_cia402_set_target_torque

Set target torque for PT or CST mode.

SYN_Status syn_cia402_set_target_torque (
    SYN_CiA402Drive * drive,
    int16_t target_torque
) 

Parameters:

  • drive Pointer to drive handle.
  • target_torque Target torque value (0x6071).

Returns:

SYN_OK on success, SYN_INVALID_PARAM if drive is NULL.


function syn_cia402_set_target_velocity

Set target velocity for PV or CSV mode.

SYN_Status syn_cia402_set_target_velocity (
    SYN_CiA402Drive * drive,
    int32_t target_vel
) 

Parameters:

  • drive Pointer to drive handle.
  • target_vel Target velocity value (0x60FF).

Returns:

SYN_OK on success, SYN_INVALID_PARAM if drive is NULL.


function syn_cia402_trigger_fault

Trigger a fault state in the drive.

SYN_Status syn_cia402_trigger_fault (
    SYN_CiA402Drive * drive,
    uint16_t error_code
) 

Parameters:

  • drive Pointer to drive handle.
  • error_code 16-bit error code (0x603F).

Returns:

SYN_OK on success, SYN_INVALID_PARAM if drive is NULL.


function syn_cia402_update

Periodic motion control update step.

SYN_Status syn_cia402_update (
    SYN_CiA402Drive * drive,
    uint32_t dt_ms
) 

Executes trajectory planning (S-Curve PP, PV ramps) and state machine updates.

Parameters:

  • drive Pointer to drive handle.
  • dt_ms Elapsed time step in milliseconds.

Returns:

SYN_OK on success, SYN_INVALID_PARAM if drive is NULL.


Macro Definition Documentation

define SYN_CIA402_CW_ABS_REL

#define SYN_CIA402_CW_ABS_REL `(1U << 6)`

Bit 6: PP Absolute(0) / Relative(1)


define SYN_CIA402_CW_CHANGE_IMMED

#define SYN_CIA402_CW_CHANGE_IMMED `(1U << 5)`

Bit 5: PP Change Immediately


define SYN_CIA402_CW_ENABLE_OP

#define SYN_CIA402_CW_ENABLE_OP `(1U << 3)`

Bit 3: Enable Operation


define SYN_CIA402_CW_ENABLE_VOLTAGE

#define SYN_CIA402_CW_ENABLE_VOLTAGE `(1U << 1)`

Bit 1: Enable Voltage


define SYN_CIA402_CW_FAULT_RESET

#define SYN_CIA402_CW_FAULT_RESET `(1U << 7)`

Bit 7: Fault Reset (0->1 transition)


define SYN_CIA402_CW_HALT

#define SYN_CIA402_CW_HALT `(1U << 8)`

Bit 8: Halt motion


define SYN_CIA402_CW_NEW_SETPOINT

#define SYN_CIA402_CW_NEW_SETPOINT `(1U << 4)`

Bit 4: PP New Setpoint


define SYN_CIA402_CW_QUICK_STOP

#define SYN_CIA402_CW_QUICK_STOP `(1U << 2)`

Bit 2: Quick Stop (active low)


define SYN_CIA402_CW_SWITCH_ON

#define SYN_CIA402_CW_SWITCH_ON `(1U << 0)`

Bit 0: Switch On


define SYN_CIA402_SW_FAULT

#define SYN_CIA402_SW_FAULT `(1U << 3)`

Bit 3: Fault


define SYN_CIA402_SW_INTERNAL_LIMIT

#define SYN_CIA402_SW_INTERNAL_LIMIT `(1U << 11)`

Bit 11: Internal Limit Active


define SYN_CIA402_SW_OPERATION_ENABLED

#define SYN_CIA402_SW_OPERATION_ENABLED `(1U << 2)`

Bit 2: Operation Enabled


define SYN_CIA402_SW_QUICK_STOP

#define SYN_CIA402_SW_QUICK_STOP `(1U << 5)`

Bit 5: Quick Stop (1 = not active)


define SYN_CIA402_SW_READY_TO_SWITCH_ON

#define SYN_CIA402_SW_READY_TO_SWITCH_ON `(1U << 0)`

Bit 0: Ready to Switch On


define SYN_CIA402_SW_SETPOINT_ACK

#define SYN_CIA402_SW_SETPOINT_ACK `(1U << 12)`

Bit 12: Setpoint Acknowledge


define SYN_CIA402_SW_SWITCHED_ON

#define SYN_CIA402_SW_SWITCHED_ON `(1U << 1)`

Bit 1: Switched On


define SYN_CIA402_SW_SWITCH_ON_DISABLED

#define SYN_CIA402_SW_SWITCH_ON_DISABLED `(1U << 6)`

Bit 6: Switch On Disabled


define SYN_CIA402_SW_TARGET_REACHED

#define SYN_CIA402_SW_TARGET_REACHED `(1U << 10)`

Bit 10: Target Reached


define SYN_CIA402_SW_VOLTAGE_ENABLED

#define SYN_CIA402_SW_VOLTAGE_ENABLED `(1U << 4)`

Bit 4: Voltage Enabled


define SYN_CIA402_SW_WARNING

#define SYN_CIA402_SW_WARNING `(1U << 7)`

Bit 7: Warning



The documentation for this class was generated from the following file src/syntropic/proto/syn_cia402.h