Description of the DP Functions, Data, and
4.1 List of Functions of the CP 5613 and CP 5614
4.1.1 Overview of the Functions
Administrative Functions
Name Purpose
DP_start_cp Downloads the firmware and the database to the CP 5613/CP 5614.
DP_open Logs on a DP user program, assigns a user handle.
DP_get_pointer Requests a pointer to the process image.
DP_init_sema_object This function initializes a Windows semaphore at which your DP user program can wait for the arrival of events.
DP_delete_sema_object This function clears a semaphore again.
DP_release_pointer Releases the pointer to the process image.
DP_close The DP user logs off.
DP_reset_cp Stops the CP firmware.
Standard DP Functions
Name Purpose
DP_set_mode This function sets the required DP mode (OFFLINE, STOP, CLEAR, OPERATE).
DP_slv_state This function activates or deactivates a slave explicitly and can be used to change the AUTOCLEAR property.
DP_read_slv_par This function reads out the parameters of a DP slave from the database.
DP_global_ctrl This function sends a global control command to one or more slaves.
DP Base Programming Interface for CP 5613/CP 5614
C79000-G8976-C139-09 111
Functions for the DP-V1 Master Class 1 (DPC1)
Name Purpose
DP_alarm_ack This function sends an "Alarm Acknowledge" call to a DP-V1 slave.
DP_ds_read This function sends a "Read Data Record" call to a DP-V1 slave.
DP_ds_write This function sends a "Write Data Record" call to a DP-V1 slave.
DP_fetch_alarm This function fetches a DPC1 alarm, a DPC1 status message or other diagnostic data.
DP_get_actual_cfg This function reads out the current configuration data of a slave.
DP_get_cref This function obtains the communication reference (c_ref) from the slave address and the user ID for DP-V1 jobs.
Auxiliary Functions
Name Purpose
DP_get_err_txt This functions gets the error information and returns it as plain text.
DP_enable_event This function activates the waiting for status changes or diagnostic information on slaves.
DP_get_result This function fetches the confirmation of an asynchronous call and other software events.
DP_disable_event This function cancels DP_enable_event.
DP_watchdog This function starts or stops the sign-of-life monitoring (watchdog) of the DP master user program.
DP_write_trc With this function, a DP user program can write its own trace outputs to a trace file.
Fast Logic
Name Purpose
DP_fast_logic_on This function assigns parameters to the CP 5613/CP 5614 for automatic monitoring of a slave and data transfer to another slave.
DP_fast_logic_off This function cancels the parameter assignment made with DP_fast_logic_on.
Constant bus cycle time
Name Purpose
DP_delay_irq As an option, the cycle start interrupt can be delayed on the CP 5623/CP 5624 with this function.
DP_cycle_time With this function, the remaining cycle time can be queried on the CP 5623/CP 5624.
DP Base Programming Interface for CP 5613/CP 5614
C79000-G8976-C139-09 113
4.1.2 DP_start_cp
Purpose
This function initializes the CP 5613/CP 5614. The CP firmware and the database are downloaded.
Syntax
DPR_DWORD DP_start_cp
(const DPR_STRING *cp_name, // in
const DPR_STRING *database, // in
DP_ERROR_T *error ); // out
Parameters
Name Description
cp_name Logical name of the CP (for example, "CP_L2_1:") database Enter a null pointer.
Only in the special situation Development Kit
"Dev-Kit 5613":
path and name of the database
error Address of a structure provided by the DP user program of the type DP_ERROR_T - If an error occurred, the structure contains details for troubleshooting (see Section 4.4).
Return Value
Name Description
DP_OK Successful completion of function. The
green token LED is lit.
DP_ERROR_CI
and error->error_code ==
CI_RET_START_ALREADY_
DATABASE
Error: The CP has already been started with a different database.
DP_ERROR_CI
and error->error_code ==
CI_RET_START_ALREADY_
DONE
Error: The CP has already been started with the same database.
This error can be ignored.
Others Unsuccessful completion of function.
DP Base Programming Interface for CP 5613/CP 5614
C79000-G8976-C139-09 115
4.1.3 DP_reset_cp
Purpose
This function resets the CP 5613/CP 5614. Following this, the CP is no longer active on the bus (Token LED is off).
If other applications use the CP, this function does not reset it.
Note
To use the CP again, your DP user program must use the DP_start_cp call.
Syntax
DPR_DWORD DP_reset_cp (const DPR_STRING *cp_name, // in
DP_ERROR_T *error ); // out
Parameters
Name Description
cp_name Access point of the CP (for example, "CP_L2_1:")
error Address of a structure provided by the DP user program of the type DP_ERROR_T - If an error occurred, the structure contains details for troubleshooting (see Section 4.4).
Return Value
Name Description
DP_OK Successful completion of function
DP_ ERROR_CI and error->error_code ==
CI_RET_RESET_CP_USED
Unsuccessful because other applications are still using the CP.
other Unsuccessful completion of function
4.1.4 DP_open
Purpose
This function logs on a DP user program for communication. If successful, the function returns a user handle. The user handle must be included in all further function calls.
Syntax
DPR_DWORD DP_open (
const DPR_STRING *cp_name, // in
DPR_DWORD *user_handle, // out
DP_ERROR_T *error );
// out
Parameters
Name Description
cp_name Logical name of the CP (for example, "CP_L2_1:")
user_handle Pointer to the user handle variable - if successful, the user handle assigned to the DP user program is entered here.
error Address of a structure provided by the DP user program of the type DP_ERROR_T - If an error occurred, the structure contains details for troubleshooting (see Section 4.4).
DP Base Programming Interface for CP 5613/CP 5614
C79000-G8976-C139-09 117
Return Value
Name Description
DP_OK Successful completion of function.
DP_ ERROR_CI and error->error_code ==
CI_RET_OPEN_CP_NOT_STAR TED
CP was not started earlier with DP_start_cp.
DP_ERROR_EVENT_NET and error->error_code ==
DP_RET_CP USR_NOT_
COMPATIBLE
The dplib.dll and the dp_base.dll cannot register on the same CP.
DP_ERROR_RES and error->error_code ==
DP_RET_CP_TOO_MANY_USR
No further DP instances can log on at the CP.
DP_ERROR_RES and error->error_code ==
DP_RET_CP_NO_DP_PAR
There are no DP parameters in the database of the CP.
Others Unsuccessful completion of function.