/home/laradmin/lar/bases/atlasmv_base/src/des70_10.cpp File Reference

Des70-10 Communication library source code. More...

#include <des70_10.h>
Include dependency graph for des70_10.cpp:

Go to the source code of this file.

Defines

#define MAX_WAIT_TIME   0.023
#define WAIT   0.05
#define WAIT   0.05

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 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.
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

Detailed Description

Des70-10 Communication library source code.

Definition in file des70_10.cpp.


Define Documentation

#define MAX_WAIT_TIME   0.023
#define WAIT   0.05
#define WAIT   0.05

Function Documentation

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

Parameters:
msg - TYPE_msg_frame must be specified previously, were is updated the crc field
Returns:
- this function returns always 1 and crc field at msg structure

Definition at line 88 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

Parameters:
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
Returns:
the function returns: (0)-if error occurs, (-1)- waiting time exceeds limits, (1)-no error

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).

Parameters:
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
Returns:
- (0) if error occurs when requesting message

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.

Parameters:
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
Returns:
(0) error occurs during sending

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.

Parameters:
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
Returns:
(0) error occurs during sending

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.

Note:
WARNING: This is a toggle function, so is required to verify if the brake is disable or not. check TYPE_DES_status_var::sys_op_status.bits.bb13
Parameters:
port - serial port connection
flg - (1) to print debug info
Returns:
(0) error occurs during sending

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.

Parameters:
port - serial port device
sysparam - struct with all des system parameters
flg - if is required to print data
Returns:
(0) if error occurs when requesting 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.

Parameters:
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
Returns:
(0) error occurs during sending (-1) when receiving msg

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.

Parameters:
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
Returns:
(0) error occurs during sending

Definition at line 718 of file des70_10.cpp.

int DES_ST_clear_errors ( const int  port,
char  flg 
)

Clear all DES system errors.

Parameters:
port - device for serial port connection
flg - (1) to print debug info
Returns:
- this function returns 0 if error occurs

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.

Parameters:
port - serial conection device port
newState - (0) disable servoamplifier (1) enable servoamplifier
flg - (1) to print debug info
Returns:
- this function returns 0 if error occurs sending msg

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)

Parameters:
port - Device Port for serial connection
errors - 16bits WORD containing all errors list
flg - (1) to print debug info
Returns:
this function will returns 0 if error occurs

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.

Parameters:
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
Returns:
this function will returns 0 if error occurs

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.

Parameters:
port - serial device port
flg - (1) to print debug info
Returns:
- this function returns 0 if error occurs

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.

Parameters:
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
Returns:
(-1) no errors, (0) brake not disabled or servoamplifier didn't not enabled, (1...) error according Standard Error Messages

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

Parameters:
com_device - path to device
port - device port identification (exit)
Returns:
this function will returns 0 if error occurs

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

Parameters:
port - device port
msg - message frame type
flg - (1) to print out debug info
Returns:
()

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 
)
Parameters:
port - serial port conection
msg - message frame to be sent according DES frame struct (TYPE_msg_frame)
flg - (1) to print out debug info
Returns:
(-1)-'F' is received from DES,(0)-max num of tries is reached, (1)-'O' is received from DES

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

Parameters:
port - device port
msg - TYPE_msg_frame frame
flg - (1) if required print debug data
Returns:
(0) if any error occurs during data transfer

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

Parameters:
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
Returns:
(-1)-'F' is received from DES,(0)-max num of tries is reached, (1)-'O' is received from DES

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

Parameters:
port - device port
data - vector with streaming of data
size - number of bytes to be sent
Returns:
this function will returns 0 if error occurs

Definition at line 119 of file des70_10.cpp.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


atlasmv_base
Author(s): David Gameiro, Jorge Almeida
autogenerated on Wed Jul 23 04:34:43 2014