28
Application Example – Add on Description on STEP 7-Micro/WIN library for SMS sending and receiving Appendix for Micro Application Example 5

Set5 DocLibrary V2D0 En

Embed Size (px)

DESCRIPTION

Set5 DocLibrary V2D0 En

Citation preview

Page 1: Set5 DocLibrary V2D0 En

Application Example – Add on

Description on STEP 7-Micro/WIN library for SMS sending and receiving

Appendix for Micro Application Example 5

Page 2: Set5 DocLibrary V2D0 En

Table of Contents

Micro Automation Set 5 Beitrags-ID 21063345

Page 2/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

Note The Micro Automation Sets are not binding and do not claim to be complete regarding the circuits shown, equipping and any eventuality. The Micro Automation Sets do not represent customer-specific solutions. They are only intended to provide support for typical applications. You are responsible for ensuring that the described products are correctly used. These Micro Automation Sets do not relieve you of the responsibility of safely and professionally using, installing, operating and servicing equipment. When using these Micro Automation Sets, you recognize that Siemens cannot be made liable for any damage/claims beyond the liability clause described. We reserve the right to make changes to these Micro Automation Sets at any time without prior notice. If there are any deviations between the recommendations provided in these Micro Automation Sets and other Siemens publications – e.g. Catalogs – the contents of the other documents have priority.

Warranty, Liability and Support We accept no liability for information contained in this document.

Any claims against us – based on whatever legal reason – resulting from the use of the examples, information, programs, engineering and performance data etc., described in this Micro Automation Set shall be excluded. Such an exclusion shall not apply in the case of mandatory liability, e.g. under the German Product Liability Act (“Produkthaftungsgesetz”), in case of intent, gross negligence, or injury of life, body or health, guarantee for the quality of a product, fraudulent concealment of a deficiency or breach of a condition which goes to the root of the contract (“wesentliche Vertragspflichten”). However, claims arising from a breach of a condition which goes to the root of the contract shall be limited to the foreseeable damage which is intrinsic to the contract, unless caused by intent or gross negligence or based on mandatory liability for injury of life, body or health. The above provisions does not imply a change in the burden of proof to your detriment.

Copyright© 2006 Siemens A&D. It is not permissible to transfer or copy these Micro Automation Sets or excerpts of them without first having prior authorization from Siemens A&D in writing.

For questions about this document please use the following e-mail-address:

[email protected]

Page 3: Set5 DocLibrary V2D0 En

Table of Contents

Micro Automation Set 5 Beitrags-ID 21063345

Page 3/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

Foreword Micro Automation Sets are fully functional and tested automation configurations based on A&D standard products for simple, fast and inexpensive implementation of automation tasks for small-scale automation. Each of the available Micro Automatic Sets covers a frequently occurring subtask of a typical customer problem in the low-end performance level.

The sets help you obtain answers with regard to required products and the question how they function when combined.

However, depending on the system requirements, a variety of other components (e.g. other CPUs, power supplies, etc.) can be used to implement the functionality on which this set is based. Please refer to the respective SIEMENS A&D catalogs for these components. The Micro Automation Sets are also available by clicking the following link:

http://www.siemens.de/microset

Table of Contents

Table of Contents 3

1 Library Overview............................................................................................. 4

1.1 The “SMS_init” block in detail ........................................................................... 5

1.2 The “SMS_send” block in detail ........................................................................ 9

1.3 The “SMS_receive” block in detail .................................................................. 11

1.4 The “SMS_xmt_rcv_manage” block in detail .................................................. 14

1.5 The “SMS_tele_handle” block in detail ........................................................... 17

2 Working with the library............................................................................... 19

2.1 Integrating the library into STEP 7 Micro/WIN ................................................ 19

2.2 Using library blocks......................................................................................... 20

2.3 Editing and supplementing library blocks ....................................................... 21

3 Interface Description of the Library ............................................................ 22

3.1 Calling SMS_init ............................................................................................. 22

3.2 Calling SMS_send .......................................................................................... 24

3.3 Calling SMS_receive ...................................................................................... 26

3.4 Calling SMS_tele_handle ............................................................................... 27

4 Status and Error Words in the Library........................................................ 28

Page 4: Set5 DocLibrary V2D0 En

Library Overview

Micro Automation Set 5 Beitrags-ID 21063345

1 Library Overview

The library contains the following blocks:

• SMS_init

• SMS_send

• SMS_receive

• SMS_xmt_rcv_manage (must not be called directly)

• INT_XMT (is called automatically during pending event)

• SMS_tele_handle

To be able to use the functionality for sending and receiving an SMS, the SMS_init, SMS_send and SMS_receive blocks must be called cyclically in your user program.

Page 4/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

The “INT_XMT“ interrupt program is called automatically when the according event is pending.

To use the teleservice functionality, the SMS_tele_handle block must additionally be called cyclically in your user program.

The SMS_xmt_rcv_manage block must not be called. Note

Figure 1-1

2.9 Kbyte

2.6 Kbyte

X-XXXTeleservice

--XXXSend and receive SMSSMS_in

it

SMS_sen

d

SMS_rece

ive

SMS_xmt_r

cv_m

anag

e

SMS_tele_

hand

le

X = called- = not called

Block s

ize, to

tal

Desire

d fun

ction

ality

Note The blocks described below were tested with the GSM modems

• TC65 Terminal Revision 02.000

• MD720-3 HW version 3.4, FW version 1.7.4

• TC35 Terminal Revision 3.00

• TC35i Revision 3.01

Page 5: Set5 DocLibrary V2D0 En

Library Overview

Micro Automation Set 5 Beitrags-ID 21063345

1.1 The “SMS_init” block in detail

The “SMS_init” block starts the initialization procedure of the modem after a positive edge at the “SMS_Send” block input.

Page 5/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

Figure 1-2

Start timeout

Configure interface

Deactivate echo mode

Check PIN

End

Change rate at port 0

Deactivate echo mode

Change rate at modem

Transfer PIN

Transfer SMS format

Transfer SMS servicecenter

Start

successfulnot successful

successfulnot successful

successfulnot successful

Tim

er>

80 s

econ

ds

Only the most important parameters and program routines of the library for sending and receiving SMS messages are described. You receive detailed information in the respective networks in the STEP 7 Micro/WIN project after adding the library. The password for the library is “1234”.

Note

During this initialization phase, each step is monitored for a successful acknowledgement. If a step cannot be performed, this leads to a respective comment in the error word. The initialization phase is interrupted.

If the above step chain does not terminate, the process is cancelled after a timeout of 80 seconds. This may be the case if, for example, no AT command is acknowledged and switching the transmission speed at port 0 does not change this behavior.

Page 6: Set5 DocLibrary V2D0 En

Library Overview

Micro Automation Set 5 Beitrags-ID 21063345

Page 6/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

Configuring the interface The “SMS_init“ sub program is used to prepare interface 0 of the S7-200 CPU for using the AT commands. After completing the “SMS_init” block, port 0 is set as follows.

The settings are made in special memory byte “SMB30”. The most important settings are mentioned in the following table. Table 1-1

No. Parameter Entry 1. Communication protocol Protocol of Freeport communication mode

2. Transmission rate 9.6 Kbit/s

3. Number of data bits 8 data bits per character

4. Parity No parity

5. Stop bit One stop bit

After configuring the communication interface, the procedure for recognizing incoming data is parameterized. This parameterization occurs in special memory byte “SMB87”. Table 1-2

No. Parameter Entry

1. Condition for terminating the receive routine.

Terminate receiving when the time period after receiving the first character has been exceeded. The time period is entered in special memory word “SMW92”.

2. Recognize idle line time period. If a certain time period is exceeded between the receive characters, this is interpreted as telegram end. The time for the idle line time period is parameterized in special memory word “SMW90”.

3. Condition for starting the receive routine.

The receive routine is started if an idle line time period was recognized and the first character arrives.

4. Mode of serial interface. After initializing, the interface is set to “Receive”. For pending send jobs, the “Send” mode is always switched to separately later.

The idle line time period (“SMW90“) between the characters is set to one millisecond. The timeout for terminating the receive routine (“SMW92“) shows 5 milliseconds.

Page 7: Set5 DocLibrary V2D0 En

Library Overview

Micro Automation Set 5 Beitrags-ID 21063345

Deactivate echo mode and change rate at port 0

Figure 1-3

Deactivate echo mode

successfulnot successful

Während der Initialisierungsroutine wird das Modemecho ausgeschaltet.

Ist der Versuch zum Ausschalten des Modemechos beim ersten Mal erfolgreich, wird die Routine zum Ändern der Geschwindigkeit an Port 0 nicht durchlaufen. Figure 1-4

Page 7/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

Change rate at port 0

Deactivate echo mode

Change rate at modem

successfulnot successful

If the command is not acknowledged by the modem, the rate at port 0 of the S7-200 is changed to the following transmission rates:

• 9,600 Kbit/s

• 19,200 Kbit/s

• 115,200 Kbit/s

These are the transmission rates parameterized as default in TC65 Terminal and SINAUT MD720-3.

After each changing of the transmission rate there will be another attempt to switch off the modem echo. If successful, the modem is set to the transmission rate of 9.600 Kbit/s.

Check and transfer PIN Figure 1-5

Check PIN

Transfer PIN

successfulnot successful

During the initialization it is checked whether the PIN number has already been transferred to the modem.

Page 8: Set5 DocLibrary V2D0 En

Library Overview

Micro Automation Set 5 Beitrags-ID 21063345

If the PIN has already been transferred, it is assumed, that the modem has already logged on to the GSM network. In this case, the next step is started. Figure 1-6

Transfer PIN

If the PIN number has not been transferred, the routine for transmitting this number is started. Up to 40 seconds may elapse until the AT command is acknowledged successfully. A waiting time of maximum 40 seconds is parameterized in the library. The waiting time results from the different reactions of the GSM modems TC65 Terminal and SINAUT MD720-3 as well as the site-specific field intensity.

• TC65 Terminal immediately delivers an acknowledgment after the PIN has been transferred.

Page 8/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

• The SINAUT MD720-3 only delivers an acknowledgement after the PIN has been transferred, if the modem has successfully logged on to the GSM network.

• Insufficient signal intensity and/or insufficient signal quality may additionally delay the logon to the provider and thus an acknowledgement.

Transfer SMS format Figure 1-7

Transfer SMS format

Sending and receiving SMS messages is handled in this library in the text mode of the GSM modem. The modem must be explicitly informed of these settings via an AT command.

Transfer SMS service center Figure 1-8

Transfer SMS service center

During the initialization the provider-dependent SMS service center is transferred.

A transfer of the SMS service center is only possible, if the modem is successfully logged on to the provider. If this log on procedure takes considerably longer, the initialization process is cancelled with the “16” status. The initialization must be restarted.

Page 9: Set5 DocLibrary V2D0 En

Library Overview

Micro Automation Set 5 Beitrags-ID 21063345

After this step, the initialization process is terminated.

1.2 The “SMS_send” block in detail

The “SMS_send“ block starts the SMS send process after a positive edge at the “SMS_send_start“ block input. Figure 1-9

Start timeout

Transmit receiver call number

Transmit SMS text

End

Start

Tim

er>

25 s

econ

ds

Page 9/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

Only the most important parameters and program routines of the library for sending and receiving SMS messages are described. You receive detailed information in the respective networks in the STEP 7 Micro/WIN project after adding the library. The password for the library is “1234”.

Note

During the send process, each step is monitored for a successful acknowledgement. If a step cannot be performed, this is noted in the error word accordingly and the send process is cancelled.

If the above step chain does not terminate, the process is cancelled after a timeout of 25 seconds. This case may occur, for example, if during transmission of receiver call number or SMS text the connection between S7-200 controller and GSM modem is interrupted.

Transmit receiver call number Figure 1-10

Transmit receivercall number

The first step during the send process transmits the call numbers of the receiver to receive the following message to the modem.

Page 10: Set5 DocLibrary V2D0 En

Library Overview

Micro Automation Set 5 Beitrags-ID 21063345

Transmit SMS text

Figure 1-11

Transmit SMS text

The second step during the send process transmits the SMS message and starts the send process in the modem.

The length of the SMS must not exceed 160 characters.

After this step, the send process is terminated.

Page 10/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

Page 11: Set5 DocLibrary V2D0 En

Library Overview

Micro Automation Set 5 Beitrags-ID 21063345

1.3 The “SMS_receive” block in detail

It is recommended to ask the provider to deactivate receiving news or advertising messages for the used SIM card. These SMS messages may cause unintended system states.

Note

The “SMS_receive“ block starts the SMS send process after a positive edge at the “SMS_rcv_start“ block input.

Page 11/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

Figure 1-12

Start timeout

End

Process first existing short message

Start

notsuccessful

Tim

er>

40 s

econ

ds successful

Delete short message

Request all existing short messages

Only the most important parameters and program routines of the library for sending and receiving SMS messages are described. You receive detailed information in the respective networks in the STEP 7 Micro/WIN project after adding the library. The password for the library is “1234”.

Note

To recognize an existing SMS on the SIM card or the integrated modem memory in the GSM modem, the “SMS_receive” block must be actively triggered. The shorter you select the duration between calling the block, the faster newly received SMS messages are recognized. However, the following aspects have to be considered:

• In the current setting, the timeout in the “SMS_receive“ subprogram may take up to 40 seconds. The cycle between two calls of the block should not fall below that.

• The “SMS_receive“ block blocks the “SMS_tele_handle“ subprogram during the receive process to avoid falsification of the data input. For the used teleservice functionality, this may cause increased waiting times until the teleservice request is answered by the GSM modem.

During receiving, each step is monitored for a successful acknowledgement. If a step cannot be performed, a respective remark is placed in the error word. The receive process is cancelled.

Page 12: Set5 DocLibrary V2D0 En

Library Overview

Micro Automation Set 5 Beitrags-ID 21063345

If the above step chain does not terminate, the process is cancelled after a timeout of 40 seconds.

Requesting all existing short messages Figure 1-13

Requesting all existing short messages

If the receive process is triggered, it is checked in the first step whether at least one SMS exists on the SIM card.

When receiving data, it is detected whether

• no SMS exists. The receive routine is thus completed and terminated with status 4. The receive process has been regularly terminated although the “Aborted” bit is set. It is not a malfunction of the block.

Page 12/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

• one or more SMS messages are available. Up to 240 characters are stored in the buffer. It is always at least the complete first SMS and a part of the possibly existing second SMS.

The table below describes some steps during this routine in greater detail. Table 1-3

No. Function Comment

1. During this step the pointer, which defines the receive buffer at the input of the “SMS_receive“ subprogram, is increased by +15.

This prevents overwriting the buffer by further AT commands.

2. The S7-200 controller reads all SMS messages from the memory of the GSM modem up to character 240. Afterwards, all subsequent incoming characters are blocked.

• Even at full 160 characters content plus header, at least the first SMS can always be received.

• If several SMS messages are pending at the modem, it is possible that several SMS messages are now displayed in the buffer. However, only the first SMS must be evaluated. For evaluating the second SMS, the “SMS_receive“ block must be called a second time.

3. The index number of the first SMS is cut.

• It is therefore irrelevant whether several SMS messages are in the buffer.

• Via this index number, the SMS can later be definitely deleted.

• The chronological order of the messages cannot be

Page 13: Set5 DocLibrary V2D0 En

Library Overview

Micro Automation Set 5 Beitrags-ID 21063345

No. Function Comment determined uniquely during reading (see Note)

4. Pointer, which defines the receive buffer at the input of the “SMS_receive“ subprogram, is reduced by +15.

All reactions to the now incoming AT commands do not overwrite the content of the received SMS.

Page 13/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

Note The chronological order of the SMS on the SIM card may become mixed up under the following circumstances.

1. There are at least two SMSes on the SIM card (index number 1 and 2)

2. The SMS with the index number 1 is read out as it is located at the top within the SIM card memory.

3. Another SMS arrives. The SMS with index number 2 has not been read out, even though in chronological order it is located before the just arrived SMS.

4. Index number 1 is assigned to the just arrived SMS.

5. The SMS with index number 1 is read out again as the latest SMS has filled the previously created gap.

The SMS is now located in the user defined “SMS_rcv_msg“ buffer with an offset of +15 bytes.

Delete SMS Figure 1-14

Delete short message

In the last step of the receive routine the SMS in the modem memory is deleted via the previously cut out index number (see Table 1-3 No. 3).

The receive routine has been successfully terminated.

Page 14: Set5 DocLibrary V2D0 En

Library Overview

Micro Automation Set 5 Beitrags-ID 21063345

1.4 The “SMS_xmt_rcv_manage” block in detail

The “SMS_xmt_rcv_manage“ block is used by all other blocks to send AT commands to the modem via the serial interface. Furthermore, this block evaluates the reaction of the modem. Figure 1-15

Page 14/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

Start waiting time

Set serial interface to send mode

End

Start

Send AT command to modem

Set serial interface to receive mode

Evaluate reaction of the modem

Start timeout

Tim

eout

> 15

sec

onds

Terminate receive mode of the serial interface

Start waiting time Figure 1-16

Start waiting time

Between a reaction on an AT command with “OK” or “ERROR”, for example, and a new AT command, a defined period of time must elapse so the new AT command can be transmitted correctly. In the subprogram a waiting time of 500 milliseconds is therefore parameterized prior to each AT command.

Exception: If an SMS is being currently fetched from the modem, the following AT command is only sent after 3 seconds to ensure that the incoming SMS characters are not corrupted by the following command.

Page 15: Set5 DocLibrary V2D0 En

Library Overview

Micro Automation Set 5 Beitrags-ID 21063345

Set serial interface to send mode

Figure 1-17

Set serial interface to send mode

Prior to an AT command, receiving is deactivated at the serial interface and the send mode is activated.

Sending the AT command to the modem Figure 1-18

Send AT command to the modem

The AT command transferred by the respective subprogram is now sent to the modem.

Page 15/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

Set serial interface to receive mode Figure 1-19

Set serial interface to receive mode

As soon as the AT command has been sent successfully, the port is switched back to receive mode.

The “INT_XMT” interrupt program is used as an indicator for successful sending of an AT command.

Start timeout and wait for and evaluate the reaction of the modem Figure 1-20

End

Start timeout

Tim

eout

> 15

sec

onds

Evaluate reaction of modem

Terminate receive mode of the serial interface

The respective subprogram which calls the “SMS_xmt_rcv_manage“ routine has, in addition to the transferred AT command, also specified the expected reaction of the modem to the AT command.

Page 16: Set5 DocLibrary V2D0 En

Library Overview

Micro Automation Set 5 Beitrags-ID 21063345

Page 16/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

Table 1-4

Command Expected acknowledgement

ATE0 OK

AT+IPR= OK

AT+CPIN? READY

AT+CPIN= OK

AT+CMGF= OK

AT+CSCA= OK

AT+CMGS= >

<<Text input>> +

AT+CPMS? OK

AT+CMGL= ,$“

AT+CMGD= OK

ATA CON

+++ OK

If the desired string is received, the “SMS_xmt_rcv_manage“ block reports successful processing.

After having received characters, the receive mode of the serial interface is deactivated to prevent the evaluation from being distorted by the incoming characters.

If the desired text is not received, or the waiting time of 15 seconds elapses, faulty processing is reported.

Exception: After the PIN number has been transferred to the modem, a waiting time of 40 seconds starts until a modem reaction is obtained. This approximately corresponds to the maximum duration of a log on procedure to the mobile communications network of the provider. The routine for the “Send and Confirm AT Command” is terminated.

Page 17: Set5 DocLibrary V2D0 En

Library Overview

Micro Automation Set 5 Beitrags-ID 21063345

1.5 The “SMS_tele_handle” block in detail

The cyclically called “SMS_tele_handle“ block monitors the interface for incoming calls at the modem. If a call is recognized, a teleservice connection is established.

When using the teleservice functionality, the following should be considered:

• For an initialization, send or receive job during a teleservice connection these jobs are immediately cancelled. The teleservice connection takes precedence.

• During an initialization, send or receive process no call can be taken. The time up to taking the call and until generating the teleservice connection can so be prolonged or cancelled entirely if not waited long enough.

• As soon as the “SMS_tele_handle“ is called cyclically in the program, anyone who knows the call number of the SIM card in your modem can access it.

Page 17/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

Figure 1-21

Wait for call

Searching the buffer for“RING“ signal

End

Start

Receive call and activatePPI protocol

Start teleservice session

Activate Freeport protocoland terminate teleservice

successfulnot successful

Wait for call and search the buffer Figure 1-22

Wait for call

Search the buffer for“RING“ signal

successfulnot successful

If the “SMS_tele_handle“ subprogram has been activated, it monitors incoming calls. An incoming call is signaled by the “RING“ string.

Page 18: Set5 DocLibrary V2D0 En

Library Overview

Micro Automation Set 5 Beitrags-ID 21063345

Accept call and activate PPI protocol

Figure 1-23

Accept call and activatePPI protocol

After the call has been recognized, the call is accepted via an AT command. To enable the connection between a remote STEP 7 Micro/WIN and the local S7-200 with GSM Modem, port 0 of the “Freeport communication mode“ is switched to “PPI” mode.

During PPI communication, i.e. while the teleservice connection is active, no SMS can be sent or received.

Establish duration of the teleservice session Figure 1-24

Page 18/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

Start teleservice session

With the successful acceptance of the call, the teleservice session has a time window of 180 seconds reserved to it.

The time window can be extended in the “SMS_tele_handle“ library block in network 10. Input in milliseconds.

Terminate teleservice and activate Freeport communication mode Figure 1-25

Terminate teleservice and activate Freeport

communication mode

After 180 seconds, the teleservice connection is terminated automatically. To enable repeated sending and receiving of SMSes, port 0 of the “PPI“ mode is switched to “Freeport communication mode”.

The routine for starting and terminating a teleservice connection is terminated.

Page 19: Set5 DocLibrary V2D0 En

Working with the library

Micro Automation Set 5 Beitrags-ID 21063345

2 Working with the library

2.1 Integrating the library into STEP 7 Micro/WIN

In order to use a library in STEP 7 Micro/WIN, it has to be integrated into the configuration software first. The necessary steps are shown in the following table. Table 2-1

Step Action Comment

1. The library is available on the HTML page where you loaded this document. Save the library onto your hard disk.

set5_s7-200-library.mwl

2. Open STEP 7 Micro/WIN. 3. • Right click on “Libraries” in the

project tree. • Select “Add/Remove Libraries”.

Page 19/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

4. • Click the “Add“ button on the left.

• Navigate on your hard disk to the position of the stored library and highlight it.

• Confirm this dialog with "OK". 5. • The library appears in a window.

• Acknowledge this window with "OK".

6. The library is available in STEP 7-

Micro/WIN now.

Page 20: Set5 DocLibrary V2D0 En

Working with the library

Micro Automation Set 5 Beitrags-ID 21063345

2.2 Using library blocks

Table 2-2

Step Action Figure/Comment

1. Open STEP 7 Micro/WIN. 2. 1

2

Assign the respective memory area to the library. Click “Program Block” (1) with the right mouse button and select “Library Memory...” (2) from the context menu.

3. Enter the memory area which you want

to use in the following menu. (The library requires 218 bytes) Acknowledge with “OK”.

Page 20/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

12

4. In the program you navigate to the location where you wish to add the subprogram of the library (1). In “Libraries“ you select the desired block and dag&drop it into your user program.

2

1

5. Link the EN input of the library block with the SM0.0 variable.

The SM0.0 variable is a special memory bit and is “On“ in each CPU cycle.

Page 21: Set5 DocLibrary V2D0 En

Working with the library

Micro Automation Set 5 Beitrags-ID 21063345

2.3 Editing and supplementing library blocks

The subprograms in the library are password protected to avoid accidental changes. However, you can enter the password at any time to have full access to the subprograms. Table 2-3

No. Function Comment

1. Select the desired block in Library (1) and open the context menu with the left mouse button. Click the “Properties” button (2).

1

2

Page 21/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

2. Select the “Protection” tab (1) and

place the cursor into the input field (2) on the left side of the ”Authorize” button. Enter the password “1234” (3) and acknowledge by pressing “Authorize” (4). 4

5

1

2

Acknowledge by pressing “OK” (5).

12343

3.

In the respective subprogram of the library you can now obtain detailed information via the comments, or supplement the blocks yourself.

Page 22: Set5 DocLibrary V2D0 En

Interface Description of the Library

Micro Automation Set 5 Beitrags-ID 21063345

3 Interface Description of the Library

3.1 Calling SMS_init

Figure 3-1

Table 3-1

No. Designation Transfer Data Type Description/Note

1. EN IN BOOL • Activates the subprogram

Page 22/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

• Is usually called with the special memory bit “SM0.0”

2. SMS_init_start IN BOOL • Starts the process for initializing the connected modem

• The library subprogram only evaluates the positive edge

3. SMS_init_pin IN STRING • Enters the PIN number of the SIM card to your modem

• Is transferred as pointer and must be marked by a leading “&” (e.g. &VB100)

• Four digit number • Value assignment occurs in the

data block 4. SMS_init_ssc IN STRING • Specifies your provider’s short

message center for sending SMSes

• Is transferred as pointer and must be marked by a leading “&” (e.g. &VB100)

• Value assignment occurs in the data block

• It is written with a leading “+” and the respective country code. The leading 0 of the area code is left out. (e.g. “+4912344444444”)

5. SMS_init_busy OUT BOOL • Is activated if the subprogram performs the initialization of the modem

• Is set immediately after the start via

Page 23: Set5 DocLibrary V2D0 En

Interface Description of the Library

Micro Automation Set 5 Beitrags-ID 21063345

Page 23/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

No. Designation Transfer Data Type Description/Note “SMS_init_start”

6. SMS_init_done OUT BOOL • Is activated as soon as the initialization has been completed successfully.

7. SMS_init_aborted OUT BOOL • Is activated as soon as the initialization was faulty.

• If this bit is active, the status word “SMS_init_status” must be looked out for

• This output is set after 80 seconds at the latest, if “SMS_init_done” has not become active by then

8. SMS_init_status OUT WORD • Indicates the current step of the initialization.

• Can be used in case of an error to determine the source of error (see Chapter 4)

Page 24: Set5 DocLibrary V2D0 En

Interface Description of the Library

Micro Automation Set 5 Beitrags-ID 21063345

3.2 Calling SMS_send

Figure 3-2

Table 3-2

No. Designation Transfer Data Type Description

1. EN IN BOOL • Activates the subprogram • Is usually called with the special

memory bit “SM0.0” 2. SMS_send_start IN BOOL • Starts the send process for

sending an SMS via the connected modem

Page 24/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

• The library subprogram only evaluates the positive edge

3. SMS_send_tn IN STRING • Specifies the receive address for sending your SMS

• Is transferred as pointer and must be marked by a leading “&” (e.g. &VB100)

• Value assignment occurs in the data block

• It is written with a leading “+” and the respective country code. The leading 0 of the area code is left out. (e.g. “+4912344444444”)

4. SMS_send_msg IN STRING • Specifies the message to be sent. • Is transferred as pointer and must

be marked by a leading “&” (e.g. &VB100)

• Value assignment occurs in the data block

• The number of characters is reduced to 160.

• Control characters are labeled with a starting “$”

• Control characters are for example: – $$ Single dollar sign – $’ Single quote character

Page 25: Set5 DocLibrary V2D0 En

Interface Description of the Library

Micro Automation Set 5 Beitrags-ID 21063345

Page 25/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

No. Designation Transfer Data Type Description – $" Double quote character – $L or $l line feed character – $N or $n new line character – $P or $p form feed, new page – $R or $r carriage return

character – $T or $t tabulation, i.e. tab

character – $1f The two Hex digits 1f after

the $ specify ASCII code 1f.ASCII 1f Hex = ASCII 31 Decimal

• Das Verwenden von Steuerzeichen sollte vermieden werden. Es kann je nach verwendetem Modem zu unterschiedlichen Verhalten führen.

5. SMS_send_busy OUT BOOL • Is activated if the subprogram performs the send procedure of the modem

• Is set immediately after the start via “SMS_send_start”

6. SMS_send_done OUT BOOL • Is activated when the send process was completed successfully.

7. SMS_send_aborted OUT BOOL • Is activated if the send process was faulty.

• If this bit is active, the status word “SMS_send_status” must be looked out for

• This output is set after 25 seconds at the latest, if “SMS_send_done” has not become active by then

8. SMS_send_status OUT WORD • Indicates the current step of the send process.

• Can be used in case of an error to determine the source of error (see Chapter 4)

Page 26: Set5 DocLibrary V2D0 En

Interface Description of the Library

Micro Automation Set 5 Beitrags-ID 21063345

3.3 Calling SMS_receive

Figure 3-3

Table 3-3

No. Designation Transfer Data type Description

1. EN IN BOOL • Activates the subprogram • Is usually called with the special

memory bit “SM0.0” 2. SMS_rcv_start IN BOOL • Starts the process for receiving

an SMS via the connected modem

Page 26/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

• The library subprogram only evaluates the positive edge

3. SMS_rcv_msg IN STRING • Specifies the buffer for the messages to be received and the reactions to the AT commands

• Is transferred as pointer and must be marked by a leading “&” (e.g. &VB100)

• The buffer must have a size of 255 bytes.

• The buffer is simultaneously used by the reactions of the modem to the sent AT command, as well as by the actually received SMS. To prevent the AT command from overwriting the SMS message, SMS messages are filed with an offset of +15 bytes. If the storage location VB100 has been specified for the “SMS_rcv_msg“ buffer, a received SMS can be found from VB115 on.

4. SMS_rcv_busy OUT BOOL • Is activated if the subprogram performs the receive procedure of the modem

• Is set immediately after the start via “SMS_rcv_start”

5. SMS_rcv_done OUT BOOL • Becomes active when the receive

Page 27: Set5 DocLibrary V2D0 En

Page 27/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

Interface Description of the Library

Micro Automation Set 5 Beitrags-ID 21063345

No. Designation Transfer Data type Description process was completed successfully.

6. SMS_rcv_aborted OUT BOOL • Is activated if the receive process was faulty.

• If this bit is active, the status word “SMS_rcv_status” must be looked out for

• This output is set after 40 seconds at the latest, if “SMS_rcv_done” has not become active by then

7. SMS_rcv_status OUT WORD • Indicates the current step of the receive process.

• Can be used in case of an error to determine the source of error (see Chapter 4)

3.4 Calling SMS_tele_handle

Figure 3-4

Table 3-4

No. Designation Transfer Data type Description

1. EN IN BOOL • Activates the subprogram • If no teleservice functionality is

desired anymore, this input must be deactivated

Page 28: Set5 DocLibrary V2D0 En

Status and Error Words in the Library

Micro Automation Set 5 Beitrags-ID 21063345

Page 28/28

Cop

yrig

ht ©

Sie

men

s A

G 2

008

All

right

s re

serv

ed

Set

5_D

ocLi

brar

y_V

2D0_

en.d

oc

4 Status and Error Words in the Library

Each block for sending and receiving SMSes informs of the current step in which it is operating by means of a status word. This information can be used to delimit the cause in case of an error.

The status is output in form of a decimal number and can be assigned as displayed in the following table.

SMS_init SMS_init_status SMS_send SMS_send_status SMS_receive SMS_rcv_status No. Meaning No. Meaning No. Meaning 1 Initializing and configuring port 0. 1 Initializing 1 Initializing 2 Switching off the echo. 2 Start send procedure. Transfer target call number. 2 SMS text received. 3 Echo switched off successfully. 3 Transfer of target call number successful. 3 SMS text received successfully.

4 Switching off the echo failed. 4 Transfer of target call number failed. 4 Receiving of SMS text failed. No message available.

5 Polling the Pin status. 5 Transfer message text. 5 Extract index number of the first received SMS. 6 Pin already transferred. 6 Transfer of message text successful. 6 Delete read SMS. 7 Pin not yet transferred. 7 Transfer of message text failed. 7 Deleting read out SMS successful. 8 Pin transferred. 8 Send procedure aborted. Timeout exceeded. 8 Deleting of read out SMS failed. 9 Pin transferred successfully. 9 Receive procedure cancelled Timeout exceeded.

10 Pin not transferred successfully. 11 Set text mode. 12 Text mode set successfully. 13 Text mode not set successfully. 14 Transfer of short message center. 15 Transfer of short message center successful. 16 Transfer of short message center unsuccessful. 17 AT transfer now possible. Switch system to 9600 bps. 18 Set port rate. 19 Setting of port rate failed. 20 Port rate not set successfully. 21 Initialization aborted. Timeout exceeded.