 |
plc.myforum.ro PLCs users www.plc.myforum.ro!
|
| View previous topic :: View next topic |
| Author |
Message |
mmohamed15 Junior

Joined: 13 Feb 2012 Posts: 18
|
Posted: 23/05/2016 12:41 Post subject: reading HART variables through SFC58 & SFC59 |
|
|
Dear friends
does anyone have a sample program for reading HART variables as data records as descried in Siemens ET200M hart Manual
i can not use the hardware configured variables since this will exceed the 244 byte limitation of the ET200M allowed memory space
best regards
Mohamed |
|
| Back to top |
|
 |
kaminsky Junior

Joined: 29 Apr 2016 Posts: 10
|
Posted: 23/05/2016 18:17 Post subject: Re: reading HART variables through SFC58 & SFC59 |
|
|
| mmohamed15 wrote: | Dear friends
does anyone have a sample program for reading HART variables as data records as descried in Siemens ET200M hart Manual
i can not use the hardware configured variables since this will exceed the 244 byte limitation of the ET200M allowed memory space
best regards
Mohamed |
try this testbed
| Code: | FUNCTION_BLOCK fbTestHartProt
VAR
Command : byte := B#16#FF;
BusyOut : bool;
BusyIn : bool;
LADDR : dword;
Index : int;
Valid : bool;
Done : bool;
ErrorOut : bool;
ErrorIn : bool;
mStatusOut : array[1..4] of byte;
StatusOut at mStatusOut : dword ;
mStatusIn : array[1..4] of byte;
StatusIn at mStatusIn : dword ;
LenOut : int;
LenIn : int;
LenInRes : int;
BufferOut : array[0..240] of byte;
BufferIn : array[0..240] of byte;
END_VAR
// Forming a command according to document "ET 200M distributed I/O device
// HART analog modules" part 7.2.4
BufferOut[0] := B#16#60; // in bits 0110_0000
BufferOut[1] := B#16#05; // Number of preamble butes
BufferOut[2] := B#16#01; // Universal HART Command - READ PRIMARY VARIABLE
// Calling SFB53 (WRREC) for writing a command
WRREC.dbWRREC(REQ := (Command = 1) // Entered from VAR-table
,ID := 512 // Configurated adress of module
,INDEX := 80 // Command for Channel 0
,LEN := 3 // Number of writing bytes
,RECORD := BufferOut // Pointer to command buffer
);
Done := dbWRREC.DONE; // OUT: BOOL
BusyOut := dbWRREC.BUSY; // OUT: BOOL
ErrorOut := dbWRREC.ERROR; // OUT: BOOL
StatusOut := dbWRREC.STATUS; // OUT: DWORD
if not BusyOut and (Command = 1) then
Command := B#16#02;
end_if;
// Calling SFB52 (RDREC) for reading a reply
RDREC.dbRDREC(REQ := (Command = 2) // Setted after function WRREC is ended
,ID := 512
,INDEX := 81 // Reply for Channel 0
,MLEN := 7 // Number of reading bytes
,RECORD := BufferIn // Pointer to reply buffer
);
Valid := DB52.VALID; // OUT: BOOL
BusyIn := DB52.BUSY; // OUT: BOOL
ErrorIn := DB52.ERROR; // OUT: BOOL
StatusIn := DB52.STATUS; // OUT: DWORD
LenInRes := DB52.LEN; // OUT: INT
if not BusyIn and (Command = 2) then
Command := B#16#FF;
end_if;
END_FUNCTION_BLOCK
DATA_BLOCK dbTestHartProt fbTestHartProt
BEGIN
END_DATA_BLOCK
DATA_BLOCK dbRDREC RDREC //DB of SFB52
BEGIN
END_DATA_BLOCK
DATA_BLOCK dbWRREC WRREC //DB of SFB53
BEGIN
END_DATA_BLOCK
ORGANIZATION_BLOCK OB1
VAR_TEMP
info : ARRAY[0..19] OF BYTE;
END_VAR
;
END_ORGANIZATION_BLOCK
ORGANIZATION_BLOCK OB35
VAR_TEMP
info : ARRAY[0..19] OF BYTE;
END_VAR
fbTestHartProt.dbTestHartProt();
END_ORGANIZATION_BLOCK |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro
|