[Advantech] PAC SW Multiprog Tutorial step by step

104
Advantech PAC training: KW multi-prog Step by Step IAG Inter - corn AE Alex Hsieh ( 謝明宏 )

Transcript of [Advantech] PAC SW Multiprog Tutorial step by step

Advantech PAC training:

KW multi-prog Step by Step

IAG Inter-corn AE

Alex Hsieh (謝明宏)

C:\Program Files

(x86)\Advantech\DAQNavi\LabviewDriver

Outline

• Level 1 : Create a new project and link test

• 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

1.Create a new project

2.Link configuration and test

Create a new project and link 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

Connection

(Run)

Disconnection

(Timeout)

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

• Base unit : Byte

• Output : %Q_data type_

• Input : %I_data type_

• Share memory : %M_data type_

• Data type :

• Boolean : %_IO_X0.1

• Byte : %_IO_B0

• Word : %_IO_W0

• 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) /

output(write) Slave IP Data type Start Address Length Address

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

• Modbus commend : 1X

• Slave ID : 1

• Datatype : Byte

• Start address : 1

• NO. of points : 8 (bits)

1x0001~1x0008 (Byte)

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

• Slave ID : 1

• Datatype : Word

• Start address : 1

• NO. of points : 1

3x0001 (Word)

Modbus client – Input IO

• Input IO : add MODBUSTCP

• Modbus commend : 3X

• Slave ID : 1

• Datatype : Word

• Start address : 5

• NO. of points : 1

3x0005 (Word)

Modbus client – Input IO

• Input IO : add MODBUSTCP

• Modbus commend : 3X

• Slave ID : 1

• Datatype : Word

• Start address : 6

• NO. of points : 1

3x0006 (Word)

Modbus client – Input IO configuration

• Input IO configuration

Modbus client – Output IO

• Output IO : add MODBUSTCP

Modbus client – Output IO

• Output IO : add MODBUSTCP

• Modbus commend : 0X

• Slave ID : 1

• Datatype : Byte

• Start address : 1

• NO. of points : 8 (bits)

0x0001-0x0008 (Byte)

Modbus client – Output IO

• Output IO : add MODBUSTCP

• Modbus commend : 4X

• Slave ID : 1

• Datatype : Word

• Start address : 1

• NO. of points : 1

4x0001 (Word)

Modbus client – Output IO

• Output IO : add MODBUSTCP

• Modbus commend : 0X

• Slave ID : 1

• Datatype : Bool

• Start address : 9

• NO. of points : 1

0x0009 (Bool)

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

• Base unit : Byte

• Output : %Q_data type_

• Input : %I_data type_

• Data type :

• Boolean :%_IO_X0.1

• Word :%_IO_W0

• 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

• Base unit : Byte

• Share memory : %M_data type_

• Bit data type rule

• Data type :

• Boolean : %_IO_X3.0.0

• Byte : %_IO_B3.0

• Word : %_IO_W3.0

• Dword : %_IO_D3.0

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

• DWord or Real 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

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

%MW3.2 = 4x2002Share : %MW3.0 = MB3.0 + MB3.1

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 ModSim’s data

4.Modbus server : ModScan read /write controller’s data

5.Simple example

Read /Write data from slot

• Read : ADAM5051_B02C000_I (DI)

• Write : ADAM5056_B01C000_O (DO)

DI

DI0

DO0 Read

Write

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

• Move : AI = AO

• AI : ADAM5017_S3C0_I (AI)

• AO : ADAM5024_S2C00_O (AO)

DI

AI0

AO0Read

Write

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 ModSim’s data

4.Modbus server : ModScan read /write controller’s data

5.Simple example

How to define User function – Scale function

• Scale functionDI

T/C 0Scale

function1Scale

function2T/C 0

output

input

inputinput_highinput_low

out_high

out_low

output = out_low+ (out_high - out_low)/(input_high - input_low)*input

How to define User function – Scale function

• Scale functionDI

T/C 0Scale

function1Scale

function2T/C 0

output = out_low+ (out_high - out_low)/(input_high - input_low)*input

DWORD output

T/C input

input1370.00.0

0xFFFFFFFF

0x00000000

20.6

0x03D96E8C

How to define User function – Scale function

• Read thermocouple value AD5018P_S0C0_I (T/C)

• Datatype converter : Real (2Word) to DWORD (2Word)

DI

T/C 0

Read

Real type

Scale

function1Scale

function2

DWORD type

T/C 0

Real type

Real : 20.6 ˚C Real : 20.6 ˚CDWORD : 03D96E8C

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

• Out_low : 0.0

• Input_high : 1370.0

• Input_low : 0.0

• Output : TC_DWORD

• Input: TC_Real_Slot

How to define User function – Setting

• Scale_Dword_To_Real :

• Out_high : 1370.0

• Out_low : 0.0

• Input_high : 2^32 = 4294967296.0

• Input_low : 0.0

• Output :TC_Real_Internal

• Input: TC_DWORD

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 Real : 20.6 ˚C

DWORD : 03D96E8C

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 ModSim’s data

4.Modbus server : ModScan read /write controller’s data

5.Simple example

Controller read /write Modsim’s data

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

• Move 3x0001 value to 4x0001 (Modsim)

DI

Read

• 1x0001-1x0008

• 3x0001

• 0x0001-0x0008

• 4x0001

Modsim (Modbus server)

Write

Controller (Modbus client)

• Internal memory

Controller read /write Modsim’s data

• POU : main

• Purpose :

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

2. Move 3x0001 value to 4x0001 (Modsim)

Controller read /write Modsim’s data

• POU : main

• Purpose :

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

2. Move 3x0001 value to 4x0001 (Modsim)

Controller read/write Modsim’s data – Purpose

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

• Move 3x0001 value to 4x0001 (Modsim)

Controller read/write Modsim’s data – Purpose

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

• Move 3x0001 value to 4x0001 (Modsim)

Controller read /write Modsim’s data – Demo

• Compile and download project to ADAM-5560KW

• Debug mode : show the data

• Read 1x0001-8 to 0x0001-8

Controller read /write Modsim’s 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 ModSim’s data

4.Modbus server : ModScan read /write controller’s data

5.Simple example

ModScan read /write controller’s data

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

• Move 4x0001 value to share40001 (Adam-5560 4x2002)

DI

Read

• 3x0001

• 4x0001

Modsim (Modbus server)

Read

• Share30001

• Share40001

Controller (Modbus client)

• 4x2001

• 4x2002

Controller(Modbus server)

• 4x2001

• 4x2002Write

ModScan (Modbus client)

ModScan read/write Controller’s 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 Controller’s data –Purpose

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

• Move 4x0001 value to share40001 (Adam-5560 4x2002)

ModScan read/write Controller’s 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 controller’s 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 ModSim’s data

4.Modbus server : ModScan read /write controller’s data

5.Do it : Simple example

Simple example

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

the true or false to 0x0005DI

Read

• 3x0005

• 3x0006• 0x0005

Modsim (Modbus server/slave)

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

• Create variable : input and output

if (input1 > input2) then

output := true;

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