Example 3: READ_VAR function for reading bits. Schneider Electric PL7 Micro/Junior/Pro - Communication applications, volume 2
जाहिरात
जाहिरात
Modbus programming
Example 3: READ_VAR function for reading bits
General
Example with
READ_VAR
Exchanges with Modbus slave devices are programmed using the READ_VAR and
WRITE_VAR communication functions only (the SEND_REQ function is not supported on the TER port).
Description of the objects used in the example:
Object
%MW0:X0
%M20
%MW100:10
Description
Request transmission request
Requesting
Reception buffer
%MW200..203
Report zone:
%MW200 Session number and activity bit (X0)
%MW201 Error code
%MW202 Time-out in units of 10 ms
%M30
%MW204
%MW205
%MW206
%MW207
Bit set to 1 after a successful exchange
Counter of requests sent
Counter of successful requests
Counter of unsuccessful requests
Error code of the last unsuccessful request
Example of the program:
!(*Reading of bits %M0 to %M8 from the Nano at address 37 *)
IF %MW0:X0 AND NOT %M20 THEN
%MW200:4:=0;%MW202:=50;SET %M20;
READ_VAR(ADR#0.0.37,’%M’,0,8,%MW100:10,%MW200:4);
(*8 bits %M0..%M7 are read in the slave 37 and placed in the
%MW100 word of the master*)
END_IF;
!(*Analysis of the results*)
IF %M20 AND NOT %MW200:X0 THEN
INC %MW204;RESET %M20;RESET %MW0:X0;
IF %MW201=0 THEN INC %MW205;SET %M30;
ELSE INC %MW206;%MW207:=%MW201;RESET %M30;
END_IF;
46
TLX DS COM PL7 xxE
डाउनलोड
जाहिरात