Technical data
Linkage with PLC
160 VIPA GmbH CP486 ⋅ 00/14
6.4.3.4 Write a Single Element to the PC
FUNCTION CP_write_AG(size, typ, bst : BYTE; adr: longint; bit: BYTE; p: POINTER)
: integer;
size: data size (see Tab. 1)
typ: data type single elements (see Tab. 2)
bst: module number
adr: address in module or absolute address
bit: bit number
p: pointer to date to be written
for data type bit, semaphore or byte: pointer to a byte
for data type word: pointer to a word
for data type doubleword: pointer to a doubleword
Return: job number or negative number if there is an error
This function calls the driver function "write a single element into the PC". The registers are preset
according to the transferred parameters when calling up. Meaning of the parameters is described in
the section of driver function. If the driver has detected an error during the execution, then the
respective error message (negative number) is returned as function value. If the function can be
executed without errors, the job number is returned as function value.
Recommended calling method
VAR a_nr, (* job number for read job*)
stat : INTEGER; (* momentaneous job status *)
wert : BYTE; (* value to be written *)
BEGIN
...
(* start job *)
wert := $7E;
a_nr := CP_write_AG(BYTE_ELM, DB_SNG, 10, 1, 0, Addr(value));
IF a_nr < 0 (* error occurred *)
THEN WriteLn('job finished with error: ', a_nr);
ELSE BEGIN (* a_nr contains job number *)
REPEAT
stat := CP_stat_AG(a_nr, NIL); (* read job status *)
UNTIL stat <> REQ_WRKN; (* as long as job is ready with or without errors *)
CASE stat OF
REQ_NO_ERR: WriteLn('date: ', value, ' was written');
REQ_UNDEF: WriteLn('job status nondefined.');
ELSE WriteLn('job is ready with error: ', stat);
END;
END;