Skip to content

File syn_cia402.c

FileList > proto > syn_cia402.c

Go to the source code of this file

CANopen CiA 402 Servo Drive Profile Engine implementation.

  • #include "syntropic/proto/syn_cia402.h"
  • #include <math.h>
  • #include <string.h>

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.

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.



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