Receive And Transmit Example - Siemens SIMATIC S7-200 System Manual

Hide thumbs Also See for SIMATIC S7-200:
Table of Contents

Advertisement

Receive and Transmit Example

This sample program (Figure 9-74) shows the use of Receive and Transmit. This
program will receive a string of characters until a line feed character is received.
The message is then transmitted back to the sender.
MAIN (OB1)
Network 1
SM0.1
Figure 9-74
S7-200 Programmable Controller System Manual
A5E00066097-02
LAD
On the first scan:
MOV_B
- Initialize freeport
EN
ENO
- Select 9600 baud
- Select 8 data bits
- Select no parity
IN
OUT
SMB30
16#9
Initialize RCV message
MOV_B
control byte
EN
ENO
- RCV enabled
- Detect end of message
IN
OUT
SMB87
16#B0
- Detect idle line condition
MOV_B
EN
ENO
Set end of message
character to hex 0A
(line feed)
16#A
IN
OUT
SMB89
Set idle line timeout to
MOV_W
5 ms.
EN
ENO
+5
IN
OUT
SMW90
Set maximum number of
MOV_B
characters to 100.
EN
ENO
100
IN
OUT
SMB94
ATCH
EN
ENO
0
INT
23
EVNT
Attach interrupt to
ATCH
transmit complete event.
EN
ENO
1
INT
9
EVNT
Enable user interrupts.
ENI
Enable receive box with
RCV
buffer at VB100 for port 0.
ENO
EN
VB100
TBL
0
PORT
Example of Transmit Instruction for SIMATIC LAD, STL, and FBD
Network 1
LD
MOVB
MOVB
MOVB
MOVW
MOVB
ATCH
ATCH
ENI
character
RCV
as message start
condition
Attach interrupt to
receive complete event.
SIMATIC Instructions
STL
SM0.1
16#9, SMB30
16#B0, SMB87
16#0A, SMB89
+5, SMW90
100, SMB94
0, 23
1, 9
VB100, 0
9-193

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents