Program instructions
7.3 Communication
Example: Transmit and Receive instructions
MAIN
Network 1
INT 0
Network 1
INT 1
Network 1
212
Network 1
//This program receives a string of characters until a line feed character
is received. The message is then transmitted back to the sender.
LD SM0.1
MOVB 16#09, SMB30
MOVB 16#B0, SMB87
MOVB 16#0A, SMB89
MOVW +5, SMW90
MOVB 100, SMB94
ATCH INT_0, 23
ATCH INT_2, 9
ENI
RCV VB100, 0
Network 1
LDB= SMB86, 16#20
MOVB 10, SMB34
ATCH INT_1, 10
CRETI
NOT
RCV VB100, 0
Network 1
LD SM0.0
DTCH 10
XMT VB100, 0
On the first scan:
1. Initialize Freeport:
- Select 9600 baud.
- Select 8 data bits.
- Select no parity.
2. Initialize RCV message control byte:
- RCV enabled.
- Detect end of message character.
- Detect idle line condition as the mes-
sage start condition.
3. Set end of message character to
hex 0A (line feed).
4. Set idle line timeout to 5 ms.
5. Set maximum number of characters
to 100.
6. Attach interrupt 0 to the Receive
Complete event.
7. Attach interrupt 2 to the Transmit
Complete event.
8. Enable user interrupts.
9. Enable receive box with buffer at
VB100.
Receive complete interrupt routine:
1. If receive status shows receive of
end character, then attach a 10 ms
timer to trigger a transmit and return.
2. If the receive completed for any
other reason, then start a new receive.
10-ms Timer interrupt:
1. Detach timer interrupt.
2. Transmit message back to user on
port.
System Manual, V2.3, 07/2017, A5E03822230-AF
S7-200 SMART