Network Drive Module

This module provides a Service to perform Motor Control over different networks. It needs to be interfaced to the CANopen Interface Service and some Services belonging to the Motor Control Library.

It deploys over EtherCAT all the features of the SOMANET Motor Control Library and it responds to a CiA402-compliant control scheme. It features a state machine, configuration update from the Master application, different Cyclic modes for Position, Velocity and Torque, and a Special Engineering Mode for tuning.

How to use

Important

We assume that you are using SOMANET Base, SOMANET Motor Control, and SOMANET EtherCAT libraries. And therefore, your app includes the required board support files for your SOMANET device, and the required Motor Control and EtherCAT Services.

See also

You might find the EtherCAT Drive Slave Firmware example app useful, which illustrate the use of this module.

The EtherCAT Drive Service implements a CiA402 compliant slave with its state machine. It receives sdo configuration parameters from the master which are then used to configure all the Somanet Motorcontrol services. It receives opmode, controlword and position/velocity/torque target which is used to change the states of the state machine, enable the motion control in the desired mode and control the motor. Do do so the service is connected to multiple Somanet services:

API

void ethercat_drive_service(ProfilerConfig &profiler_config, client interface i_pdo_communication i_pdo, client interface i_coe_communication i_coe, client interface TorqueControlInterface i_torque_control, client interface MotionControlInterface i_motion_control, client interface PositionFeedbackInterface i_position_feedback_1, client interface PositionFeedbackInterface ?i_position_feedback_2)

This Service enables motor drive functions via EtherCAT.

Parameters:
  • profiler_config – Configuration for profile mode control.
  • i_pdo – Channel to send and receive information to EtherCAT Service.
  • i_coe – Channel to receive motor configuration information from EtherCAT Service.
  • i_torque_control – Interface to Motor Control Service
  • i_motion_control – Interface to Motion Control Service.
  • i_position_feedback_1 – Interface to the fisrt sensor service
  • i_position_feedback_2 – Interface to the second sensor service
check_list init_checklist(void)

Initialize checklist params.

Returns:check_list initialized checklist parameters
void update_checklist(check_list &check_list_param, int mode, int fault)

Update Checklist.

Parameters:
  • check_list_param – Check List to be updated
  • mode – sets mode of operation
  • fault – sets fault
int16_t update_statusword(int current_status, DriveState_t state_reached, int ack, int q_active, int shutdown_ack)

Update status word according to the current state of the statemachine.

Parameters:
  • current_status – current statusword
  • state_reached – current state of the statemachine
  • ack – more internal state
  • q_active – more internal state
  • shutdown_ack – more internal state
Returns:

new statusword

int get_next_state(int in_state, check_list &checklist, int controlword, int localcontrol)

Change state of the state machine according to master controlword and local conditions.

Parameters:
  • in_state – current state
  • checklist – local conditions checked before changing the state
  • controlword – contains the control command from the master
  • localcontrol – local command checked before changing the state
Returns:

new state

int8_t update_opmode(int8_t opmode, int8_t opmode_request, client interface MotionControlInterface i_motion_control, MotionControlConfig &motion_control_config, uint8_t polarity)

Update opmode, check if this opmode is supported.

Also set the polarity if the new opmode it CSP or CSV

Parameters:
  • opmode – the current opmode
  • opmode_request – the new opmode
  • i_motion_control – client class to the motion control
  • motion_control_config – config of to the motion control
  • polarity – CiA402 object 0x607E DICT_POLARITY
Returns:

new opmode, OPMODE_NONE if opmode is unsupported

int tuning_handler_ethercat(uint32_t tuning_command, uint32_t &user_miso, uint32_t &tuning_status, TuningModeState &tuning_mode_state, MotorcontrolConfig &motorcontrol_config, MotionControlConfig &motion_ctrl_config, PositionFeedbackConfig &pos_feedback_config_1, PositionFeedbackConfig &pos_feedback_config_2, int sensor_commutation, int sensor_motion_control, UpstreamControlData &upstream_control_data, client interface MotionControlInterface i_motion_control, client interface PositionFeedbackInterface ?i_position_feedback_1, client interface PositionFeedbackInterface ?i_position_feedback_2)

Function to handle the Tuning mode of ethercat drive It handles the muxing of mulitple parameters to send to the master It also handles the command received from the master and calls the tuning_command_handler function.

Parameters:
  • tuning_command – tuning command code
  • user_miso – to send multiple parameters and status to the master
  • tuning_status – to send multiple parameters and status to the master
  • tuning_mode_state – state of the motorcontrol in tuning mode
  • motorcontrol_config – configuration structure of the motorcontrol service
  • motion_ctrl_config – configuration structure of the motion control service
  • pos_feedback_config_1 – configuration structure of the position feedback number 1
  • pos_feedback_config_2 – configuration structure of the position feedback number 2
  • sensor_commutation – number of the commutation sensor
  • sensor_motion_control – number of the motion control sensor
  • upstream_control_data – structure with positon, velocity and status of sensor and motorcontrol
  • i_motion_control – client class to the motion control service
  • i_position_feedback_1 – client class to the position feedback number 1
  • i_position_feedback_2 – client class to the position feedback number 2
void tuning_command_handler(TuningModeState &tuning_mode_state, MotorcontrolConfig &motorcontrol_config, MotionControlConfig &motion_ctrl_config, PositionFeedbackConfig &pos_feedback_config_1, PositionFeedbackConfig &pos_feedback_config_2, int sensor_commutation, int sensor_motion_control, client interface MotionControlInterface i_motion_control, client interface PositionFeedbackInterface ?i_position_feedback_1, client interface PositionFeedbackInterface ?i_position_feedback_2)

Function to handle the tuning commands.

Parameters:
  • tuning_mode_state – state of the motorcontrol in tuning mode, also contains the tuning command and value
  • motorcontrol_config – configuration structure of the motorcontrol service
  • motion_ctrl_config – configuration structure of the motion control service
  • pos_feedback_config_1 – configuration structure of the position feedback number 1
  • pos_feedback_config_2 – configuration structure of the position feedback number 2
  • sensor_commutation – number of the commutation sensor
  • sensor_motion_control – number of the motion control sensor
  • upstream_control_data – structure with positon, velocity and status of sensor and motorcontrol
  • i_motion_control – client class to the motion control service
  • i_position_feedback_1 – client class to the position feedback number 1
  • i_position_feedback_2 – client class to the position feedback number 2
uint8_t tuning_set_flags(TuningModeState &tuning_mode_state, MotorcontrolConfig &motorcontrol_config, MotionControlConfig &motion_ctrl_config, PositionFeedbackConfig &pos_feedback_config_1, PositionFeedbackConfig &pos_feedback_config_2, int sensor_commutation)

Function to parse different status flags to send to the master.

Parameters:
  • motorcontrol_config – configuration structure of the motorcontrol service
  • motion_ctrl_config – configuration structure of the motion control service
  • pos_feedback_config_1 – configuration structure of the position feedback number 1
  • pos_feedback_config_2 – configuration structure of the position feedback number 2
  • sensor_commutation – number of the commutation sensor