Vous êtes sur la page 1sur 104

Advantech PAC training:

KW multi-prog Step by Step

IAG Inter-corn AE
Alex Hsieh ()
Outline
Level 1 : Create
C:\Program Files a new project and link test
(x86)\Advantech\DAQNavi\LabviewDriver
Level 2 : IO configuration - IO slot
Level 3 : IO configuration - Modbus client and
Level 4 : IO configuration - Shared memory
Level 5 : KW Program - R/W data and define user function
Level 6 : KW Program - Modbus client and server expert
Level 7 : KW Program - Do it !
Level 1 : Create a new project and link test
Create a new project and link test

1.Create a new project


2.Link configuration and test
Create a new project New project
New project : select the target controller type
Link configuration and test Connection
Set up connection: Resource Setting .dll for ethernet
Link configuration and test Compile project
Compile project : before download project
Make : Compile change in this project
Rebuild project : Rebuild this project
Link configuration and test Check status
PAC status : check connect to PAC procoOS
Disconnection
Connection
(Timeout)
(Run)
Link configuration and test Project type
Download project : Click Info check the version, loading ..
Boot project :PAC run this project when booting up
Project : Now running project
Project source : Download the project from PAC
Link configuration and test Connection
Parameter : - ip 192.168.77.60 - TO 20000 (Time out)
PAC IP : 192.168.77.60
Time out : 2000 ms
Link configuration and test Download project
Download project : select download to PLC
Check list : bootporject and ensure real-time for download
change
Level 2 : IO configuration - IO slot

1. IO slot
2. Modbus client
3. Share memory
IO slot configuration system configuration
Advantech_DAQ : ADAM-5560KW IO slot
Product Slot / IP IO
ADAM-5560KW (192.168.77.60) 0 ADAM-5018
1 ADAM-5056
2 ADAM-5051
3 ADAM-5017
4 ADAM-5024
Laptop modsim utility 192.168.77.77 TCP server
Laptop modscan utility 192.168.77.77 TCP client
IO slot configuration Slot IO
Advantech_DAQ : input / output / Com port / ModbusTCP
IO slot configuration Slot 0
Input IO : add ADAM-5018P
Board ID : slot 0
Task : task
IO slot configuration Slot 0
AI type (T/C and input range): K type
All channel : Apply to All
IO slot configuration Slot 0
Start address : 0 (auto-napping)
Size : 28 byte (7ch T/C channel * 4 byte= 28 byte)
IO slot configuration Slot 1
Output IO : Add ADAM-5056
Board ID : slot 1
Task : task
IO slot configuration Slot 1
Start address : 0 (auto-mapping)
Size : 2 byte(16ch DO * 1bit = 2 byte)
IO slot configuration Slot 2
Output IO : Add ADAM-5051
Board ID : slot 2
Task : task
IO slot configuration Slot 2
Start address : 28 (follow ADAM-5018P)
Size : 2 byte (16ch DI * 1bit = 2 byte )
IO slot configuration Slot 3
Output IO : Add ADAM-5017
Board ID : slot 3
Task : task
IO slot configuration Slot 3
Start address : 30 (follow ADAM-5051)
Size : 32 byte (8ch AI channel * 4 byte = 32 byte )
IO slot configuration Slot 4
Output IO : Add ADAM-5024
Board ID : slot 1
Task : task
IO slot configuration Slot 4
Start address : 2 (follow ADAM-5056)
Size : 16 byte (4ch AI channel * 4 byte = 16 byte )
IO slot configuration Create all variable
Input : click create all group variable
Output : click create all group variable
Click ok to finish IO slot configuration
IO slot configuration Global variable
Global variable : see all variable Data type :
Base unit : Byte Boolean : %_IO_X0.1
Output : %Q_data type_ Byte : %_IO_B0
Input : %I_data type_ Word : %_IO_W0
Share memory : %M_data type_ Dword : %_IO_D0

Output : %QX0.0 - %QX0.1 - %QX1.7 Input : %ID0 - %ID4 - %ID24


Boolean = 1 bit Real = 2*Word = 4*Byte
IO slot configuration Practice
Example :
1. Input / Dword / 3 length / start address 4
%ID4 = (%IW4 + %IW6 ) = (%IB4 + %IB5 + %IB6 + %IB7 )
%ID8 = (%IW8 + %IW10 ) = (%IB8 + %IB9 + %IB10 + %IB11 )
%ID12 = (%IW12 + %IW14 ) = (%IB12 + %IB13 + %IB14 + %IB15 )
2. %QX4.1 - %QX4.6
Ontput / bit / 6 length / start address 4.1

Practice :
1. Input / word / 3 length / start address 0
2. Output / bit / 18 length / start address 7
3. %IB10 - %IB21
4. %QX1.0 - %QX2.5
Level 3 : IO configuration - Modbus client

1. IO slot
2. Modbus client
3. Share memory
IO slot configuration Modbus client
Advantech_DAQ : ADAM-5560KW Modbus client
Input(Read) /
Slave IP Data type Start Address Length Address
output(write)
Input(Read) 192.168.77.77 Byte 1 8 1x0001~1x0008
Input(Read) 192.168.77.77 WORD 1 1 3x0001
Input(Read) 192.168.77.77 WORD 5 1 3x0005
Input(Read) 192.168.77.77 WORD 6 1 3x0006
Output(Write) 192.168.77.77 Byte 1 8 0x0001~0x0008
Output(Write) 192.168.77.77 Byte 1 1 4x0001
Output(Write) 192.168.77.77 Bit 9 1 0x0009
Modbus client Add
Input IO : add MODBUSTCP

1x0001~1x0008 (Byte)
Modbus client Input IO
Input IO : add MODBUSTCP
1x0001~1x0008 (Byte)
Modbus commend : 1X
Slave ID : 1
Datatype : Byte
Start address : 1
NO. of points : 8 (bits)
Modbus client Input IO
Start address : 18 (follow ADAM-5024)
Size : 1 byte (1x0001-1x0008 = 1 byte )
Modbus client Input IO
Input IO : add MODBUSTCP
Modbus commend : 3X 3x0001 (Word)
Slave ID : 1
Datatype : Word
Start address : 1
NO. of points : 1
Modbus client Input IO
Input IO : add MODBUSTCP
Modbus commend : 3X 3x0005 (Word)
Slave ID : 1
Datatype : Word
Start address : 5
NO. of points : 1
Modbus client Input IO
Input IO : add MODBUSTCP
Modbus commend : 3X 3x0006 (Word)
Slave ID : 1
Datatype : Word
Start address : 6
NO. of points : 1
Modbus client Input IO configuration
Input IO configuration
Modbus client Output IO
Output IO : add MODBUSTCP
Modbus client Output IO
Output IO : add MODBUSTCP 0x0001-0x0008 (Byte)
Modbus commend : 0X
Slave ID : 1
Datatype : Byte
Start address : 1
NO. of points : 8 (bits)
Modbus client Output IO
Output IO : add MODBUSTCP 4x0001 (Word)
Modbus commend : 4X
Slave ID : 1
Datatype : Word
Start address : 1
NO. of points : 1
Modbus client Output IO
Output IO : add MODBUSTCP 0x0009 (Bool)
Modbus commend : 0X
Slave ID : 1
Datatype : Bool
Start address : 9
NO. of points : 1
Modbus client Output IO
Output IO configuration
Modbus client Create all variable
Input : click create all group variable
Output : click create all group variable
Click ok to finish IO slot configuration
Modbus client Global variable
Global variable : see all variable Data type :
Base unit : Byte Boolean :%_IO_X0.1
Output : %Q_data type_ Word :%_IO_W0
Input : %I_data type_ Dword :%_IO_D0
Modbus protocol Modsim32
ModSim32 : open file simulate folding 4 simulated file
Modbus protocol Modsim32
ModSim32 : connect to Modbus/TCP server
Modbus protocol Modsim32
ModSim32 simulated modbus/TCP server in local PC.
IP: 127.0.0.1 (default setting)

DO AI

DI AO
Modbus client Test with modsim
Compile and download project to ADAM-5560KW
Debug mode : show the data
Level 4 : IO configuration - Shared memory

1. IO slot
2. Modbus client
3. Share memory
IO slot configuration shared memory variable
Global variable : see all variable Data type :
Base unit : Byte Boolean : %_IO_X3.0.0
Share memory : %M_data type_ Byte : %_IO_B3.0
Word : %_IO_W3.0
Dword : %_IO_D3.0

Bit data type rule


Data KW address Length Address
Data1 %MX3.0.0 1bit 0x2001
Data2 %MX3.0.1 1bit 0x2002
Data3 %MX3.1.1 1bit 0x2009
IO slot configuration shared memory variable
Word or Integer data type rule

Data KW address Length Address


Data1 %MW3.0 (+3.1) 2 Bytes 4x2001
Data2 %MW3.2 (+3.3) 2 Bytes 4x2002
Data3 %MW3.4 (+3.5) 2 Bytes 4x2003

DWord or Real data type rule


Data KW address Length Address
Data1 %MD3.0 (+3.1+3.2+3.3) 4 Bytes 4x2001 (+4x2002)
Data2 %MD3.4 (+3.5+3.6+3.7) 4 Bytes 4x2003 (+4x2004)
Data3 %MD3.8 (+3.9+3.10+3.11) 4 Bytes 4x2005 (+4x2006)
IO slot configuration Global variable
Global variables : add new variable
Name : Share30001, Share40001
Type : word
Address : %MW3.0, %MW3.2 (Start from %MW3.0~)

%MW3.0 = 4x2001
Share : %MW3.0 = MB3.0 + MB3.1 %MW3.2 = 4x2002

Word
Level 5 : KW Program : R/W data and
define user function
1.Read /Write data from slot
2.How to define User function
3.Modbus client : Controller read /write ModSims data
4.Modbus server : ModScan read /write controllers data
5.Simple example
Read /Write data from slot

DI Read : ADAM5051_B02C000_I (DI)


Write : ADAM5056_B01C000_O (DO)

DI0
Write

DO0 Read
Read /Write data from slot Add ladder
POU : main
Ladder : Traditional PLC language
Network : Add a coil and contact network
Read /Write data from slot 0 Coil / Contact
Coil / Contact : if / then if DI High, then DO High
Contact : ADAM5051_B02C000_I (DI)
Coil : ADAM5056_B01C000_O (DO)
Read /Write data from slot

DI Move : AI = AO
AI : ADAM5017_S3C0_I (AI)
AO : ADAM5024_S2C00_O (AO)

AI0 Write

Read
AO0
Read /Write data from slot Function block
POU : main
Edit Wizard : Functions Add move block
Read /Write data from slot Input / output
Move : AI = AO
AI : ADAM5017_S3C0_I (AI)
AO : ADAM5024_S2C00_O (AO)
Read /Write data from slot Demo
Compile and download project to ADAM-5560KW
Debug mode : show the data

False False

0.001 0.001
Level 5 : KW Program : R/W data and
define user function
1.Read /Write data from slot
2.How to define User function
3.Modbus client : Controller read /write ModSims data
4.Modbus server : ModScan read /write controllers data
5.Simple example
How to define User function Scale function

DI Scale function

Scale Scale T/C 0


T/C 0
function1 function2
output

out_high

out_low
input
input_low input_high
input
output = out_low+ (out_high - out_low)/(input_high - input_low)*input
How to define User function Scale function

DI Scale function

Scale Scale T/C 0


T/C 0
function1 function2
DWORD output

0xFFFFFFFF

0x03D96E8C

0x00000000
T/C input
0.0 20.6 1370.0
input
output = out_low+ (out_high - out_low)/(input_high - input_low)*input
How to define User function Scale function

DI Read thermocouple value AD5018P_S0C0_I (T/C)


Datatype converter : Real (2Word) to DWORD (2Word)
Real : 20.6 C DWORD : 03D96E8C Real : 20.6 C

Real type DWORD type Real type


Scale Scale
T/C 0 function1 T/C 0
function2
Read
How to define User function
POU : main
Purpose : Move TC input (ADAM-5018) vlaue to
TC_real_slot (local variable)
User define function : From Real to DWORD and reverse
How to define User function Local variable
POU : main
Function : move
Input : AD5018P_S0C0_I (Real)
Output : TC_Real_slot (Real)
How to define User function Real_To_Dword
Add POU : function block
Name : Scale_Real_To_Dword
Language : Structure text
How to define User function Real_To_Dword
POU : Scale_Real_To_Dword
Create variable : input and output
output_real := out_low+ (out_high - out_low)/(input_high - input_low)*input;
output :=REAL_TO_DWORD( output_real );
How to define User function Real_To_Dword
Create variable : Input right click variable
Data Type : Real
Usage : VAR_INPUT
How to define User function Real_To_Dword
Variable table : VAR, input and output
output_real := out_low+ (out_high - out_low)/(input_high - input_low)*input;
output :=REAL_TO_DWORD( output_real );
How to define User function Dword_To_Real
Add POU : function block
Name : Scale_Dword_To_Real
Language : Structure text
How to define User function Dword_To_Real
POU : Scale_Dword_To_Real
Create variable : input and output
input_Real :=DWORD_TO_REAL( input );
output := out_low+ (out_high - out_low)/(input_high - input_low)*input_Real;
How to define User function Dword_To_Real
Create variable : input and output right click variable
Data Type : DWORD
Usage : VAR_INPUT
How to define User function Dword_To_Real
Variable table : VAR, input and output
input_Real :=DWORD_TO_REAL( input );
output := out_low+ (out_high - out_low)/(input_high - input_low)*input_Real;
How to define User function Setting
Scale_ Real_To_Dword :
Out_high : 2^32 = 4294967296.0 Output : TC_DWORD
Out_low : 0.0 Input: TC_Real_Slot
Input_high : 1370.0
Input_low : 0.0
How to define User function Setting
Scale_Dword_To_Real :
Out_high : 1370.0 Output :TC_Real_Internal

Out_low : 0.0 Input: TC_DWORD

Input_high : 2^32 = 4294967296.0


Input_low : 0.0
How to define User function Demo
Compile and download project to ADAM-5560KW
Debug mode : show the data

Real : 20.6 C Real : 20.6 C

Real : 20.6 C DWORD : 03D96E8C Real : 20.6 C


Level 6 : KW Program : Modbus client and
server expert
1.Read /Write data from slot
2.How to define User function
3.Modbus client : Controller read /write ModSims data
4.Modbus server : ModScan read /write controllers data
5.Simple example
Controller read /write Modsims data

DI Move 1x0001-1x0008 value to 0x0001-0x0008 (Modsim)


Move 3x0001 value to 4x0001 (Modsim)
Modsim (Modbus server)
1x0001-1x0008 0x0001-0x0008
3x0001 4x0001

Read Write

Controller (Modbus client)


Internal memory
Controller read /write Modsims data
POU : main
Purpose :
1. Move 1x0001-1x0008 value to 0x0001-0x0008 (Modsim)
2. Move 3x0001 value to 4x0001 (Modsim)
Controller read /write Modsims data
POU : main
Purpose :
1. Move 1x0001-1x0008 value to 0x0001-0x0008 (Modsim)
2. Move 3x0001 value to 4x0001 (Modsim)
Controller read/write Modsims data Purpose
Move 1x0001-1x0008 value to 0x0001-0x0008 (Modsim)
Move 3x0001 value to 4x0001 (Modsim)
Controller read/write Modsims data Purpose
Move 1x0001-1x0008 value to 0x0001-0x0008 (Modsim)
Move 3x0001 value to 4x0001 (Modsim)
Controller read /write Modsims data Demo
Compile and download project to ADAM-5560KW
Debug mode : show the data
Read 1x0001-8 to 0x0001-8
Controller read /write Modsims data Demo
Compile and download project to ADAM-5560KW
Debug mode : show the data
Read 3x0001 to 4x0001
KW Program : ladder, function block, and
structure text
1.Read /Write data from slot
2.How to define User function
3.Modbus client : Controller read /write ModSims data
4.Modbus server : ModScan read /write controllers data
5.Simple example
ModScan read /write controllers data

DI Move 3x0001 value to share30001 (Adam-5560 4x2001)


Move 4x0001 value to share40001 (Adam-5560 4x2002)
Modsim (Modbus server) ModScan (Modbus client)
3x0001 4x2001
4x0001 4x2002

Read Read

Controller (Modbus client) Controller(Modbus server)


Share30001 4x2001
Share40001 Write 4x2002
ModScan read/write Controllers data
Purpose
Move 3x0001 value to share30001 (Adam-5560 4x2001)
Move 4x0001 value to share40001 (Adam-5560 4x2002)
Share memory :

%MW3.0 = 4x2001
%MW3.2 = 4x2002
ModScan read/write Controllers data
Purpose
Move 3x0001 value to share30001 (Adam-5560 4x2001)
Move 4x0001 value to share40001 (Adam-5560 4x2002)
ModScan read/write Controllers data
Purpose
Move 3x0001 value to share30001 (Adam-5560 4x2001)
Move 4x0001 value to share40001 (Adam-5560 4x2002)
Modbus protocol ModScan
ModScan32 : connect
Modbus protocol ModScan
Connect Modbus server IP :192.168.77.60 (ADAM-5560KW)
Modbus protocol ModScan
Modbus Address : 4x2001 4x2008
Address : 2001
Length : 8
ModScan read/write controllers data Demo
Compile and download project to ADAM-5560KW
Debug mode : show the data
Level 7 : KW Program : Do it !

1.Read /Write data from slot


2.How to define User function
3.Modbus client : Controller read /write ModSims data
4.Modbus server : ModScan read /write controllers data
5.Do it : Simple example
Simple example

DI Compare 3x0005 and 3x0006 value from Modsim and write


the true or false to 0x0005
Modsim (Modbus server/slave)
3x0005
0x0005
3x0006

Read Write

Modsim (Modbus client/master)


compare
Simple example
POU : main
Purpose : Compare 3x0005 and 3x0006 value from Modsim
and write the true or false to 0x0005
1. If 3x0005 > 3x0006 then 0x0005 is high
2. Else 0x0005 is low
Simple example CompareTwoValue
Add POU : function block
Name : CompareTwoValue
Language : Structure text
Simple example CompareTwoValue
POU : CompareTwoValue if (input1 > input2) then
output := true;
Create variable : input and output else
output := false;
end_if;
Simple example CompareTwoValue
Variable table : VAR, input and output if (input1 > input2) then
output := true;
else
output := false;
end_if;
Simple example
Purpose : Compare 3x0005 and 3x0006 value from modsim
and write the true or false to 0x0005
Simple example
Purpose : Compare 3x0005 and 3x0006 value from modsim
and write the true or false to 0x0005
Simple example Demo
Compile and download project to ADAM-5560KW
Debug mode : show the data
Simple example Demo
Compile and download project to ADAM-5560KW
Debug mode : show the data
Thank You