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.
Parameters:
drivePointer to drive handle.
Returns:
16-bit Statusword (0x6041), or 0 if drive is NULL.
function syn_cia402_init¶
Initialize a CiA 402 Drive instance.
Parameters:
drivePointer to drive handle.cfgPointer 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:
entriesOutput array of SYN_CANOpenODEntry elements.max_entriesMaximum capacity of entries array (must be >= 10).drivePointer 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:
drivePointer to drive handle.actual_posActual measured position (0x6064).actual_velActual measured velocity (0x606C).actual_torqueActual 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.
Parameters:
drivePointer to drive handle.controlwordReceived 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.
Parameters:
drivePointer to drive handle.modeTarget 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.
Parameters:
drivePointer to drive handle.target_posTarget 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.
Parameters:
drivePointer to drive handle.target_torqueTarget 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.
Parameters:
drivePointer to drive handle.target_velTarget 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.
Parameters:
drivePointer to drive handle.error_code16-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.
Executes trajectory planning (S-Curve PP, PV ramps) and state machine updates.
Parameters:
drivePointer to drive handle.dt_msElapsed 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