Programming Structure
(Original Document)
Steps Comments
Step number
Step description
Element
0
Initial state of function
When Start bit switches to 1, initialize error to 0 and go to step 5.
Modem
5
Read serial port status and check that no command is active.
Switch to Character mode and initialize Test_inc counter to 0.
Go to step 10.
10
Read serial port status and check that no command is active.
Reset TO_CHAR_MODE command bit.
  • If there is no error on the serial port
    • and Character mode is active, then go to step 15.
    • and Character mode is not active, then increment Test_inc and retry step 10 up to 1000 times. After 1000 failing retries, set Error to 10 and go to step 130.
  • If there is an error on the serial port then
    • set Error to 10.
    • Go to step 130.
15
Send a dial command to the modem via the PRINT_CHAR block.
Go to step 20.
20
If the result of PRINT_CHAR is conclusive then go to step 25 otherwise set Error to 20 and go to step 130.
25
Waiting for the response of the modem via the INPUT_CHAR block. Once the response string is fully received, go to step 30.
30
If the result of INPUT_CHAR is conclusive then go to step 35 otherwise set Error to 30 and go to step 130.
35
If the modem responds as expected then go to step 40 otherwise set Error at 35 and go to step 130.
40
Read serial port status and check that no command is active.
Switch to Modbus Master mode and initialize Test_inc counter to 0.
Go to step 45.
Modbus Master Mode
45
Read serial port status and check that no command is active.
Reset TO_CHAR_MODE command bit.
  • If there is no error on the serial port
    • and Character mode is active, then go to step 50.
    • and Character mode is not active, then increment Test_inc and retry step 45 up to 1000 times. After 1000 failing retries, set Error to 45 and go to step 130.
  • If there is an error on the serial port then
    • set Error to 45.
    • Go to step 130.
50
Initialization of WRITE_VAR block parameter.
Send data to write on the PLC using the WRITE_VAR function.
Go to step 55.
Write function
55
If the result of WRITE_VAR is conclusive then go to step 60 otherwise set Error to 55 and go to step 130.
60
Read serial port status and check that no command is active.
Switch to Character mode and initialize Test_inc counter to 0.
Go to step 65
Character mode
65
Read serial port status and check that no command is active.
Reset TO_CHAR_MODE command bit.
  • If there is no error on the serial port
    • and Character mode is active, then go to step 70.
    • and Character mode is not active, then increment Test_inc and retry step 65 up to 1000 times. After 1000 failing retries, set Error to 65 and go to step 130.
  • If there is an error on the serial port then
    • set Error to 65.
    • Go to step 130.
70
Send an escape sequence to the modem using the PRINT_CHAR block.
Go to step 75.
Modem
75
If the result of PRINT_CHAR is conclusive then go to step 80 otherwise set Error at 75 and go to step 130.
80
Waiting for the response of the modem via the INPUT_CHAR block. Once the response string is fully received, go to step 85.
85
If the result of INPUT_CHAR is conclusive then go to step 90 otherwise set Error to 85 and go to step 130.
90
If the modem responds as expected then go to step 95 otherwise set Error to 90 and go to step 130.
95
Send a disconnection command to the modem using the PRINT_CHAR block.
Go to step 100.
100
If the result of PRINT_CHAR is conclusive then go to step 105 otherwise set Error to 100 and go to step 130.
105
Waiting for the response of the modem via the INPUT_CHAR block. Once the response string is fully received, go to step 110.
110
If the result of INPUT_CHAR is conclusive then go to step 115 otherwise set Error to 110 and go to step 130.
115
If the modem responds as expected then go to step 120 otherwise set Error to 115 and go to step 130.
120
Read serial port status and check that no command is active.
Switch to Modbus Slave mode and initialize Test_inc counter to 0.
Go to step 125.
Modbus Slave mode
125
Read serial port status and check that no command is active.
Reset TO_CHAR_MODE command bit.
  • If there is no error on the serial port
    • and Character mode is active, then go to step 130.
    • and Character mode is not active, then increment Test_inc and retry step 125 up to 1000 times. After 1000 failing retries, set Error to 125 and go to step 130.
  • If there is an error on the serial port then
    • set Error to 125.
    • Go to step 130.
130
Return to step 0.