Des70-10 Communication library header. More...
#include <termios.h>#include <sys/ioctl.h>#include <unistd.h>#include <termio.h>#include <fcntl.h>#include <string.h>#include <stdio.h>#include <crc.h>#include <timer.h>

Go to the source code of this file.
Classes | |
| struct | TYPE_DES_status_var | 
| DES data structure with all status variables, all variables are 16bits except Nb136 that is 32bits (double word).  More... | |
| struct | TYPE_des_sysparam | 
| data struct with all DES System Parameters definition, all fields have a length of 16bits but the variable range can change normally [0, 32767]  More... | |
| struct | TYPE_msg_frame | 
| struct with message frame  More... | |
Enumerations | |
| enum | ENUM_DES_STATUS_VAR {  SYS_OP_STATUS = 128, ACTUAL_MEAN_CUR_D = 129, ACTUAL_MEAN_CUR_Q = 130, CUR_SETTING_VAL = 131, REL_ROT_POS_REV = 132, SPEED_SETTING_VAL = 133, ACTUAL_MEAN_SPEED_VAL = 134, ABS_ROTOR_POS = 135, STANDARD_ERROR = 136, CAN_ERROR = 137, ACTUAL_CUR_Q = 138, ACTUAL_SPEED_VAL = 139, ERROR_HIST1 = 140, ERROR_HIST2 = 141, ENC_COUNTER = 142, ENC_COUNTER_LAST_IND = 143, HALL_SENS_PAT = 144 }  | 
enumerator connected with DES status var typedefinition, and is used when communicating with DES servo amplifier More... | |
| enum | ENUM_DES_SYS_PARAMS {  BAUDRATE = 0, SYS_CONFIG = 1, CUR_REG_GAIN_P = 2, CUR_REG_GAIN_I = 3, MAX_CUR_OUTPUT = 4, SPEED_REG_GAIN_P = 5, SPEED_REG_GAIN_I = 6, INTERNAL_PARAM1 = 7, INTERNAL_PARAM2 = 8, INTERNAL_PARAM3 = 9, MAX_SPEED_ERROR = 10, SETTING_UNIT_GAIN = 11, SETTING_UNIT_OFFSET = 12, SETTING_UNIT_DELAY = 13, PEAK_CURRENT = 14, MAX_CONT_CURRENT = 15, THERM_CONST = 16, MAX_SPEED = 17, ACCELERATION = 18, SPEED_CONSTANT = 19, ENC_RESOLUTION = 20, POLE_PAIR_NUMBER = 21, INTERNAL_PARAM4 = 22, RPM_2QC_FACTOR = 23, INDEX_OFFSET = 24, PWM_PERIOD = 25, MAX_DUTY_CYCLE = 26, CUR_DET_PH_U_OFFSET = 27, CUR_DET_PH_V_OFFSET = 28, AD_CONV_OFFSET = 29, CAN_MODULE_ID = 30, CAN_SERVICE_ID = 31, CAN_RX_PDO_ID = 32, CAN_TX_PDO_ID = 33, CAN_BCR1 = 34, CAN_BCR2 = 35, CAN_OP_MODE = 36, CAN_RX_SDO_ID = 37, CAN_TX_SDO_ID = 38, CAN_RTR0_ID = 39, CAN_RTR1_ID = 40, CAN_CONFIG = 41, INTERNAL_PARAM5 = 42, ERROR_PROC = 43, MAX_SPEED_CURR = 44, HALL_ANGLE_OFFS = 45 }  | 
enumerator connected with TYPE_des_sysparam and is used when comunication is required with DES servoamplifier More... | |
Functions | |
| int | calc_crc_16 (TYPE_msg_frame *msg) | 
| function used to get the message crc for 16bits data, the crc is obtained using first the higher byte of the WORD   | |
| int | check_msg_aceptance (const int port, float wait_time, unsigned char *msg) | 
| verify if there is some by in RX serial buffer   | |
| int | DES_MF_read_velocity_is_must (const int port, int vel_type, int *velocity, int *requested_vel, char flg) | 
| Read the effective and requested velocity of the motor. This is a Monitor Function (MF).   | |
| int | DES_set_new_baud (int *port, int baud, char flg) | 
| int | DES_SF_set_current (const int port, int newCurrent, char flg) | 
| Set a new current of the motor. This function is only available in current mode regulation mode. please garantee that SysConfig field inside DES_SysParam struct. SF is a setting function.   | |
| int | DES_SF_set_velocity (const int port, int newVelocity, char flg) | 
| Set a new velocity of the motor. This function is only available in speed mode regulation mode. please garantee that SysConfig field inside DES_SysParam struct. SF is a setting function.   | |
| int | DES_SF_stop_motion (const int port, char flg) | 
| This command changes the stopping state. if the motor is already stopped it will be released. Only available in speed regulation mode. SF is a setting function.   | |
| int | DES_SPF_read_all_temp_param (const int port, TYPE_des_sysparam *sysparam, char flg) | 
| Read all temporary system parameters. DES answer the structure described by TYPE_des_sysparam. SPF is a System Parameter Functions.   | |
| int | DES_SPF_read_temp_param (const int port, int paramNb, int dataFormat, int *response, char flg) | 
| Read the requested temporary system parameter from DES-RAM. SPF is a System Parameter Functions.   | |
| int | DES_SPF_set_temp_param (const int port, int paramNb, int dataFormat, int *newValue, char flg) | 
| Write a new value to a temporary system parameter. Refer to the section about system parameters to find the desired system parameter numbers. SPF is a System Parameter Functions.   | |
| int | DES_ST_clear_errors (const int port, char flg) | 
| Clear all DES system errors.   | |
| int | DES_ST_enable (const int port, int *newState, char flg) | 
| Set the system to enabled or disabled state. The DES has to be configured for a software setting of enable. If the hardware enabled is activated this command has no effect.   | |
| int | DES_ST_read_error (const int port, int *errors, char flg) | 
| execute the rs232 command ReadError (OpCode 0x02)   | |
| int | DES_ST_read_sys_status (const int port, int *sys_status, char flg) | 
| execute the DES RS232 command 'ReadSysStatus' (OpCode=0x01). The system status is a 16bits value containing different flags.   | |
| int | DES_ST_reset (const int port, char flg) | 
| RS232 command that reset the des system by restarting the software.   | |
| int | InitDES (const int port, TYPE_des_sysparam *newSysParam, char, char, char flg) | 
| Function that initializes DES servoamplifier with a start configuration. also enables the servoamplifier to be used by software and garantees that the electric brake is not active.   | |
| int | InitDES_communication (std::string com_device, int *port) | 
| function to open serial port and set some params for servoamplifier   | |
| int | read_buffer (const int port, TYPE_msg_frame *msg, char flg) | 
| function to read the buffer into a msg frame   | |
| int | send_data (const int port, TYPE_msg_frame *msg, char flg) | 
| int | send_msg_frame (const int port, TYPE_msg_frame *msg, char flg) | 
| send by rs232 all the data frame inclusively crc value. CRC value is obtained were before send message   | |
| int | send_OpCode (const int port, unsigned char tries, unsigned char OpCode, char flg) | 
| function just to send OpCode and verify if command was understood   | |
| int | stopDES (const int port, char flg) | 
| int | write_msg_inbuf (const int port, unsigned char *data, int size) | 
| send to serial port a stream of bytes   | |
Des70-10 Communication library header.
Definition in file des70_10.h.
| enum ENUM_DES_STATUS_VAR | 
enumerator connected with DES status var typedefinition, and is used when communicating with DES servo amplifier
Definition at line 237 of file des70_10.h.
| enum ENUM_DES_SYS_PARAMS | 
enumerator connected with TYPE_des_sysparam and is used when comunication is required with DES servoamplifier
Definition at line 144 of file des70_10.h.
| int calc_crc_16 | ( | TYPE_msg_frame * | msg | ) | 
function used to get the message crc for 16bits data, the crc is obtained using first the higher byte of the WORD
| msg | - TYPE_msg_frame must be specified previously, were is updated the crc field | 
Definition at line 79 of file des70_10.cpp.
| int check_msg_aceptance | ( | const int | port, | |
| float | wait_time, | |||
| unsigned char * | msg | |||
| ) | 
verify if there is some by in RX serial buffer
| port | - device port | |
| wait_time | - maximum delay to receive the acknowledge from DES servoamplifier in seconds | |
| msg | - the return byte if the result is 1 | 
Definition at line 146 of file des70_10.cpp.
| int DES_MF_read_velocity_is_must | ( | const int | port, | |
| int | vel_type, | |||
| int * | velocity, | |||
| int * | requested_vel, | |||
| char | flg | |||
| ) | 
Read the effective and requested velocity of the motor. This is a Monitor Function (MF).
| port | - serial port connection | |
| vel_type | - (0)required mean value (1)realtime values | |
| velocity | - velocity is the actual velocity depending on vel_type value. | |
| requested_vel | - requested velocity to the servoamplifier | |
| flg | - (1) to print debug info | 
Definition at line 1100 of file des70_10.cpp.
| int DES_set_new_baud | ( | int * | port, | |
| int | baud, | |||
| char | flg | |||
| ) | 
Definition at line 1314 of file des70_10.cpp.
| int DES_SF_set_current | ( | const int | port, | |
| int | newCurrent, | |||
| char | flg | |||
| ) | 
Set a new current of the motor. This function is only available in current mode regulation mode. please garantee that SysConfig field inside DES_SysParam struct. SF is a setting function.
| port | - serial port device | |
| newCurrent | - new current in mA {positive value rotor turns counter clockwise, negative value rotor turns in clockwise} | |
| flg | - (1) to print debug info | 
Definition at line 1034 of file des70_10.cpp.
| int DES_SF_set_velocity | ( | const int | port, | |
| int | newVelocity, | |||
| char | flg | |||
| ) | 
Set a new velocity of the motor. This function is only available in speed mode regulation mode. please garantee that SysConfig field inside DES_SysParam struct. SF is a setting function.
| port | - serial port device | |
| newVelocity | - new velocity in rpm {positive value rotor turns in counter clockwise, negative value rotor turns in clockwise} | |
| flg | - (1) to print debug info | 
Definition at line 1001 of file des70_10.cpp.
| int DES_SF_stop_motion | ( | const int | port, | |
| char | flg | |||
| ) | 
This command changes the stopping state. if the motor is already stopped it will be released. Only available in speed regulation mode. SF is a setting function.
| port | - serial port connection | |
| flg | - (1) to print debug info | 
Definition at line 1066 of file des70_10.cpp.
| int DES_SPF_read_all_temp_param | ( | const int | port, | |
| TYPE_des_sysparam * | sysparam, | |||
| char | flg | |||
| ) | 
Read all temporary system parameters. DES answer the structure described by TYPE_des_sysparam. SPF is a System Parameter Functions.
| port | - serial port device | |
| sysparam | - struct with all des system parameters | |
| flg | - if is required to print data | 
Definition at line 769 of file des70_10.cpp.
| int DES_SPF_read_temp_param | ( | const int | port, | |
| int | paramNb, | |||
| int | dataFormat, | |||
| int * | response, | |||
| char | flg | |||
| ) | 
Read the requested temporary system parameter from DES-RAM. SPF is a System Parameter Functions.
| port | - device port | |
| paramNb | - Parameter Number according table DES System Parameters and DES Status Variables. check TYPE_DES_sysparam and TYPE_DES_status_var | |
| dataFormat | - (0)answer will be a WORD (1) answer will be a LWORD | |
| response | - pointer to a WORD | |
| flg | - (1) to print debug info | 
Definition at line 675 of file des70_10.cpp.
| int DES_SPF_set_temp_param | ( | const int | port, | |
| int | paramNb, | |||
| int | dataFormat, | |||
| int * | newValue, | |||
| char | flg | |||
| ) | 
Write a new value to a temporary system parameter. Refer to the section about system parameters to find the desired system parameter numbers. SPF is a System Parameter Functions.
| port | - serial device number | |
| paramNb | - Parameter Number according table DES System Parameters and DES Status Variables. check TYPE_DES_sysparam and TYPE_DES_status_var | |
| dataFormat | - (0)answer will be a WORD (1) answer will be a LWORD | |
| newValue | - pointer to a WORD | |
| flg | - (1) to print debug info | 
Definition at line 718 of file des70_10.cpp.
| int DES_ST_clear_errors | ( | const int | port, | |
| char | flg | |||
| ) | 
Clear all DES system errors.
| port | - device for serial port connection | |
| flg | - (1) to print debug info | 
Definition at line 579 of file des70_10.cpp.
| int DES_ST_enable | ( | const int | port, | |
| int * | newState, | |||
| char | flg | |||
| ) | 
Set the system to enabled or disabled state. The DES has to be configured for a software setting of enable. If the hardware enabled is activated this command has no effect.
| port | - serial conection device port | |
| newState | - (0) disable servoamplifier (1) enable servoamplifier | |
| flg | - (1) to print debug info | 
Definition at line 641 of file des70_10.cpp.
| int DES_ST_read_error | ( | const int | port, | |
| int * | errors, | |||
| char | flg | |||
| ) | 
execute the rs232 command ReadError (OpCode 0x02)
| port | - Device Port for serial connection | |
| errors | - 16bits WORD containing all errors list | |
| flg | - (1) to print debug info | 
Definition at line 541 of file des70_10.cpp.
| int DES_ST_read_sys_status | ( | const int | port, | |
| int * | sys_status, | |||
| char | flg | |||
| ) | 
execute the DES RS232 command 'ReadSysStatus' (OpCode=0x01). The system status is a 16bits value containing different flags.
| port | - Device Port for serial connection | |
| sys_status | - sys_status is a variable inside data structure DES_Status_Variables | |
| flg | - (1) to print debug info | 
Definition at line 498 of file des70_10.cpp.
| int DES_ST_reset | ( | const int | port, | |
| char | flg | |||
| ) | 
RS232 command that reset the des system by restarting the software.
| port | - serial device port | |
| flg | - (1) to print debug info | 
Definition at line 609 of file des70_10.cpp.
| int InitDES | ( | const int | port, | |
| TYPE_des_sysparam * | newSysParam, | |||
| char | enable_des, | |||
| char | brake_des, | |||
| char | flg | |||
| ) | 
Function that initializes DES servoamplifier with a start configuration. also enables the servoamplifier to be used by software and garantees that the electric brake is not active.
| port | - serial port conection | |
| newSysParam | - DES start configuration, although there is 45 start configuration variable is just defined SYS_CONFIG, ENC_RESOLUTION, MAX_SPEED, MAX_CONT_CURRENT, PEAK_CURRENT, SPEED_REG_GAIN_P and SPEED_REG_GAIN_I | |
| enable_des | - | |
| brake_des | - | |
| flg | - if is required to print out some infomration | 
Definition at line 1142 of file des70_10.cpp.
| int InitDES_communication | ( | std::string | com_device, | |
| int * | port | |||
| ) | 
function to open serial port and set some params for servoamplifier
| com_device | - path to device | |
| port | - device port identification (exit) | 
Definition at line 41 of file des70_10.cpp.
| int read_buffer | ( | const int | port, | |
| TYPE_msg_frame * | msg, | |||
| char | flg | |||
| ) | 
function to read the buffer into a msg frame
| port | - device port | |
| msg | - message frame type | |
| flg | - (1) to print out debug info | 
this define the time that at maximum time is necessary to wait for a msg with a lenght of 110bytes with a baud of 38400 near 23ms
Definition at line 330 of file des70_10.cpp.
| int send_data | ( | const int | port, | |
| TYPE_msg_frame * | msg, | |||
| char | flg | |||
| ) | 
| port | - serial port conection | |
| msg | - message frame to be sent according DES frame struct (TYPE_msg_frame) | |
| flg | - (1) to print out debug info | 
Definition at line 264 of file des70_10.cpp.
| int send_msg_frame | ( | const int | port, | |
| TYPE_msg_frame * | msg, | |||
| char | flg | |||
| ) | 
send by rs232 all the data frame inclusively crc value. CRC value is obtained were before send message
| port | - device port | |
| msg | - TYPE_msg_frame frame | |
| flg | - (1) if required print debug data | 
Definition at line 457 of file des70_10.cpp.
| int send_OpCode | ( | const int | port, | |
| unsigned char | tries, | |||
| unsigned char | OpCode, | |||
| char | flg | |||
| ) | 
function just to send OpCode and verify if command was understood
| port | - device port | |
| tries | - max number of tries to receive msg | |
| OpCode | - unsigned char with DES command, according to DES command reference | |
| flg | - (1) will printf special info | 
Definition at line 192 of file des70_10.cpp.
| int stopDES | ( | const int | port, | |
| char | flg | |||
| ) | 
Definition at line 1271 of file des70_10.cpp.
| int write_msg_inbuf | ( | const int | port, | |
| unsigned char * | data, | |||
| int | size | |||
| ) | 
send to serial port a stream of bytes
| port | - device port | |
| data | - vector with streaming of data | |
| size | - number of bytes to be sent | 
Definition at line 119 of file des70_10.cpp.