|
ADAM-5510
Series' Powerful Communication Capacity with Communication Functional
Block
Compared to other PLCs, the rich communication interface of the
ADAM-5510 SoftLogic Controller Series is a major advantage. To provide
an easy-to-use environment through networking interfaces, Advantech
has released a new functional block for ASCII communication integration
through onboard COM ports and ADAM-5090 (4-Port RS-232 Module) modular
expansion COM ports.
This means you have not only five IEC61131 compatible programming
languages, but also great communication capacity.
Following is
a quick example to show how the Communication Functional Block is
used.
Note:
1. This function has been supported from ADAM-5510 KW Series (ADAM-5510KW,
ADAM-5510EKW, ADAM-5510EKW/TP) firmware version 1.21 Build 033 or
above.
2. The recommended maximum polling speed is 30 ms
Communication
Functional Block Example
Introduction
of Functional Blocks
1.
COM_FB: Communication Functional Blocks

2. ADAM-4000:
Functional Block for Connecting Multiple ADAM-4000 Modules by ADAM
ASCII Protocol 
3. Get_ASC_CMD:
Functional Blocks for Getting Dedicated Response from Respective
ADAM-4000 Modules.
·Overview
of the example
COM_FB Parameters

| Send_Array:
|
Byte
Array for Command |
| Recv_Array:
|
Byte
Array for Response |
| EN:
|
enable;
0: disable |
| Slot: |
0~7:
ADAM-5510KW Series I/O slot number 0~7 for ADAM-5090 |
|
8:
COM4 |
| Channel: |
0~3:
ADAM-5090 Channel 0~3 |
|
0: COM4 |
| Baud
Rate: |
1200,
2400, 4800, 9600, 19200, 38400, 57600, 115200 bps |
| Parity:
0: |
None |
|
1: Even |
|
2:
Odd |
| Stop
Bit: |
1 or 2 |
| Data
Length: |
7
or 8 |
| Expect_Send_Len: |
Bytes
Count for Command (max. 80 bytes) |
| Expect_Recv_Len: |
Bytes
Count for Response (max. 80 bytes) |
| Terminate_Char: |
Terminate
Character of ASCII Command |
| Note:
|
1. The value of Terminate_Char is specified as 0 while sending
binary command. |
|
2.
The maximum length of Command is 80 bytes including Terminate
Character. |
| Timeout: |
msec
Unit |
| CLK:
|
Trig
Signal by Rising Edge |
| Q: |
If
the execution is completed, Q changes from FALSE to TRUE |
| Error_Code: |
0:
No Error |
|
1:
Buffer Allocation Error for Sent Command |
|
2:
Illegal Parameter Setting for Slot or Channel number |
| Recv_Ready:
|
0:
Not Ready; 1: Ready
|
ADAM4000
Source Codes by Structured Text

| (*
Set timeout period based on Timeout_Val*Cycle Time *) |
|
Timeout
:= Timeout+1; |
|
if
Timeout > Timeout_Val then (* Poll next module while time-out
*)
|
| Timeout
:= 0; |
| IsCOMMRetry
= true; (* Retry is true *) |
| if
idx < Module_Amt then |
| idx
:= idx+1; |
|
| end_if; |
|
| Excute
:= true; |
|
| else |
|
| IsCOMMRetry
:= false; (* Retry is false *) |
| end_if; |
|
| if
Excute = true then |
|
| Timeout
:= 0; |
|
| if
idx = 0 then (* idx is the index of array *) |
| comfbs[1].Send_CMD
:= '#01'; (* ADAM-4011 ID=1 Read AI Command *) |
| comfbs[1].Send_CMD_Len
:= 3; (* ADAM-4011 AI Command Length Response excluding |
| Terminate
Character *) |
| comfbs[1].recv_CMD_Len
:= 8; (* ADAM-4011 AI Response excluding Terminate Character
*) |
| comfbs[2].Send_CMD
:= '$026'; (* ADAM-4056S ID=2 Read DO Status Command *) |
| comfbs[2].Send_CMD_Len
:= 4; (* ADAM-4056S DO Status Command Length excluding |
| Terminate
Character *) |
| comfbs[2].recv_CMD_Len
:= 7; (* ADAM-4056S DO Status Response excluding Terminate |
| Character
*) |
| idx
:= 1; |
| end_if; |
| Module_Amt
:= 2; (* Number of ADAM-4000 Modules *) |
| if
idx > Module_Amt then (* Reset the index to 1 after the last
ADAM-4000 modulee is polled *) |
| idx
:= 1; |
| end_if; |
| Send_cmd
:= comfbs[idx].Send_CMD; (* Send current command out *) |
| Send_cmd_len
:= comfbs[idx].Send_CMD_Len; (* Set sent command length *) |
| Recv_cmd_len
:= comfbs[idx].recv_CMD_Len; (* Set received response length
*) |
| if
idx = 1 then (* Received response is previous one *) |
| prv_Idx
:= Module_Amt; (* If index is 1 then received response is from
the last module *) |
| else |
| prv_Idx
:= idx-1; |
| end_if; |
| if
IsCOMMRetry = false then (* Move the string while Retry is false
*) |
| comfbs[prv_Idx].Recv_cmd
:= Recv_cmd; (* Received response is previous one *) |
| end_if; |
| idx
:= idx+1; |
| Done
:= true; |
| else |
| if
idx = 0 then (* The ID=1 module must work at program start in
this example *) |
| Send_cmd
:= '#01'; (* ADAM-4011 ID=1 Read AI Command *) |
| Send_cmd_len
:= 3; (* ADAM-4011 AI Command Length Response excluding Terminate
Character *) |
| Recv_cmd_len
:= 8; (* ADAM-4011 AI Response excluding Terminate Character
*) |
| end_if;
|
| Done
:= false; |
| end_if; |
| Data
Type Definition: Com_FBs |
| TYPE |
|
|
| |
Com_FBs
: |
|
| |
STRUCT |
|
| |
|
Send_CMD
: String; |
| |
|
Recv_CMD
: String; |
| |
|
Send_CMD_Len
: int; |
| |
|
recv_CMD_Len
: int; |
| |
END_STRUCT; |
|
| END_TYPE |
|
|
| Data
Type Definition: ASCFB_Array |
|
TYPE
|
|
|
|
ASCFB_Array
: ARRAY [1..10] OF Com_FBs; |
| END_TYPE |
|
|
Get_ASC_CMD
Source Codes by Structured Text
| if
Excute |
= true then |
asc_cmd
:= com_fbs[idx].Recv_cmd;
|
(*
Get the dedicated responsefrom respective command of idx *) |
| end_if;
|
|
Setting
the polling speed

Note: Recommended
maximum speed is 30 ms.
|