DELTA IA-OSW AX Series Standard Instructions Manual-V1.6.0 ENG 20240329

Download as pdf or txt
Download as pdf or txt
You are on page 1of 341

Industrial Automation Headquarters

Delta Electronics, Inc.


Taoyuan Technology Center
No.18, Xinglong Rd., Taoyuan District,
Taoyuan City 330477, Taiwan
TEL: +886-3-362-6301 / FAX: +886-3-371-6301

Asia EMEA
Delta Electronics (Shanghai) Co., Ltd. Delta Electronics (Netherlands) B.V.
No.182 Minyu Rd., Pudong Shanghai, P.R.C. Sales: [email protected]
Post code : 201209 Marketing: [email protected]
TEL: +86-21-6872-3988 / FAX: +86-21-6872-3996 Technical Support: [email protected]
Customer Service: 400-820-9595 Customer Support: [email protected]
Service: [email protected]
Delta Electronics (Japan), Inc. TEL: +31(0)40 800 3900
Industrial Automation Sales Department
2-1-14 Shibadaimon, Minato-ku Delta Electronics (Netherlands) B.V.
Tokyo, Japan 105-0012 Automotive Campus 260, 5708 JZ Helmond, The Netherlands
TEL: +81-3-5733-1155 / FAX: +81-3-5733-1255 Mail: [email protected]
TEL: +31(0)40 800 3900
Delta Electronics (Korea), Inc. Delta Electronics (Netherlands) B.V.
1511, 219, Gasan Digital 1-Ro., Geumcheon-gu,
Coesterweg 45, D-59494 Soest, Germany
Seoul, 08501 South Korea
Mail: [email protected]
TEL: +82-2-515-5305 / FAX: +82-2-515-5302
TEL: +49 2921 987 238
Delta Energy Systems (Singapore) Pte Ltd. Delta Electronics (France) S.A.
4 Kaki Bukit Avenue 1, #05-04, Singapore 417939 ZI du bois Challand 2, 15 rue des Pyrénées,
TEL: +65-6747-5155 / FAX: +65-6744-9228 Lisses, 91090 Evry Cedex, France
Mail: [email protected]
Delta Electronics (India) Pvt. Ltd. TEL: +33(0)1 69 77 82 60
Plot No.43, Sector 35, HSIIDC Gurgaon,
PIN 122001, Haryana, India Delta Electronics Solutions (Spain) S.L.U
TEL: +91-124-4874900 / FAX: +91-124-4874945 Ctra. De Villaverde a Vallecas, 265 1º Dcha Ed.
Hormigueras – P.I. de Vallecas 28031 Madrid
Delta Electronics (Thailand) PCL. TEL: +34(0)91 223 74 20
909 Soi 9, Moo 4, Bangpoo Industrial Estate (E.P.Z), Carrer Llacuna 166, 08018 Barcelona, Spain
Pattana 1 Rd., T.Phraksa, A.Muang, Mail: [email protected]
Samutprakarn 10280, Thailand Digitized Automation for a Changing World
TEL: +66-2709-2800 / FAX: +66-2709-2827 Delta Electronics (Italy) S.r.l.
Via Meda 2–22060 Novedrate(CO)
Delta Electronics (Australia) Pty Ltd.
Unit 2, Building A, 18-24 Ricketts Road,
Mount Waverley, Victoria 3149 Australia
Piazza Grazioli 18 00186 Roma Italy
Mail: [email protected]
TEL: +39 039 8900365
DIADesigner - AX Series Standard
Instructions Manual
Mail: [email protected]
Delta Energy System LLC
TEL: +61-1300-335-823 / +61-3-9543-3720
Vereyskaya Plaza II, office 112 Vereyskaya str.
17 121357 Moscow Russia
Americas Mail: [email protected]
TEL: +7 495 644 3240
Delta Electronics (Americas) Ltd.
5101 Davis Drive, Research Triangle Park, NC 27709, U.S.A. Delta Greentech Elektronik San. Ltd. Sti. (Turkey)
TEL: +1-919-767-3813 / FAX: +1-919-767-3969 Şerifali Mah. Hendem Cad. Kule Sok. No:16-A
34775 Ümraniye – İstanbul
Delta Electronics Brazil Ltd. Mail: [email protected]
Estrada Velha Rio-São Paulo, 5300 Eugênio de TEL: + 90 216 499 9910
Melo - São José dos Campos CEP: 12247-004 - SP - Brazil
TEL: +55-12-3932-2300 / FAX: +55-12-3932-237 Eltek Dubai (Eltek MEA DMCC)
OFFICE 2504, 25th Floor, Saba Tower 1,
Delta Electronics International Mexico S.A. de C.V. Jumeirah Lakes Towers, Dubai, UAE
Gustavo Baz No. 309 Edificio E PB 103 Mail: [email protected]
Colonia La Loma, CP 54060 TEL: +971(0)4 2690148
Tlalnepantla, Estado de México
TEL: +52-55-3603-9200

*We reserve the right to change the information in this manual without prior notice. DIAS-Manual-0025-EN
2023/05/11 www.deltaww.com
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l Re v is i on H is t or y

Revision History
Version Revision Date
1st The first version was published. 10/30/2020

1. Updated CH3:
• Added supported products AX-364E & AX-324N for DFB_Capture,
DFB_Compare, DFB_HCnt, DFB_HTmr, DFB_PresetValue,
DFB_Sample
• Updated library DL_BuiltInIO_AX3.library for DFB_Capture,
DFB_Compare, DFB_HCnt, DFB_HTmrr, DFB_PresetValue,
DFB_Sample
• Updated “dwTimerValue” unit
2. Updated CH4:
• Added supported product AX-364E for DFB_EcGetAllSlaveAddr,
DFB_EcGetSlaveCount, DFB_EtherCATLink_Diag,
DFB_GetAllECATSlaveInfo, DFB_GetECATMasterError,
DFB_GetECATMasterState, DFB_ResetECATMaster,
DFB_ResetECATSlave
3. Updated CH6:
• Added supported products AX-364E, AX-300, and AX-324N for
DFB_From, DFB_To
4. Updated CH7:
• Added supported products AX-364E,AX-300, and AX-324N for
DFB_ModbusComChannel, DFB_ModbusRequest,
DFB_ModbusRequest2
2nd 02/28/2021
“DFB_MR_ERROR“ update
• Added DFB_SLAVE_DEVICE_FAILURE, DFB_ACKNOWLEDGE,
DFB_SLAVE_DEVICE_BUSY, DFB_GATEWAY_PATH_UNAVAILABLE,
DFB_GATEWAY_DEVICE_FAILED_TO_RESPOND
• Removed DFB_NO_MDBSCOM_CONFIG
• Updated DFB_ILLEGAL_DATA_VALUE
5. Updated CH8:
• Added supported products AX-364E, AX-300, and AX-324N for
DFB_TCP_Client, DFB_TCP_Server, DFB_UDP_Socket,
DFB_ModbusTCPChannel, DFB_ModbusTCPRequest
“DFB_MR_ERROR“ update
• Added DFB_SLAVE_DEVICE_FAILURE, DFB_ACKNOWLEDGE,
DFB_SLAVE_DEVICE_BUSY, DFB_GATEWAY_PATH_UNAVAILABLE,
DFB_GATEWAY_DEVICE_FAILED_TO_RESPOND,
DFB_INVALID_FUNCTION_CODE, DFB_NO_ETHERNET_CONFIG
• Removed DFB_NO_MDBSETH_CONFIG
• Updated DFB_ILLEGAL_DATA_VALUE,
DFB_MEMORY_NOT_ENOUGH
6. Updated CH9:
• Added supported products AX-364E, AX-300, and AX-324N for
DFB_MemoryRead, DFB_MemoryWrite
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l Re v is i on H is t or y

Version Revision Date


7. Added CH10 High Speed Output Instructions
8. Updated CH11:
• Added supported products AX-364E, AX-300, and AX-324N for
DFC_LogGetSize, DFB_LogDump
1. Updated Section 1.1: Added Setting Value range of wNum
2. Updated Section 2.5: Updated input pin note
3. Updated Section 4.3: Updated DFB_EtherCATLink_Diag library:
DL_EtherCAT_Diag.library
4. Added Section 6.3–Section 6.19: DFB_DLCCAL, DFB_DLCWEI,
DFB_DPUCONF, DFB_PUSTAT, DFB_DPUPLS, DFB_DPUPLS,
DFB_DPUDRI, DFB_DPUDRA, DFB_DPUZRN, DFB_DPUJOG,
3rd 07/31/2021
DFB_DPUCNT, DFB_DMPID library: DL_ASModuleAPI_AX3.library,
DFB_DHCCNT, DFB_DHCCAP, DFB_HCDO, DFB_DHCCMP,
DFB_DHCCMPT, DFB_DHCMEAS
5. Updated Section 7.3: Added Notes 4 & 5
6. Updated Section 7.4: Added Notes 1 & 2
7. Updated Sections 8.1, 8.2, and 8.3: Updated example program
8. Updated Sections 8.1–8.5: Added Function notes
1. Updated Section 5.1~5.3:
• Corrected output Error_ID data type
• Adjusted dwLen Input to wLen
• Updated Input pSrc range and added notes
• Updated error code description
2. Added Section 6.20–6.21: DFB_DADLOG, DFB_DADPEAK
4th 06/01/2022
3. Updated Section 6.22:
Added DFB_DADLOG, DFB_DADPEAK error codes
4. Updated Section 9.2: Updated Input FileInfo data type
5. Updated Section 9.3: Updated error code content
6. Updated Section 11.3: Updated error code content, added
DFB_FTPClient
1. Updated Section 3.1: Added bEdgeSelect and bCycle.
5th 2. Updated Section 3.2: Added OutputAction, diTablePosition, diTableSize. 03/31/2023
3. Updated Section 3.3: Added xUD_Select, bTriggerMode.
1. Updated Section 3.1: Updated the bEdgeSelect description.
2. Added general description of instructions to Chapter 3, Chapter 4,
Chapter 6, and Chapter 10.
3. Updated Chapter 6: Updated supported products.
4. Updated Section 6.13: Updated the bUpdate description.
6th 5. Updated Chapters 7 and 8: Updated the description of the command 09/30/2023
library.
6. Updated Section 8.6: Added a new instruction DFB_SetIPConfig.
7. Added Sections 12.1 and 12.2: SNTPGetUTCTime and SNTPServer
instructions.
8. Added Chapter 13: Added util library-related instructions.
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l Re v is i on H is t or y

Version Revision Date


9. Added Chapter 14: Added instructions related to the MEMUtils library.

1. Updated the supported products and libraries of instructions.


2. Added Section 1.3: Added DFC_Clear instruction.
3. Updated Section 1.4: Added DFC_Clear error codes and troubleshooting.
4. Updated Section 6.21: Added AS08AD_B and AS08AD_C modules.
5. Added Section 6.22: Added DFB_SCMRS instruction.
6. Updated Section 6.23: Added DFB_SCMRS error codes and
7th troubleshooting. 03/29/2024
7. Updated Section 8.6: Updated DFB_SetIPConfig.
8. Updated Section 11.2: Changed the image of Example.
9. Removed Section 11.3: Removed DFB_FTPClient instruction.
10. Added Section 14.2: Added MemSet instruction.
11. Added Chapter 15: Added SysTimeRtc library instructions.
12. Added Chapter 16: Added DL_SysInfo library instructions.
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l TO C

TOC
P1 Preface .......................................................................................................................... 1
P1.1 Introduction ............................................................................................................ 2
P1.1.1 Applicable Products ............................................................................................... 2
P1.1.2 Associated Manuals ............................................................................................... 2
Chapter 1 Move Instructions .............................................................................................. 3
1.1 DFC_NIBMOV .......................................................................................................... 4
1.2 DFC_XCH ................................................................................................................ 7
1.3 DFC_Clear ............................................................................................................... 9
1.4 Error Code and Troubleshooting ............................................................................... 11
Chapter 2 Comparison Instructions................................................................................... 12
2.1 DFC_CMP .............................................................................................................. 13
2.2 DFC_UCMP ............................................................................................................ 15
2.3 DFC_LRCMP .......................................................................................................... 17
2.4 DFC_ZCP .............................................................................................................. 19
2.5 DFC_UZCP ............................................................................................................ 21
2.6 DFC_LRZCP ........................................................................................................... 23
Chapter 3 Timers and Counters Instructions ...................................................................... 25
3.1 DFB_Capture ......................................................................................................... 26
3.2 DFB_Compare ....................................................................................................... 35
3.3 DFB_HCnt ............................................................................................................. 42
3.4 DFB_HTmr ............................................................................................................ 48
3.5 DFB_PresetValue.................................................................................................... 52
3.6 DFB_Sample.......................................................................................................... 57
3.7 Error Codes and Troubleshooting .............................................................................. 61
Chapter 4 EtherCAT Network Instructions .......................................................................... 65
4.1 DFB_EcGetAllSlaveAddr .......................................................................................... 66
4.2 DFB_EcGetSlaveCount ............................................................................................ 70
4.3 DFB_EtherCATLink_Diag ......................................................................................... 73
4.4 DFB_GetAllECATSlaveInfo ....................................................................................... 78
4.5 DFB_GetECATMasterError........................................................................................ 82
4.6 DFB_GetECATMasterState ....................................................................................... 85
4.7 DFB_ResetECATMaster ............................................................................................ 88
4.8 DFB_ResetECATSlave.............................................................................................. 92
4.9 Error Codes and Troubleshooting .............................................................................. 96
Chapter 5 Checksum Instructions ..................................................................................... 97
5.1 DFC_LRC8 ............................................................................................................. 98
5.2 DFC_LRC16 .......................................................................................................... 100
5.3 DFC_LRC32 .......................................................................................................... 102
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l TO C

5.4 Error Codes and Troubleshooting ............................................................................. 104


Chapter 6 Module Read-write Instructions ........................................................................ 105
6.1 DFB_From ............................................................................................................ 106
6.2 DFB_To ................................................................................................................ 109
6.3 DFB_DLCCAL ........................................................................................................ 112
6.4 DFB_DLCWEI ........................................................................................................ 116
6.5 DFB_DPUCONF ..................................................................................................... 120
6.6 DFB_PUSTAT ........................................................................................................ 124
6.7 DFB_DPUPLS ........................................................................................................ 127
6.8 DFB_DPUDRI ........................................................................................................ 130
6.9 DFB_DPUDRA ....................................................................................................... 134
6.10 DFB_DPUZRN ....................................................................................................... 136
6.11 DFB_DPUJOG ....................................................................................................... 140
6.12 DFB_DPUCNT ....................................................................................................... 143
6.13 DFB_DMPID ......................................................................................................... 146
6.14 DFB_DHCCNT ....................................................................................................... 154
6.15 DFB_DHCCAP ....................................................................................................... 165
6.16 DFB_HCDO ........................................................................................................... 171
6.17 DFB_DHCCMP ....................................................................................................... 174
6.18 DFB_DHCCMPT ..................................................................................................... 184
6.19 DFB_DHCMEAS ..................................................................................................... 192
6.20 DFB_DADLOG ....................................................................................................... 196
6.21 DFB_DADPEAK...................................................................................................... 204
6.22 DFB_ SCMRS ........................................................................................................ 207
6.23 Error Codes and Troubleshooting ............................................................................. 214
Chapter 7 Modbus Communication Instructions ................................................................. 220
7.1 DFB_COMRS ......................................................................................................... 221
7.2 DFB_ModbusComChannel ....................................................................................... 226
7.3 DFB_ModbusRequest ............................................................................................. 229
7.4 DFB_ModbusRequest2 ........................................................................................... 233
7.5 Error codes and Troubleshooting ............................................................................. 237
Chapter 8 Network Communication Instructions ................................................................ 240
8.1 DFB_TCP_Client .................................................................................................... 241
8.2 DFB_TCP_Server ................................................................................................... 248
8.3 DFB_UDP_Socket .................................................................................................. 255
8.4 DFB_ModbusTCPChannel ........................................................................................ 261
8.5 DFB_ModbusTCPRequest ........................................................................................ 264
8.6 DFB_SetIPConfig................................................................................................... 268
8.7 Error Codes and Troubleshooting ............................................................................. 271
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l TO C

Chapter 9 Instructions for Reading and Writing a Memory Card ........................................... 275
9.1 DFB_MemoryRead ................................................................................................. 276
9.2 DFB_MemoryWrite ................................................................................................ 279
9.3 Error Codes and Troubleshooting ............................................................................. 283
Chapter 10 High Speed Output Instructions........................................................................ 286
10.1 DFB_PWM ............................................................................................................ 287
10.2 Error Codes and Troubleshooting ............................................................................. 291
Chapter 11 Additional Instructions .................................................................................... 292
11.1 DFC_LogGetSize ................................................................................................... 293
11.2 DFB_LogDump ...................................................................................................... 295
11.3 Error Codes and Troubleshooting ............................................................................. 298
Chapter 12 SNTP Instructions ........................................................................................... 302
12.1 SNTPGetUTCTime .................................................................................................. 303
12.2 SNTPServer .......................................................................................................... 306
12.3 Error Codes .......................................................................................................... 308
Chapter 13 Util Library Instructions ................................................................................... 309
13.1 SeparateDateTime ................................................................................................. 310
13.2 Error Codes .......................................................................................................... 312
Chapter 14 MEMUtils Library Instructions ........................................................................... 313
14.1 MemCpy .............................................................................................................. 314
14.2 MemSet ............................................................................................................... 316
14.3 Error Codes .......................................................................................................... 318
Chapter 15 SysTimeRtc Library Instructions ......................................................................... 319
15.1 SysTimeRtcHighResGet .......................................................................................... 320
15.2 SysTimeRtcConvertHighResToDate .......................................................................... 322
15.3 Error Codes .......................................................................................................... 324
Chapter 16 DL_SysInfo Library Instructions ......................................................................... 325
16.1 DFC_GetPLCErrorID............................................................................................... 326
16.2 DFC_ReadBatteryLowStatus ................................................................................... 328
16.3 DFB_HWInfo......................................................................................................... 330
16.4 Error Codes .......................................................................................................... 333
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l P r ef ac e

P1 Preface

1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l P r ef ac e

P1.1 Introduction
Thank you for purchasing our product. The AX series motion controller provides a high-level motion control system
based on CODESYS to integrate the control function of PLCs and Motion Control.
This manual introduces Delta self-developed function blocks and functions for customers to perform PLC application
development.
P1.1.1 Applicable Products

This manual applies to the following products:


- AX-3 series
- AX-8 series
- AX-C series
P1.1.2 Associated Manuals

1. DIADesigner-AX User Manual


Includes the information of software operation, programming languages (Ladder Diagram, Sequential function
charts, ST (Structured Text) and function blocks), concept of POU and Task, as well as motion control
programming.
2. AX-3 Series Operational Manual
Introduces the concept of motion control system, while gives the information of hardware and software
configuration, motion control programming framework, troubleshooting, analog input-output module and
temperature measurement module.
3. AX-8 Series Operational Manual
Introduces the concept of motion control system, while gives the information of hardware and software
configuration, motion control programming framework, troubleshooting, analog input-output module and
temperature measurement module.
4. AX-C Series Operational Manual
Introduces the concept of motion control system, while gives the information of hardware and software
configuration, motion control programming framework, troubleshooting, analog input-output module and
temperature measurement module.

2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 1

Chapter 1 Move Instructions

3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 1

1.1 DFC_NIBMOV
DFC_NIBMOV: Data shift.

FB/FC Instruction Graphic Expression ST Language

DFC_NIBMOV(
pSrc:= ,
wSrcStartPos:= ,
FC DFC_NIBMOV pDst:= ,
wDstStartPos:= ,
wNum:= ,
ErrorID=> );

• Inputs

Setting Value
Name Function Data Type
(Default value)
Memory address of source
pSrc POINTER TO BYTE Memory address (0)
variables
Start address for source
wSrcStartPos variable shift WORD* Positive integer (0)
(Unit: Nibble)
Memory address of target
pDst POINTER TO BYTE Memory address (0)
variables
Start address for storing
wDstStartPos target variable WORD* Positive integer (0)
(Unit: Nibble)
The data length for data
1–256
wNum shift WORD*
Positive integer (0)
(Unit: Nibble)
*Note: The variable types BYTE and WORD can be used for inputs.

• Outputs

Output Range
Name Function Data Type
(Default value)
Instruction running result
DFC_NIBMOV (The parameter is BOOL True/False (False)
returned)
ErrorID Error code DL_MOV_ERROR DL_MOV_ERROR(DFC_NO_ERROR)

4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 1

• Function

After running this Function, the value of variable1 (pSrc) will be copied to variable2 (pDst), while the length of copied
data is determined by wNum input. (Unit: Nibble)

• Programming Example

 Example 1
In this example, FC instruction (DFC_NIBMOV) is used for shifting the content of wVar0 (pSrc) to the
variable wVar1 (pDst).

Since wSrcStartPos=2, wNum=2 and wDstStartPos=0, two consecutive Nibbles (Length=2), which start
from Nibble2 of variable wVar0 (pSrc), are shifted to the address Nibble0 inside the memory of wVar1
(pDst).

Variable Nibble3 Nibble2 Nibble1 Nibble0


wVar0 Memory content
[16#1234] 1 2 3 4

wVar1 Memory content


[16#FFFF] F F F F

wVar1 Memory content (after running FC)


[16#FF12] F F 1 2

5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 1

 Example 2
In this example, FC instruction (DFC_NIBMOV) is used for shifting the content of ar_wVar0 (pSrc) to the
variable ar_wVar1 (pDst).

Since wSrcStartPos=3, wNum=2 and wDstStartPos=0, two consecutive Nibbles (Length=2), which start
from Nibble3 of variable ar_wVar0 (pSrc), are shifted to the address Nibble0 inside the memory of ar_wVar1
(pDst).

Variable Nibble7 Nibble6 Nibble5 Nibble4 Nibble3 Nibble2 Nibble1 Nibble0


ar_wVar0 Memory content
[16#0123,16#4567] 4 5 6 7 0 1 2 3

ar_wVar1 Memory content


[16#FFFF,16#FFFF] F F F F F F F F

ar_wVar1 Memory content (after running FC)


[16#FF70,16#FFFF] F F F F F F 7 0

• Supported Products

 AX series

• Library

 DL_Mov.library

6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 1

1.2 DFC_XCH
DFC_XCH: Data exchange between two variables.

FB/FC Instruction Graphic Expression ST Language

DFC_XCH(
pSrc1:= ,
FC DFC_XCH pSrc2:= ,
dwNum:= ,
ErrorID=> );

• Inputs

Setting Value
Name Function Data Type
(Default value)

Memory address of
pSrc1 POINTER TO BYTE Memory address (0)
variable1
Memory address of
pSrc2 POINTER TO BYTE Memory address (0)
variable2
The length of data for 1–65535
dwNum DWORD*
exchange.(Unit: Byte) Positive integer(0)
*Note: The variable types BYTE, WORD and DWORD can be used for dNum input.

• Outputs

Output Range
Name Function Data Type
(Default value)
Instruction running result
DFC_XCH (This parameter is BOOL True/False (False)
returned)
ErrorID Error code DL_MOV_ERROR DL_MOV_ERROR(DFC_NO_ERROR)

• Function
After running this Function, the value of variable1 (pSrc1) will be copied to variable2 (pSrc2), while the length
of copied data is determined by dwNum input.

7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 1

• Programming Example
In this example, Function (DFC_XCH) is used for exchanging contents of two variables.

Since the data length for data exchange is set to one Byte (Length=1), low-byte of variable1 and 2 will be
switched after running Function (DFC_XCH).

Before ruuning the Function After running the Function


Variable wVar0 wVar1 Variable wVar0 wVar1
Content 16#1234 16#5678 Content 16#1278 16#5634

• Supported Products

 AX series

• Library

 DL_Mov.library

8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 1

1.3 DFC_Clear
DFC_Clear: Clear the value of the variable.

FB/FC Instruction Graphic Expression ST Language

DFC_Clear(
In:= ,
FC DFC_Clear
ErrorID=>
);

• Inputs

Setting Value
Name Function Data Type
(Default value)

In Clear the value. Any -

• Outputs

Output Range
Name Function Data Type
(Default value)
Instruction running result
DFC_Clear (This parameter is BOOL True/False (False)
returned)
ErrorID Error code DL_MOV_ERROR DL_MOV_ERROR(DFC_NO_ERROR)

• Function
1. This function is supported with DL_Mov V1.0.6.1 or later.
2. When this instruction is running, the value of the variable (In) is cleared to 0, instead of the initial value
declared by the variable.
3. Supported variable types:

9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 1

Real Times, durations,

POINTER

REFERENCE
BOOL Bit strings Integers
Numbers dates, and text strings
BOOL

BYTE
WORD
DWORD
LWORD

USINT

UINT

UDINT

ULINT

SINT

INT

DINT

LINT

REAL

LREAL

TIME

DATE

TOD

DT

STRING
                   
In  
Support an enumeration, array, array element, struct, or struct member.

• Programming Example
This example uses DFC_Clear to clear the variable value.
1. Declare Structure

2. When bCallFunction is True, clear the value entered by DFC_Clear of the variable.

• Supported Products

 AX series

• Library

 DL_Mov.library

10
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 1

1.4 Error Code and Troubleshooting


Description Reasons for error Troubleshooting
DFC_NIBMOV_ERR_PARAMETER Incorrect value of wNum Check if the value of wNum is bigger than 0.
Check if the value of dwNum is bigger than
DFC_XCH_ERR_PARAMETER Incorrect value of dwNum
0.
Not enough memory space Check if the size of downloaded program
DFC_XCH_ERR_NOMEMORY
in the controller exceeds the limit, then reboot the controller.
DFC_CLEAR_ERR_PAR Invalid input Check the input.
DFC_CLEAR_ERR_DA Unsupported variable data
Check the variable data type of Input.
type

11
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 2

Chapter 2 Comparison Instructions

12
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 2

2.1 DFC_CMP
DFC_CMP: Comparison between LINT variables.

FB/FC Instruction Graphic Expression ST Language

DFC_CMP(
FC DFC_CMP liSrc1:= ,
liSrc2:= )

• Inputs

Setting Value
Name Function Data Type
(Default value)
LINT:-263–263-1
liSrc1 Variable1 LINT*
(0)
LINT:-263–263-1
liSrc2 Variable2 LINT*
(0)
*Note: The variable types SINT, INT, DINT and LINT can be used for inputs.

• Outputs

Output Range
Name Function Data Type
(Default value)
1:liSrc1 = liSrc2
Instruction running result
2:liSrc1 < liSrc2
DFC_CMP (The parameter is WORD
3:liSrc1 > liSrc2
returned)
(0)

• Function
The FC instruction is used to compare the values in variable 1 with that in variable 2.

• Programing Example
This example use FC instruction (DFC_CMP) to do comparison between two variable values.

Since variable1 (liVar0) is smaller than variable2 (liVar1), the calculation result (wVar0) would be 2.

13
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 2

• Supported Products

 AX series

• Library

 DL_Comparison.library

14
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 2

2.2 DFC_UCMP
DFC_UCMP: Comparison between ULINT variables.

FB/FC Instruction Graphic Expression ST Language

DFC_UCMP(
FC DFC_UCMP lwSrc1:= ,
lwSrc2:= )

• Input

Setting Value
Name Function Data Type
(Default Value)
ULINT/LWORD:0–264-1
lwSrc1 Variable 1 ULINT/LWORD*
(0)
ULINT/LWORD:0–264-1
lwSrc2 Variable 2 ULINT/LWORD*
(0)
*Note: The variable types USINT, UINT, UDINT, ULINT, BYTE, WORD, DWORD and LWORD can be used for inputs.

• Output

Output Range
Name Function Data Type
(Default Value)
1:lwSrc1 = lwSrc2
Instruction running result
2:lwSrc1 < lwSrc2
DFC_UCMP (The parameter is WORD
3:lwSrc1 > lwSrc2
returned)
(0)

• Function
The FC instruction is used to compare the values in variable 1(lwSrc1) with that in variable 2(lwSrc2).

• Programming Example
This example use FC instruction (DFC_UCMP) to do comparison between two variable values.

15
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 2

Since variable1 (uiVar0) is smaller than variable2 (uiVar1), the calculation result (wVar0) would be 2.

• Supported Products

 AX series

• Library

 DL_Comparison.library

16
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 2

2.3 DFC_LRCMP
DFC_LRCMP: Comparison between LREAL variables.

FB/FC Instruction Graphic Expression ST Language

DFC_LRCMP(
FC DFC_LRCMP lrSrc1:= ,
lrSrc2:= )

• Input

Setting Value
Name Function Data Type
(Default Value)
LREAL:-1.7976931348623157E+308–
lrSrc1 Variable 1 LREAL* 1.7976931348623157E+308
(0)
LREAL:-1.7976931348623157E+308–
lrSrc2 Variable 2 LREAL* 1.7976931348623157E+308
(0)
*Note: The variable types REAL and LREAL can be used for inputs.

• Output

Output Range
Name Function Data Type
(Default Value)
1:lrSrc1 = lrSrc2
Instruction running result
2:lrSrc1 < lrSrc2
DFC_LRCMP (The parameter is WORD
3:lrSrc1 > lrSrc2
returned)
(0)

• Function
The FC instruction is used to compare the values in variable 1(lrSrc1) with that in variable 2(lrSrc2).

• Programming Example
This example use FC instruction (DFC_LRCMP) to do comparison between two variable values.

17
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 2

Since variable1 (lrVar0) is smaller than variable2 (lrVar1), the calculation result (wVar0) would be 2.

• Supported Products

 AX series

• Library

 DL_Comparison.library

18
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 2

2.4 DFC_ZCP
DFC_ZCP: Compares a range with a value of LINT variable.

FB/FC Instruction Graphic Expression ST Language

DFC_ZCP(
liLowbound:= ,
FC DFC_ZCP
liHighbound:= ,
liSrc:= );

• Input

Setting Value
Name Function Data Type
(Default Value)
LINT:-263–263-1
liLowbound Lower value LINT*
(0)
LINT:-263–263-1
liHighbound Upper value LINT*
(0)
LINT:-263–263-1
liSrc Variable LINT*
(0)
*Note: The variable types SINT, INT, DINT and LINT can be used for inputs.

• Output

Output Range
Name Function Data Type
(Default Value)
1:liSrc < Lower value
Instruction running result
2: Lower value < liSrc < Upper value
DFC_ZCP (The parameter is WORD
3:liSrc > Upper value
returned)
(0)

• Function
This FC instruction is used to compare the values in variable (liSrc) with the upper and lower value of the range.

• Programming Example
This example use FC instruction (DFC_ ZCP) to compare variable values with the upper and lower value.

19
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 2

Since the value in variable (liVar0) is larger than the upper value (H_liVar), the calculation result (wVar0) is 3.

• Supported Products

 AX series

• Library

 DL_Comparison.library

20
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 2

2.5 DFC_UZCP
DFC_UZCP: Compares a range with a value of ULINT variable.

FB/FC Instruction Graphic Expression ST Language

DFC_UZCP(
lwLowbound:= ,
FC DFC_UZCP
lwHighbound:= ,
lwSrc:= );

• Input

Setting Value
Name Function Data Type
(Default Value)
ULINT/LWORD:0–264-1
lwLowbound Lower value ULINT/LWORD*
(0)
ULINT/LWORD:0–264-1
lwHighbound Upper value ULINT/LWORD*
(0)
ULINT/LWORD:0–264-1
lwSrc Variable ULINT/LWORD*
(0)
*Note: The variable types USINT, UINT, UDINT, ULINT, BYTE, WORD, DWORD, and LWORD can be used for inputs.

• Output

Output Range
Name Function Data Type
(Default Value)
1:lwSrc < Lower value
Instruction running result
2: Lower value < lwSrc < Upper value
DFC_UZCP (The parameter is WORD
3:lwSrc > Upper value
returned)
(0)

• Function
The FC instruction is used to compare the values in variable (lwSrc) with the upper and lower value of the range.

• Programming Example
This example use FC instruction (DFC_ UZCP) to compare variable values with the upper and lower value.

21
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 2

Since the value in variable (ulVar0) is larger than the upper value (H_ulVar), the calculation result (wVar0) is 3.

• Supported Products

 AX Series

• Library

 DL_Comparison.library

22
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 2

2.6 DFC_LRZCP
DFC_LRZCP: Compares a range with a value of LREAL variable.

FB/FC Instruction Graphic Expression ST Language

DFC_LRZCP(
lrLowbound:= ,
FC DFC_LRZCP
lrHighbound:= ,
lrSrc:= );

• Input

Setting Value
Name Function Data Type
(Default Value)
LREAL:-1.7976931348623157E+308–
lrLowbound Lower value LREAL* 1.7976931348623157E+308
(0)
LREAL:-1.7976931348623157E+308–
lrHighbound Upper value LREAL* 1.7976931348623157E+308
(0)
LREAL:-1.7976931348623157E+308–
lrSrc Variable LREAL* 1.7976931348623157E+308
(0)
*Note: The variable types REAL and LREAL can be used for inputs.

• Output

Output Range
Name Function Data Type
(Default Value)
1:lrSrc < Lower value
Instruction running result
2: Lower value < lrSrc < Upper value
DFC_LRZCP (The parameter is WORD
3:lrSrc > Upper value
returned)
(0)

• Function
The FC instruction is used to compare the values in variable (lrSrc) with the upper and lower value of the range.

• Programming Example
This example use FC instruction (DFC_LRZCP) to compare variable values with the upper and lower value.

23
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 2

Since the value in variable (lrVar0) is smaller than the upper value (H_lrVar) and larger than the lower value
(L_lrVar), the calculation result (wVar0) is 2.

• Supported Products

 AX series

• Library

 DL_Comparison.library

24
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

Chapter 3 Timers and Counters Instructions

The instructions in this chapter are applicable to HSIOs with built-in I/O on the host. You can
use the instructions to get the signal sampling or signal measurement.

FB/FC Description Library


Captures the commanded pulses of the
DFB_Capture specified high-speed counter according to the DL_BuiltInIO_AX3 / DL_BuiltInIO
designated external trigger device.
Compares the designated source and setting
DFB_Compare values and then sets or resets the desired DL_BuiltInIO_AX3 / DL_BuiltInIO
device when the comparison result is True.
Enables the high-speed counter and monitors
DFB_HCnt DL_BuiltInIO_AX3 / DL_BuiltInIO
the counter value.
Enables the high-speed timer to count the
DFB_HTmr frequency wave bandwidth and monitors and DL_BuiltInIO_AX3 / DL_BuiltInIO
timed value.
The function block for high-speed counters. It
DFB_PresetValue can reset the current counter value to the default DL_BuiltInIO_AX3 / DL_BuiltInIO
value.
The function block for high-speed counters. It
DFB_Sample reads the increasing and decreasing number of DL_BuiltInIO_AX3 / DL_BuiltInIO
the counter value during the sampling cycle.

25
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

3.1 DFB_Capture
DFB_Capture captures the commanded pulses of the specified high-speed counter according to the designated
external trigger device.

FB/FC Instruction Graphic Expression ST Language

DFB_Capture_instance(
Capture :=,
Counter :=,
bEnable :=,
uiMaskValue :=,
diDeltaMin :=,
diDeltaMax :=,
bEdgeSelect :=,
bCycle :=,bValid =>,
FB DFB_Capture
bBusy =>,
bError =>,
ErrorID =>,
bCapFlag =>,
diCapValue =>,
diCapValuePrevious =>,
diDelta =>,
bCapLenBeyondFlag =>,
dwCapLenBeyondCount =>);

• Input

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Designate the
source of the DFB_ DFB_COUNTER_REF
Counter -
specified high- COUNTER_REF*1 (Cannot be null.)
speed counter.
Run the instruction
True/False
bEnable when bEnable BOOL -
(False)
changes to True.
When bEnable shifts to True,
Define the mask Positive number or
uiMaskValue UINT the setting parameters of
range of Capture. 0(0)
uiMaskValue will be updated.
Define the
minimum Positive number,
When bEnable shifts to True
diDeltaMin*3 difference DINT negative number or
and Busy is False
between each 0(0)
Capture*2.
Define the
maximum Positive number,
When bEnable shifts to True
diDeltaMax*3 difference DINT negative number or
and Busy is False
between each 0(0)
Capture*2.

26
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Define the rising When b Eable is rising edge,
True/False
bEdgeSelect edge or falling BOOL update the parameter of
(False)
edge capture bEdgeSelect
Define whether When b Eable is rising edge,
True/False
bCycle*3 capture values BOOL update the parameter of
(False)
continuously bCycle

*Note:
1. DFB_Counter_REF (FB): As the I/O interface of the high-speed counter to perform actions include parameter
adjustment and the driver.
2. uiMaskValue is in the DL_BuiltInIO library, and UINT is changed to UDINT after v1.0.5.0.
3. Once diDeltaMin and diDeltaMax are set to 0, the system will not check whether the capture range is
appropriate or not.

• Output

Output Range(Default
Name Function Data Type
value)
True when the output
bValid BOOL True/False (False)
value is valid
True when the instruction
bBusy BOOL True/False (False)
is enabled
bError True if an error occurs BOOL True/False (False)
Indicates the error code if DFB_HSIO_ERROR
ErrorID DFB_HSIO_ERROR*
an error occurs. (DFB_HSIO_NO_ERR)
Indicates that the current
Capture is valid.
bCapFlag (The flag shifts to True for BOOL True/False (False)
one scan cycle and will be
reset immediately)
Positive number, negative
diCapValue The captured value DINT
number or 0(0)
The previous captured Positive number, negative
diCapValuePrevious DINT
value number or 0(0)
The difference between
Positive number, negative
diDelta the previous and the DINT
number or 0(0)
current captured values.
Indicates that a capture is
failed.
bCapLenBeyondFlag (The flag shifts to True for BOOL True/False (False)
one scan cycle and will be
reset immediately)
Counts the number of the
dwCapLenBeyondCount DWORD Positive number or 0(0)
failed Capture.

*Note: DFB_HSIO_ERROR: Enumeration (Enum)

27
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

 Outputs Update Timing

Name Timing for shifting to True Timing for shifting to False


 When the values at the outputs are When bEnable shifts to False
bValid valid after bEnable being True for
When bError shifts to False
one scan cycle
 When bEnable is rising edge  When bEnable shifts to False
bBusy
triggered  When bError shifts to True
bError  When an error occurs during the
 When bEnable shifts from True to
running or there are incorrect input
ErrorID False (Error code is cleared)
values
 Updates value continuously when  Updates value continuously when
bCapFlag
bValid is True. bValid is True.
 Updates value continuously when  Updates value continuously when
diCapValue
bValid is True. bValid is True.
 Updates value continuously when  Updates value continuously when
diCapValuePrevious
bValid is True. bValid is True.
 Updates value continuously when  Updates value continuously when
diDelta
bValid is True. bValid is True.
 Updates value continuously when  Updates value continuously when
bCapLenBeyondFlag
bValid is True. bValid is True.
 Updates value continuously when  Updates value continuously when
dwCapLenBeyondCount
bValid is True. bValid is True.

• Timing Diagram

bEnable

bValid

bBusy

bError

• In-Outs

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Refer to the
source of the DFB_CAPTURE_REF DFB_CAPTURE_REF When bEnable shifts to True and
Capture
specified high- (FB)* (Cannot be null.) bBusy is False.
speed capture

28
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

*Note: DFB_CAPTURE_REF (FB): The I/O function block of the high-speed counter which contains parameter
adjustment and the driver.

• Function

 bEdgeSelect
This feature is supported on AX-3 series with firmware version V1.0.5.0 or later and with lilbrary
DL_BuiltInIO V1.1.0.2 or later.
 uiMaskValue
Refer to the following figure for the function description of uiMaskValue input.
1. Set uiMaskValue to 500 and bEnable to True, then Capture function is enabled. At the same time,
the output bValid is True and the first captured value would be the center value of the mask range. In
addition, the next capture action will be invalid if the next captured value is within the mask range.
2. In the figure below, the 1st capture happens in a -500~500 range and the captured value changes
from 0 to 1500.
3. The captured value 1500 becomes the new center of mask range. Therefore, the next captured
value which locates from 1000 to 2000 (1000 < diCapValue < 2000) will be invalid. So when the 2nd
capture is triggered (in the mask range), the captured value would remain as 1500.
4. Since the 3rd capture is triggered outside of the mask range, the captured value would be updated to
4000.

 diDeltaMin,diDeltaMax,bCapLenBeyondFlag,dwCapLenBeyondCount

DeltaMin/DeltaMax define the minimum and maximum distance between each Capture, while
CapLenBeyondFlag and CapLenBeyondCount represent the error flag and the number of the failed
Capture.
1. The function of diDeltaMin/diDeltaMax is to judge if a trigger mark is missed and the Capture is not
Run. For example, if the value of DeltaMin is 1000 and DeltaMax is 1300, when the detected
distance between 2 Capture exceeds 1000~1300, the system will flag this situation as trigger mark
missing.
2. When a mark missing condition occurs, CapLenBeyondFlag shifts to Ture for one scan cycle and
will be reset immediately. At the same time dwCapLenBeyondCount counts 1.

29
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

3. Refer to the below diagram for the explanation of these inputs and outputs:
 The mask range is between -500~500 and the 1st Capture occurs at 900.
 The 2nd Capture occurs at 2500. Because DeltaMax is set to 1300 and DeltaMin is set to
1000 (1000-1300), the detected distance between two captures has exceeded the range of
1000~1300. Therefore, a trigger mark missing condition is flagged for a scan cycle, while
bCapLenBeyondFlag remains as TRUE.
 The 3rd Capture occurs at 3700. Because the difference between 3700 and the previous
captured value 2500 is 1200, which is within the range of 1000~1300 (DeltaMin/DeltaMax),
also 3700 is out of the mask range 2000~3000, the captured value changes to 3700 in this
case, and bCapLenBeyondFlag will not change to True.

 bEdgeSelect
EdgeSelect defines whether the DI signal is the rising edge triggered or the falling-edge triggered to
capture the signal. This function is only applicable to AX-332E models.
1. When EdgeSelect=False, the capture is triggered when DI generates the rising edge signal, and
when EdgeSelect=True, the capture is triggered when DI generates the fallingr edge signal.
2. Refer to the below diagram for the explanation of these inputs and outputs:
When EdgeSelect=False:

When EdgeSelect+True

30
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

 bCycle
The Cycle setting determines whether the Capture function block will capture values continuously. This
function is only applicable to the AX-332El.
1. When Cycle=False, the Capture function block can only capture the value once triggered by DI.
When Cycle=True, the Capture function block can capture multiple values for multiple times.
2. Refer to the below diagram for the explanation of these inputs and outputs:
When Cycle=False

When Cycle=True

3. Only support AX-332E v1.0.4.2 or later.

• Troubleshooting
If an error occurs during the running of the instruction, bError will change to True and the Capture will stop. You
can refer to ErrorID (Error Code) to address the problem.

31
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

• Programming Example

 This example uses DFB_HCnt and DFB_Capture in AX-308E to perform the Capture function.
1. As the following figure shows, select a Counter and a Capture for Hardware IO Configuration in
BuiltIn_IO and set the trigger source of Capture to a signal input on the hardware (e.g. IN15).

2. Enable the FB DFB_Capture (bEnable=True) after using the FB DFB_HCnt to activate the high-speed

counter (bEnable=True) in the POU, then the present counter value would be captured and shown on

the diCapValue output of DFB_Capture after the external signal (IN15) being triggered.

32
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

3. Refer to AX-3 series operational manual for more details related to the settings and operation of
Hardware IO Configuration.
 This example uses DFB_HCnt and DFB_Capture in AX-308E to capture the high-speed counter.
1. As the following figure shows, select a Counter and a Capture for Hardware IO Configuration in BuiltIn_IO
and set the trigger source of Capture to a signal input on the hardware (e.g. IN0).

2. Enable the FB DFB_Capture (bEnable=True) after using the FB DFB_HCnt to activate the high-speed

counter (bEnable=True) in the POU, then the present counter value would be captured and shown on the

diCapValue output of DFB_Capture after the external signal (IN0) being triggered.

3. Refer to AX-3 Series Operation Manual for more details related to the settings and operation of Hardware
IO Configuration.

33
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

• Supported Products

 AX-3 series (except for AX-300), AX-C

• Library

 DL_BuiltInIO.library
Note: From version 1.0.5.0, library DL_BuiltInIO_AX3 is changed to DL_BuiltInIO.

34
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

3.2 DFB_Compare
DFB_Compare compares the designated source value and the setting value and then to Set or Reset the desired
device when the comparison result is True or False.

FB/FC Instruction Graphic Expression ST Language

DFB_Compare_instance(
Compare :=,
Counter :=,
bEnable :=,
Mode :=,
OutputAction :=,
wRefreshCycle :=,
FB DFB_Compare
diCmpValue :=,
diTablePosition :=,
uiTableSize :=,
bValid =>,
bBusy =>,
bError =>,
ErrorID =>);

• Input

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Designates the DFB_
DFB_COUNTER_REF
Counter source of high- COUNTER_ -
(Cannot be null.)
speed counter. REF*1
Run the
instruction when True/False
bEnable BOOL -
bEnable changes (False)
to True.
0:Equal(=)
DFB_ 1:Bigger_Equal(≧) When bEnable shifts
Comparison
Mode COMPARE_ to True and bBusy is
condition 2:Smaller_Equal(≦)
MODE*2 False.
(Equal)

DFB_ 1: SET When bEnable is


Define the output
OutputAction*3 COMPARE_ 2: RESET rising edge and bBusy
mode.
OUTPUT_ACTION (SET) is False.

Define the cycle


When bEnable shifts
time to refresh the
wRefreshCycle WORD Positive number or 0(0) to True and bBusy is
status of the
False.
output device.
When bEnable shifts
Specifies the Positive number,
diCmpValue DINT to True and bBusy is
compare value negative number or 0(0)
False.

35
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Specify the When bEnable is
diTablePosition*4 compare value ARRAY OF DINT rising edge and bBusy
array is False.
Specify the When bEnable is
Positive number 0 to 256
diTableSize*4 compare value DINT rising edge and bBusy
(0)
array scope is False.

*Note:
1. DFB_Counter_REF (FB): As the I/O interface of the high-speed counter to perform actions include parameter
adjustment and the driver.
2. DFB_COMPARE_MODE: Enumeration (Enum).
3. Except for AX-332E, other AX-3 series with DL_BuiltInIO_AX3 version V1.0.4.2 or later also supports this
function.
4. This parameter is only applicable to AX-332E.
5. In AX-332E, diCmpValue will not refer to the value of this variable for comparison.

• Output

Output Range(Default
Name Function Data Type
value)
bValid True when the output value is valid BOOL True/False (False)
True when the instruction is
bBusy BOOL True/False (False)
enabled
bError True if an error occurs BOOL True/False (False)
Indicates the error code if an error DFB _HSIO_ERROR
ErrorID DFB_HSIO_ERROR*
occurs. (DFB _HSIO_NO_ERR)
*Note: DFB _HSIO_ERROR: Enumeration (Enum)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


 When the values at the outputs are  When bEnable shifts to False
bValid valid after bEnable being True for one
scan cycle
 When bError shifts to True

 When bEnable shifts to False


bBusy  When bEnable is rising edge triggered
 When bError shifts to True
bError  When an error occurs during the
 When bEnable shifts from True to
running or there are incorrect input
ErrorID False (Error code is cleared)
values

• Timing Diagram

36
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

bEnable

bValid

bBusy

bError

• In/ Outs

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Reference to the
source of high- DFB_COMPARE_REF DFB_COMPARE_REF When bEnable shifts to
Compare
speed (FB)* (Cannot be null.) True and bBusy is False
comparator.
*Note: DFB_COMPARE_REF (FB): As the I/O interface of the high-speed comparator to perform actions include
parameter adjustment and the driver.

• Function
1. Cannot run this function block in Ethercat Task in AX-332, or it will affect update cycle of other device in
Ethercat.
2. When the comparison result is True (Counter Value = diCmpValue), DFB_Compare will outputs the results
according to the settings of HW IO configuration in BuiltIn IO.
3. When bValid output of DFB_Compare is True, the comparator would continue to compare on the high-speed
counter values. In case that the comparison condition is fulfilled and the output result is given according to the
settings, the device would remain at a high-level signal and would not retrigger the output (True  False 
True) after the condition is fulfilled once again. If you need to reset the output device and change the high-level
signal to low, find the following methods.
 Define the variable at the output of Compare via I/O mapping in DIO, then set the output variable to
falling-edge in the POU programming area so as to reset the output device.
 Use the setting of wRefreshCycle to change the high-level signal to low automatically after the PLC
keeps it at a high-level signal for a period of time.
Either ways, the purpose of changing from high-level signals to low can be reached. However, the comparison
conditions must be fulfilled again if you intend to make the output back to high-level.
4. The output device status can be refreshed by using the input wRefreshCycle. For example, set the value of
wRefreshCycle to 10000(Unit: 0.1ms), then the designated output device will be pulled to a low level by the
controller after the condition is fulfilled and remains a high-level output for one second. If wRefreshCycle is set
to zero, the output device would keep at a high level without being reset.

37
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

5. diTablePosition is the numerical array to be compared, and diTableSize is the number of values to be
compared. For example, the size of the diTablePosition array is 256, if diTableSize=100 is set, the 0-99
elements of the array will be set as the values to be compared. The timing diagram is as follows:

If comparing multiple value at the same time, the following two situations will affect the ouput of Do.
Case1: In the process of Do output, other value of diTablezpodtion is compared, the value will not generate Do
output. The output will be the Do output of the current value. Refer the following diagram for the timing and
parameter:

38
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

Case2: When comparing multiple values of diTablePosion at the same time, the defined Do output time is the
time of of one cycle of wRefreshCycle. Refer the following diagram for the timing and parameter:

OutputAction is an output variable that define the action of the output device once the comparison condition is met.
When it is set to SET, the ouput device will be set to high level. When it is set to RESET, the output device will be
set to low level.
Only support AX-332E version 1.0.4.2 or later.

• Troubleshooting
If an error occurs during the running of the instruction, bError will change to True and the Capture will stop. You
can refer to ErrorID (Error Code) to address the problem.

• Programming Example
 This example uses DFB_HCnt and DFB_Compare in AX-308E to perform the Compare function.
1. As the following figure shows, select a Counter and a Compare for Hardware IO Configuration in
BuiltIn_IO and set a signal output on the hardware as the output device of Compare (e.g. OUT3).

39
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

2. Run the function block DFB_Compare after enable the high-speed counter by using DFB_HCnt in the
POU as shown in follows. At the same time, the output device (OUT3) will output the signal once the
comparison condition is fulfilled (DFB_HCnt_0.diCounterValue = DFB_Compare_0.diCmpValue).

3. Refer to AX-3 series operational manual for more details related to the settings and operation of
Hardware IO Configuration.

 This example uses DFB_HCnt and DFB_Compare in AX-332E to perform the Compare function.
1. As the following figure shows, select a Counter and a Compare for Hardware IO Configuration in
BuiltIn_IO and set a signal output on the hardware as the output device of Compare (e.g. OUT1).

2. Run the function block DFB_Compare after enable the high-speed counter by using DFB_HCnt in the
POU as shown in follows. At the same time, the output device (OUT1) will output the signal once the
comparison condition is fulfilled (DFB_HCnt_0.diCounterValue = DFB_Compare_0.diCmpValue).

40
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

3. Refer to AX-3 series operational manual for more details related to the settings and operation of
Hardware IO Configuration.

• Supported Products

 AX-3 series (except for AX-300), AX-C

• Library

 DL_BuiltInIO_AX3.library
Note: From version 1.0.5.0, library DL_BuiltInIO_AX3 is changed to DL_BuiltInIO.

41
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

3.3 DFB_HCnt
DFB_HCnt enables the specified high speed counter according to the specified parameters and monitors the counter
value.

FB/FC Instruction Graphic Expression ST Language

DFB_HCnt_instance(
Counter :=,
bEnable :=,
bTrigerMode :=,
FB DFB_HCnt bValid =>,
bBusy =>,
bError =>,
ErrorID =>,
diCounterValue =>);

• Input

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Run the instruction
True/False
bEnable when bEnable BOOL -
(False)
changes to True.
Define the high-
True/False When bEnable is rising edge,
xUD_Select*2 speed counter to BOOL
(False) update parameter of xUD_Select.
count up or down
Define the capture
is triggered by True/False When bEnable is rising edge,
bTriggerMode*2 BOOL
rising edge or (False) update parameter of tiggerMode.
falling edge
*Note:
1. DFB_HSIO_ERROR: Enumeration (Enum)
2. Only applicable to AX-332.

• Output

Output Range
Name Function Data Type
(Default value)
True when the output
bValid BOOL True/False (False)
value is valid.
True when the instruction
bBusy BOOL True/False (False)
is enabled.
bError True if an error occurs. BOOL True/False (False)
Indicates the error code if DFB_HSIO_ERROR
ErrorID DFB_HSIO_ERROR*
an error occurs. (DFB_HSIO_NO_ERR)
The present counter value Positive number, negative
diCounterValue DINT
of the counter number or 0(0)

42
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

*Note: DFB_HSIO_ERROR: Enumeration (Enum)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


 When the values at the outputs are  When bEnable shifts to False
bValid valid after bEnable being True for
one scan cycle
 When bError shifts to True

 When bEnable is rising edge  When bEnable shifts to False


bBusy
triggered  When bError shifts to True
bError  When an error occurs during the
 When bEnable shifts from True to False
running or there are incorrect input
ErrorID (Error code is cleared)
values
 Updates value continuously when  Updates value continuously when bValid is
diCounterValue
bValid is True. True.

• Timing Diagram

bEnable

bValid

bBusy

bError

• In/ Outs

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Reference to the
source of DFB_COUNTER_REF DFB_COUNTER_REF When bEnable shifts to True
Counter
specified high- (FB)* (Cannot be null.) and Busy is False.
speed counter.
*Note: DFB_Counter_REF (FB): As the I/O interface of the high-speed counter to perform actions include
parameter adjustment and the driver.

• Function

1. When the input bEnable is True, the counter would start calculating pulses to the corresponding input
points based on the Counter configuration of HW IO configuration in BuiltIn IO.
2. The counter value is given through the output diCounterValue during the counting process.

43
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

3. bTriggerMode defines whether the DI signal is triggered by the rising edge or the falling edge for high-
speed counting. It is only applicable to AX-332E. When EdgeSelect=False, high-speed counting is
triggered when DI generates the rising edge signal; when EdgeSelect=True, high-speed counting is
triggered when DI generates the falling edge signal. This function is only available when the
corresponding input Counter setting mode is MODE_UD/ MODE_UDR/ MODE_UDRE/MODE_UDRE2.
4. xUD_Select defines whether to count up or count down when the external DI signal triggers counting.It
is only applicable to AX-332E. When xUD_Select=False, the DI signal is triggered to count up, and when
xUD_Select=True, the DI signal is triggered to count down. This function is only available when the
corresponding input Counter setting mode is MODE_UD/ MODE_UDR/ MODE_UDRE.
Refer the following timing diagram for bTriggerMode and xUD_Select:bTriggerMode=False
xUD_Select=False

bTriggerMode=True
xUD_Select=False

bTriggerMode=False
xUD_Select=True

44
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

bTriggerMode=True
xUD_Select=True

5. Only supports AX-332 v1.0.4.2 or later.

• Troubleshooting
If an error occurs during the running of the instruction, bError will change to True and Capture will stop. You can
refer to ErrorID (Error Code) to address the problem.

• Programming Example
This example uses DFB_HCnt in AX-308 to perform the Count function.
1. As the following figure shows, select a Counter (Counter 2) in Hardware IO Configuration and you will
see the input points (e.g. IN 0, IN 1, IN 2) matched to the corresponding encoder A, B, Z phase outputs,
which the wiring should follows the configuration so as to perform the normal function of high speed
counting.

45
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

2. After using the FB DFB_HCnt in the POU to activate the high-speed counter(bEnable=True), it starts

receiving and counting the pulses from the external signals(IN 0, IN 1) based on the counting mode set
in Counter Configuration, then the counter value would be displayed in the output diCounterValue. In
addition, you should make sure that the mode of sending pulses from the external signal source matches
the counting mode so as to get the correct counter values.

3. Refer to AX-3 series Operation Manual for more details related to the settings and operation of Hardware
IO Configuration and Counter Configuration.

This example uses DFB_HCnt in AX-332E to perform the Count function.

1. As the following figure shows, select a Counter (Counter 0) in Hardware IO Configuration and you will

see the input points (e.g. A+A-/B+B-/C+C-)) matched to the corresponding encoder A, B, Z phase

outputs, which the wiring should follows the configuration so as to perform the normal function of high
speed counting.

46
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

2. After using the FB DFB_HCnt in the POU to activate the high-speed counter(bEnable=True), it starts

receiving and counting the pulses from the external signals(A+A-/B+B-) based on the counting mode set
in Counter Configuration, then the counter value would be displayed in the output diCounterValue. In
addition, you should make sure that the mode of sending pulses from the external signal source matches
the counting mode so as to get the correct counter values.

3. Refer to AX-3 series operational manual for more details related to the settings and operation of
Hardware IO Configuration and Counter Configuration.

• Supported Products

 AX-3 series (except for AX-300), AX-C

• Library

 DL_BuiltInIO_AX3.library

47
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

3.4 DFB_HTmr
DFB_HTmr enables the specified high speed timer channel according to the specified parameters and monitors and
timed value.

FB/FC Instruction Graphic Expression ST Language

DFB_HTmr_instance(
Timer :=,
bEnable :=,
TriggerMode :=,
FB DFB_HTmr bValid =>,
bBusy =>,
bError =>,
ErrorID =>,
dwTimerValue =>);

• Input

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Run the instruction
True/False
bEnable when bEnable BOOL -
(False)
changes to True.
0:UP_DOWN
DFB_TIMER_ When bEnable shifts to True and
TriggerMode Timing mode settings. 1:UP_UP
MODE * bBusy is False.
(UP_DOWN)
*Note: DFB_TIMER_MODE: Enumeration (Enum)

Up-Down mode:

Up-Up mode:

• Output

48
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

Output Range(Default
Name Function Data Type
value)
True when the output
bValid BOOL True/False (False)
value is valid.
True when the instruction
bBusy BOOL True/False (False)
is enabled.
bError True if an error occurs. BOOL True/False (False)
Indicates the error code if DFB_HSIO_ERROR
ErrorID DFB_HSIO_ERROR*
an error occurs. (DFB_HSIO_NO_ERR)
Timed value (Unit:
dwTimerValue DWORD Positive number or 0(0)
0.01us)
*Note: DFB_HSIO_ERROR: Enumeration (Enum)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


 When the values at the outputs are  When bEnable shifts to False
bValid valid after bEnable being True for
one scan cycle
 When bError shifts to True

 When bEnable is rising edge  When bEnable shifts to False


bBusy
triggered  When bError shifts to True
bError  When an error occurs during the
 When bEnable shifts from True to False
running or there are incorrect input
ErrorID (Error code is cleared)
values
 Updates value continuously when  Updates value continuously when bValid is
dwTimerValue
bValid is True. True.

• Timing Diagram

bEnable

bValid

bBusy

bError

• In/ Outs

49
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Reference to the
source of the DFB_TIMER_REF DFB_TIMER_REF When bEnable shifts to True and
Timer
specified high- (FB)* (Cannot be null.) Busy is False
speed timer.
*Note: DFB_TIMER_REF (FB): As the I/O interface of the high-speed timer to perform actions include parameter
adjustment and the driver.

• Function
1. When the input bEnable is True, the timer would start calculating pulses to the corresponding input
points based on the Timer configuration of HW IO configuration in BuiltIn IO.
2. The counter value is given through the output dwTimerValue during the counting process.

• Troubleshooting
If an error occurs during the running of the instruction, bError will change to True and the Capture will stop. You
can refer to ErrorID (Error Code) to address the problem.

• Programming Example
This example demonstrates the function performed by DFB_HTmr.
1. As the following figure shows, select a Timer (Timer 2) in Hardware IO Configuration and you will see
the input point (IN 0) matched to the corresponding timer input channel, which the wiring should follows
the configuration so as to perform the normal function of high speed timing.

50
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

2. After using the FB DFB_HTmr in the POU to activate the high-speed timer(bEnable=True), it starts

receiving and counting the pulses from the external signals(IN 0) based on the timing mode set in Timer
Configuration, then the timed value would be displayed in the output dwTimerValue.

3. Refer to AX-3 Series Operation Manual for more details about Hardware IO Configuration.

• Supported Products

 AX-3 series (except for AX-300)

• Library

 DL_BuiltInIO.library
Note: From version 1.0.5.0, library DL_BuiltInIO_AX3 is changed to DL_BuiltInIO.

51
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

3.5 DFB_PresetValue
DFB_PresetValue is the application function block for high-speed counters, its role is to reset the current counter
value back to the default value.

FB/FC Instruction Graphic Expression ST Language

DFB_PresetValue_instance(
Counter :=,
bExecute :=,
TriggerType :=,
diPresetValue :=,
FB DFB_PresetValue
bDone =>,
bBusy =>,
bCommandAborted =>,
bError =>,
ErrorID =>);

• Input

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Run the
instruction
True/False
bExecute when bEnable BOOL -
(False)
changes to
True.
Define when 0:RUN_TRIGGER When bExecute
the default DFB_PRESET_TRIGGER_
TriggerType 1:EXTERNAL_TRIGGER shifts to True and
value would be TYPE *
(RUN_TRIGGER) bBusy is False.
preset.
The preset
When bExecute
counter value Positive number,
diPresetValue DINT shifts to True and
for high speed negative number or 0(0)
bBusy is False
counters.

*Note: DFB_PRESET_TRIGGER_TYPE: Enumeration (Enum)


• RUN_TRIGGER: Set the default value right after the input bExecute shifts to True.
• EXTERNAL_TRIGGER: Set the default value right after the external signal of high-speed counter being
triggered.

• Output

Output Range(Default
Name Function Data Type
value)
The default value of the
bDone BOOL True/False (False)
counter has been changed.
True when the instruction is
bBusy BOOL True/False (False)
enabled

52
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

Output Range(Default
Name Function Data Type
value)
True when the instruction is
bCommandAborted interrupted before it’s BOOL True/False (False)
completed
bError True when an error occurs BOOL True/False (False)
DFB_HSIO_ERROR
ErrorID Error codes DFB_HSIO_ERROR*
(DFB_HSIO_NO_ERR)
*Note: DFB_HSIO_ERROR: Enumeration (Enum)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


 True when the counter value  When bExecute shifts to False
bDone
has been set back to default.  When bError shifts to True
 When bExecute shifts to False
bBusy  When bExecute shifts to True
 When bError shifts to True
bCommandAborted  True when the FB is interrupted  When bExecute shifts to False
bError  When an error occurs during
 When bEnable shifts from True to False.
the running or there are
ErrorID (Error code is cleared)
incorrect input values

• Timing Diagram

1. 2. 3. 4.
bExecute

bDone

bBusy

bCommandAbort

bError

External Trigger

1. TriggerType = 0(RUN_TRIGGER)
2. TriggerType = 1(EXTERNAL_TRIGGER)
3. bCommandAborted = TRUE
4. bError = TRUE

• In/ Outs

53
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Reference
to the
DFB_COUNTER_REF DFB_COUNTER_REF When bExecute shifts to True
Counter source of
(FB)* (Cannot be null.) and bBusy is False
high-speed
counter.

*Note: DFB_COUNTER_REF (FB): As the I/O interface of the high-speed counter to perform actions include
parameter adjustment and the driver

• Function

1. When TriggerType = RUN_TRIGGER, the counter value would be set back to the default value right after
activating the function block.

2. When TriggerType = EXTERNAL_TRIGGER, the counter value would not be set back to the default until
the Z phase signal of the counter rises.

• Troubleshooting
If an error occurs during the running of the instruction, bError will change to True and the Capture will stop. You
can refer to ErrorID (Error Code) to address the problem.

• Programming Example
This example demonstrates the function performed by DFB_HCnt and DFB_PresetValue.
1. As the following figure shows, select a Counter (Counter 2) in Hardware IO Configuration and you will see
the input points (e.g. IN 0, IN 1, IN 2) matched to the corresponding encoder A, B, Z phase outputs, which
the wiring should follows the configuration so as to perform the normal function of high-speed counting.

2. After using the FB DFB_HCnt in the POU to activate the high-speed counter(bEnable=True), it starts
receiving and counting the pulses from the external signals(IN 0, IN 1) based on the counting mode set in
Counter Configuration, then the counter value would be displayed in the output diCounterValue. In addition,
you should make sure that the mode of sending pulses from the external signal source matches the
counting mode so as to get the correct counter values.

54
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

3. If you want to use external signal as the trigger, check the box of External trigger in Counter Configuration
as the following figure shows.

4. Then the input bExecute of DFB_PresetValue shifts to True and the FB DFB_PresetValue would wait for
the Z phase of high-speed counter to trigger the Default value function. After the counter value being set
to the default (DFB_HCnt.diCounterValue = fb), the output bDone will shift from False to True.

5. Refer to AX-3 Series Operation Manual for more details of Counter Configuration.

55
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

• Supported Products

 AX-3 series (except for AX-300), AX-C

• Library

 DL_BuiltInIO.library
Note: From version 1.0.5.0, library DL_BuiltInIO_AX3 is changed to DL_BuiltInIO.

56
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

3.6 DFB_Sample
DFB_Sample is the application function block for high-speed counters, its role is to read the increasing and
decreasing number of the counter value during the sampling period.

FB/FC Instruction Graphic Expression ST Language

DFB_Sample_instance(
Counter :=,
bEnable :=,
wSampleTime :=,
FB DFB_Sample bValid =>,
bBusy =>,
bError =>,
ErrorID =>
diSampleValue =>);

• Input

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Run the
instruction when True/False
bEnable BOOL -
bEnable changes (False)
to True.
When bEnable shifts
Sampling period 10~65535
wSampleTime WORD to True and bBusy is
(Unit: 1ms) (0) False

• Output

Output Range(Default
Name Function Data Type
value)
True when the output value is
bValid BOOL True/False (False)
valid
True when the instruction is
bBusy BOOL True/False (False)
enabled
bError True if an error occurs BOOL True/False (False)
Indicates the error code if an DFB_HSIO_ERROR
ErrorID DFB_HSIO_ERROR*
error occurs. (DFB_HSIO_NO_ERR)
Increasing number of the
Positive number, negative
diSampleValue counter value during each DINT
number or 0(0)
sampling period
*Note: DFB_HSIO_ERROR: Enumeration (Enum)

 Outputs Updating Timing

57
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

Name Timing for shifting to True Timing for shifting to False


 When the values at the outputs are  When bEnable shifts to False
bValid valid after bEnable being True for
one scan cycle.
 When bError shifts to True

 When bEnable shifts to False


bBusy  When bEnable shifts to True
 When bError shifts to True
bError  When an error occurs during the
 When bEnable shifts from True to False
running or there are incorrect input
ErrorID (Error code is cleared)
values
 Updates value continuously when  Updates value continuously when bValid is
diSampleValue
bValid is True. True.

• Timing Diagram

bEnable

bValid

bBusy

bError

• In/ Outs

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Reference
to the
DFB_COUNTER_REF DFB_COUNTER_REF When bEnable shifts to True
Counter source of
(FB)* (Cannot be null.) and bBusy is False.
high-speed
counter.
*Note: DFB_COUNTER_REF (FB): As the I/O interface of the high-speed counter to perform actions include
parameter adjustment and the driver.

• Function

1. DFB_Sample counts incoming pulses during a specified sampling period (wSampleTime).


wSampleTime = 4( unit : 1ms )

0 4 8 12 16
時間 ms
diSampleValue = 6 diSampleValue = 4 diSampleValue = 2 diSampleValue = -4

diCounterValue =12 diCounterValue =18 diCounterValue =22 diCounterValue =24 diCounterValue =20

58
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

2. When wSampleTime is shorter than the pulse period, the increasing number (diSampleValue) would be
shown between 0 and 1 for each SampleTime.

• Troubleshooting

If an error occurs during the running of the instruction, bError will change to True and the Capture will stop.
You can refer to ErrorID (Error Code) to address the problem.

• Programming Example
This example uses DFB_HCnt and DFB_Sample to perform pulse counting during the sampling period.
As the following figure shows, select a Counter (Counter 2) in Hardware IO Configuration and you will see the
input points (e.g. IN 0, IN 1, IN 2) matched to the corresponding encoder A, B, Z phase outputs, which the wiring

should follows the configuration so as to perform the normal function of high speed counting.

1. After using the FB DFB_HCnt in the POU to activate the high-speed counter(bEnable=True), it starts

receiving and counting the pulses from the external signals(IN 0, IN 1) based on the counting mode set
in Counter Configuration, then the counter value would be displayed in the output diCounterValue. In
addition, you should make sure that the mode of sending pulses from the external signal source
matches the counting mode so as to get the correct counter values.

59
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

2. After enabling DFB_Sample in the POU (bEnable=True), the FB starts counting the increasing number

of the pulse counter value during each sampling period.

3. Refer to AX-3 Series Operation Manual for more details related to the settings and operation of Counter
Configuration.

• Supported Products

 AX-3 series (except for AX-300)

• Library

 DL_BuiltInIO.library
Note: From version 1.0.5.0, library DL_BuiltInIO_AX3 is changed to DL_BuiltInIO.

60
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

3.7 Error Codes and Troubleshooting


The following table lists the error codes corresponding to the FBs and the contents of the errors:

Description Cause of Error Corrective Action


DFB_HSIO_NO_ERR No error messages.
After make sure Capture in IO
DFB_CAP_INVALID_ The variable type set for the Configuration is selected, input
CAPTURE_REF FB input is not Capture_REF. the variable of IEC Object to the
“Capture” input of DFB_Capture.
After make sure Counter in IO
DFB_CAP_INVALID_ The variable type set for the Configuration is selected, input the
COUNTER_REF FB input is not Counter_REF variable of IEC Object to the
“Counter” input of DFB_Capture.
The mask range of Reset the input value of
DFB_CAP_INVALID_ DFB_Capture (uiMaskValue) uiMaskValue to be in the rotation
VALUE_SETTING exceeds the rotation range of range of encoder axis. [0–
the axis. EncoderAxis.Modulo Value ]
When a rotary axis is used as Reset the input value of
the encoder axis, the min/max “diDeltaMax” or “diDeltaMin” to be
DFB_CAP_INVALID_
difference between each in the rotation range of encoder
DELTARANGE
Capture exceeds the rotation axis. [0–EncoderAxis.Modulo
range. Value ]
Check if this Capture device is
The high-speed capture
DFB_CAP_CAPTURE_ALREADY_ENABLE currently being used by another
device has been activated.
DFB_Capture.
Check the error message on the
DFB_CAP_DRIVE_ Errors occur in the Capture BuiltIn_IO page and refer to the
ERROR device or Count device driver. AX-3 operational manual to
troubleshoot the errors.
After make sure Compare in IO
Configuration is selected, input the
DFB_CMP_INVALID_ The variable type set for the
variable of IEC Object to the
COMPARE_REF FB input is not Compare_REF.
“Compare” input of
DFB_Compare.
After make sure Counter in IO
DFB_CMP_INVALID_ The variable type set for the Configuration is selected, input the
COUNTER_REF FB input is not Counter_REF. variable of IEC Object to the
“Counter” input of DFB_Capture.

61
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

Description Cause of Error Corrective Action


When a rotary axis is used as Reset the input value of
DFB_CMP_INVALID_ the encoder axis, the input diCompareValue to be in the
CMPVALUE "diCompareValue" exceeds rotation range of encoder axis. [0–
the rotation range. EncoderAxis.Modulo Value ]
The input "wRefreshCycle"
DFB_CMP_INVALID_ Set the value of "wRefreshCycle"
exceeds the range of ~30000
REFRESHCYCLE to be within the range of 0–30000.
(Unit: 0.1us).
Check if this Compare device is
The high-speed comparator
DFB_CMP_COMPARE_ALREADY_ENABLE currently being used by another
has been activated.
DFB_Compare.
Check the error message on the
DFB_CMP_DRIVE_ Errors occur in the Compare BuiltIn_IO page and refer to the
ERROR device or Count device driver. AX-3 operational manual to
troubleshoot the errors.
After make sure Counter in IO
DFB_HC_INVALID_ The variable type set for the Configuration is selected, input the
COUNTER_REF FB input is not Counter_REF. variable of IEC Object to the
“Counter” input of DFB_Hcnt.
Check if this Counter device is
DFB_HC_COUNTER_ The high-speed counter has
currently being used by another
ALREADY_ENABLE been activated.
DFB_HCnt.
DFB_HC_COUNTER_ The input value of “Counter” is Check if the value of the input
REF_CHANGED_ changed while the FB is Counter changes after the FB
DURING_OPERATION running. DFB_HCnt running.
Check the error message on the
DFB_HC_COUNTER_ Errors occur in the Count BuiltIn_IO page and refer to the
DRIVE_ERROR device driver. AX-3 operational manual to
troubleshoot the errors.
After make sure Timer in IO
DFB_HT_INVALID_ The variable type set for the Configuration is selected, input the
TIMER_REF FB input is not Timer_REF. variable of IEC Object to the
“Timer” input of DFB_HTmr.
Check if this Timer device is
DFB_HT_TIMER_ The high-speed timer has
currently being used by another
ALREADY_ENABLE been activated.
DFB_HTmr.
The input value of “Timer” is Check if the value of the input
DFB_HT_TIMER_REF_CHANGED_DURING_
changed while the FB is Timer changes after the FB
OPERATION
running. DFB_HTmr running.

62
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

Description Cause of Error Corrective Action


Check the error message on the
DFB_HT_TIMER_ Errors occur in the Timer BuiltIn_IO page and refer to the
DRIVE_ERROR device driver. AX-3 operational manual to
troubleshoot the errors.
After make sure Counter in IO
Configuration is selected, input the
DFB_PV_INVALID_ The variable type set for the
variable of IEC Object to the
COUNTER_REF FB input is not Counter_REF.
“Counter” input of
DFB_PresetValue.
“External Trigger” in Counter
mode configuration is not
Check the box of External Trigger
DFB_PV_NOT_ selected while the input
on the Counter configuration
ENABLE_EXTERNAL_TRIGGER TriggerType of
page.
DFB_PresetValue is set to
“EXTERNAL_TRIGGER”.
Wait for the previous preset value
The preset value function of
DFB_PV_PREVIOUS_ task of another DFB_PresetValue
the counter has been used by
PRESET_NOT_DONE completed, then you’ll be able to
other DMC_PresetValue FBs.
Run the current task.
DFB_PV_CANNOT_ Disable DFB_Sample of the
The counter is running
PRESET_WHEN_ counter to turn off the Sample
DFB_Sample.
SAMPLING function in this counter.
The counter is running Wait for the counter to finish
DFB_PV_SETRING_
DFB_SetRing and not running DFB_SetRing and then
NOT_DONE
completed. DFB_PresetValue can be Run.
When a rotary axis is used as Reset the input value of
DFB_PV_INVALID_ the encoder axis, the input " diPresetValue to be in the rotation
PRESET_VALUE diPresetValue" exceeds the range of encoder axis. [0–
rotation range. EncoderAxis.Modulo Value ]
DFB_PV_COUNTER_ The input value of “Counter” is Check if the value of the input
REF_CHANGED_ changed while the FB is Counter changes after the FB
DURING_OPERATION running. DFB_PresetValue running.
Check the error message on the
DFB_PV_COUNTER_ Errors occur in the Timer BuiltIn_IO page and refer to the
DRIVE_ERROR device driver. AX-3 operational manual to
troubleshoot the errors.
DFB_SP_INVALID_ The variable type set for the After make sure Counter in IO
COUNTER_REF FB input is not Counter_REF. Configuration is selected, input the

63
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 3

Description Cause of Error Corrective Action


variable of IEC Object to the
“Counter” input of DFB_Sample.
Make sure the counter device has
DFB_SP_COUNTER_ DFB_Counter has not enabled been enabled by DFB_HCnt and
NOT_ENABLE the high-speed counter. then you can Run the FB
DFB_Sample.
Check if this counter device is
DFB_SP_ALREADY_ The counter is running
currently being used by another
SAMPLING DFB_Sample.
DFB_Sample.
The counter is running Wait for the counter to finish
DFB_SP_PRESET_
DFB_PresetValue and not running DFB_PresetValue and
NOT_DONE
completed. then DFB_Sample can be Run.
The input “wSampleTime” of Reset the input value of
DFB_SP_INVALID_
DFB_Sample exceeds the “wSampleTime” to be in the
SAMPLE_TIME
range of 10~65535. range of 10–65535.
DFB_SP_COUNTER_ The input value of “Counter” is Check if the value of the input
REF_CHANGED_ changed while the FB is Counter changes after the FB
DURING_OPERATION running. DFB_Sample running.
Check the error message on the
DFB_SP_COUNTER_ Errors occur in the Counter BuiltIn_IO page and refer to the
DRIVE_ERROR device driver. AX-3 operational manual to
troubleshoot the errors.

64
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

Chapter 4 EtherCAT Network Instructions

The instructions in this chapter only applies to EtherCAT. Use the instructions to read or set EtherCAT information
and parameters.

FB/FC Description Library

DFB_EcGetAllSlaveAddr Gets all slave addresses. DL_EtherCAT_Diag

DFB_EcGetSlaveCoun Gets the number of slaves in the tree. DL_EtherCAT_Diag

DFB_EtherCATLink_Diag Displays the online status of all EtherCAT slaves. DL_EtherCAT_Diag

DFB_GetAllECATSlaveInfo Gets all the slave information. DL_EtherCAT_Diag

Gets the error code for the EtherCAT network


DFB_GetECATMasterError DL_EtherCAT_Diag
connection error.

DFB_GetECATasterState Gets the EtherCAT master online status. DL_EtherCAT_Diag

Reset the EtherCAT master with an abnormal online


DFB_ResetECATMaster DL_EtherCAT_Diag
status.
DFB_ResetECATSlave Reset the slave with an abnormal online status. DL_EtherCAT_Diag

65
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

4.1 DFB_EcGetAllSlaveAddr
DFB_EcGetAllSlaveAddr gets all the slave addresses.

FB/FC Instruction Graphic Expression

FB DFB_EcGetAllSlaveAddr

ST Language
DFB_EcGetAllSlaveAddr (
bExecute :=,
bDone =>,
bBusy =>,
bError =>,
ErrorID =>,
AddrArray =>,
uSlaves =>, );

• Input

Setting Value
Name Function Data Type Timing for Updating
(Default value)

Run the instruction


True/False
bExecute when bExecute BOOL -
(False)
changes to True.

• Output

Output Range
Name Function Data Type
(Default value)
The running of FB is
bDone BOOL True/False (False)
completed.
True when the
bBusy BOOL True/False (False)
instruction is enabled
bError True if an error occurs BOOL True/False (False)
Indicates the error code DFB_ECAT_Diag_ERROR
ErrorID DFB_ECAT_Diag_ERROR*
if an error occurs. (DFB_ECAT_Diag_NO_ERROR)
AddrArray Slave address array UINT[1..128] (0)
uSlaves The number of slaves UINT 0~128(0)

*Note: DFB_ECAT_Diag_ERROR: Enumeration (Enum)

 Output Updating Timing

66
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

Name Timing for shifting to True Timing for shifting to False


 When bExecute shifts to False
bDone  When the running of FB is completed  If bExecute is False and bDone shifts to
True, bDone will be True for only one
period and immediately shift to False.
 When bDone shifts to True
bBusy  When bExecute shifts to True
 When bError shifts to True
bError  When an error occurs in the running  When bExecute shifts from True to False
ErrorID conditions of the instruction (Error code is cleared)

AddrArray  When bExecute shifts to True  When bExecute shifts to False


uSlaves  When bExecute shifts to True  When bExecute shifts to False

• Timing Diagram

bExecute

bBusy

bDone

bError

• Function

When bExecute shifts to True, the output AddrArray gives the addresses of all the EtherCAT slaves in the project
tree, which supports up to 128 stations. Therefore, the maximum number of slave addresses output by AddrArray
would be 128 given by the output uSlaves.

• Troubleshooting

If an error occurs during the running of the instruction, bError will change to True and Capture will stop. You can
refer to ErrorID (Error Code) to address the problem.

67
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

• Programming Example
The following example demonstrates the behavior of DFB_EcGetAllSlaveAddr.

1. There’re a total of 7 EtherCAT slaves in the category EtherCAT_Master_SoftMotion.

2. After the input bExecute of DFB_EcGetAllSlaveAddr bExecute shifts to True, the output of AddrArray is
shown as below and the output value of uSlaves is 7.

68
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

• Supported Products

 AX-3 series motion controller, AX-8, AX-C

• Library

 DL_EtherCAT_Diag.library

69
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

4.2 DFB_EcGetSlaveCount
DFB_EcGetSlaveCount gets the number of slaves that are connected to the master.

FB/FC Instruction Graphic Expression

FB DFB_EcGetSlaveCount

ST Language

DFB_EcGetSlaveCount (
bExecute :=,
bDone =>,
bBusy =>,
bError =>,
ErrorID =>,
uSlaves =>,
);

• Input

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Run the instruction
True/False
bExecute when bExecute BOOL -
(False)
changes to True.

• Output

Output Range
Name Function Data Type
(Default value)
The running of FB is
bDone BOOL True/False (False)
completed.
True when the
bBusy BOOL True/False (False)
instruction is enabled
bError True if an error occurs BOOL True/False (False)
Indicates the error DFB_ECAT_Diag_ERROR
ErrorID DFB_ECAT_Diag_ERROR*
code if an error occurs. (DFB_ECAT_Diag_NO_ERROR)
uSlaves The number of slaves UINT 0~128(0)
*Note: DFB_ECAT_Diag_ERROR: Enumeration (Enum)

 Outputs Updating Timing

70
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

Name Timing for shifting to True Timing for shifting to False


 When bExecute shifts to False
bDone  When the running of FB is completed  If bExecute is False and bDone shifts to
True, bDone will be True for only one
period and immediately shift to False.
 When bDone shifts to True
bBusy  When bEnable shifts to True
 When bError shifts to True
bError  When an error occurs in the running  When bExecute shifts from True to False
ErrorID conditions of the instruction (Error code is cleared)

uSlaves  When bExecute shifts to True  When bExecute shifts to False

• Timing Diagram

bExecute

bBusy

bDone

bError

• Function
When bExecute shifts to True, the output uSlaves gives the number of EtherCAT slaves in the project tree.

• Troubleshooting
If an error occurs during the running of the instruction, bError will change to True and Capture will stop. You can
refer to ErrorID (Error Code) to address the problem.

• Programming Example
1. The following example demonstrates the behavior of DFB_EcGetSlaveCount.

71
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

2. There’re a total of 7 EtherCAT slaves in the category EtherCAT_Master_SoftMotion.

3. When the input bExecute of DFB_EcGetSlaveCount shifts to True, the output value of uSlaves is 7.

• Supported Products

 AX-3 series motion controller, AX-8, AX-C

• Library

 DL_EtherCAT_Diag.library

72
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

4.3 DFB_EtherCATLink_Diag
DFB_EtherCATLink_Diag is used to display all the EtherCAT slave diagnostics.

FB/FC Instruction Graphic Expression

FB DFB_EtherCATLink_Diag

ST Language

DFB_EtherCATLink_Diag (
bEnable :=,
bValid =>,
bError =>,
ErrorID =>,
StationNode =>
uSlaves =>
);

• Input

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Run the instruction
True/False
bEnable when bEnable BOOL -
(False)
changes to True.

• Output

Output Range
Name Function Data Type
(Default value)
True when the
bValid BOOL True/False (False)
instruction is running.
True if an error
bError BOOL True/False (False)
occurs.
Indicates the error
DFB_ECAT_Diag_ERROR
ErrorID code if an error DFB_ECAT_Diag_ERROR*1
(DFB_ECAT_Diag_NO_ERROR)
occurs.
Slave addresses and
StationNode structure array of StationStatus [1..128] *2 *3 StationStatus
slave status.
uSlaves Number of Slaves UINT 0–65535

*Note:

73
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

1. DFB_ECAT_Diag_ERROR: Enumeration (Enum)


2. StationStatus Structure (STRUCT)

Setting Value
Name Function Data Type
(Default value)
StationAddress Slave station address UINT (0)
True: Connected and functioning properly.
Connection status of
Node BOOL False: Abnormal connection status.
slave stations
(False)
True: Physical connection status normal
Slave physical
LinkStatus BOOL False: Physical connection status abnormal
connection status
(False)

3. The array includes all the slave addresses and connection status, which starts from the first slave station.
(Supports up to 128 stations) In addition, if the value of StationAddress is shown as 0 in the struct array after
bEnable is rising edge triggered, it indicates that the slave station does not exist.

 Outputs Updating Time

Name Timing for shifting to True Timing for shifting to False


 When bEnable shifts to False
bValid  When bEnable shifts to True
 When bError shifts to True
bError  When an error occurs in the running  When bEnable shifts from True to False
ErrorID conditions of the instruction (Error code is cleared)

StationNode  When bEnable shifts to True  When bEnable shifts to False


uSlaves  When bEnable shifts to True  When bEnable shifts to False

• Timing Diagram

bEnable

bValid

bError

ErrorID

• Function
When bEnable shifts to True, StationAddress and Node output from StationAddress are in array type to show all
the slave addresses and status with the support up to 128 slave stations. If the value of StationAddress is shown

74
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

as 0 in the struct array after bEnable is rising edge triggered, it indicates that the slave station does not exist. An
error will be reported by the function block if EtherCAT master is not found when bEnable shifts to True.

• Troubleshooting
If an error occurs during the running of the instruction, bError will change to True and Capture will stop. You can
refer to ErrorID (Error Code) to address the problem.

• Programming Example
The following example demonstrates the behavior of DFB_EtherCATLink_Diag.

1. There’s a total of two EtherCAT slave stations in the Device tree and the connection status shows PASS.

2. After bEnable of DFB_EtherCATLink_Diag shifts to True, the output uSlave shows 2, indicating that
there are two EtherCAT slaves in total. The array of StationNode index 1 to 2 shows the two slave
addresses, statuses, and physical connection statuses, and the StationAddress of StationNode shows 0
from index 3.

75
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

3. Disconnect the cable for internet connection between slave station 1 and 2 and you can see the status
of slave 2 is shown to be Fail in the device tree.

4. Now, StationNode index 2 Node and LinkStatus of DFB_EtherCATLink_Diag are False respectively.

76
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

5. If connecting the physical network of Slave 1 and Slave 2, StationNode index 2 Node and LinkStatus of
DFB_EtherCATLink_Diag will be False and True respectively.

• Supported Products

 AX-3 series motion controller, AX-8, AX-C

• Library

 DL_EtherCAT_Diag.library

77
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

4.4 DFB_GetAllECATSlaveInfo
DFB_GetAllECATSlaveInfo gets all the slaves’ information.

FB/FC Instruction Graphic Expression

FB DFB_GetAllECATSlaveInfo

ST Language

DFB_GetAllECATSlaveInfo (
bExecute :=,
bDone =>,
bBusy =>,
bError =>,
ErrorID =>,
slaveInfoArray =>,
uSlaves =>,);

• Input

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Run the instruction
True/False
bExecute when bExecute BOOL -
(False)
changes to True.

• Output

Output Range
Name Function Data Type
(Default value)
The running of FB is
bDone BOOL True/False (False)
completed.
True when the
bBusy BOOL True/False (False)
instruction is enabled
True if an error
bError BOOL True/False (False)
occurs
Indicates the error
DFB_ECAT_Diag_ERROR
ErrorID code if an error DFB_ECAT_Diag_ERROR*1
(DFB_ECAT_Diag_NO_ERROR)
occurs.
Slave information ECATSlaveInfo
slaveInfoArray ECATSlaveInfo
array. [1..128] *2

78
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

Output Range
Name Function Data Type
(Default value)
The number of
uSlaves UINT 0~128(0)
slaves
*Note:
1. DFB_ECAT_Diag_ERROR: Enumeration(Enum)
2. slaveInfoArray: Structure(STRUCT)。
Output Range
Name Function Data Type
(Default value)
vendorId Slave vendor id UDINT (0)
productCode Slave product code UDINT (0)
revisionNo Slave revision number UDINT (0)
serialNo Slave serial number UDINT (0)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


 When bExecute shifts to False
 When the running of FB is  If bExecute is False and bDone shifts to
bDone
completed. True, bDone will be True for only one
period and immediately shift to False.
 When bDone shifts to True
bBusy  When bExecute shifts to True
 When bError shifts to True
bError  When an error occurs in the running  When bExecute shifts from True to False
ErrorID conditions of the instruction (Error code is cleared)

slaveInfoArray  When bExecute shifts to True  When bExecute shifts from True to False
uSlaves  When bExecute shifts to True  When bExecute shifts from True to False

• Timing Diagram

bExecute

bBusy

bDone

bError

• Function

79
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

When bExecute shifts to True, slaveInfoArray gives the information of all the EtherCAT slaves in the device tree,
which includes vendor id, product code, revision number and serial number. Support up to 128 stations as well
as the maximum number of slaves and the corresponding information output from uSlaves and slaveInfoArray.

• Troubleshooting

If an error occurs during the running of the instruction, bError will change to True and Capture will stop. You can
refer to ErrorID (Error Code) to address the problem.

• Programming Example

The following example demonstrates the behavior of DFB_GetAllECATSlaveInfo.

1. There’re two EtherCAT slave stations in the device tree, both are ASDA_A2.

2. Double-click on the target ASDA_A2 in the device tree to view its slave information.

80
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

3. The input bExecute of DFB_GetAllECATSlaveInfo bExecute shifts to True, then the output of
slaveInfoArray is shown as below and the output value of uSlaves is 2.

• Supported Products

 AX-3 series motion controller, AX-8, AX-C

• Library

 DL_EtherCAT_Diag.library

81
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

4.5 DFB_GetECATMasterError
DFB_GetECATMasterError gets the error code of failed EtherCAT network connection.

FB/FC Instruction Graphic Expression

FB DFB_GetECATMasterError

ST Language
DFB_GetECATMasterError (
bEnable :=,
bBusy =>,
bError =>,
ErrorID =>,
EtherCATErrorId =>
);

• Input

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Run the instruction when True/False
bEnable BOOL -
bEnable changes to True. (False)

• Output

Output Range
Name Function Data Type
(Default value)
True when the instruction is
bBusy BOOL True/False (False)
enabled
bError True if an error occurs. BOOL True/False (False)
Indicates the error code if an DFB_ECAT_Diag_ DFB_ECAT_Diag_ERROR
ErrorID
error occurs. ERROR*1 (DFB_ECAT_Diag_NO_ERROR)
EtherCATErrorId EtherCAT error codes ETC_LASTERROR*2 ETC_LASTERROR(NO_ERROR)
*Note:

1. DFB_ECAT_Diag_ERROR: Enumeration (Enum)


2. ETC_LASTERROR: Enumeration (Enum)

 Outputs Updating Time

82
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

Name Timing for shifting to True Timing for shifting to False


 When bEnable shifts to False
bBusy  When bEnable shifts to True
 When bError shifts to True
bError  When an error occurs in the running  When bEnable shifts from True to False
ErrorID conditions of the instruction (Error code is cleared)

 When an error occurs in the


EtherCATErrorId  When bEnable shifts to False
EtherCAT connection

• Timing Diagram

bEnable

bBusy

bError

ErrorID

• Function
When bEnable shifts to True, the output EtherCATErrorId gives the error codes of failed EtherCAT network
connection during each cycle. If there’s no error, the output would be displayed as NO_ERROR. For more details
of error codes, Refer to the content of ETC_LASTERROR_STATE in the Library.

• Troubleshooting
If an error occurs during the running of the instruction, bError will change to True and Capture will stop. You can
refer to ErrorID (Error Code) to address the problem.

• Programming Example
The following example demonstrates the behavior of DFB_GetECATMasterError.

1. If the EtherCAT connection is normal without any existing errors, the output content of EtherCATErrorId
would be shown as NO_ERROR after the input bEnable of DFB_GetECATMasterError shifts to True.

83
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

2. Remove the network connection between the master and the slave, then the output content of
EtherCATErrorId would be shown as NO_COMM.

• Supported Products

 AX-3 series motion controller, AX-8, AX-C

• Library

 DL_EtherCAT_Diag.library

84
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

4.6 DFB_GetECATMasterState
DFB_GetECATMasterState gets the connection status of EtherCAT Master.

FB/FC Instruction Graphic Expression

FB DFB_GetECATasterState

ST Language

DFB_GetECATMasterState (
bEnable :=,
bBusy =>,
bError =>,
ErrorID =>,
bStatus =>,);

• Input

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Run the instruction
True/False
bEnable when bEnable BOOL -
(False)
changes to True.

• Output

Output Range
Name Function Data Type
(Default value)
True when the
bBusy BOOL True/False (False)
instruction is enabled
bError True if an error occurs BOOL True/False (False)
Indicates the error code DFB_ECAT_Diag_ERROR
ErrorID DFB_ECAT_Diag_ERROR*
if an error occurs. (DFB_ECAT_Diag_NO_ERROR)
EtherCAT master
bStatus BOOL True/False (False)
communication status

*Note: DFB_ECAT_Diag_ERROR: Enumeration (Enum)


 Outputs Updating Timing

85
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

Name Timing for shifting to True Timing for shifting to False


bBusy  When bEnable shifts to True  When bError shifts to True
bError  When an error occurs in the running  When bEnable shifts from True to False
ErrorID conditions of the instruction (Error code is cleared)

 When bEnable shifts to False


 When the EtherCAT master connection
bStatus  When bError shifts to True
is normal
 When the connection is abnormal

• Timing Diagram

bEnable

bBusy

bError

ErrorID

• Function
When bEnable shifts to True, the function block performs cyclical status updates of EtherCAT master
communication.

• Troubleshooting
If an error occurs during the running of the instruction, bError will change to True and the Capture will stop. You
can refer to ErrorID (Error Code) to address the problem.

• Programming Example
The following example demonstrates the behavior of DFB_GetECATMasterState.

1. The connection status of EtherCAT master shows PASS in the device tree.

86
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

2. When the input bEnable of DFB_GetECATMasterState shifts to True, the output of bStatus is displayed
as True.

3. Remove the network connection between the master and the slave, and the current connection status of
EtherCAT master would show Fail in the device tree.

4. The output bStatus of DFB_GetECATMasterState is displayed as False.

• Supported Products

 AX-3 series motion controller, AX-8, AX-C

• Library

 DL_EtherCAT_Diag.library

87
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

4.7 DFB_ResetECATMaster
DFB_ResetECATMaster resets the EtherCAT master, which has errors in connection.

FB/FC Instruction Graphic Expression

FB DFB_ResetECATMaster

ST Language

DFB_ResetECATMaster (
bExecute :=,
bDone =>,
bBusy =>,
bError =>,
ErrorID =>,);

• Input

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Run the instruction
True/False
bExecute when bExecute BOOL -
(False)
changes to True.

• Output

Output Range
Name Function Data Type
(Default value)
The running of FB is
bDone BOOL True/False (False)
completed.
True when the
bBusy BOOL True/False (False)
instruction is enabled
bError True if an error occurs BOOL True/False (False)
Indicates the error code DFB_ECAT_Diag_ERROR
ErrorID DFB_ECAT_Diag_ERROR*
if an error occurs. (DFB_ECAT_Diag_NO_ERROR)

*Note: DFB_ECAT_Diag_ERROR: Enumeration (Enum)

 Outputs Updating Timing

88
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

Name Timing for shifting to True Timing for shifting to False


 When bExecute shifts to False
 When the running of FB is  If bExecute is False and bDone shifts to
bDone
completed. True, bDone will be True for only one
period and immediately shift to False.
 When bDone shifts to True
bBusy  When bExecute shifts to True
 When bError shifts to True
bError  When an error occurs in the running  When bExecute shifts from True to False
ErrorID conditions of the instruction (Error code is cleared)

• Timing Diagram

bExecute

bBusy

bDone

bError

• Function
When bExecute shifts to True and the connection status of EtherCAT master shows Fail, the function block would
perform reset action.

• Troubleshooting
If an error occurs during the running of the instruction, bError will change to True and Capture will stop. You can
refer to ErrorID (Error Code) to address the problem.

• Programming Example
The following example demonstrates the behavior of DFB_ResetECATMaster.

1. The connection status of EtherCAT master shows PASS in the device tree.

89
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

2. Remove the network connection between the master and the slave, and the current connection status of
EtherCAT master would show Fail in the device tree.

3. To restore the network connection between the master and the slave, shift the input bExecute of
DFB_ResetECATMaster to True.

4. The network connectivity has been recovered after the output bDone shifting to True.

90
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

• Supported Products

 AX-3 series motion controller, AX-8, AX-C

• Library

 DL_EtherCAT_Diag.library

91
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

4.8 DFB_ResetECATSlave
DFB_ResetECATSlave resets the EtherCAT slave, which has errors in connection.

FB/FC Instruction Graphic Expression

FB DFB_ResetECATSlave

ST Language
DFB_ResetECATSlave(
bExecute :=,
uiSlaveAddr :=,
tTimeout :=,
bDone =>,
bBusy =>,
bError =>,
ErrorID =>,
);

• Input

Setting Value
Name Function Data Type Timing for Updating
(Default value)
Run the instruction
True/False
bExecute when bExecute changes BOOL -
(False)
to True.
When bExecute is
Reset the slave
uiSlaveAddr UINT Positive number (0) rising edge triggered
address.
and Busy is False
When bExecute is
Slave resets the time-
tTimeout TIME Positive number (0) rising edge triggered
out.
and Busy is False

• Output

Output Range
Name Function Data Type
(Default value)
The running of FB is
bDone BOOL True/False (False)
completed.
True when the
bBusy BOOL True/False (False)
instruction is enabled
bError True if an error occurs BOOL True/False (False)

92
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

Indicates the error code DFB_ECAT_Diag_ERROR


ErrorID DFB_ECAT_Diag_ERROR*
if an error occurs. (DFB_ECAT_Diag_NO_ERROR)
*Note: DFB_ECAT_Diag_ERROR: Enumeration (Enum)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


 When bExecute shifts to False
 When the running of FB is  If bExecute is False and bDone shifts to
bDone
completed. True, bDone will be True for only one
period and immediately shift to False.
 When bDone shifts to True
bBusy  When bExecute is shifts to True
 When bError shifts to True
bError  When an error occurs in the running  When bExecute shifts from True to False
ErrorID conditions of the instruction (Error code is cleared)

• Timing Diagram

bExecute

bBusy

bDone

bError

• Function

When bExecute shifts to True, the function block starts searching for the target slave station and resets the
EtherCAT slave, if the status of target slave shows Fail. If the input value of uiSlaveAddr is 0, the function block
would reset all the slave stations which have errors in connection.

• Troubleshooting

If an error occurs during the running of the instruction, bError will change to True and the Capture will stop. You
can refer to ErrorID (Error Code) to address the problem.

• Programming Example

The following example demonstrates the behavior of DFB_ResetECATSlave.

93
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

1. There’s a total of 8 EtherCAT slave stations in EtherCAT_Master_SoftMotion and all their connection
status shows PASS.

2. Remove the network connection of slave 4 and 5, and the current connection status of EtherCAT slave
starting from slave 5 would show Fail in the device tree.

94
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

3. To restore the network connection of slave 4 and 5, enter 1005 to the input uiSlaveAddr and shift the
input bExecute to True.

4. The network connectivity of slave 5 has been recovered after the output bDone of the FB shifting to
True.

5. All the slave stations would be reset if you enter 0 to the input uiSlaveAddr.

• Supported Products

 AX-3 series motion controller, AX-8, AX-C

• Library

 DL_EtherCAT_Diag.library

95
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 4

4.9 Error Codes and Troubleshooting


The following table lists the error codes corresponding to the FBs and the contents of the errors:

Description Cause of Error Corrective Action


The EtherCAT master is not in the
EtherCAT master
DFB_ECAT_Diag_MASTER_CANT_BE_FOUND mapping, Make sure the configuration of
cannot be found.
EtherCAT master is correct.
Diagnostics of
Troubleshoot the errors in EtherCAT
DFB_ECAT_Diag_MASTER_ERROR EtherCAT master
master before run the FB.
state is wrong.
The EtherCAT master is not in the
DFB_ECAT_Diag_SLAVE_ EtherCAT slave
mapping, Make sure the EtherCAT master
CANT_BE_FOUND cannot be found.
address is correct
Time out occurs
when restart Check if the time-out is too short or the
DFB_ECAT_Diag_MASTER_RESTART_TIMEOUT
EtherCAT internet has been lost.
master.
Time out occurs
DFB_ECAT_Diag_SLAVE_ Check if the time-out is too short or the
when restart
RESTART_TIMEOUT internet has been lost.
EtherCAT slave.
EtherCAT master Check whether to enable the EtherCAT
DFB_ECAT_Diag_MASTER_DISABLE
is disabled. master.

96
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 5

Chapter 5 Checksum Instructions

97
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 5

5.1 DFC_LRC8
DFC_LRC8: LRC (8-bit) checksum calculation.

FB/FC Instruction Graphic Expression ST Language

DFC_LRC8(
pSrc:= ,
FC DFC_LRC8
wLen:= ,
ErrorID=> );

• Input

Setting Value
Name Function Data Type
(Default value)
The start address for
pSrc POINTER TO BYTE Memory address 1~256 (0)
LRC calculation
The data length for
wLen DWORD* (0)
LRC calculation
*Note 1: The variable type BYTE and WORD can be used for dwLen input.
*Note 2: The memory address given by the pSrc exceeds the usable range,
it may cause controller exceptions, such as %I, %Q and %M.

• Output

Name Function Data Type Output Range(Default value)


LRC checksum
DFC_LRC8 (The parameter is BYTE (0)
returned)
ErrorID Error codes DL_LRC_ERROR DL_LRC_ERROR(DFC_NO_ERROR)

• Function

After running the FC instruction, begins to calculate LRC (8-bit) checksum from the start memory address (pSrc).
The calculation scope is determined by the input wLen.

98
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 5

• Programming Example

The example uses FC instruction (DFC_LRC8) to perform calculating the LRC (8-bit) checksum.

The checksum calculation scope is 6(dwLen = 6), therefore, the FC instruction(DFC_LRC8) will starts calculating
checksums of six consecutive BYTE data from the memory address input to pSrc(ar_byVar0[0]) and will result
in a checksum value of 16#CF.

Note: In library version 1.0.0.1, change the input from dwLen to wLen.

• Supported Products

 AX series

• Library

 DL_LRC.library

99
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 5

5.2 DFC_LRC16
DFC_LRC16: LRC (16-bit) checksum calculation.

FB/FC Instruction Graphic Expression ST Language

DFC_LRC16(
pSrc:= ,
FC DFC_LRC16
dwLen:= ,
ErrorID=> );

• Input

Setting Value
Name Function Data Type
(Default value)
The start address for
pSrc POINTER TO BYTE Memory address 1~512 (0)
LRC calculation
The data length for
wLen DWORD* (0)
LRC calculation
*Note 1: The variable type BYTE and WORD can be used for dwLen input.
*Note 2: The memory address given by the pSrc exceeds the usable range,
it may cause controller exceptions, such as %I, %Q and %M.

• Output

Name Function Data Type Output Range(Default value)


LRC checksum
DFC_LRC16 (The parameter is WORD (0)
returned)
ErrorID Error codes DL_LRC_ERROR DL_LRC_ERROR(DFC_NO_ERROR)

• Function

After running the FC instruction, begins to calculate LRC (16-bit) checksum from the start memory address pSrc.
The calculation scope is determined by the input wLen.

• Programming Example

The example uses FC instruction (DFC_LRC16) to perform calculating the LRC (16-bit) checksum.

10 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 5

The checksum calculation scope is 6(dwLen = 6), therefore, the FC instruction(DFC_LRC16) will starts
calculating checksums of six consecutive BYTE data from the memory address input to pSrc(ar_byVar0[0]) and
will result in a checksum value of 16#CFCB.
Note: In library version 1.0.0.1, change the input from dwLen to wLen.

• Supported Products

 AX series

• Library

 DL_LRC.library

10 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 5

5.3 DFC_LRC32
DFC_LRC32: LRC (32-bit) checksum calculation.

FB/FC Instruction Graphic Expression ST Language

DFC_LRC32(
pSrc:= ,
FC DFC_LRC32
wLen:= ,
ErrorID=> );

• Input

Setting Value
Name Function Data Type
(Default value)
The start address for
pSrc POINTER TO BYTE Memory address 1–512 (0)
LRC calculation
The data length for
dwLen DWORD* (0)
LRC calculation
*Note 1: The variable type BYTE and WORD can be used for dwLen input.
*Note 2: The memory address given by the pSrc exceeds the usable range,
it may cause controller exceptions, such as %I, %Q and %M.

• Output

Name Function Data Type Output Range(Default value)


LRC checksum
DFC_LRC32 (This parameter is DWORD (0)
returned)
ErrorID Error codes DL_LRC_ERROR DL_LRC_ERROR(DFC_NO_ERROR)

• Function

After running this FC instruction, begins to calculate LRC (32-bit) checksum from the start memory address pSrc.
The calculation scope is determined by the input wLen.

10 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 5

• Programming Example

The example uses FC instruction (DFC_LRC32) to perform calculating the LRC (32-bit) checksum.

The checksum calculation scope is 4(dwLen = 4), therefore, the FC instruction(DFC_LRC32) will starts
calculating checksums of four consecutive BYTE data from the memory address input to pSrc(ar_byVar0[0]) and
will result in a checksum value of 16#3935312E.

Note: From library version 1.0.0.1, change the input from dwLen to wLen.

• Supported Products

 AX series

• Library

 DL_LRC.library

10 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 5

5.4 Error Codes and Troubleshooting

Description Cause of Error Corrective Action


DFC_LRC_ERR_ Make sure the wLen value is greater than zero
The value of wLen is incorrect.
PARAMETER and does not exceed the upper limit.

10 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Chapter 6 Module Read-write Instructions


The instructions in this chapter applies only to the AX-3 expansion module (AS Series module). The instructions
can be used to read or set module parameters, or perform specific functions of the module.

FB/FC Description Library

DFB_From Reads the module CR data. DL_ASModuleAPI_AX3

DF_To Writes the module CR data DL_ASModuleAPI_AX3

DFB_DLCCAL AS02LC weight calibration instruction DL_ASModuleAPI_AX3

DFB_DLCWEI AS02LC weight measurement instruction DL_ASModuleAPI_AX3

DFB_DPUCONF PU module output control parameter setting DL_ASModuleAPI_AX3

DFB_PUSTAT PU module output status read-back DL_ASModuleAPI_AX3

PU module pulse output (no acceleration or


DFB_DPUPLS DL_ASModuleAPI_AX3
deceleration)
PU module relative positioning output (with
DFB_DPUDRI DL_ASModuleAPI_AX3
acceleration/deceleration)
PU module absolute positioning output (with
DFB_DPUDRA DL_ASModuleAPI_AX3
acceleration/deceleration)
DFB_DPUZRN PU module homing DL_ASModuleAPI_AX3

DFB_DPUJOG PU module inching output DL_ASModuleAPI_AX3

DFB_DMPID RTD/TC module PID operation DL_ASModuleAPI_AX3

AS02HC-A instructions for starting/stopping counters


DFB_DPUCNT DL_ASModuleAPI_AX3
and setting/modifying counter values

DFB_DHCCAP HC instruction for enbabling/disabling the capture DL_ASModuleAPI_AX3

DFB_HCDO HC module output point control DL_ASModuleAPI_AX3

DFB_DHCCMP HC module comparing output DL_ASModuleAPI_AX3

DFB_DHCCMPT HC module table comparing output DL_ASModuleAPI_AX3

HC module frequency and rotation speed


DFB_DHCMEAS DL_ASModuleAPI_AX3
measurement
DFB_DADLOG Analog input module log record DL_ASModuleAPI_AX3

DFB_DADPEAK Analog input module peak record DL_ASModuleAPI_AX3

10 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.1 DFB_From
DFB_From: Read the CR data in the module.

FB/FC Instruction Graphic Expression ST Language

DFB_From(
bExecute:= ,
byRemoteID:= ,
byLocalID:= ,
wCRAddr:= ,
FB DFB_ From iLength:= ,
pVal:= ,
bDone=> ,
bBusy=> ,
bError=> ,
ErrorID=> );

• Input

Setting Value
Name Function Data Type
(Default value)
Run the function block.
bExecute BOOL True/False (False)
(Rising-edge triggered)
0: CPU
The CPU or remote
byRemoteID* BYTE 1~15: Remote module
module ID
(0)
byLocalID Expansion module ID BYTE 0–31
The CR data positon in
wCRAddr WORD (0)
the module.
1~8
iLength The CR data length INT
(0)
pVal The CR data to read. POINTER TO WORD

*Note: Currently only support mode 0.

• Output

Name Function Data Type Output Range(Default value)


True when the running
bDone of the instruction is BOOL True/False (False)
completed
True when the
bBusy BOOL True/False (False)
instruction is running

bError True if an error occurs BOOL True/False (False)

10 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Name Function Data Type Output Range(Default value)


Indicates the error DFB_AS_MODULE_ DFB_AS_MODULE_API_
ErrorID
code if an error occurs. API_ERROR ERROR (DFB_NO_ERROR)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bDone  When the running of FB is completed  When bExecute shifts to False
 When the running of FB is completed
bBusy  When the running of FB starts
 When bExecute shifts to False
bError  When an error occurs during the
running or there are incorrect input  When bExecute shifts to False
ErrorID values

• Timing Diagram

• Function

1. It is suggested that this instruction be placed under Main Task.


2. The Function block DFB_From reads the CR data in the module.

• Programming Example

This example uses DFB_From to read the value of CR1 in the second module on the right side of the CPU and
store the value in the variable (wVar) of the controller.

10 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

• Supported Products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3

10 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.2 DFB_To
DFB_To: Write a value to the CR data in the module.

FB/FC Instruction Graphic Expression ST Language

DFB_To(
bExecute:= ,
byRemoteID:= ,
byLocalID:= ,
wCRAddr:= ,
FB DFB_ To iLength:= ,
pVal:= ,
bDone=> ,
bBusy=> ,
bError=> ,
ErrorID=> );

• Input

Setting Value
Name Function Data Type
(Default value)
Run the function block.
bExecute BOOL True/False (False)
(Rising-edge triggered)
0: CPU
The CPU or remote
byRemoteID* BYTE 1~15: Remote module
module ID
(0)
byLocalID Expansion module ID BYTE 0–31
The CR data positon in
wCRAddr WORD (0)
the module
1~8
iLength The CR data length INT
(0)
The CR data to be
pVal POINTER TO WORD
written

*Note: Currently only support mode 0.

• Output

Name Function Data Type Output Range(Default value)


True when the running of
bDone BOOL True/False (False)
the instruction is completed
True when the instruction is
bBusy BOOL True/False (False)
running
bError True if an error occurs BOOL True/False (False)
Indicates the error code if DFB_AS_MODULE_ DFB_AS_MODULE_API_ERROR
ErrorID
an error occurs. API_ERROR (DFB_NO_ERROR)

10 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


 When the running of FB is
bDone  When bExecute shifts to False
completed
 When the running of FB is completed
bBusy  When the running of FB starts
 When bExecute shifts to False
bError  When an error occurs during the
running or there are incorrect  When bExecute shifts to False
ErrorID input values

• Timing Diagram

• Function

1. It is suggested that this instruction be placed under Main Task.


2. The Function block DFB_To writes a value to the CR in the module.

• Programming Example

This example uses DFB_ To to write the value of variable (wVar) to CR1 in the second module on the right side
of the CPU.

11 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

• Supported Products

 AX-3 series

 Library

 DL_ASModuleAPI_AX3

111
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.3 DFB_DLCCAL
DFB_DLCCAL: AS02LC weighing module weight calibration instruction

FB/FC Instruction Graphic Expression ST Language

DFB_DLCCAL(
bEnable:= ,
byRemoteID:= ,
byLocalID:= ,
usiChannelNo:= ,
bTrigger:= ,
iTPoint:= ,
FB DFB_DLCCAL
aTWeight:= ,
bDone=> ,
bBusy=> ,
iCPoint=> ,
bTriggerDone=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run the function block BOOL True/False (False)
0: CPU
The CPU or remote
byRemoteID* BYTE 1~15: Remote module
module ID
(0)
byLocalID Expansion module ID BYTE 0–31(0)
usiChannelNo Specify channel number USINT 1–2(1)
Trigger single-point
bTrigger BOOL True/False (False)
calibration
Total number of calibration
iTPoint INT 2~20(2)
points
ARRAY[0..19]
aTWeight Calibration weight value 1.0E-44~3.402823E+38(0)
OF REAL

*Note: Currently only support mode 0.

• Output

Name Function Data Type Output Range(Default value)


bDone All calibration is done. BOOL True/False (False)
Indicates that the
bBusy function block is BOOL True/False (False)
running.

11 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Name Function Data Type Output Range(Default value)


Points number
iCPoint calibration is INT 0~20(0)
compeletd.
Single calibration is
bTriggerDone BOOL True/False (False)
done.
FB instruction error
bError BOOL True/False (False)
flag.
DFB_AS_MODULE_ DFB_AS_MODULE_API_
ErrorCode Error code
API_ERROR ERROR (DFB_NO_ERROR)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bDone  When all calibration is done  When bExecute shifts to False
bBusy  When bEnable shifts to True.  When bEnable shifts to False
 Add one when each calibration is  When bEnable shifts to False, clear to
iCPoint
done. zero.
 Every time when the calibration is
bTriggerDone  When bEnable shifts to False
done
bError  When an error occurs during the
running or there are incorrect  When bEnable shifts to False
ErrorCode input values

• Timing Diagram

bExecute

iTPoint
2
iCPoint
0 1 2

bTrigger

bTriggerDone

bDone

bError

           

The timing points in the timing diagram are described as below:


  Instruction starts, automatically clear the iCPoint value and bTrigger, bTriggerDone, bDone & bError
flags.
11 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

  User-triggered calibration flag.


  Instruction judgement module number error.
  User closing instruction.
  After being triggered by users, LC module completes single-point calibration, iCPoint adds one, and
bTriggerDone is set to ON.
  User clears the bTrigger trigger signal.
  The instruction follows to clear the bTriggerDone signal.
  After being triggered by users, LC modules are completely calibrated, iCPoint adds one, and
bTriggerDone & bDone are set to ON.

• Function

1. It is suggested that this instruction be placed under Main Task.


2. This function is supported only when AX-3 series firmware version is V1.0.1 and later.
3. This instruction is only for use with the AS02LC weighting module, and the supported version is AS02LC
V1.04 and later.
4. This is weighting module (AS02LC-A) dedicated instruction, and its function is to activate/deactivate the
weight calibration function of the module.
5. byRemoteID specifies that the weighting module should connect to the right of CPU or the right of the
remote module group numbers. The CPU number is 0, the first remote module number is 1, and so on.
The maximum group number is 15.
6. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the number
of the second module on the right of CPU is 1, and so on. Regardless of any type of modules, all modules
must be counted. The maximum number of modules is 32.
7. usiChannelNo specifies the channel numbers. The number of channel one is 1, and the number of
channel two is 2.
8. bTrigger is the instruction that triggers single-point calibration. When the bTrigger status changes from
OFF to ON, LC module will be notified to perform a single calibration, and bTriggerDone flag will be set to
ON after completion. If the calibrations of all calibrated points are done, the bDone flag will also be ON.
Before proceeding the next calibration point, users need to check the bTriggerDone flag is ON, and
changes bTrigger to OFF. At this time, the instruction will also monitor the bTrigger flag when it turns from
ON to OFF, and the bTriggerDone flag will be automatically cleared.
9. iTPoint is the total number of points for this calibration. After the instruction is activated by users, this
value cannot be changed because this iTPoint has been sent to the LC module for calibration at the first
activation.
10. aTWeight is the calibration weight value for each calibrated point, and the maximum number of calibration
points for the LC module is 20. After the instruction is activated, users cannot change this value because
this aTWeight has sent data to the LC module for calibration at the first activation. The first point calibration
weight value must be 0, if it is not 0, the bError flag will be set to ON. For example, the total points of
iTPoint calibration is 3, aTWeight gives [0.0, 100.0, 200.0, 17(0.0)] a total of 20 REAL-type ARRAY, of
which 17(0.0) means there are 17 0.0.

• Programming Example
11 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

This example uses the FB instruction (DFB_DLCCAL) to calibrate the first channel in the first module on the
right of CPU.

1. Set CalibrationPoint1 to ON.


2. Make sure that the weight platform is unloaded first, set DLCCAL_CH1_bEnable to ON, and then set
DLCCAL_CH1_bTrigger to ON. When the iCPoint value becomes 1, and bTriggerDone becomes TRUE,
it means that this first point calibration is done.
3. Place 100.0g weights on the weight platform and after ensuring the platform is steady, set
DLCCAL_CH1_bTrigger to ON. Now, iCPoint becomes 2, and bTriggerDone & bDone are TRUE, which
means that all calibrations are done. After making the third network established, deactivate DFB_DLCCAL
function block to complete this calibration.

• Supported Products

 AX-3 series

 Library

 DL_ASModuleAPI_AX3.library

11 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.4 DFB_DLCWEI
DFB_DLCWEI: AS02LC weighting module weight measurement instruction

FB/FC Instruction Graphic Expression ST Language

DFB_DLCWEI(
bEnable:= ,
byRemoteID:= ,
byLocalID:= ,
usiChannelNo:= ,
rStable:= ,
bZeroS:= ,
FB DFB_DLCWEI
bTareS:= ,
bBusy=> ,
rTareW=> ,
rWeight=> ,
iStatus=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run the function block BOOL True/False (False)
0: CPU
The CPU or remote
byRemoteID* BYTE 1~15: Remote module
module ID
(0)
byLocalID Expansion module ID BYTE 0–31(0)
usiChannelNo Specify channel number USINT 1–2(1)
Set the weight stability
rStable REAL 0.0~100000.0 (0)
range
bZeroS Set the weight to zero flag BOOL True/False (False)
bTareS Set the tare weight flag BOOL True/False (False)

*Note: Currently only support mode 0.

• Output

Name Function Data Type Output Range(Default value)


Indicates that the
bBusy function block is BOOL True/False (False)
running.
rTareW Tare weight REAL 1.0E-44~3.402823E+38(0)
rWeight Current weight REAL 1.0E-44~3.402823E+38(0)

11 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Name Function Data Type Output Range(Default value)


iStatus* LC module status code INT 0~5(0)
bError FB instruction error BOOL True/False (False)
DFB_AS_MODULE_ DFB_AS_MODULE_
ErrorCode Error code
API_ERROR API_ERROR (DFB_NO_ERROR)

*Note: iStatus is the common status code of this instruction integrating the LC module. Its statuses are as follows:

Value 0 1 2 3 4 5

Description Measuring Weight is Hardware/Calibration Calibrating Weight is Module


or unloaded steady. error out of number/Channel
range. error

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bBusy  When bEnable shifts to True  When bEnable shifts to False
 Continuously update the value when
 When bEnable shifts to False, clear to
rTareW bEnable is TRUE.
zero.

 Continuously update the weight value  When bEnable shifts to False, clear to
rWeight
when bEnable is TRUE. zero.
 Continuously update the status when  When bEnable shifts to False, clear to
iStatus
bEnable is TRUE. zero.
bError  When an error occurs during the running or
 When bEnable shifts to False
ErrorCode there are incorrect input values

• Timing Diagram

bEnable

bZeroS

bTareS

rTareW
0 10 0 20
rWeight
0 10 0 10 20 0 100
iStatus
0 1 0 1 0 1

          

11 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

The timing points in the timing diagram are described as below:


  Activate the instruction
  When users order to clear to 0, the instruction will clear the rTareW & rWeight values and the iStatus
status.
  Users place objects on the weight platform, and when the weight values is steady, iStatus becomes 1
and rWeight weight value is shown.
  Users order to set the tare weight to ON. Now, the rWeight weight is transferred to rTareW, and then the
rWeight weight is cleared.
  Users clear the tare weight setting OFF. Now the rTareW weight is transferred back to rWeight, and then
the rTareW weight is cleared.
  Users place another object on the weight platform again. Now, iStatus turns to measuring.
  Instruction is deactivated, and rTareW, rWeight, iStatus are cleared to 0.

• Function

1. It is suggested that this instruction be placed under Main Task.


2. This function is supported only when AX-3 series firmware version is V1.0.1 and later.
3. This instruction is only for use with the AS02LC weighting module, and the supported version is AS02LC
V1.04 and later.
4. This is weighting module (AS02LC-A) dedicated instruction, and its function is to activate/deactivate the
weight measurement function of the module.
5. byRemoteID specifies that the weighting module should connect to the right of CPU or the right of the
remote module group numbers. The CPU number is 0, the first remote module number is 1, and so
on. The maximum group number is 15.
6. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the
number of the second module on the right of CPU is 1, and so on. Regardless of any type of modules,
all modules must be counted. The maximum number of modules is 32.
7. usiChannelNo specifies the channel numbers. The number of channel one is 1, and the number of
channel two is 2.
8. rStable is the weight stability range value. Its data type is REAL, and the inputable floating-point number
value range is 0.0~100000.0. If the setting is out of range, the instruction will automatically set the value
to the minimum/maximum values. The timing of LC module parameter setting is when the instruction is
started for the first time. To modify the value in the LC module later, users need to deactivate the
instruction, set a new range value, and then open the instruction to reset.
9. After this instruction is activated, the specified channels will be automatically changed to “Net Weight”
display mode. If users need to know the “Gross weight (total weight)” value, add rTareW and rWeight.
10. bZeroS is the flag that sets the current weight to 0. When this flag is from OFF to ON, rTareW and
rWeight will be cleared to 0.
11. bTareS is the flag that sets the tare weight. When the bTareS flag is from OFF to ON, the current
rWeight weight will be transferred to rTareW, and the rWeight value will be cleared to 0. When the
bTareS flag is from ON to OFF, rTareW will be back to the rWeight current weight value, and the rTareW
value will be cleared to 0.

11 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

12. rWeight is the weight value after deducting the tare weight. Users can monitor if rTareW has a value to
determine whether the tare function is activated. When the value is 0, it represents that the tare weight
has not been set.

• Programming Example

After completing DLCCAL calibration, the DLCWEI instruction can used to perform weight measurement.

1. Weight measurement: Place 500g weights on the weight platform. When bEnable is On, rWeight
displays the current weight 500.0.
2. Tare weight setting:
 Place package material on the weight platform (e.g. 100 g). Now, rWeight shows that the current
weight is 100.0.
 When bTareS is ON, the rWeight weight will be transferred to rTareW, and then the rWeight weight
will be cleared.
 When rWeight = 0.0 (maybe a little unstable) and rTareW = 100.0, the tare weight setting is
complete.
3. Clear tare weight setting:
 When bTareS is OFF, the rTareW weight will be back to rWeight, and then the rTareW weight will
be cleared.
 When rWeight = 100.0 and rTareW = 0.0, tare weight setting is cleared.
4. Weight stability range setting (Stability checking function):
 Before bEnable is ON, set rStable = 10.0.
 After placing 500g weights and setting bEnable to ON, when the measurement range is between
490~510g, iStatus = 1 (Weight is stable).

• Supported Products

 AX-3 series

 Library

 DL_ASModuleAPI_AX3.library

11 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.5 DFB_DPUCONF
DFB_DPUCONF: parameter setting of PU module output control

FB/FC Instruction Graphic Expression ST Language

DFB_DPUCONF(
bEnable:= ,
byLocalID:= ,
iAxis:= ,
iMode:= ,
iStartSpeed:= ,
iAccTime:= ,
FB DFB_DPUCONF iDecTime:= ,
diMaxSpeed:= ,
iZ_no:= ,
iOffset:= ,
bDone=> ,
bBusy=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run the function block BOOL True/False (False)
byLocalID Expansion module ID BYTE 0–31(0)
iAxis Output axis number INT 1~4(1)
iMode Output mode setting INT 0~3(1)
iStartSpeed Start/End speed INT 0~10000 Hz(100)
iAccTime Acceleration time INT 0~10000 ms(100)
iDecTime Deceleration time INT 0~10000 ms(100)
Maximum output AS02PU:100~200000 Hz(100K)
diMaxSpeed DINT
frequency AS04PU:100~100000 Hz(100K)
Homing function and find
iZ_no the number of z-phase INT -100~100 times(0)
signals
Homing function is done,
and the z-phase is found,
iOffset INT -10000~10000 numbers(0)
then output the offset
position.

• Output

12 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Name Function Data Type Output Range(Default value)


Parameter setting
bDone BOOL True/False (False)
completion flag
Indicates that the
bBusy function block is BOOL True/False (False)
running.
FB instruction error
bError BOOL True/False (False)
flag
DFB_AS_MODULE_ DFB_AS_MODULE_API_
ErrorCode Error code
API_ERROR ERROR (DFB_NO_ERROR)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bDone  When the parameter setting is done  When bEnable shifts to False
bBusy  When bEnable shifts to TRUE  When bEnable shifts to False
bError  When an error occurs during the running or
 When bEnable shifts to False
ErrorCode there are incorrect input values

• Timing Diagram

bEnable

bDone

bBusy

bError

• Function

1. It is suggested that this instruction be placed under Main Task.


2. This function is supported only when AX-3 series firmware version is V1.0.1 and later.
3. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the
number of the second module on the right of CPU is 1, and so on. Regardless of any type of modules,
all modules must be counted. The maximum number of modules is 32. This PU dedicated instruction is
only for the PU module on the right of CPU and is not for the PU module on the right of the remote
module. If the specified module is not the PU module, the bError flag will be set to ON.
4. iAxis is the axis number of the specified output PU module. The input values 1~4 respectively represent
the specified PU module axis 1–axis 4 output. If the PU module does not have this axis number, the

12 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

bError flag will be set to ON. The combination of the axis number and the corresponding output points is
as follows:

PU Module Name Axis1 Combination Axis2 Combination Axis3 Combination Axis4 Combination
AS02PU Y0.0 / Y0.1 Y0.2 / Y0.3 NA NA
AS04PU Y0.0 / Y0.1 Y0.2 / Y0.3 Y0.4 / Y0.5 Y0.6 / Y0.7

5. iMode selects parameters for the output mode of setting the output axis, and the setting values are as
shown in the following table:

Output Mode
Mode Note
Value
Single-point pulse output (even-point
N For example: Y0.0 or Y0.2 output
output only)
For example: Y0.0 is pulse, Y0.1 is direction. When
Pulse (even points) + Direction (odd
1 the direction is positive, Y0.1 is OFF; when the
points)
direction is negative, Y0.1 is ON.
For example: Y0.0 is CW (Positive direction), and
2 CW (even points) + CCW (odd points)
Y0.1 is CCW (negative direction).
For example: Y0.0 is A, and Y0.1 is B. When A is
A-phase (even points) + B-phase (odd ahead of B, it represents positive direction output;
3
points) when B is ahead of A, it represents negative direction
output.
Automatically change to mode 1
Others -
(Default)

6. iStartSpeed~iOffset are non-power outage persistence value. If the setting value is out of range, bError
will be reported.
7. bDone is the output axis of the specified PU module, and is the parameter setting completion flag.
When the flag is ON, it represents that parameter setting is successful. Users can perform the
subsequent positioning output function according to the flag status. The bDone flag clearance needs to
be Run by users, and this instruction will set this flag once when the setting is done.
8. bError is the output axis of the specified PU module, and is the parameter error flag. Because most of
parameter ranges are automatically filtered by PLC, if this error flag occurs, it means that there is no
specified PU module, the PU module number is incorrect, or the output axis number is incorrect.
9. This parameter setting instruction is pulse running instruction. Even if the A contact method is used for
the user conditional contact, this instruction will set the parameters of the PU module at the time when
it’s started. Therefore, when the axis parameters are changed, restart the instruction and reset the
parameters.

12 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

10. Because the parameter setting is ordered through the module communication, Check the bDone or
bError flags of the setting results each time the parameters are modified, and then perform the related
output action.

• Programming Example

The following example shows hoe to Run the DFB_DPUCONF function block to set the parameter setting of
the PU output module.
1. Delta_LocalBus_Master configures an AS02PU_A.

2. Use the DFB_DPUCONF function block to set the first axis parameter of the 02PU module on the right.

• Supported Products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

12 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.6 DFB_PUSTAT
DFB_PUSTAT: PU module output status read-back

FB/FC Instruction Graphic Expression ST Language

DFB_PUSTAT(
bEnable:= ,
byLocalID:= ,
iAxis:= ,
bZeroSet:= ,
FB DFB_ PUSTAT bBusy=> ,
diCurrentPosi=> ,
bMoving=> ,
bPause=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run the function block BOOL True/False (False)
byLocalID Expansion module ID BYTE 0–31(0)
iAxis Output axis number INT 1~4(1)
The current output
BOOL True/False (False)
bZeroSet location is cleared to 0.

• Output

Name Function Data Type Output Range(Default value)


Indicates that the
bBusy function block is BOOL True/False (False)
running.
diCurrentPosi Current output position DINT 0~ 2,147,483,648(0)
bMoving Output running flag BOOL True/False (False)
bPause Output pause flag BOOL True/False (False)
FB instruction error
bError BOOL True/False (False)
flag.
DFB_AS_MODULE DFB_AS_MODULE_
ErrorCode Error code
_API_ERROR API_ERROR (DFB_NO_ERROR)

 Outputs Updating Timing

12 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Name Timing for shifting to True Timing for shifting to False


bBusy  When bEnable shifts to True  When bEnable shifts to False
 Continuously updating when bEnable shifts to
diCurrentPosi  When bEnable shifts to False
True.
 If the module is outputting pulse after bEnable
bMoving  When bEnable shifts to False
shifts to True.
 If the module is not outputting pulse after
bPause  When bEnable shifts to False
bEnable shifts to True.
bError  When an error occurs during the running or
 When bEnable shifts to False
ErrorCode there are incorrect input values

• Timing Diagram

bEnable

bBusy

bError

• Function

1. It is suggested that this instruction be placed under Main Task.


2. This function is supported only when AX-3 series firmware version is V1.0.1 and later.
3. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the
number of the second module on the right of CPU is 1, and so on. Regardless of any type of modules,
all modules must be counted. The maximum number of modules is 32. This PU dedicated instruction is
only for the PU module on the right of CPU and is not for the PU module on the right of the remote
module. If the specified module is not the PU module, the bError flag will be set to ON.
4. iAxis is the axis number of the specified output PU module. The input values 1~4 respectively represent
the specified PU module axis 1–axis 4 output. If the PU module does not have this axis number, the
bError flag will be set to ON.
5. diCurrentPosi is the current position of the output axis of the specified PU module. This values is
outage persistent, and is stored in the PU module. If users want to clear this value, clear the bZeroSet
flag to 0 (OFF  ON) when the instruction is started.
6. bMoving is the output running flag (Read-only) of the output axis of the PU module. When this flag is
ON, it means that the output is in progress; when the flag is OFF, it means that the output axis is not
being used and can accept the next output instruction.
7. bPause is the output pause flag (Read-only) of the output axis of the PU module. When this flag is ON,
it means that the output is paused, the current speed is 0, and the current position has not yet reached

12 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

the target position of the specified output. If users resume the output, this flag will be automatically
cleared. Note: When the bPause flag is ON, the bMoving flag becomes OFF.
8. BError is the specified PU module and is the read error flag (Read-only). When the error occurs, Refer
to ErrorCode description.

• Programming Example

This example shows how to Run the DFB_PUSTAT function block to set the current output position of the first
axis of the PU output module.

1. Delta_LocalBus_Master configures an AS02PU_A.

2. Use the DFB_PUSTAT function block to set the current output position of the first axis of the 02PU
module.

• Supported Products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

12 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.7 DFB_DPUPLS
DFB_DPUPLS: PU module pulse output (No acceleration/deceleration)

FB/FC Instruction Graphic Expression ST Language

DFB_DPUPLS(
bEnable:= ,
byLocalID:= ,
iAxis:= ,
diTarPulse:= ,
FB DFB_DPUPLS
diTarSpeed:= ,
bDone=> ,
bBusy=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run the function block BOOL True/False (False)
byLocalID Expansion module ID BYTE 0–31(0)
iAxis Output axis number INT 1~4(1)
diTarPulse Target output number DINT -2,147,483,648~ 2,147,483,648(0)
Target output frequency AS02PU: -200K~200K(0)
diTarSpeed DINT
(Unit: Hz) AS04PU: -100K~100K(0)

• Output

Name Function Data Type Output Range(Default value)


Pulse output
bDone BOOL True/False (False)
completion flag
Indicates that the
bBusy function block is BOOL True/False (False)
running.
FB instruction error
bError BOOL True/False (False)
flag.
DFB_AS_MODULE DFB_AS_MODULE_API
ErrorCode Error code
_API_ERROR _ERROR (DFB_NO_ERROR)

 Outputs Updating Timing

12 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Name Timing for shifting to True Timing for shifting to False


bDone  When the pulse output is done  When bEnable shifts to False
bBusy  When bEnable shifts to True  When bEnable shifts to False
bError  When an error occurs during the running or
 When bEnable shifts to False
ErrorCode there are incorrect input values

• Timing Diagram

bEnable

bDone

bBusy

bError

• Function

1. It is suggested that this instruction be placed under Main Task.


2. This function is supported only when AX-3 series firmware version is V1.0.1 and later.
3. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the
number of the second module on the right of CPU is 1, and so on. Regardless of any type of modules,
all modules must be counted. The maximum number of modules is 32. This PU dedicated instruction is
only for the PU module on the right of CPU and is not for the PU module on the right of the remote
module. If the specified module is not the PU module, the bError flag will be set to ON.
4. iAxis is the axis number of the specified output PU module. The input values 1~4 respectively
represent the specified PU module axis 1–axis 4 output. If the PU module does not have this axis
number, the bError flag will be set to ON.
5. diTarPulse is the pulse number of the specified output. The pulse number that can be input is the
signed numbers 32-bit positive value. When the vale is 0, it means keeping outputting and the output
numbers are not limited until the instruction is deactivated and the output stops; when the value is less
than 0, PLC will automatically use the 2’s complement method to convert to the number output of a
positive integer number.
6. diTarSpeed is the target speed (Unit: Hz) of the specified output and the number that can be input is
the signed numbers 32-bit value. Users can modify the target frequency any time after the instruction
starts output, and the PU module will switch to the latest target frequency after outputting a complete
pulse. Note: Before changing the target frequency, consider if the change speed and the PLC scan
time are appropriate. The corresponding diTarSpeed setting range of the module is as follows:

12 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

PU Module Name diTarSpeed Setting Range


AS02PU -200,000(-200K)–200,000(200K)
AS04PU -100,000(-100K)–100,000(100K)

7. When the target speed of diTarSpeed is positive (>0), it means that the output point of “positive
direction” is OFF; when the target speed of diTarSpeed is negative (<0), it means that the output point
of “negative direction” is ON; when the target speed of diTarSpeed is 0, it means that after outputting a
complete running pulse, it enters the pause output status.
8. This output instruction does not provide the acceleration/deceleration function. For
acceleration/deceleration function requirement, use the DPUDRI instruction.
9. This output instruction can be used for changing speed. When the instruction is running output, users
can change the target frequency value of diTarSpeed to achieve the purpose of changing the output
speed.
10. When the output has reached the specified diTarPulse pulse number, the bDone completion flag will be
set to ON. The bDone flag clearance needs to be Run by users, and this instruction will set this flag
once when the setting is done
11. If any error situation occurs during output startup, the bError error flag will be set to ON. Users can
refer to ErrorCode for troubleshooting.

• Supported Products

 AX-3 series

• Library
 DL_ASModuleAPI_AX3.library

12 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.8 DFB_DPUDRI
DFB_DPUDRI: PU module relative positioning output (With acceleration/deceleration)

FB/FC Instruction Graphic Expression ST Language

DFB_DPUDRI(
bEnable:= ,
byLocalID:= ,
iAxis:= ,
diRTarPosi:= ,
FB DFB_DPUDRI
diTarSpeed:= ,
bDone=> ,
bBusy=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run the function block BOOL True/False (False)
byLocalID Expansion module ID BYTE 0–31(0)
iAxis Output axis number INT 1~4(1)
Number of relative
diRTarPosi DINT -2,147,483,648~ 2,147,483,648(0)
positioning outputs
Target output frequency AS02PU: -200K~200K(0)
diTarSpeed DINT
(Unit: Hz) AS04PU: -100K~100K(0)

• Output

Name Function Data Type Output Range(Default value)


Pulse output
bDone BOOL True/False (False)
completion flag
Indicates that the
bBusy function block is BOOL True/False (False)
running.
FB instruction error
bError BOOL True/False (False)
flag
DFB_AS_MODULE_ DFB_AS_MODULE_API_
ErrorCode Error code
API_ERROR ERROR (DFB_NO_ERROR)

 Outputs Updating Timing

13 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Name Timing for shifting to True Timing for shifting to False


bDone  When the pulse output is done  When bEnable shifts to False
bBusy  When bEnable shifts to True  When bEnable shifts to False
bError  When an error occurs during the running or
 When bEnable shifts to False
ErrorCode there are incorrect input values

• Timing Diagram

bEnable

bDone

bBusy

bError

• Function
1. It is suggested that this instruction be placed under Main Task.
2. This function is supported only when AX-3 series firmware version is V1.0.1 and later.
3. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the
number of the second module on the right of CPU is 1, and so on. Regardless of any type of modules,
all modules must be counted. The maximum number of modules is 32. This PU dedicated instruction is
only for the PU module on the right of CPU and is not for the PU module on the right of the remote
module. If the specified module is not the PU module, the bError flag will be set to ON.
4. iAxis is the axis number of the specified output PU module. The input values 1~4 respectively represent
the specified PU module axis 1–axis 4 output. If the PU module does not have this axis number, the
bError flag will be set to ON.
5. diRTarPosi is the position of the specified output relative positioning, and the pulse number that can be
input is the signed numbers 32-bit value. When the value is greater than 0, the output is toward the
positive direction (direction output point OFF); when the value is less than 0, the output is toward the
negative direction (direction output point ON); when the value equals 0, this instruction will instantly set
the bDone output completion flag to ON.
6. diTarSpeed is the target speed (Unit: Hz) of the specified output and the frequency value that can be
input is the signed numbers 32-bit value. When the value is less than 0, the instruction will use the 2’s
complement method to convert to a positive integer number; when the values equals to 0, the instruction
will inform the module to enter the pause mode. The actual output will decelerate according to
deceleration slope until the output speed reaches 0, and users set the pause flag (refer to the PUSTAT
instruction). The corresponding diTarSpeed setting range of the module is as follows:

13 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

PU Module Name diTarSpeed Setting Range


AS02PU -200,000(-200K)–200,000(200K)
AS04PU -100,000(-100K)–100,000(100K)

7. After starting the output, the target frequency can be changed anytime; however, when the frequency is
actually changed, PLC will automatically change the frequency according to the
acceleration/deceleration rate slope set by the DPUCONF instruction.
8. When the output has reached the specified diRTarPosi relative positioning position, the bDone
completion flag will be set to ON. The bDone flag clearance needs to be Run by users, and this
instruction will set this flag once when the setting is done.
9. During the output startup process, if any error situation occurs, the bError flag will be set to ON. Users
can refer to ErrorCode to perform troubleshooting.
10. Acceleration/Deceleration curve of the PU module positioning output instruction is as follows:

 The value of the maximum output frequency. Refer to the DPUCONF instruction setting for this
parameter.
 The target frequency specified by the PU module output instruction. The target frequency cannot output
the frequency that exceeds the maximum output frequency. The output will be limited to the maximum
output frequency.
 Start/End output frequency setting value. Refer to the DPUCONF instruction setting for this parameter.
 Acceleration time value. Refer to the DPUCONF instruction setting for this parameter.
 Deceleration time value. Refer to the DPUCONF instruction setting for this parameter.
The acceleration/deceleration of the PU module is a fixed slope, so the actual acceleration/deceleration time
will change according to the target frequency of the specified output. The acceleration/deceleration slope
conversion formulas are (1) (maximum output frequency - startup frequency) / acceleration time, and (2)
(maximum output frequency - end frequency) / deceleration time.

• Supported Products

 AX-3 series

13 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

• Library

 DL_ASModuleAPI_AX3.library

13 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.9 DFB_DPUDRA
DFB_DPUDRA: PU module absolute positioning output (With acceleration/deceleration)

FB/FC Instruction Graphic Expression ST Language

DFB_DPUDRI(
bEnable:= ,
byLocalID:= ,
iAxis:= ,
diATarPosi:= ,
FB DFB_DPUDRA
diTarSpeed:= ,
bDone=> ,
bBusy=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run the function block BOOL True/False (False)
byLocalID Expansion module ID BYTE 0–31(0)
iAxis Output axis number INT 1~4(1)
Number of relative
diATarPosi DINT -2,147,483,648~ 2,147,483,648(0)
positioning outputs
Target output frequency AS02PU: -200K~200K(0)
diTarSpeed DINT
(Unit: Hz) AS04PU: -100K~100K(0)

• Output

Name Function Data Type Output Range(Default value)


Pulse output
bDone BOOL True/False (False)
completion flag
Indicates that the
bBusy function block is BOOL True/False (False)
running.
FB instruction error
bError BOOL True/False (False)
flag
DFB_AS_MODULE_ DFB_AS_MODULE_API_
ErrorCode Error code
API_ERROR ERROR (DFB_NO_ERROR)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False

13 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

bDone  When pulse output is done  When bEnable shifts to False


bBusy  When bEnable shifts to True  When bEnable shifts to False
bError  When an error occurs during the running or
 When bEnable shifts to False
ErrorCode there are incorrect input values

• Timing Diagram

bEnable

bDone

bBusy

bError

• Function

1. It is suggested that this instruction be placed under Main Task.


2. This function is supported only when AX-3 series firmware version is V1.0.1 and later.
3. diATarPosi is the position of the absolute positioning of the specified output. The number of pulses that
can be entered is a 32-bit number. The PU module will automatically compare the current position in the
record. After comparison, if the value is greater than 0, it means that the output is toward the positive
direction; if the value is less than 0, it means that the output is toward the negative direction; if the value
is 0, this instruction will instantly set the bDone output completion to ON.
4. Refer to the DPUDRI instruction for the description of other parameters.

• Supported Products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

13 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.10 DFB_DPUZRN
DFB_DPUZRN: PU module homing

FB/FC Instruction Graphic Expression ST Language

DFB_DPUZRN(
bEnable:= ,
byLocalID:= ,
iAxis:= ,
iMode:= ,
FB DFB_DPUZRN diTarSpeed:= ,
iJogSpeed:= ,
bDone=> ,
bBusy=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run the function block BOOL True/False (False)
byLocalID Expansion module ID BYTE 0–31(0)
iAxis Output axis number INT 1~4(1)
iMode Homing mode selection INT 0~8, 255(0)

AS02PU:-200K~-100 和

Homing maximum output 100~200K(100)


diTarSpeed DINT
frequency AS04PU: -100K~-100
100~100K(100)

Homing inching output


iJogSpeed INT 1~10000(1)
frequency

• Output

Name Function Data Type Output Range(Default value)


bDone Completion flag BOOL True/False (False)
Indicates that
the function
bBusy BOOL True/False (False)
block is
running.
FB instruction
bError BOOL True/False (False)
error flag

13 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Name Function Data Type Output Range(Default value)


DFB_AS_MODULE_API_ DFB_AS_MODULE_API_ERROR
ErrorCode Error code
ERROR (DFB_NO_ERROR)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bDone  When the pulse output is done  When bEnable shifts to False
bBusy  When bEnable shifts to True  When bEnable shifts to False
bError  When an error occurs during the running or
 When bEnable shifts to False
ErrorCode there are incorrect input values

• Timing Diagram

bEnable

bDone

bBusy

bError

• Function

1. It is suggested that this instruction be placed under Main Task.


2. This function is supported only when AX-3 series firmware version is V1.0.1 and later.
3. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the
number of the second module on the right of CPU is 1, and so on. Regardless of any type of modules, all
modules must be counted. The maximum number of modules is 32. This PU dedicated instruction is only for
the PU module on the right of CPU and is not for the PU module on the right of the remote module. If the
specified module is not the PU module, the bError flag will be set to ON.
4. iAxis is the axis number of the specified output PU module. The input values 1~4 respectively represent
the specified PU module axis 1–axis 4 output. If the PU module does not have this axis number, the bError
flag will be set to ON.
5. iMode is the mode selection for homing. The mode description is as shown below:

Select Matching Input


Mode
Function Point (Parameter Setting Remark
Parameter
of PU Module)
0 Directly clear the current position to 0. None
Stops when the negative direction
1 DOG
leaves the origin.
13 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Select Matching Input


Mode
Function Point (Parameter Setting Remark
Parameter
of PU Module)
Stops when the positive direction leaves
2 DOG
the origin.
Look for z-phase times after mode 1 is
3 DOG and Z-phase input
done. Set Z-phase times with
Look for z-phase times after mode 2 is DPUCONF
4 DOG and Z-phase input
done.
Output the offset position after mode 1
5 DOG Set output offset
is done.
position with
Output the offset position after mode 2 DPUCONF
6 DOG
is done.
After mode 1 is done, look for z-phase Set z-phase times and
7 DOG and Z-phase input
first, then output the offset position output the offset
After mode 2 is done, look for z-phase position with
8 DOG and Z-phase input DPUCONF
first, then output the offset position
Modify the current output position of the Used with the
255 None
axis TarSpeed parameter
Others Reserved

Note: If the mode selects the required input points that are not matched with the Parameter setting of the PU
module, the homing function may fail.
Note: For the above iMode 1~4, the PU module firmware version V1.02.00, when the action is complete, the
current output position of the axis will not be cleared to 0, and it can be cleared with the PUSTAT instruction.
For the PU module firmware version V1.02.10 and later, when the action is complete, the current output
position will be cleared to 0.
Note: For the above iMode 5~8, the PU module firmware version V1.02.00, when the action is complete, the
current output position is now the output result, and the current position must be modified to the specified
position with the mode 255. For the PU module firmware version V1.02.10 (included) and later, when the
action is complete, the axis current output position will be cleared to 0.
6. When diTarSpeed is selected to be mode is 1~8, it is the highest output speed for specifying to return to
the origin, and this value is the signed numbers 32-bit value. Positive/Negative represents the default startup
direction to fine the origin. For example, positive means that the instruction starts to look for the origin from
the positive direction; the corresponding diTarSpeed setting range of the module is as follows: (If the mode
parameter is specified as 255, the diTarSpeed will become the value of updating the PU module current
position.)

PU Module
When Mode is 1~8, diTarSpeed Setting Range
Name

AS02PU -200,000–-100(Hz) and 100–200,000(Hz)

AS04PU -100,000–-100(Hz) and 100–100,000(Hz)

7. iJogSpeed is the inching output speed when it touches the origin. This value is the signed number 16-
bit value, and the setting value is 1~10,000 Hz.

13 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

8. When the output has reached the specified origin position, the bDone completion flag will be se5t to ON.
This bDone flag clearance needs to be Run by users, and this instruction will set this flag once when the
output is done.
9. During the output startup process, if any error situation occurs, the bError flag will be set to ON. Users
can refer to ErrorCode to perform troubleshooting.

• Supported Products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

13 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.11 DFB_DPUJOG
DFB_DPUJOG: PU module inching output

FB/FC Instruction Graphic Expression ST Language

DFB_DPUJOG(
bEnable:= ,
byLocalID:= ,
iAxis:= ,
FB DFB_DPUJOG
diJogSpeed:= ,
bBusy=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run the function block BOOL True/False (False)
byLocalID Expansion module ID BYTE 0–31(0)
iAxis Output axis number INT 1~4(1)
AS02PU: -200K~200K(0)
diJogSpeed Inching output frequency DINT
AS04PU: -100K~100K(0)

• Output

Name Function Data Type Output Range(Default value)


Indicates that the
bBusy function block is BOOL True/False (False)
running.
FB instruction error
bError BOOL True/False (False)
flag
DFB_AS_MODULE_ DFB_AS_MODULE_API_
ErrorCode Error code
API_ERROR ERROR (DFB_NO_ERROR)

14 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bBusy  When bEnable shifts to True  When bEnable shifts to False
bError  When an error occurs during the running or
 When bEnable shifts to False
ErrorCode there are incorrect input values

• Timing Diagram

bEnable

bBusy

bError

• Function
1. It is suggested that this instruction be placed under Main Task.
2. This function is supported only when AX-3 series firmware version is V1.0.1 and later.
3. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the
number of the second module on the right of CPU is 1, and so on. Regardless of any type of modules,
all modules must be counted. The maximum number of modules is 32. This PU dedicated instruction is
only for the PU module on the right of CPU and is not for the PU module on the right of the remote
module. If the specified module is not the PU module, the bError flag will be set to ON.
4. iAxis is the axis number of the specified output PU module. The input values 1~4 respectively represent
the specified PU module axis 1–axis 4 output. If the PU module does not have this axis number, the
bError flag will be set to ON.
5. diJogSpeed is the output speed of the specified inching, and this value is the signed number 32-bit
value. When the value is greater than 0, it means that the output is toward the positive direction
(Direction output point is OFF); when the value is less than 0, it means that the output is toward the
negative direction (Direction output point is ON); when the value is 0, it means that the output stops. The
corresponding diJogSpeed setting range of the module is as follows:

PU Module Name JogSpeed Setting Range


AS02PU -200,000(-200K)–200,000(200K)
AS04PU -100,000(-100K)–100,000(100K)

6. If any error situation occurs during output startup, the bError error flag will be set to ON. Users can refer
to ErrorCode for troubleshooting.

14 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

7. The output timing diagram of the DPUJOG instruction is as follows: (In the timing diagram, Jog_in is the
instruction startup switch, and Busy flag is the flag of bBusy runningning.)

8. When the DPUJOG instruction is deactivated, it can perform other output control after the bBusy flag is
already OFF.

• Supported Products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

14 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.12 DFB_DPUCNT
DFB_DPUCNT: PU module high-speed counter function

FB/FC Instruction Graphic Expression ST Language

DFB_DPUCNT(
bEnable:= ,
byLocalID:= ,
iInputMode:= ,
iPeriod:= ,
FB DFB_DPUCNT bZeroSet:= ,
bBusy=> ,
diInputPulse=> ,
diInputSpeed=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run the function block BOOL True/False (False)
byLocalID Expansion module ID BYTE 0–31(0)
Encoder input mode and
iInputMode counting frequency INT 1~7(4)
multiplication setting
iPeriod Speed fetch cycle time INT 10~1000(1000)
bZeroSet Counter is cleared to 0. BOOL True/False (False)

• Output

Name Function Data Type Output Range(Default value)


Indicates that the
bBusy function block is BOOL True/False (False)
running.
The entered number
diInputPulse DINT 0~ 2,147,483,648(0)
display
Counting number of
diInputSpeed DINT 0~ 2,147,483,648(0)
every cycle time
FB instruction error
bError BOOL True/False (False)
flag
DFB_AS_MODULE_ DFB_AS_MODULE_API_
ErrorCode Error code
API_ERROR ERROR (DFB_NO_ERROR)

 Outputs Updating Timing

14 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Name Timing for shifting to True Timing for shifting to False


bBusy  When bEnable shifts to True  When bEnable shifts to False
 Continuously updating after bEnable shifts to
diInputPulse  When bEnable shifts to False
True.
 Continuously updating after bEnable shifts to
diInputSpeed  When bEnable shifts to False
True.
bError  When an error occurs during the running or
 When bEnable shifts to False
ErrorCode there are incorrect input values

• Timing Diagram

bEnable

bBusy

bError

• Function
1. It is suggested that this instruction be placed under Main Task.
2. This function is supported only when AX-3 series firmware version is V1.0.1 and later.
3. This instruction is supported only by the AS02PU module.
4. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the
number of the second module on the right of CPU is 1, and so on. Regardless of any type of modules,
all modules must be counted. The maximum number of modules is 32. This PU dedicated instruction is
only for the PU module on the right of CPU and is not for the PU module on the right of the remote
module. If the specified module is not the PU module, the bError flag will be set to ON.
5. iInputMode is the encoder source input mode and counting frequency multiplication setting, and its setting
parameters are as follows:
Note: When A-phase is ahead of B-phase, it represents the positive counting. When B-phase is ahead of
A-phase, it represents the negative counting.

iInputMode Setting Description


Value Input Mode (Set the following reserved setting, and the module will Run in default values.)
16#0000 Reserved
16#0001 1 time frequency multiplication A/B phase input
16#0002 2 times frequency multiplication A/B phase input
16#0003 Reserved
16#0004 4 times frequency multiplication A/B phase input (default value)
Pulse + direction input (A+/A- is pulse input; B+/B- is direction input.)
When B-phase is Off, it represents positive counting, and when it is On, it represents
16#0005
negative counting.
A-phase uses rising edge-triggered counting.
14 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

iInputMode Setting Description


Value Input Mode (Set the following reserved setting, and the module will Run in default values.)
Pulse + direction input (A+/A- is pulse input; B+/B- is direction input.)
When B-phase is On, it represents positive counting, and when it is Off, it represents
16#0006
negative counting.
A-phase uses rising edge-triggered counting.
Single-phase pulse input (A+/A- is pulse input.)
16#0007
A-phase uses rising edge-triggered counting.
Other value Automatically transferred to (default value).

6. iPeriod is the cycle time setting value of speed fetching, and the settable range is 10ms–1000ms. If the
value is out of range, it will be set to the minimum/maximum value.
7. diInputPulse displays the entered pulse counting numbers (signed number 32-bit values), which are
outage persistence value. If there is a need to clear it to 0, during the instruction startup, use the bZeroS
setting flag (OFF  ON) to perform the clearance.
8. diInputSpeed displays values that each iPeriod time counts (signed number 32-bit values). If users need
to convert the values in Hz, use calculation formulas.

9. When the instruction is activated/ deactivated, it means that CPU needs to inform the high-speed
counter of the module to activate/deactivate. This instruction cannot be used with API1409 DPUMPG at
the same time, otherwise the instructions may activate or deactivate the module counting with each
other.

• Supported Products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

14 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.13 DFB_DMPID
DFB_DMPID: RTD/TC module PID operation

FB/FC Instruction Graphic Expression ST Language

DFB_DMPID(
bEnable:= ,
byRemoteID:= ,
byLocalID:= ,
usiChannelNo:= ,
bUpdate:= ,
bPID_Run:= ,
iSV:= ,
byPID_MODE:= ,
bPID_M_A:= ,
bMOUT_AUTO:= ,
uiAUTO_DBW:= ,
rKc_Kp:= ,
rTi_Ki:= ,
rTd_Kd:= ,
FB DFB_DMPID rTf:= ,
bPID_EQ:= ,
bPID_DE:= ,
bPID_DIR:= ,
iERR_DBW:= ,
iALPHA:= ,
iBETA:= ,
uiMOUT:= ,
iBIAS:= ,
uiCYCLE:= ,
bBusy=> ,
rMV=> ,
rPV=> ,
rI_MV=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run the function block BOOL True/False (False)
CPU or remote module 0: CPU
byRemoteID*1 BYTE
number 1~15: remote module(0)

byLocalID Expansion module ID BYTE 0–31(0)

usiChannelNo Specified channel number USINT (0)

14 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Setting Value
Name Function Data Type
(Default value)
bPID_Run Activate PID operation BOOL True/False (False)
iSV Target value INT -32768~32767(0)
TRUE: Manual, MV value will output
according to the MOUT value. When
bPID_M_A PID Auto/Manual mode BOOL PID_MODE is 1, this setting is invalid.
FALSE: Auto, MV value will output
according to the PID formula. (False)
TRUE: Auto, MOUT value changes with
Manual value (MOUT) the MV value.
bMOUT_AUTO BOOL
automatic update mode FALSE: Normal, MOUT value does not
change with the MV value.
When it applies to Auto
tuning, the SV ± dead
uiAUTO_DBW*2 USINT 0~32000(0)
band range does not
operate.
PID calculation formula
bPID_EQ BOOL True/False (False)
selection
PID differential error
bPID_DE BOOL True/False (False)
calculation selection
PID positive negative FALSE: heating operation (E=SV-PV)
bPID_DIR BOOL
direction TRUE: cooling operation (E=PV-SV)
Deviation amount (E)
iERR_DBW INT -32768~32767(0)
ineffective range
Feedforward control
iBIAS INT -32768~32767(0)
output value
*Note:
1. Support only mode0 currently.
2. If the PID parameter write value exceeds the parameter upper limit, only the upper limit value will be written; if
the PID parameter write value is lower than the parameter lower limit, only the lower limit value will be written.

• Input Output Parameters

Setting/Output value range


Name Function Data Type
(Default Value)
True/False (False)
After Enable is activated, if users want to
change parameters, set parameters to new
bUpdate Update PID parameter flag BOOL values, then set the bUpdate flag to TRUE.
When the instruction change is done, the
instruction will clear the bUpdate flag to
FALSE.
0: auto control function
byPIDMode PID contol mode BYTE
1: auto adjust parameter function
scale coefficient (Kc or Kp, Positive single-precision floating-point
rKc_Kp REAL
determin which coefficient to number range

14 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Setting/Output value range


Name Function Data Type
(Default Value)
use accordingt o the bPID_EQ
parameter)
Integral coefficient (Ti or Ki,
Positive single-precision floating-point
determin which coefficient to
rTi_Ki REAL number range
use accordingt o the bPID_EQ
(Unit: Ti = sec; Ki = 1/sec)
parameter)
Differential coefficient (Td or
Positive single-precision floating-point
Kd, determin which coefficient
rTd_Kd REAL number range
to use accordingt o the
(Unit: sec)
bPID_EQ parameter)
Positive single-precision floating-point
Differential action time constant
rTf REAL number range
(Tf)
(Unit: sec)
Initial integral compensation 0~100(0)
iALPHA INT
parameter (heating) (Unit: 1%)
Initial integral compensation 0~100(0)
iBETA INT
parameter (cooling) (Unit: 1%)
uiMOUT * MV manual value UINT 0~1000(0)
*Note: If the PID parameter write value exceeds the parameter upper limit, only the upper limit value will be written
to the module; if the PID parameter write value is lower than the parameter lower limit, only the lower limit value will
be written to the module.

• Output

Name Function Data Type Output Range(Default value)

Instruction
bBusy BOOL True/False (False)
running flag

0.0~100.0(0)
lrMV MV output value LREAL
(Unit: 1%)
lrPV Current value LREAL Positive/Negative number or 0(0)
Accumulated
lrI_MV LREAL Positive/Negative number or 0(0)
integral value

FB instruction
bError BOOL True/False (False)
error flag
DFB_AS_MODULE_API DFB_AS_MODULE_API_ERROR
ErrorCode Error code
_ERROR (DFB_NO_ERROR)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bBusy  When bEnable shifts to True  When bEnable shifts to False.

14 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

 Continuously updating the record value when  Clear to 0 when bEnable shifts to
lrMV
bBusy is True True.
 Continuously updating the record value when  Clear to 0 when bEnable shifts to
lrPV
bBusy is True True.
 Continuously updating the record value when  Continuously updating the record
lrI_MV
bBusy is True value when bValid is True
bError  When an error occurs during the running or
 When bEnable shifts to False
ErrorCode there are incorrect input values

• Timing Diagram

bEnable

bBusy

bError

• Function
1. It is suggested that this instruction be placed under Main Task.
2. This function is supported only when AX-3 series firmware version is V1.0.1 and later.
3. The instruction is supported only by AS series temperature modules (supported version: AS04RTD-A

V1.04 and later/AS06RTD-A V1.00 and later;AS04TC-A V1.04 and later /AS08TC-A V1.00 and later)

4. byRemoteID specifies that the analog input module should connect to the right of CPU or the right of the
remote module group numbers. The CPU number is 0, the first remote module number is 1, and so on.
The maximum group number is 15.
5. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the number
of the second module on the right of CPU is 1, and so on. Regardless of any type of modules, all modules
must be counted. The maximum number of modules is 32.
6. usiChannelNo specifies the channel numbers. The number of channel one is 1, and the number of
channel two is 2.
7. When PID_RUN is TRUE  FALSE, the rMV output value will be cleared to 0. If users want the rMV
output value to be kept as the last rMV output value when PID is not working, make bEnable TRUE 
FALSE to deactivate the instruction.
8. When bUPDATE’s Enable = True, if you want to modify the parameters related to bPID_RUN–uiCYCLE,
you need to set the bUpdate parameter to ON, and it will be automatically changed to False after a cycle.
9. If the auto adjust parameter function is used (byPID_MODE =1), it will automatically enter the
autocontrol mode when the adjustment is complete (byPID_MODE changes to 0 automatically), and the
debugged rKc_Kp, rTi_Ki, rTd_Kd, rTf, iALPHA, and iBETA parameters will be filled back to the
corresponding parameter variables of the DMPID input. Users can also use the outage persistence

14 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

variables to meet the requirement of saving PID control parameters.

• Programming Example
1. When bEnable=TRUE, the instruction is running. When M2=TRUE, the DMPID instruction starts to operate.
When M2=FALSE, MV value is 0 and is sent to D30. When bEnable become OFF, the instruction is not Run,
and the parameter values in the original instruction does not change.
2. The MV output value range is 0.0~100.0. Users need to convert the required control quantity per requirement.
This application example converts to PWM output. Convert the MV output value to the pulse output width
TimeSet2 with a range of 0%~100%, and then multiply the PWM cycle to convert to the time TimeSet1.
3. Input the pulse output width and pulse output cycle to the TON function block, PWM control can be realized in
the specified pulse output device.
Duty cycle = pulse output width/pulse output cycle

• PID Calculation Formula:

15 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

When the PID_MODE control mode is set to 0, it is the autocontrol mode. PID calculation formula is as follows:
 Independent Formula & Derivative of E (PID_EQ=False & PID_DE=False)
t
dE E = SV – PV or
MV = K P E + Ki ∫ Edt + K d * + BIAS E = PV – SV
0
dt

 Independent Formula & Derivative of PV (PID_EQ=False & PID_DE=True)


t
dPV
MV = K P E + Ki ∫ Edt − K d * + BIAS E = SV – PV
0
dt
Or
t
dPV
MV = K P E + Ki ∫ Edt + K d * + BIAS E =PV – SV
0
dt
 Dependent Formula & Derivative of E (PID_EQ=True & PID_DE=False)
 1
t
dE 
MV = K c  E + ∫ Edt + Td *  + BIAS E = SV – PV or E = PV – SV
 Ti 0 dt 
 Dependent Formula & Derivative of PV (PID_EQ=True & PID_DE=True)
 1
t
dE 
MV = K c  E + ∫ Edt − Td *  + BIAS E = SV – PV
 Ti 0 dt 
Or
 1
t
dE 
MV = K c  E + ∫ Edt + Td *  + BIAS E = PV – SV
 Ti 0 dt 

• PID Block Diagram:

PID Block Diagram (Independent)


PID_D IR
E
+ 1
SV + DEAD BAND
-
PV REVERSE
0
X(-1)

ERR_DBW

Kc_Kp
PID-P
>0 PID_MAN
BIAS
+ 0
<=0 +
0 +
Kc_Kp MV_LIMIT
1
MV
Ti_Ki
PID-I
>0
MV_MAX, MV_MIN
+
<=0 +
0 +
Ti_Ki MOUT_AUTO
+ MOUT
0
Td_Kd MOUT
PID-D PID_MAN
>0 1
0

<=0
0 1
Td_Kd, Tf MOUT

15 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

PID Block Diagram (Dependent)


PID_D IR
E
+ 1
SV + DEAD BAND PID-P
-
REVERSE
PV 0
X(-1)

Kc_Kp
ERR_DBW Kc_Kp
>0

<=0
0

PID_MAN
BIAS
+ 0
+
+
MV_LIMIT
1
Ti_Ki MV
PID-I
>0
MV_MAX, M V_MIN
<=0
0
Ti_Ki MOUT_AUTO
MOUT
0
Td_Kd MOUT PID_MAN
PID-D
>0 1
0

<=0
0 1
Td_Kd, Tf MOUT

• Deviation Ineffective Range


When the PV value enters the ERR_DBW range, at first the CPU still performs the PID calculation according to
the E value until PV crosses the SV value (Zero Cross Point), which means that Cross Status is established,
and E = 0 will be substituted into the PID calculation. Then, when the PV value exceeds the ERR_DBW range,
the E value will be resumed for the PID calculation. If PID_DE=True, it means that using the PV value to perform
the differential calculation. After the Cross Status conditions are established, the CPU will take Delta PV as 0
to perform the PID differential calculation. (Delta PV= Current PV- previous PV).
For example, in the following PV trend diagram, CPU in A area will perform the normal PID calculation; however,
CPU in B area will take E or Delta PV as 0 to perform the PID calculation.

15 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

• α, β VALUE:
ALPHA and BETA are used to compensate initial integral when PID starts and the SV target values changes,
the aim of which is to reduce the overshoot phenomenon. As shown in the following figures, ALPHA
parameter is used to slow down the rising overshoot; BETA parameter is used to slow down the falling
overshoot.

• Notes and recommendations:


1. When you adjust three main parameters, Kc_Kp, Ti_Ki, and Td_Kd (PID_MODE=0), adjust the Kc_Kp value at first (based
on past experience), and then set Ti_Ki and Td_Kd values to 0. When the adjustment is generally controllable, then adjust
the Ti_Ki value (small  large) and the Td_Kd value (large  small) in sequence. When Kc_Kp = 1, it represents 100%,
that is, the gain of the deviation value is 1. A value less than 100% will attenuate the deviation value; a value more than
100% will increase the deviation value.
2. The automatically adjusted parameters are not guaranteed to be suitable for each control environment; therefore, users
can certainly modify the adjusted parameters. It is recommended to modify only the Ti_Ki or Td_Kd value.
3. The CYCLE parameter is how much time for the PID function to calculate once and update the output value (MV).
4. Note that when the number of channels which is open for measurement changes, the update time of the measurement
value will change (for example, when opening only one channel for measurement, the measurement value will be updated
every 200ms. When opening the other three channels for measurement, the measurement value will be updated every
800ms). The Kc_Kp, Ti_Ki, Td_Kd, etc. parameters may not be applicable.

• Supported Products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

15 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.14 DFB_DHCCNT
DFB_DHCCNT: This instruction is for AS02HC-A instruction only. Its functions include starting/shutting counter and
setting/modifying counter value.

FB/FC Instruction Graphic Expression ST Language

DFB_DHCCNT(
bEnable:= ,
byLocalID:= ,
usiChannelNo:= ,
bUpdate:= ,
usiAction:= ,
diActionValue:= ,
bBusy=> ,
FB DFB_DHCCNT diCurCnt=> ,
byCurSSI_SingleTurn=> ,
byCurSSI_MultiTurn=> ,
wSSIStatus=> ,
wRefCnt=> ,
bDir=> ,
uiCntStat=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run the function block BOOL True/False (False)

byLocalID Expand the module BYTE 0–31(0)


number
usiChannelNo Specify channel number USINT 1–2(1)

usiAction* Counter Action mode USINT 0–7(0)


setting
diActionValue New counter value/offset DINT -32768~32767(0)

*Note: usiAction is the action mode setting of the counter, and diActionValue usage descriptions are as below:

usiAction Function Description

0 Keep the current mode -


and not to change.
When setting the new counter value, set diActionValue value.
Set/Change the current
1 counter value diCurCnt Note: When using SSI encoder and the counter form is set as Absolute
to diActionValue Position, this usiAction is invalid.

15 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

usiAction Function Description


2 Set SSI encoder offset When the counter form is set as Absolute Position, users can set the
as diActionValue
offset of the SSI encoder counter value. Set the offset through
diActionValue, and its counter value diCurCnt = encoder original
counter value + diActionValue.
Note:

1. diActionValue range: < diActionValue <


Setting is not allowed when it is out of range.

2. diActionValuerange: < diActionValue < .


Setting is not allowed when it is out of range.
3. When using SSI encoder and the counter form is set as Ring
counter, this diActionValue is invalid.
When the device area HC module configuration is re-downloaded, the
offset will be cleared to 0.

When the counter form is set as Absolute Position, the SSI encoder
counter value will be automatically shifted to the diActionValue vale, and

its counter value diCurCnt=diActionValue.

Note:

Set/Change SSI 1. diActionValue range: 0 < diActionValue <


3 encoder absolute
position value to . Setting is not allowed when it is out of range.
diActionValue
2. When using SSI encoder and the counter form is set as Ring
counter, this usiAction is invalid. Use usiAction=1 to change the
counter value.
3. When the device configuration is re-downloaded, the offset will be
cleared to 0.

1. Reset diCurCnt as 0.
2. Reset iCurrentNo of table compare output instruction
DFB_DHCCMPT.

Reset the current 3. Reset the bMatch1 and bMatch2 flags of compare output instruction
4
counter value diCurCnt DFB_DHCCMP.
Note: When using SSI encoder, and the counter form is set as Absolute
Position, the counter value cannot be reset. However, the iCurrentNo,
bMatch1, and bMatch2 flags will be reset.

Reset diCurCnt current In addition to the above usiAction=4 reset content, compare output
counter value
5 diCurCnt, and reset instructions/specified Y output point of compare output instructions (ON
table compare output  OFF) are also reset.
instructions/specified Y
15 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

usiAction Function Description


output point of
compare output
instructions.
1. diCurCnt is specified to be modified to diActionValue.
2. Reset iCurrentNo of table compare output instruction
DFB_DHCCMPT. Note that after Preset, DFB_DHCCMPT will wait
the comparison to arrive from the first compare value; therefore, if
the counter value is bigger than the first compare value after Preset,
the table comparison cannot be done correctly. Run Preset, then
6 Preset the current
counter value diCurCnt set the bUpdate flag of DFB_DHCCMPT to ON.
3. Reset the bMatch1/2 flag of compare output instruction
DFB_DHCCMP.
Note: When using SSI encoder, and the counter form is set as Absolute
Position, the counter value cannot be preset, but the iCurrentNo,
bMatch1, and bMatch2 flags will be reset.

Preset the current


counter value
diCurCnt, and reset In addition to the above usiAction=6 reset content, table compare output
7 table compare output instructions/specified Y output point of compare output instructions (ON
instruction/ specified Y
output point of  OFF) are also reset.
compare output
instructions.

• Input/Output Pin

Setting/Output value range


Name Function Data Type
(Default Value)

bUpdate Update DFB_DHCCNT BOOL True/False (False)


parameter flag

• Output

Setting/Output value range


Name Function Data Type
(Default Value)
Instruction running BOOL
bBusy True/False (False)
flag
Specify the current
Positive number, negative number
counter value of DINT
diCurCnt or
module count
0(0)
channels
Absolute SSI
byCurSSI_SingleTurn encoder BYTE Positive number or 0(0)
Single-Turn Data

15 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Setting/Output value range


Name Function Data Type
(Default Value)
Absolute SSI
byCurSSI_MultiTurn encoder BYTE Positive number or 0(0)
Multi-Turn Data
Absolute SSI
wSSIstatus encoder status WORD Positive number or 0(0)
information
Absolute SSI
wRefCnt encoder data refresh WORD Positive number or 0(0)
counter
True: Positive direction
Counting direction BOOL
bDir False: Negative direction
display
(False)

uiCntStat* Counter status UINT Positive number or 0(0)

bError Instruction error flag BOOL True/False (False)

DFB_AS_MODULE_
DFB_AS_MODULE_API_
ErrorCode Error code
API_ERROR ERROR (DFB_NO_ERROR)

Note: uiCntStat is counting module action status, and its usage descriptions are as below:

Bit Status
Status Name Note
Number Description
15–11 Reserved Reserved

The device configuration area starts or shuts detection, and


the default is no detection.
When the counter type is Absolute Position: When users have
set the offset, the over-zero detection will be performed with
the position value after the offset is adjusted.
SSI absolute 0: Normal
10 position across When the counter type is Ring Counter: Because the offset will
zero point 1: Abnormal
be reset to 0, the over-zero detection will be performed with
the encoder original position value.
Cause of error: over-zero occurs.
Clear method: DFB_DHCCNT performs resetting or presetting
instructions, or the external input point performs resetting.

SSI 0: Normal Cause of error: communication anomaly 5 times in a row.


9 communication
anomaly 1: Abnormal Clear method: communication is restored to normal.

0: Normal Cause of error: parity check error


8 SSI parity
check error 1: Abnormal Clear method: next reading value parity check is correct.

15 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Bit Status
Status Name Note
Number Description
Cause of error: The change size of two position data exceeds
SSI data
change size 0: Normal protection setting.
7 exceeds
protection 1: Abnormal Clear method: Next data change size is within a reasonable
setting range.

6 Reserved Reserved

0: Normal The device configuration area starts or shuts the detection,


5 Ring counting
Overflow 1: Abnormal and the default is not to detect the cause of error: when
hardware counter Overflow (> 2*32− 1) or Underflow (< -2*32−
1) occurs, there will be no more counting. The counting will be
0: Normal restored after running the following:
4 Ring counting
Underflow 1: Abnormal The DFB_DHCCNT instruction performs resetting or presetting
instructions, or the external input point performs resetting.

Linear count is 0: Normal Cause of error: Linear count exceeds the user set range.
3 higher than the
1: Abnormal Clear method: Linear counter value is back to the upper and
set limit
lower limit.

Linear count is 0: Normal Note: When count exceeds the upper/lower limit, the counter
2 lower than the value remains at the upper/lower limit. When counter value is
set limit 1: Abnormal
back to the upper/lower limit range, the counting resumes.

0: Normal Cause of error: When linear count exceeds upper/lower limit,


1 Linear count
Overflow 1: Abnormal hardware counter continues counting. When hardware counter
Overflow(> 2*32 − 1 ) or Underflow

(< –2*32 − 1) occurs, there will be no more counting. The


0: Normal
0 Linear count counting will be restored after running the following:
Underflow 1: Abnormal
The DFB_DHCCNT instruction performs resetting or presetting
instructions, or the external input point performs resetting.

 Outputs Updating Timing

15 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Name Timing for shifting to True Timing for shifting to False

 When bEnable shifts to true and the  When bEnable shifts to false and the
bBusy
function is enabled in the module function is disabled in the module
 Continuously update the record when
diCurCnt -
bBusy is True.
 Continuously update the record when
byCurSSI_SingleTurn bBusy is True, and the counter form -
is Absolute Position.
 Continuously update the record when
byCurSSI_MultiTurn bBusy is True, and the counter form -
is Absolute Position.
 Continuously update the record when
wSSIstatus bBusy is True, and the counter form -
is Absolute Position.
 Continuously update the record when
wRefCnt bBusy is True, and the counter form -
is Absolute Position.
 Continuously update the record when
bBusy is True.
bDir  False when the count direction is negative
 True when the count direction is
positive
 Clear the error when using usiAction
 Continuously update the record when clearance function.
uiCntStat
bBusy is True.  When the status of the error counting
module is cleared
bError  When an error occurs during the
running or there are incorrect input  When bEnable shifts to false
ErrorCode values

• Timing Diagram

bEnable

bBusy

bError

• Function
1. It is suggested that this instruction be placed under Main Task.
2. This function is supported with AX-3 firmware V1.0.2 and later.
3. This instruction is only supported by AS Series count module (The supported version is AS02HC-A V1.00
and above).

15 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

4. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the number
of the second module on the right of CPU is 1, and so on. Regardless of any type of modules, all modules
must be counted. The maximum number of modules is 32.
5. usiChannelNo specifies the channel numbers. The number of channel one is 1, and the number of
channel two is 2.
6. Complete the usiAction and diActionValue settings before running this instruction. When bEnable is
started for the first time, usiAction and usiAction of HC module will be set once. When usiAction and
diActionValue need to be re-changed during running, set usiAction and diActionValue as new values,
and then set the bUpdate flag to On. When this instruction completes changes, the instruction will clear
bUpdate as Off itself.
7. diCurCnt is to display the current counter value of the specified module count channel.
8. byCurSSI_SingleTurn is absolute SSI encoder Single-Turn Data display (When the counter form is set
as Ring Position, byCurSSI_SingleTurn shows the value after deviation; when setting the counter as
Ring counter, byCurSSI_SingleTurn will show the original SSI encoder value), when the channel mode
is set as incremental encoder, the byCurSSI_SingleTurn will be 0.
9. byCurSSI_MultiTurn is absolute SSI encoder Multi-Turn Data display (When the counter form is set as
Absolute Position, byCurSSI_MultiTurn shows the value after deviation; when setting the counter as Ring
counter, byCurSSI_MultiTurn will show the original SSI encoder value), when the channel mode is set
as incremental encoder, the byCurSSI_MultiTurn will be 0.
10. WSSIstatus is absolute SSI encoder Status Data display. When the channel mode is set as incremental
encoder, wSSIstatus will be 0.
11. wRefCnt is absolute SSI encoder data refresh counter, and its length is 16 bits. When new SSI data is
captured, refresh counter will be incremented by one, and when this counter overflows, it will re-
accumulate from 0. When the channel mode is set as incremental encoder, wRefCnt will be 0.
12. bDir is the count direction display. When it shows On, it represents going in positive direction; when it
shows Off, it represents going in negative direction.
13. If the instruction is closed, the specify channel will stop updating the values of the right half of the
instruction.

• Programming Example

This example uses the FB instruction (DFB_DHCCNT) to read the first channel in the right module (AS02HC)
of the host, and after setting the count parameter to the module, start updating counter value to a new
variable (D4) through the function block.

16 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

 Example 1: Set/Change the current counter value. (usiAction = 1)


1. When setting M0 = ON, Counter starts to count.
2. When setting usiAction parameter of the DHCCNT instruction as 1 and setting diActionValue
parameter as 10000; when users set the bUpdate flag M1=ON, the current counter value
CurNo will be changed to 10000.

16 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

3. When setting bUpdate flag is complete, M1 will be cleared as OFF.

Counter value

10000

usiAction 1

diActionValue 10000

diUpdate flag

 Example 2 – set absolute SSI encoder offset (usiAction = 2)


1. Module device parameter sets the channel 1 as SSI Input, and select the counter form as
Absolute Position.
2. When M0=ON, counter starts to count.
3. Set the usiAction parameter of the DHCCNT instruction as 2, and set diActionValue
parameter as 500. Suppose the current counter value diCurCnt is 2500, and users set the
bUpdate flag M1=ON, now the counter value will be changed to 3000.
4. After setting the bUpdate flag is complete, M1 will be clear to OFF automatically.
Original positon of the
SSI encoder
(ST+MT Le ngth)
2

Counter value N

usiAction 2

diAct ionV alue N

diUpdate flag

16 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

 Example 3: Set/Change SSI encoder absolute position value (Action = 3)


1. Module device parameter sets channel 1 as SSI Input, and select the counter form as
Absolute Position.
2. When setting M0=ON, counter starts to count.
3. Set the usiAction parameter of the DHCCNT instruction to 3, and set the diActionValue
parameter to 0. When users set the bUpdate flag M1=ON, the HC module will calculate the
deviation amount automatically, and shift current counter value diCurCnt (encoder absolute
position) to 0.
4. When setting the bUpdate flag is complete, M1 will be cleared to OFF.
original position of the
SSI encoder
(ST+MT Le ngth)
2

Counter value

usiAction 3

diAct ionValue 0

diUpdate flag

 Example 4: Reset or preset the current counter value (usiAction = 4、6)

1. When setting M0=ON, counter starts to count.


2. Set the usiAction parameter of the DHCCNT instruction as 4. When users set the bUpdate
flag M1=ON, the current counter value CurNo will be reset to 0. When setting the update
flag is complete, M1 will be reset as OFF.
3. Set the usiAction parameter of the DHCCNT instruction to 6, and set the diActionValue
parameter to 10000. When users set the bUpdate flag to M1=ON, the current counter value
diCurCnt will be preset as 10000. When setting the bUpdate flag is complete, M1 will be
reset as OFF.

Counter value

10000
Preset
0 Reset

usiAction 4 6

diAct ionValue 10000

Match1, Match2,
CurNo

diUpdate flag

• Supported Products

16 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

16 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.15 DFB_DHCCAP
DFB_DHCCAP: This instruction is for HC counting only. Its functions include starting/shutting catcher.

FB/FC Instruction Graphic Expression ST Language

DFB_DHCCAP(
bEnable:= ,
byLocalID:= ,
usiChannelNo:= ,
byTrgSel:= ,
bBusy=> ,
FB DFB_DHCCAP
diCapValue1=> ,
bCapValue1_Complete=> ,
diCapValue2 => ,
bCapValue2_Complete=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run the function block BOOL True/False (False)

byLocalID Expand the module BYTE 0–31(0)


number

usiChannelNo Specify the channel USINT 1–2(1)


number

byTrgSel* TRIGGER method BYTE 0–1(0)


selection
Note: byTrgSel is the trigger method selection captured by counter value. Its usage is as follows:

byTrgSel Function Note

Triggered by the digital input Capture function is selected for the external input point function with
0
of the specified channel. the HC device configuration.

Example: When channel 2 starts DFB_DHCCAP and sets


byTrgSel=1, and when instruction channel 1 is used for compare
output instruction DFB_DHCCMP, when channel 1 compare arrives
Triggered by bMatch1 and bMatch1 and bMatch2, the current counter values captured by
1 bMatch2 of another channel channel 2 will be triggered and saved in diCapValue1 or
compare output instruction. diCapValue2.
Note: When byTrgSel=1, even if the external input point function of
the HC device configuration is selected as Capture, the external
input point capture function will be considered invalid.

• Output

16 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Name Function Data Type Output Value Range (Default)


Instruction BOOL
bBusy True/False (False)
running flag
Capture counter DINT Positive number, negative
diCapValue1
value1 number or 0(0)
diCapValue1
bCapValue1_Complete capture BOOL True/False (False)
completion flag
Capture counter DINT Positive number, negative
diCapValue2
value2 number or 0(0)
diCapValue2
bCapValue2_Complete capture BOOL True/False (False)
completion flag
Instruction error BOOL
bError True/False (False)
flag

DFB_AS_MODULE_API_ERROR DFB_AS_MODULE_API_
ErrorCode Error code
ERROR (DFB_NO_ERROR)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False

 When bEnable shifts to true and the  When bEnable shifts to false and the
bBusy
function is enabled in the module function is disabled in the module
 When bBusy is true and update the
diCapValue1 record when the capture signal is -
established.
 When bBusy is true and after the
 When bEnable shifts to false
bCapValue1_Complete capture value is updated to
 Cleared by users
diCapValue1.
 When bBusy is True and updated
diCapValue2 the record when the capture signal is -
established.
 When bBusy is true and after the
 When bEnable shifts to false
bCapValue2_Complete capture value is updated to
 Cleared by users
diCapValue2

bError  When an error occurs during the


running or there are incorrect input  When bEnable shifts to false
ErrorCode values

• Timing Diagram

16 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

bEnable

bBusy

bError

• Function

1. It is suggested that this instruction be placed under Main Task.


2. This function is supported with AX-3 firmware V1.0.2 and later.
3. This instruction is only supported by AS Series count module (The supported version is AS02HC-A V1.00
and above).
4. DFB_DHCCAP needs to be used with the DFN_DHCCNT instruction. Only when DFB_DHCCNT is
enabled, the counter value will count according to the input signals, and the counter value captured by
DFB_DHCCAP is valid. When DFB_DHCCNT is off, the counter value will stop receiving input signals
and stop updating counter vale. At this time, the captured counter value will not change.
5. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the
number of the second module on the right of CPU is 1, and so on. Regardless of any type of modules,
all modules must be counted. The maximum number of modules is 32.
6. usiChannelNo specifies the channel numbers. The number of channel one is 1, and the number of
channel two is 2.
7. Complete byTrgSel setting before running this instruction. When the En instruction starts for the first
time, byTrgSel will be set once for the HC module. During running, if byTrgSel needs to be re-changed,
disable the instruction and start again.
8. diCapValue1 and diCapValue2 are capture counter value 1 and capture counter value 2 respectively.
When byTrgSel=0, diCapValue1 is the counter value stored in external input point rising edge, and
diCapValue2 is the counter value stored in external input point falling edge. When byTrgSel=1,
diCapValue1 is the counter value that stored in another channel compare input instruction bMatch1 from
OffOn, and diCapValue2 is the counter value that stored in another channel compare input instruction
bMatch2 from OffOn.
9. bCapValue1_Complete and bCapValue2_Complete are the flags of capture completion counter value1
and capture completion counter value2. When bCapValue1_Complete/bCapValue2_Complete is
Off->On, it means that diCapValue1/ diCapValue2 are already the latest capture values, and users
need to clear the bCapValue1_Complete/ bCapValue2_Complete flags after reading capture values.
When next bCapValue1_Complete and bCapValue2_Complete are Off->On, there are new capture
values. If users do not clear the bCapValue1_Complete and bCapValue2_Complete flags, the module
latest capture values will keep updating until diCapValue1 and diCapValue2.
10. If bEnable is from On to Off, it means that disabling the instruction Capture function. At this time,
diCapValue2 and diCapValue2 content values will remain the same and will not be updated. However,

16 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

bCapValue1_Complete and bCapValue2_Complete flags will be cleared.

• Programming Example

This example uses the FB instruction (DFB_DHCCNT) to start the first channel counting function in the right
module (AS02HC) of the host, and use the FB instruction (DFB_DHCCAP) to capture the counter value.

16 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

byTrgSel = 0

11000

Channel 1 8500
Counter
Value 6000

1800

CH1 Z-Phase
Input

diCapValue1 1800 8500

bCapValue1_Complete
CH1

*1

diCapValue2 6000 11000

bCapValue2_Complete
*2

* 1: bCap Value1_Complete is not cleared to OFF, the captured value still up dates in di CapValue 1.
*2: bCap Value2_Complete is cleared to OFF, the captured value still up dates in CapValue 2.

 Programming example: Another channel DHCCMP compares arrival and captures the counter value.
1. Set the byTrgSel parameter of the DHCCAP instruction in channel 1. When M0=ON, the
DHCCAP instruction will starts to wait for compare arrival of the other channel (channel 2).
2. When channel 2 counter value arrives compare value diCompareValue1, and at this time
channel 1 counter value 2000 will immediately output to diCapValue1, and the
bCapValue1_Complete flag will be set to ON.
3. When channel 2 counter value arrives compare value diCompareValue2, and at this time
counter value 8000 will be immediately output to diCapValue2, and the bCapValue2_Complete
flag will be set to ON.
4. Same as Example1, even if the bCapValue1_Complete/bCapValue2_Complete flags are not
cleared to OFF, the new captured values will still output to diCapValue1/ diCapValue2 when
channel 2 has a compare arrival event again.

16 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Timing diagram

byTrgSel = 1

Channel 1 8000
Counter
Value

2000

bMATCH 2 is OFF to ON
CH2 Comp2 on channel 2.
Channel 2
Counter CH2 Comp1
Value bMATCH 1 is OFF to ON
on channel 2.
0

diCapValue1 2000

bCapValue1_Complete
CH1

diCapValue2 8000

bCapValue2_Complete

• Supported Products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

17 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.16 DFB_HCDO
DFB_HCDO: HC module output point control

FB/FC Instruction Graphic Expression ST Language

DFB_HCDO(
bEnable:= ,
byLocalID:= ,
bUpdate:= ,
FB DFB_HCDO iOutputSetting:= ,
bBusy=> ,
iOutputState=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run function block BOOL True/False (False)
byLocalID Expand module number BYTE 0–31(0)
bUpdate Update parameter BOOL True/False (False)
Output point motion
iOutputSetting INT 0~15(0)
setting

• Output

Setting Value
Name Function Data Type
(Default value)
bBusy The FB is running. BOOL True/False (False)
iOutputState Output point status INT 0~15(0)
FB instruction error
bError BOOL True/False (False)
flag
DFB_AS_MODULE_ DFB_AS_MODULE_API_
ErrorCode Error code
API_ERROR ERROR (DFB_NO_ERROR)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bBusy  When bEnable shifts to true  When bEnable shifts to false
iOutputState  Continuously update after bEnable  When bEnable shifts to false
bError  When an error occurs during the running or
 When bEnable shifts to false
ErrorCode there are incorrect input values

17 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

• Timing Diagram

bEnable

bBusy

bError

• Function

1. It is suggested that this instruction be placed under Main Task.


2. This function is supported with AX-3 firmware V1.0.2 and later.
3. The output point Y0.0~Y0.3 in this instruction is the output point on the 02HC module.
4. The HCDO instruction is AS02HC-A dedicated instruction, and it can control the output point Y0.0~Y0.3
and show the status of the output point Y0.0~Y0.3.
5. Complete the iOutputSetting setting before running the instruction. When bEnable is started,
iOutputSetting will be set once for the HC module, so the iOutputSetting set before starting will be
taken as the initial state of the output point Y0.0~Y0.3. If users want to change the output point status
during running, set iOutputSetting as a new value, and then set the bUpdate flag as On. After the
instruction completes parameter change, the bUpdate flag will be cleared.
6. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the
number of the second module on the right of CPU is 1, and so on. Regardless of any type of modules,
all modules must be counted. The maximum number of modules is 32.
7. iOutputSetting is the setting value of the output point action:

b15~b4 b3 b2 b1 b0
NA Y0.3 action Y0.2 action Y0.1 action Y0.0 action

0:OFF
NA
1:ON

8. iOutputState is the status display of the output point

b15~b4 b3 b2 b1 b0
NA Y0.3 status Y0.2 status Y0.1 status Y0.0 status

0:OFF
NA
1:ON

17 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

8 When the instruction is off, iOutputState will be 0.


9 When compare output instruction DHCCMP or table compare output instruction DHCCMPT starts, output
point cannot be changed through iOutputSetting. However, the display of the iOutputState status can
be continuously updated.
10 As stated before, if compare output instruction needs to set the initial value to output point, start the HCDO
instruction first, and then start the DHCCMP or DHCCMPT instruction. If changing output point is needed,
shut the DHCCMP or DHCCMPT instruction, and then IOutputSetting of the HCDO instruction will update
the latest output action.
11 During start-up, when any error condition occurs, this bError error flag will be set to ON. Refer to error
codes of ErrorCode for troubleshooting.

• Supported Products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

17 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.17 DFB_DHCCMP
DFB_DHCCMP: HC module compare output.

FB/FC Instruction Graphic Expression ST Language

DFB_DHCCMP(
bEnable:= ,
byLocalID:= ,
usiChannelNo:= ,
bUpdate:= ,
diCompareValue1:= ,
iActionValue1:= ,
iY_OutputNo1:= ,
iInterruptNo1:= ,
FB DFB_DHCCMP
diCompareValue2:= ,
iActionValue2:= ,
iY_OutputNo2:= ,
iInterruptNo2:= ,
bBusy=> ,
bMatch1=> ,
bMatch2=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run function block BOOL True/False (False)
byLocalID Expand module number BYTE 0–31(0)
usiChannelNo Channel number USINT 1–2(1)
bUpdate Update parameter flag BOOL True/False (False)
-2, 147, 483, 648–2, 147, 483,
diCompareValue1 Compare value 1 DINT
648(0)
Action of arrival compare
iActionValue1 INT 0–8(0)
value1
Y output point number of
iY_OutputNo1 INT 0–3(0)
arrival compare value1
Arrive compare value1,
iInterruptNo1 External Event interrupts INT 0、400–431(0)
number.
-2, 147, 483, 648–2, 147, 483,
diCompareValue2 Compare value2 DINT
648(0)
Action of arrival compare
iActionValue2 INT 0–8(0)
value2

17 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Setting Value
Name Function Data Type
(Default value)
Y output point number of
iY_OutputNo2 INT 0–3(0)
arrival compare value2
Arrive compare value2,
iInterruptNo2 External Event interrupts INT 0, 400–431(0)
number.

• Output

Setting Value
Name Function Data Type
(Default value)
bBusy The FB is running. BOOL True/False (False)
Arrival compare value1
bMatch1 BOOL True/False (False)
flag
Arrival compare value2
bMatch2 BOOL True/False (False)
flag
FB instruction error
bError BOOL True/False (False)
flag
DFB_AS_MODULE_ DFB_AS_MODULE_API_
ErrorCode Error code
API_ERROR ERROR (DFB_NO_ERROR)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bBusy  When bEnable shifts to true  When bEnable shifts to false
bMatch1  Arrival compare value1  When bEnable shifts to false
bMatch2  Arrival compare value2  When bEnable shifts to false
bError  When an error occurs during the running or
 When bEnable shifts to false
ErrorCode there are incorrect input values

• Timing Diagram

bEnable

bBusy

bError

• Function

1. It is suggested that this instruction be placed under Main Task.

17 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

2. This function is supported with AX-3 firmware V1.0.2 and later.


3. The output point Y0.0~Y0.3 in this instruction is the output point on the 02HC module.
4. The DHCCMP instruction is AS02HC-A dedicated instruction. When the counting up/counting down
value reaches the preset compare value, perform actions to output point and counter according to users’
settings.
5. DHCCMP needs to be used with the DHCCNT instruction. Only when DHCCNT is started, counter value
counts according to input signals and performs comparison action.
6. Complete diCompareValue1, diCompareValue2, iActionValue1, iActionValue2, iY_OutputNo1,
iY_OutputNo2, iInterruptNo1, iInterruptNo2 parameters setting before running the instruction. When
the instruction is enabled, the parameters of the AS02HC-A module will be set once.
7. diCompareValue1, diCompareValue2, iActionValue1, iActionValue2, iY_OutputNo1,
iY_OutputNo2, iInterruptNo1, iInterruptNo2 parameters can be changed during running. The change
method is to set new values first, and then set the bUpdate flag to On. When this instruction completes
changing compare value, the instruction will clear the bUpdate flag to Off, and clear the bMatch1 and
bMatch2 to Off.
8. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the
number of the second module on the right of CPU is 1, and so on. Regardless of any type of modules,
all modules must be counted. The maximum number of modules is 32.
9. usiChannelNo specifies the channel numbers. The number of channel one is 1, and the number of
channel two is 2.
10. diCompareValue1 and diCompareValue2 are compare value number 1 and compare value number 2
respectively (diCompareValue1 and diCompareValue2 need to be different values). When the
usiChannelNo channel counter value reaches the compare value of the number, the corresponding
bMatch1 and bMatch2 flags will be set to On, and the specified iY_OutputNo1 and iY_OutputNo2
output points will perform actions according to iActionValue1 and iActionValue2.
When selecting the counter form as Linear Counter, diCompareValue1 and diCompareValue2 need to
meet “Minimum counter value < diCompareValue < Maximum counter value”. When using SSI encoder
and set the counter value as Absolute Position, diCompareValue1 and diCompareValue2 need to meet

“0 ≤ diCompareValue < ”.
11. Note that compare arrival timing will be different according to the input interfaces “pulse input” or “SSI
input” as shown in the following figure.

17 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Ex. diCompareValue = 5
8
Counting up
7 7 Counting down
6 6
diCompareValue
5 5
4 4
3 3
2 2
1 1
0 0

Counted Value
0 1 2 3 4 5 6 7 8 9 7 6 5 4 3 2 1 0
Pulse Input -
Timing to consider as reaching the target

SSI Input -
Timing to consider as reaching the target

Take diCompareValue = 5 as an example, SSI input compare arrival timing occurs in the counter value
4→5 and 6→5 instantaneous. For pulse input, when counting up, compare arrival timing occurs in the

counter value 5→6 instantaneous; when counting down, compare arrival timing occurs in the counter

value 5→4 instantaneous.


12. iActionValue1 and iActionValue2 are the specified running actions when compare arrival. The
functions are as below:

iActionValue1 Function iActionValue2 Function Note


0 No action 0 No action
iY_OutputNo1 specifies iY_OutputNo2 specifies
1 1
output point Off. output point Off.
iY_OutputNo1 specifies iY_OutputNo2 specifies
2 2
output point On. output point On.
iY_OutputNo1 specifies iY_OutputNo2 specifies
3 output point Toggle output 3 output point Toggle output
(alternating ON/OFF) (alternating ON/OFF)
iY_OutputNo1 specifies iY_OutputNo2 specifies Since the
4 output point Off + clears the 4 output point Off + clears the bMatch1
channel counter value. channel counter value. and
iY_OutputNo1 specifies iY_OutputNo2 specifies bMatch2
5 output point On + clears the 5 output point On + clears the flags will be
channel counter value. channel counter value. cleared
iY_OutputNo1 specifies iY_OutputNo2 specifies when
output point Toggle output point Toggle clearing the
6 6 counter
(alternating ON/OFF) + clears (alternating ON/OFF) + clears
the channel counter value. the channel counter value. value, it is
Clear the channel counter Clear the channel counter not
7 7 suggested
value value
Clear the channel counter Clear the channel counter to judge
the two
value + value +
bMatch
8 iY_OutputNo1/iY_OutputNo2 8 iY_OutputNo1/iY_OutputNo2 flags when
specifies output point Off. specifies output point Off. selecting
these five
modes.

Note: There will be a little delay between compare arrival occurrence and iActionValue running. The maximum
delay time is 100us.

13. iY_OutputNo1 and iY_OutputNo2 specify Y output point numbers for compare arrival number 1 and
number 2 respectively. After compare instruction starts, the HCDO instruction will not be able to control

17 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

output point:

iY_OutputNo1/iY_OutputNo2 Specified Output Point


0 Y0.0
1 Y0.1
2 Y0.2
3 Y0.3

14. iInterruptNo1 and iInterruptNo2 are specified interrupt numbers. The functions are as below:

iInterruptNo Action
0 Not to set interrupt
 = 00~31, Interrupt_400_ModuleIN0 to Interrupt_431_ModuleIN31 of the
4 corresponding External Event
The corresponding Task will be started when compare arrives.

15. bMatch1 and bMatch2 are the status flag display for the comparison values of compare arrival number1
and number2. When the counter value of the specified channel and number1 compare value & number
compare value arrive, the corresponding bMatch1 or bMatch2 flag will be set to On; When the host
STOP, clear counter, DHCCMP is OFFON, or the bUpdate flag is set, the instruction will clear the
bMatch1 and bMatch2 flags to Off.
16. When the instruction is off, the relevant compare values and the output functions will not be updated.
17. If any error situation occurs during startup, the bError error flag will be set to ON. Users can refer to
ErrorCode for troubleshooting.

• Programming Example 1: Control Y point output when compare arrives.


1. Set CH1 Input Interface in AS02HC-A Parameters as “Pulse Input”, set Pulse Type as “A/B phase(2x)”,
and set Counter Type as “Ring counter”, as the following:

2. Set diCompareValue1 to 2000, set iActionValue1 to 3, set iY_OutputNo1 to 0, and set iInterruptNo1
to 0; set diCompareValue2 to 4000, set iActionValue2 to 3, set iY_OutputNo2 to 1, and set
iInterruptNo2 to 0.
3. When setting M0 = ON, DHCCNT counter starts to count. At the same time, set the DHCCMP parameter
for the module, and start to wait for counter compare arrival.
4. When counter values reach diCompareValue1, the bMatch1 flag is set to ON, and Y0.0 is OFFON.
5. Continuous counting until diCompareValue2 is reached, and the bMatch2 flag is set to ON, and Y0.1 is
OFFON.

17 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6. Continuous counting until diCompareValue1 is reached again, Y0.0 is ONOFF; Continuous counting

until diCompareValue2 is reached again, Y0.1 is ONOFF.

Timing Diagram

Programming Example2: Clear the counter value when compare arrives

17 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

1. Set diCompareValue1 to 2500, set iActionValue1 to 2, set iY_OutputNo1 to 0 and set iInterruptNo1
to 0; set diCompareValue2 to 5000, set iActionValue2 to 8, set iY_OutputNo2 to 1, and set
iInterruptNo2 to 0.
2. When setting M0 = ON, DHCCNT counter starts to count. At the same time, set the DHCCMP parameter
for the module, and start to wait for counter compare arrival.
3. When counter values reach diCompareValue1, the bMatch1 flag is set to ON, and Y0.0 is set to ON.
4. Continuous counting until diCompareValue2 is reached. Since the action of iActionValue2 = 8 is “clear
the channel counter value + clear iY_OutputNo1 and iY_OutputNo2 specified output point”, counter
value is cleared to 0, bMatch1 and bMatch2 are cleared to False, and Y0.0 & Y0.1 are cleared to OFF.
5. Continuous counting until diCompareValue1 is reached again, the bMatch1 flag will be set to on again,
Y0.0 will be set to ON, and so on.

Timing Diagram

Programming Example3: Update the compare value

18 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

1. Set diCompareValue1 to 1000, set iActionValue1 to 3, set iY_OutputNo1 to 0,and set iInterruptNo1
to 0; set diCompareValue2 to 3000, set iActionValue2 to 3, set iY_OutputNo2 to 1, and set
iInterruptNo2 to 0.
2. When setting M0 = ON, DHCCNT counter starts to count. At the same time, set the DHCCMP parameter
for the module, and start to wait for counter compare arrival.
3. When counter value reaches diCompareValue1, the bMatch1 flag will be set to ON, and Y0.0 will be
OFFON.
4. When counter value reaches diCompareValue2, the bMatch2 flag will be set to ON, and Y0.1 will be
ONOFF.
5. Then, set new compare value: set diCompareValue1 to 5000, set iActionValue1 to 3, set OutputNo1
to 0, set iInterruptNo1 to 0, set diCompareValue2 to 7000, set iActionValue2 to 6, set iY_OutputNo2
to 1, and set iInterruptNo2 to 0.
6. Set the bUpdate flag to ON. When the setting completes, the bUpdate flag will be automatically cleared
to OFF. At the same time, the bMatch1 and bMatch2 flags will be cleared to OFF.
7. When counter value reaches new compare value diCompareValue1, the bMatch1 flag will be set to
ON, and Y0.0 will be ONOFF.
8. When counter value reaches new compare value diCompareValue2, Y0.1 will be OFFON. Because
iActionValue2 = 6 include Reset, counting value will be cleared to 0. At the same time, the bMatch1
and bMatch2 flags will be cleared to OFF.

Timing Diagram

18 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

New Comp2
New Comp1
Comp2
Comp1
Channel 1
Counter 0
Value

bUpdate Flag

bMATCH1

Y0.0

bMATCH2

Y0.1

Programming Example4: Compare arrival interruption

1. DHCCMP can also configure compare arrival interruption. Set iInterruptNo1 and iInterruptNo2 to 400
and 401 respectively, and configure two Tasks at the same time. In the tasks, select
Interrupt_400_ModuleIN0 or Interrupt_401_ModuleIN1 for External event as shown in the following
figures.

2. Set diCompareValue1 to 2500, set iActionValue1 to 3, set iY_OutputNo1 to 0 set iInterruptNo1 to


400; set diCompareValue2 to 5000, set iActionValue2 to 3, set iY_OutputNo2 to 1, and set
iInterruptNo2 to 401.
3. When setting M0 = ON, DHCCNT counter starts to count. At the same time, set the DHCCMP parameter
for the module, and start to wait for counter compare arrival.
4. When counter value reaches diCompareValue1, External event corresponding to iInterruptNo1 will be
Run, and Y0.0 will be toggled (alternating ON/OFF).
5. When counter value reaches diCompareValue2, External event corresponding to iInterruptNo2 will be
Run, and Y0.1 will be toggled (alternating ON/OFF).

18 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

• Supported Products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

18 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.18 DFB_DHCCMPT
DFB_DHCCMPT: Compare the count value of the HC module with the table, and output the action when the
condition is established.

FB/FC Instruction Graphic Expression ST Language

DFB_DHCCMPT(
bEnable:= ,
byLocalID:= ,
usiChannelNo:= ,
bUpdate:= ,
iCompareLength:= ,
aCompareValue:= ,
FB DFB_DHCCMPT
aAction:= ,
aY_OutputNo:= ,
aInterruptNo:= ,
bBusy=> ,
iCurrentNo=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run function block BOOL True/False (False)
byLocalID Expand module number BYTE 0–31 (0)

usiChannelNo Channel number USINT 1–2 (1)


bUpdate Update parameter flag BOOL True/False (False)
The number of rows of the
iCompareLength INT 2–10 (2)
table
The storage source of the
32-bit value to be ARRAY[0..9] –2, 147, 483, 648–2, 147, 483,
aCompareValue
compared in the compare OF DINT 648 (0)
table
The action storage source
in the table when
ARRAY[0..9]
aAction comparison is complete 0–8 (0)
OF INT
and the action condition is
reached
The storage source of the
Y output No. in the table
ARRAY[0..9]
aY_OutputNo when comparison is 0–3 (0)
OF INT
complete and the action
condition is reached
The storage source of the ARRAY[0..9]
aInterruptNo external event interrupt 0, 400–431 (0)
OF INT
No. in the table when

18 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Setting Value
Name Function Data Type
(Default value)
comparison is complete
and the action condition is
reached

• Output

Setting Value
Name Function Data Type
(Default value)
bBusy The FB is running. BOOL True/False (False)
The number of
conditions and
iCurrentNo actions that has INT 0–10 (0)
been compared so
far.
FB instruction error
bError BOOL True/False (False)
flag
DFB_AS_MODULE_API_ERROR
ErrorCode Error code DFB_AS_MODULE_API_ERROR
(DFB_NO_ERROR)

• Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bBusy  When bEnable shifts to true  When bEnable shifts to false
 Display according to the number of the group
iCurrentNo  When bEnable shifts to false
that currently has compare arrived.
bError  When an error occurs during the running or
 When bEnable shifts to false
ErrorCode there are incorrect input values

• Timing Diagram

bEnable

bBusy

bError

• Function
1. It is suggested that this instruction be placed under Main Task.
2. This function is supported with AX-3 firmware V1.0.2 and later.

18 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

3. The output point Y0.0~Y0.3 in this instruction is the output point on the 02HC module.
4. The DHCCMPT instruction is AS02HC-A dedicated instruction. Its compare action is “cyclical” compare
according to the set groups. When the number of comparison step by step reaches the last compare
value, the next compare value will be reset as the first compare value. The DHCCMPT instruction is
limited to be used when the counter counts in only one direction (Changing the direction will cause
incorrect action), and can be set up to 10 compare values. Compare values need to be sorted by
incremental or decremental numbers. For incremental sorting, counter needs to counting up, and only
positive numbers for compare value. For decremental sorting, counter needs to counting down, and only
negative numbers for compare value. When the counting reaches the preset compare value, actions will
be performed to output pint and counter according to users setting, and the request to the host
interrupts.
5. DHCCMPT needs to be used with the DHCCNT instruction. Only when DHCCNT starts, counter value
counts according to the input signal, and perform compare action.
6. Complete iCompareLength, aCompareValue, aAction, aY_OutputNo, and aInterruptNo parameter
setting before running the instruction. bEnable will write the parameter once when it is first started.
7. The parameters of iCompareLength, aCompareValue, aAction, aY_OutputNo, and aInterruptNo can
be changed during running. The changing methods is to set them as new values, and then set the
bUpdate flag to On. When the changing is complete, the instruction will clear the bUpdate flag to Off.
8. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the
number of the second module on the right of CPU is 1, and so on. Regardless of any type of modules,
all modules must be counted. The maximum number of modules is 32.
9. usiChannelNo specifies the channel numbers. The number of channel one is 1, and the number of
channel two is 2.
10. iCompareLength is the number of groups of compare tables. Its compare action is cyclical according to
the set group numbers. The group number length can be set to 2–10. When the set value is out of this
range, the instruction will not be run, and the error code shows.
11. aCompareValue is the storage source of the compare vale, and its type is ARRAY[0..9] OF DINT.
Compare values needs to be sorted by incremental or decremental numbers (each compare value
needs to be different). For incremental sorting, counter needs to counting up, and only positive numbers
for compare value. For decremental sorting, counter needs to counting down, and only negative
numbers for compare value.
When selecting the counter form as Linear Counter, each vale in aCompareValue needs to meet
“Minimum counter value < aCompareValue < Maximum counter value”.
When using SSI encoder and the counter form is set as Absolute Position, each value in

aCompareValue needs to meet “0 ≤ aCompareValue ≤ ”.

12. Note that compare arrival timing will be different according to the input interface “Pulse input” or “SSI
input” as shown in the following figure.

18 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Ex. aCompareValue = 5
8
Cou ntin g up
7 7 Cou ntin g do wn
6 6
aCompareValue
5 5
4 4
3 3
2 2
1 1
0 0

Cou nted Value


0 1 2 3 4 5 6 7 8 9 7 6 5 4 3 2 1 0
Pulse Inp ut -
Timing to con sid er as reaching the target

SSI Inp ut -
Timing to con sid er as reaching the target

Take aCompareValue = 5 as an example, SSI input compare arrival timing occurs in the counter value
4→5 and 6→5 instantaneous. For pulse input, when counting up, compare arrival timing occurs in the

counter value 5→6 instantaneous; when counting down, compare arrival timing occurs in the counter

value 5→4 instantaneous.


13. aAction is the specified action code when compare arrives. The functions are as below:

aAction Function Note


0 No action
1 aY_OutputNo specifies the output point Off.
2 aY_OutputNo specifies the output point On.
aY_OutputNo specifies the output point Toggle
3
output (alternating ON/OFF).
aY_OutputNo specifies the output point Off + clear
4
the channel counter value.
aY_OutputNo specifies the output point On + clear
5
the channel counter value. In addition to clearing the channel counter
aY_OutputNo specifies the output point Toggle value, clear iCurrentNo to 0.
6 (alternating ON/OFF) + clear the channel counter
value.
7 Clear the channel counter value.

Clear the channel counter value+ all aY_OutputNo Same as aAction = 7 clearance, and clear
8 all specified aY_OutputNo output point.
specify the output point Off.
Note: There will be a little delay between compare arrival occurrence and Action running. The maximum delay time
is 100us.
14. aY_OutputNo is specified output point number. The function is as the following:

18 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

aY_OutputNo Output Point


0 Y0.0
1 Y0.1
2 Y0.2
3 Y0.3

15. aInterruptNo is specified interruption number. The function is as the following:

aInterruptNo Action
0 Not to set interruption
 = 00~31, Interrupt_400_ModuleIN0 to Interrupt_431_ModuleIN31 of the
4 corresponding External Event
The corresponding Task will be started when compare arrives.

16. iCurrentNo displays the number of the group that currently has compare arrived. For example, when the
counter value is 200, which is lower than the group number 1 in the following compare table, the
iCurrentNo value is 0; when the counter value reaches 1000, which equals to the group number 1 in the
following compare table, the iCurrentNo value is 1.
17. Refer to the following table for the operator description of aCompareValue, aAction, aY_OutputNo,
aInterruptNo, and iCurrentNo. In the table, the iCompareLength value is assumed as 6.

aAction
aCompareValue
ICurrentNo Specified Action after aY_OutputNo aInterruptNo
Source of Value to be
Item Number comparison and Output Number Interruption Number
compared
condition is reached

1 1000 2(On) 0(Y0.0) 400

2 2000 2(On) 1(Y0.1) 401

3 3000 3(Toggle) 0(Y0.0) 402

4 4500 2(On) 2(Y0.2) 403

5 5500 1(Off) 3(Y0.3) 404

6 6500 1(Off) 1(Y0.1) 405

18. When the instruction is started (bEnable is from Off to On) and the bUpdate flag is set to On to change
the parameter, the instruction will compare all the compare values in the compare table set by users
according to the current counter vale. The group values that are smaller than the current counter value
will Run the compare arrival action. For example, when the instruction starts with the counter value 3500,
the actions numbered 1 ~3 (compare value < current counter value) in the compare table will be Run once

with the compare arrival action (Y0.0=On, Y0.1=On, Y0.0 Toggle (alternating ON/OFF)), and iCurrentNo

will be set to 3.

18 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

19. If bEnable is from On to Off, it means that shutting the table compare output function. iCurrentNo status
display will return to 0. The output point state is not changed by the instruction being off. Counter remains
counting, but no more comparison.
20. If any error situation occurs during startup, the bError error flag will be set to ON. Users can refer to
ErrorCode for troubleshooting.

• Programming Example

1. Set the parameters of the relevant input pins as shown in the following figure (The settings in the
following figure are equivalent to those shown in the following table).

aAction
aCompareValue
ICurrentNo Specified Action after aY_OutputNo aInterruptNo
Source of Value to be
Item Number comparison and Output Number Interruption Number
compared
condition is reached

1 1000 3 (Toggle) 0 (Y0.0) 400

2 2000 3 (Toggle) 1 (Y0.1) 401

3 3000 3 (Toggle) 2 (Y0.2) 402

4 4000 3 (Toggle) 3 (Y0.3) 403

5 5000 3 (Toggle) 0 (Y0.0) 404

6 6000 3 (Toggle) 1 (Y0.1) 405

7 7000 3 (Toggle) 2 (Y0.2) 406

8 8000 3 (Toggle) 3 (Y0.3) 407

9 9000 3 (Toggle) 0 (Y0.0) 408

10 10000 3 (Toggle) 1 (Y0.1) 409

2. When EN is OFF→ON, the instruction will compare all the compare values in the compare table set by
users. The group values that are smaller than the current counter value will Run the compare arrival
action. Because the counter value is still smaller than the first compare value 1000 when startup. No
compare arrival specified action will be Run, and iCurrentNo is 0 currently.
3. When the counter value reaches 1000, compare arrives the first compare value (If it is pulse input,
compare arrival specified action will be Run when the counter value is 1000→1001).
4. When the counter value reaches 2000, compare arrives the second compare value, Y0.1 is OFFON,
401 interruption program is running, and iCurrentNo=2.
5. When the counter value reaches 3000, compare arrives the third compare value, Y0.2 is OFFON, 402
interruption program is running, and iCurrentNo=3.

18 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6. When the counter value reaches 4000, compare arrives the fourth compare value, Y0.3 is OFFON,
403 interruption program is running, and iCurrentNo=4.
7. Follow this rule to continue compare arrival from the fifth to tenth compare value. At this time
iCurrentNo=10. Because the last comparison has done, next compare vale will be set as the first
compare value 1000.
8. When the ring counter counts to 1000 again, compare arrives the first counter value, Y1.0 is ONOFF,
400 interruption program is running, and iCurrentNo=1. Follow this rule to Run the subsequent
comparison.

• Timing Diagram

10000
9000
8000
7000
6000
5000
4000
3000
2000
1000
Channel 1
Counter 0
Value

EN

iCurrenNo 0 1 2 3 4 5 6 7 8 9 10 10 1 2

Y0.0

Y0.1

Y0.2

Y0.3

19 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

• Supported Products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

19 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.19 DFB_DHCMEAS
DFB_DHCMEAS: HC module frequency and rotation speed measurement

FB/FC Instruction Graphic Expression ST Language

DFB_DHCMEAS(
bEnable:= ,
byLocalID:= ,
usiChannelNo:= ,
bUpdate:= ,
udiPulsePerRev:= ,
FB DFB_DHCMEAS iSamplingTime:= ,
iMovingAvgWindow:= ,
bBusy=> ,
diFrequency=> ,
diRPM=> ,
bError=> ,
ErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
bEnable Run function block BOOL True/False (False)
byLocalID Expand module number BYTE 0–31 (0)
usiChannelNo Channel number USINT 1–2 (1)
bUpdate Update parameter flag BOOL True/False (False)
Counting quantity per
udiPulsePerRev UDINT 1~4294967295 (1)
lap
Sampling period
iSamplingTime INT 1–1000 (1)
(unit: ms)
Average number of
iMovingAvgWindow INT 1–10 (1)
moves

• Output

Setting Value
Name Function Data Type
(Default value)
bBusy The FB is running. BOOL True/False (False)
Average
–2, 147, 483, 648–2, 147, 483,
diFrequency measurement DINT
frequency results 648 (0)

Average rotation
–2, 147, 483, 648–2, 147, 483,
diRPM speed measurement DINT
results 648 (0)

19 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Setting Value
Name Function Data Type
(Default value)
FB instruction error
bError BOOL True/False (False)
flag
DFB_AS_MODULE_API_ERROR
ErrorCode Error code DFB_AS_MODULE_API_ERROR
(DFB_NO_ERROR)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bBusy  When bEnable shifts to true  When bEnable shifts to false
diFrequency  Continuously update after bEnable  When bEnable shifts to false
diRPM  Continuously update after bEnable  When bEnable shifts to false
bError  When an error occurs during the running or
 When bEnable shifts to false
ErrorCode there are incorrect input values

• Timing Diagram

bEnable

bBusy

bError

• Function
1. It is suggested that this instruction be placed under Main Task.
2. This function is supported with AX-3 firmware V1.0.2 and later.
3. The output point Y0.0~Y0.3 in this instruction is the output point on the 02HC module.
4. The DHCMEAS instruction is AS02HC-A dedicated instruction. Its functions are frequency and rotation
speed measurements.
5. DHCMEAS needs to be used with the DHCCNT instruction. Only when DHCCNT is started, the counter
value counts according to input signals, and the measurement results are calculated by the change of the
counter values.
6. Complete setting udiPulsePerRev, iSamplingTime, and iMovingAvgWindow parameters before
running the instruction. bEnable will write the parameter once when it is first started. If users want to
change parameters during running, the change method is to set new values first, and then set the bUpdate
flag to On. When this instruction completes the change, the instruction will clear the bUpdate flag to Off.

19 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

7. byLocalID specifies module numbers. The number of the first module on the right of CPU is 0, the number
of the second module on the right of CPU is 1, and so on. Regardless of any type of modules, all modules
must be counted. The maximum number of modules is 32.
8. usiChannelNo specifies the channel numbers. The number of channel one is 1, and the number of
channel two is 2.

9. udiPulsePerRev is the counter value of one rotation of the encoder, and its setting range is 1–

4294967295 (H’00000001~H’FFFFFFFF).
10. iSamplingTime is sampling period, and its setting range is 1~1000 (unit: ms). According to the setting of
iSamplingTime, diFrequency frequency measurement result output and diRPM rotation speed
measurement result output will have different resolution.
𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝 resolution = 1000 ÷ 𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢 (unit: Hz)
𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝 resolution = 60000 ÷ (𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢 × 𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮)(unit: rev/min)
Because the rotation speed calculation method is based on the CurCnt counter value of the beginning and end
of the sampling period, the following situations need to be excluded when designing sampling periods.

Encoder Type Counter Type Factors to Effect Measurement Accuracy


Ring Counter Displacement exceeds 231 in the sampling period.
Incremental encoder Displacement exceeds 231 in the sampling period, or the counter
Linear Counter
value exceeds the upper/lower limit.
Shows absolute Displacement exceeds in the sampling period.
Absolute SSI encoder position
Ring counter Displacement exceeds 231 in the sampling period.

11. iMovingAvgWindow is the average number of times, which performs moving average to measurement
results. Its setting range is 1–10.
12. diFrequency is the result of average measurement frequency (unit: Hz). The calculation method of the
frequency is as below:
CurCnt(t + 𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢) − CurCnt(t)
𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝(Hz) =
𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢(ms) × 10−3
13. diRPM is the result of the average rotation speed measurement (unit: rev/min). The calculation method of
the rotation speed is as below:
( CurCnt(t + 𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢) − CurCnt(t) ) × 60
𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝𝐝(rev/min) =
𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮𝐮 × 𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢𝐢(ms) × 10−3
14. When the instruction is shut off, it means that the measurement function is disabled, and diFrequency &
diRPM will remain the same and no more update.
15. Note that when the counter value is cleared or users change the counter value, the calculation result of
diFrequency and diRPM of the sampling period will be affected.
16. If any error situation occurs during startup, the bError error flag will be set to ON. Users can refer to
ErrorCode for troubleshooting.

Programming Example: Incremental encoder

19 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

1. Set CH1 Input Interface in AS02HC-A Parameters to “Pulse Input”, set Pulse Type to “A/B phase (2x)”,
and set Counter Type to “Ring counter” as shown in the following figure:

2. Set udiPulsePerRev to 1000, set iSamplingTime to 1000, and set iMovingAvgWindow to 10.
3. When setting M0=ON, the DHCCNT counter starts to count. At the same time, set the DHCMEAS
parameters to the module, and start to measure frequency and rotation speed. The pulse number
counted every 1000ms is displayed in diFrequency and diRPM.
4. When the motor operation frequency is 5kHz, diFrequency shows 5kHz, and diRPM shows 300rev/min.

• Supported products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

19 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.20 DFB_DADLOG
DFB_DADLOG: Analog input module data record.

FB/FC Instruction Graphic Expression ST Language

DFB_DADLOG(
bEnable:= ,
byRemoteID:= ,
byLocalID:= ,
usiChannelNo:= ,
iMode:= ,
iPeriod:= ,
iTotalPoints:= ,
FB DFB_DADLOG
iPostTrigger:= ,
bDone=> ,
bBusy=> ,
aIntegerData=> ,
aFloatData=> ,
iCurPointNo=> ,
bError=> ,
ErrorCode=> );

• Input

Name Function Data Type Setting Value (Default value)


bEnable Run function block BOOL True/False (False)
0: CPU
byRemoteID* CPU or remote module BYTE
1~15: remote module(0)

byLocalID Expansion module ID BYTE 0–31(0)

usiChannelNo Specified channel number USINT 1–2(1)

iMode Output mode setting INT 0–3 (0)


iPeriod Speed fetch cycle time INT 10~1000(1000)
Refer to the description in the
iTotalPoints total number of records INT
Function description ( 1 )
Number of records after Refer to the description in the
iPostTrigger INT
triggering Function description (0)

*Note: Currently only support mode 0.

• Output

Name Function Data Type Output Range (Default value)


bDone When the pulse output is done BOOL True/False (False)
bBusy The FB is running BOOL True/False (False)

19 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Name Function Data Type Output Range (Default value)


The device that stores the
ARRAY[0~1999] Refer to chapter 15.2.1 of AS
aIntegerData record value when Format is
OF INT Module Manual (0).
Integer
The device that stores the
ARRAY[0~1999] Refer to chapter 15.2.1 of AS Module
aFloatData recorded value when Format is
OF REAL Manual (0).
Floating
iCurPointNo Accumulated record points INT 0–2000 (0)
bError FB instruction error flag BOOL True/False (False)
DFB_AS_MODUL DFB_AS_MODULE_API_ERROR
ErrorCode Error Code
E_API_ERROR (DFB_NO_ERROR)

• Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bDone  When the running of FB is complete  When bExecute shifts to False
bBusy  When the running of FB starts  When bExecute shifts to False
aIntegerData  Keep updating until the record is complete.  When bExecute shifts to False
aFloatData  Keep updating until the record is complete.  When bExecute shifts to False
iCurPointNo  Keep updating until the record is complete.  When bExecute shifts to False
bError  When an error occurs during the running or
 When bExecute shifts to False
ErrorCode there are incorrect input values

• Timing Diagram

bEnable

bDone

bBusy

bError

• Funtion
1. This Function is only supported by the AX-3 series firmware version V1.0.3 or above.
2. This command is a dedicated command for analog input modules (AS04AD-A, AS06XA-A, AS02ADH-
A). Function is to enable/disable the recording function, and send the recorded data from the module to
the specified aIntegerData or aFloatData (Determined according to the Format setting in the module
Parameters page).

19 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

3. The specifications of the Record Period and the number of points corresponding to each Model are
described in the following table. For detailed usage, refer to the iMode parameter description.
Model Record Period Number of Records
AS04AD-A Fixed period mode:
Fixed to 500 records
AS06XA-A The setting range is 1~100, and the unit time is fixed at 10ms
Fixed period (Fixed period) mode, trigger start types fixed
period (Fixed period + Trigger Start) mode, trigger position
designation (Fixed period + Trigger position Assign)
recording mode:
Setting range 1~32000, selectable time unit 20us/40us/80us
(Note: The time unit is the sampling period set by
AS02ADH-A HWCONFIG) Can set from 1 to 2000 records
Point Logging mode:
One point is recorded every time the external input point
is triggered, and there is no fixed period; the trigger timing of
the external input point is set by HWCONFIG.
Channel 1 triggers when X0.0 shift to True or False
Channel 2 triggers when X0,1 shift to True or False

4. byRemoteID specifies the group number of the analog input module connected to the right side of the
host or the right side of the remote module, the host number is 0, the number of the first remote module
is 1, and so on, the maximum number of groups is 15.
5. byLocalID specifies the module number. The sequence number of the modules connected to the right
side of the host starts from 0, second module is 1, and so on. Regardless of any type of modules, they
must be counted, and the maximum number of modules is limited to 32 units.
6. usiChannelNo specifies the channel number. Channel 1 is numbered 1, channel 2 is numbered 2.
7. iMode is recording mode. Modes supported by each Model are shown in the table below.

Applicable Model iMode Value Name Recording Mode Descroption


AS04AD-A
0 Fixed Period mode Run fixed period records
AS06XA-A
0 Fixed Period mode Run fixed period records
Waiting for the trigger signal of
the external input point. When
1 Fixed period + Trigger Start mode the trigger is received, the fixed
AS02ADH-A period recording is running
immediately.
No fixed period. One record is
2 Point Logging mode recorded every time the external
input point is triggered.

19 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Applicable Model iMode Value Name Recording Mode Descroption


The external trigger timing point
can be specified to record the
3 Fixed period + Trigger Start mode
data recorded in the fixed period
before / after.

(1) Fixed period (Fixed period) mode:


Set iMode=0, the command bEnable is turned on to Run the recording with the set Record Period. When
the set total number of records is completed, the bDone flag will be automatically set to TRUE.

Example:

Set iTotalPoints = 2000

(2) Fixed period + Trigger Start mode:

Set iMode=1, turn on the command bEnable before starting the recording. When the external trigger input
point is triggered, the recording will be Run with the set Record Period immediately, and the bDone flag
will be automatically set to True when the recording is completed. Any operation on the external trigger
input point will not affect the recording until the set total number of records is completed; however, when
the record number has been completed and the bDone flag is True, the external input point can be re-
triggered to start a new record. A round of records does not need to be closed and restarted by bEnable.

Corresponding to external trigger input signal source


Record Channel (Set the trigger timing of the external input point in the External Trigger Input of the
module Parameters)
Channel 1 Triggers when X0.0 shift to True or False
Channel 2 Triggers when X0,1 shift to True or False

Example:

Set iTotalPoints = 2000. The trigger timing of the external input point is set as the rising edge trigger.

19 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

The fixed period + trigger start mode is similar to the fixed period mode, but the recording start timing of
the fixed period mode will be affected by the host scan time and module communication time, causing
delay, refer to below picture. In the Fixed period mode, it is assumed that M0 is the device that controls
the DADLOG command bEnable. When M0 is turned OFF->ON, the module does not start recording
immediately, but with a small delay.

Fixed period mode record point

Trigger start mode record point

0
Fixed period mode

M0
Host scan time +
Record start
Communication delay

Trigger fixed period mode

External Trigger
input

Record start

(3) Point Logging Mode:

Set iMode=2. Turn on the command bEnable before starting to record. Each time the external trigger
input point is triggered, one record will be recorded. When the set total number of records is reached, the
bDone flag will be automatically set to True; if wish to continue recording after the bDone flag is True, user
must restart the command.

20 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Corresponding to external trigger input signal source


Record
(Set the trigger timing of the external input point in the External Trigger Input of the module
Channel
Parameters)
Channel 1 Triggers when X0.0 shift to True or False
Channel 2 Triggers when X0,1 shift to True or False

Example:
Set iTotalPoints = 2000, The trigger timing of the external input point is set as the rising edge.

(4) Fixed period + Trigger position Assign Mode:


Set iMode=3, and set the iTotalPoints and iPostTrigger parameters. This mode is triggered by an external
input point and records a specific number of strokes before/after the trigger according to the setting. After
using the command bEnable to enable this recording mode, AS02ADH-A will start to wait for the external
trigger input signal, and start sampling immediately after the signal is triggered. When the Number of
Records reaches the set number of records, the bDone flag will be automatically set to True. The
iCurPointNo value is 0 before the trigger. After the trigger, the module starts to send the record data
before the trigger to the host, so the iCurPointNo value will gradually catch up with the accumulated
record number.

Corresponding to external trigger input signal source


Record
(Set the trigger timing of the external input point in the External Trigger Input of the module
Channel
Parameters)
Channel 1 Triggers when X0.0 shift to True or False
Channel 2 Triggers when X0,1 shift to True or False

Example:

Set iMode=3, iTotalPoints = 2000, iPostTrigger = 1500, means that the position of the 501st point

(iTotalPoints - iPostTrigger) will be the first data recorded by the current external trigger.

20 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

1. iPeriod is set for Record Period, the description is as follows:


Model iPeriod Range iPeriod Unit
AS04AD-A
1~100 Fixed as 10ms, cannot be changed.
AS06XA-A
The sampling cycle time must be set by AS02ADH-A Parameters,
20us, 40us and 80us can be selected.
AS02ADH-A 1~32000
If "iMode=2: Point Logging Mode" is used, this iPeriod setting is
invalid.

2. iTotalPoints is the total number of records. This parameter is only valid for AS02ADH-A, and can be set
up to 2000 points; other models are fixed at 500 points regardless of the setting of this parameter.
Model Total Recordm Setting Range
AS04AD-A
The setting is invalid, fixed at 500.
AS06XA-A
AS02ADH-A Can be set, 1~2000 records.

3. iPostTrigger is the points recorded after the trigger occurs. This parameter is used in combination with
the total number of records iTotalPoints to record the data before and after the trigger. This parameter is
only used in Fixed period + Trigger position Assign mode (iMode=3), and is invalid in other modes. Be
cautious that this value should not be greater than the total number of iTotalPoints. If it exceeds, it will
automatically use the iTotalPoints value as Number of Records.
Example:If set iTotalPoints=100, iPostTrigger=200. Since iPostTrigger is greater than the total
number of records, iPostTrigger will be automatically regarded as 100, so only 100 records after the trigger
will be recorded.
Model iPostTrigger Setting Range

AS02ADH-A 0~2000 records (Must not be greater than the total number of iTotalPoints records)

Example:

Set iTotalPoints= 100, iPostTrigger= 700, the 1000 records include the first 300 records and the last 700
records triggered by the external trigger input point.

20 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

1. aIntegerData and aFloatData are specified arrays to store record values. (According to the Format
setting in the parameters page of the module to determine which array to store in, the value in the other
array will be cleared to 0).
2. iCurPointNo is to display the number of records that the module has sent back to the host. When the
record is in progress, the iCurPointNo value may not be displayed in a consistent value due to the
influence of the scanning cycle.
3. bDone is the flag of record completion. When bDone is OFF->ON, it means that all record values have
been transferred to the specified aIntegerData or aFloatData array. The bDone flag will be automatically
initialized to OFF when bEnable changes from OFF->ON.
4. If the command is closed, the specified channel will stop updating the values in the right half of the
command.
5. When any error occurs during startup, the bError error flag will be set to ON. Refer to the error code of
ErrorCode for troubleshooting.

• Supported products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

20 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.21 DFB_DADPEAK
DFB_DADPEAK: Analog input module peak record.

FB/FC Instruction Graphic Expression ST LANGUAGE

DFB_DADPEAK(
bEnable:= ,
byRemoteID:= ,
byLocalID:= ,
usiChannelNo:= ,
bBusy=> ,
FB DFB_DADPEAK
iMaxValue=> ,
iMinValue=> ,
rMaxValue=> ,
rMinValue=> ,
bError=> ,
ErrorCode=> );

• Input

Name Function Data Type Setting Value (Default value)


bEnable Run function block BOOL True/False (False)
0: CPU
The CPU or remote 1~15: Remote module
byRemoteID* BYTE
module ID
(0)

byLocalID Expansion module ID BYTE 0–31(0)

Specify channel
usiChannelNo USINT 1–2(1)
number
Note: Currently only support mode 0.

• Output

Name Function Data Type Output Range (Default value)


Indicates that the function
bBusy BOOL True/False (False)
block is running
Maximum value when Refer to AS Module Manual
iMaxValue INT
Format is Integer chapter 15.2.1 of (0)
Minimum value when Refer to AS Module Manual
iMinValue INT
Format is Integer chapter 15.2.1 of (0)
Maximum value when Refer to AS Module Manual
rMaxValue REAL
Format is Floating chapter 15.2.1 of (0)
Minimum value when Refer to AS Module Manual
rMinValue REAL
Format is Floating chapter 15.2.1 of (0)
bError FB instruction error flag BOOL True/False (False)
DFB_AS_MODUL DFB_AS_MODULE_API_ERROR
ErrorCode Error Code
E_API_ERROR (DFB_NO_ERROR)

20 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

• Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


 When bExecute shifts to
bBusy  When the running of FB starts
False
 When bExecute shifts to
iMaxValue  Continuous update after bEnable
False
 When bExecute shifts to
iMinValue  Continuous update after bEnable
False
 When bExecute shifts to
rMaxValue  Continuous update after bEnable
False
 When bExecute shifts to
rMinValue  Continuous update after bEnable
False
bError  When an error occurs during the running  When bExecute shifts to
ErrorCode or there are incorrect input values False

• Timing Diagram

bEnable

bBusy

bError

• Funtion

1. This Function is only supported with AX-3 series firmware version 1.0.3 or later.
2. AX-3 series firmware version 1.0.7 or later supports AS08AD_B and AS08AD_C modules (v1.0.2 or
later).
3. The DADPEAK command is a dedicated command for analog input modules (AS04AD-A, AS08AD-B,
AS08AD-C, AS06XA-A, AS02ADH-A), and its Function is to enable/disable the module to record the
peak value.
4. byRemoteID specifies the group number of the analog input module connected to the right side of the
host or the right side of the remote module, the host number is 0, the number of the first remote module
is 1, and so on, the maximum number of groups is 15.
5. byLocalID specifies the module number, the sequence number of the modules connected to the right
side of the host, the number of the first module is 0, the number of the second module is 1, and so on,
regardless of any type of modules, they must be counted, and the maximum number of modules is
limited. for 32 units.
6. usiChannelNo specifies the number of the counter channel to be controlled, the number of Channel 1 is
1, and the number of Channel 2 is 2.
7. According to the Format setting in the module Parameters page, determine whether the maximum and
minimum values are placed in iMaxValue and iMinValue or in rMaxValue and rMinValue. The
maximum and minimum values of another Data Type will be cleared to 0.
8. The following describes the maximum and minimum values of INT or REAL type represented by
MaxValue and MinValue.
9. MaxValue and MinValue are the maximum and minimum values respectively. When bEnable is
changed from OFF->ON, MaxValue and MinValue will be initialized to the latest measurement value,

20 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

and then the peak value recording Function will start, and the channel will continue to detect the
maximum and minimum values. value and update to MaxValue and MinValue.
10. If bEnable changes from ON to OFF, it means that the peak value recording function is turned off. At this
time, the content values of MaxValue and MinValue will remain unchanged and will not be updated.
11. When any error occurs during the startup process, the bError flag will be set to ON. Refer to the error
code of ErrorCode for troubleshooting.

• Supported Products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

20 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.22 DFB_ SCMRS


DFB_ SCMRS: Send and receive communication data via the COM port.

FB/FC Instruction Graphic Expression ST Language

DFB_SCMRS(
bEnable:= ,
ComPort:= ,
RxMode:= ,
DFB_ ParaSet:= ,
FB
SCMRS bDone=> ,
bBusy=> ,
bError=> ,
ErrorCode=> ,
uiRcvLen=> );

• Input

Setting Value
Name Function Data Type
(Default value)

bEnable Run the function block. BOOL True/False (False)

ComPort COM port number DFB_SCMRS_COM_PORT (SCM_1_CARD_1)

RxMode*1 Receiving mode DFB_SCMRS_RXMODE (NO_RECEIVING)

ParaSet*2 COM port parameters DFB_SCMRS_SET_VALUE (COMRS_SET_VALUE)

Note:
1. DFB_SCMRS_RXMODE: STRUCT

Name Description
No receiving data mode:
NO_RECEIVING(0) After the packet is sent, the receiving task is complete. Then the
completion flag is set to True.
Discontinuous time mode:
When the interval between receiving packets is longer than the
specified time, the receiving task is complete. Then the
DISCONTINUOUS_TIME(1) completion flag is set to True.
The discontinuous time for receiving the packet can be set via
ParaSet.uiDiscontinuousTime.

Specific end character (1) mode:


When a specific character is received, the data receiving is
SPECIFIC_END_CHAR_1
complete. Then the completion flag is set to True.
(2) The end character can be set via ParaSet.pSpecificEndChar.

SPECIFIC_END_CHAR_2 Specific end character (2) mode:


When two consecutive specific characters are received, the data
(3)
receiving is complete. Then the completion flag is set to True.
20 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Name Description
The end character can be set via ParaSet.pSpecificEndChar.

Specific start character and discontinuous time mode:


SPECIFIC_START_CHAR_AND_ When a specific character is received, starts to receive the
packet, and when the packet interval is longer than the specified
DISCONTINUOUS_TIME time, the receiving task is complete.
(4) The start character can be configured via
ParaSet.pSpecificStartChar and the discontinuous time can be
set via ParaSet.uiDiscontinuousTime.
Specific start character and end character mode:
SPECIFIC_START_CHAR_AND_ When a specific character is received, starts to receive the
SPECIFIC_END_CHAR packet. The receiving task is not complete until receive an end
character.
(5) The start character can be set via ParaSet.pSpecificStartChar.
The end character can be set via ParaSet.pSpecificEndChar.
Specific length mode:
SPECIFIC_LENGTH A specific quantity of data is received and the receiving task is
(6) complete.
The packet length can be set via ParaSet.uiSetVarue.
Specific end character and interrupt mode:
SPECIFIC_END_CHAR_AND_INTERRUPT The receiving task is not complete until receive a specific
(7) character. At the same time, an external interrupt is generated.
The packet length can be set via ParaSet.uiSpecificRxLen.
Specific length and interrupt mode:
SPECIFIC_LENGTH_AND_INTERRUPT The receiving task is not complete until receive a specific quantity
(8) of data. At the same time, an external interrupt is generated.
The packet length can be set via ParaSet.uiSpecificRxLen.
Specific end character or specific length mode:
SPECIFIC_ END_CHAR _OR_
The receiving task is not complete until receive a specific quantity
SPECIFIC_LENGTH of data. At the same time, an external interrupt is generated.
The end character can be set via ParaSet.pSpecificEndChar and
(9)
the packet length can be set via ParaSet.uiSpecificRxLen.

2. DFB_SCMRS_SET_VALUE: STRUCT

Setting Value
Name Function Data Type
(Default value)
The length of packet to be
uiWriteLen sent UINT 0 –200 (0)
(Unit: Byte)
Packet interval
uiDiscontinuousTime UINT 5–3,000 (5)
(Unit: ms)
Memory address of the start
pSpecificStartChar POINTER TO BYTE Memory address (0)
character
Memory address of the end
pSpecificEndChar POINTER TO BYTE Memory address (0)
character
UINT
uiSpecificRxLen Receiving length 1–198 (1)
(Unit: Byte)

20 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Setting Value
Name Function Data Type
(Default value)
T#0ms–T#3000ms(T#100ms)
tTimeout Communication time-out TIME
T#0ms: No time-out

• Output

Name Function Data Type Output Range(Default value)


bDone FB is completed. BOOL True/False (False)
True when the
bBusy BOOL True/False (False)
instruction is running
bError True if an error occurs BOOL True/False (False)
Indicates the error code DFB_AS_MODULE_API_ERROR
ErrorID DFB_AS_MODULE_API_ERROR
if an error occurs. (DFB_NO_ERROR)
The length of the data UINT
uiRcvLen (0)
received (Unit: Byte)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bDone  When bEnable is True  When bEnable is False
bBusy  When bEnable is True  When bEnable is False
bError  When an error occurs during the running  When bEnable is False
ErrorID or there are incorrect input values

• Timing Diagram

bEnable

bDone

bBusy

bError

• Function

1. This function requires AX-3 series firmware version 1.0.3 or later.


2. This function requires AS00SCM firmware version 2.08.00 or later.

20 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

3. Before using this function, the communication protocol corresponding to the SCM function card must be set
to SCM RS.
4. ComPort is the communication port number. Up to four AS00SCM can be connected to the right side of the
PLC. If the communication port range is exceeded, the FB will not receive any communication data.
Card1 No. Card2 No.
1st AS00SCM 1 2
2nd AS00SCM 11 12
3rd AS00SCM 21 22
4th AS00SCM 31 32
5. When the condition of ending receiving has the specific character, it is recommended to use ASCII-
encoded communication data. If not, it is recommended to use the communication time-out as a mark to
end.
6. Take the first AS00SCM CARD1 on the right side of AX-3 as an example. FunctionCardOutput(Slave)[0] is
the length of the received data, and FunctionCardOutput(Slave)[0]+1~ FunctionCardOutput(Slave)[0]+n is
the stored received data. Suppose RxMode = SPECIFIC_END_CHAR_2 and ParaSet.PSpecificEndChar =
16#0D0A, the FB will store the data after FunctionCardOutput(Slave)[1] according to the order of receiving.
The data will not be stopped to receive until the two consecutive ending characters are 16#0D and 16#0A.
The length will be entered in FunctionCardOutput(Slave)[0], and then the completion flag will be set to
Done.
7. When the receiving mode is 7, 8, and 9, the corresponding communication interrupt numbers generated by
each communication port are as follows:
32 modules can be connected to the right side of the AX-3 controller, and there are different interrupt
numbers according to the location of the SCM, as shown in the following table:
The Nth
position on 1st 2nd … 31st 32nd
the right
Card1
I400 I401 … I430 I431
interrupt No.
Card2
I432 I433 … I462 I463
interrupt No.
Note: Up to four SCM modules can be connected to the right side of the AX-3.
• Programming Example

 Example 1
 This example uses DFB_SCMRS and the communication receiving mode is NO_RECEIVING to
send serial communication packets.

21 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

 Output variable address is based on the output address of the module. %QW7 is the start address
in this example.

 Example 2
 This example uses DFB_SCMRS and the communication receiving mode is
SPECIFIC_START_CHAR_AND_SPECIFIC_END_CHAR to receive serial communication
packets.

211
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

 Output variable address is based on the output address of the module. %QW7 is the start address
in this example.

 Example 3
 This example uses DFB_SCMRS and the communication receiving mode is
SPECIFIC_END_CHAR_2 to stop receiving packets when the two consecutive ending characters
are 16#0D and 16#0A.

 Output variable address is based on the output address of the module. %QW7 is the start address
in this example.

21 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

• Supported Products

 AX-3 series

• Library

 DL_ASModuleAPI_AX3.library

21 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

6.23 Error Codes and Troubleshooting

Description Cause of Error Corrective Action


Confirm if the input
DFB_FROM_ERR_PARAMETER Enter parameter error
parameters are correct.
DFB_FROM_ERR_COMMUNICATION CAN bus communication error Confirm the error record.
Check if the CR address
DFB_FROM_ERR_CRADDR CR address error
is correct.
Confirm if the input
DFB_TO_ERR_PARAMETER Enter parameter error
parameters are correct.
DFB_TO_ERR_COMMUNICATION CAN bus communication error Confirm the error record.
Check if the CR address
DFB_TO_ERR_CRADDR CR address error
is correct.
byRemoteID and byLocalID Confirm byRemoteID,
DFB_DLCCAL_ERR_NOT_SUPPORT
correspond to the module that is not byLocalID, and the
_MODULE
the AS02LC module. corresponding module.
Confirm if byRemoteID
DFB_DLCCAL_ERR_INVALID_GROUP byRemoteID input error
input value is correct.
Confirm if byLocalID
DFB_DLCCAL_ERR_INVALID_MODULE byLocalID input error
input value is correct.
Confirm if usiChannelNo
DFB_DLCCAL_ERR_INVALID_CHNO usiChannelNo input error
input value is correct.
Confirm if aTWeight input
DFB_DLCCAL_ERR_INVALID_TWEIGHT aTWeight input error
value is correct.
Confirm if iTPoint input
DFB_DLCCAL_ERR_INVALID_TPOINT iTPoint input error
value is correct.
Check the error code
reported in the Diagnosis
Message in the Status of
DFB_DLCCAL_ERR_MODULE_
Module on the right reports error. the module page, and
REPORTS_AN_ERROR
check this error code in
the AS Series module
manual.
byRemoteID and byLocalID Confirm byRemoteID,
DFB_DLCWEI_ERR_NOT_SUPPORT_
correspond to the module that is not byLocalID, and the
MODULE
the AS02LC module. corresponding module.
Confirm if byRemoteID
DFB_DLCWEI_ERR_INVALID_GROUP byRemoteID input error
input value is correct.
Confirm if byLocalID
DFB_DLCWEI_ERR_INVALID_MODULE byLocalID input error
input value is correct.
Confirm if usiChannelNo
DFB_DLCWEI_ERR_INVALID_CHNO usiChannelNo input error
input value is correct.
Confirm if rStable input
DFB_DLCWEI_ERR_INVALID_STABLE rStable input error
value is correct.
Check the error code
reported in the Diagnosis
Message in the Status of
DFB_DLCWEI_ERR_MODULE_REPORTS
Module on the right reports error. the module page, and
_AN_ERROR
check this error code in
the AS Series module
manual.
Confirm if byLocalID
DFB_DPUCONF_ERR_INVALID_MODULE byLocalID input error
input value is correct.

21 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Description Cause of Error Corrective Action


byLocalID and iAxis correspond to Confirm byLocalID, iAxis,
DFB_DPUCONF_ERR_NOT_SUPPORT
the module that is not the PU and the corresponding
_MODULE
module. module.
Confirm if iAxis input
DFB_DPUCONF_ERR_INVALID_AXIS iAxis input error
value is correct.
Confirm if iMode input
DFB_DPUCONF_ERR_INVALID_MODE iMode input error
value is correct.
Confirm if iStartSpeed
DFB_DPUCONF_ERR_INVALID_SSPEED iStartSpeed input error
input value is correct.
Confirm if iAccTime input
DFB_DPUCONF_ERR_INVALID_ATIME iAccTime input error
value is correct.
Confirm if iDecTime input
DFB_DPUCONF_ERR_INVALID_DTIME iDecTime input error
value is correct.
Confirm if diMaxSpeed
DFB_DPUCONF_ERR_INVALID_MSPEED diMaxSpeed input error
input value is correct.
Confirm if iZ_no input
DFB_DPUCONF_ERR_INVALID_ZNO iZ_no input error
value is correct.
Confirm if iOffset input
DFB_DPUCONF_ERR_INVALID_OFFSET iOffset input error
value is correct.
Confirm if byLocalID
DFB_PUSTAT_ERR_INVALID_MODULE byLocalID input error
input value is correct.
byLocalID and iAxis correspond to Confirm byLocalID, iAxis,
DFB_PUSTAT_ERR_NOT_SUPPORT
the module that is not the PU and the corresponding
_MODULE
module. module.
Confirm if iAxis input
DFB_PUSTAT_ERR_INVALID_AXIS iAxis input error
value is correct.
DFB_DPUPLS_DPUDRI_DPUDRA_ERR Confirm if byLocalID
byLocalID input error
_INVALID_MODULE input value is correct.
byLocalID and iAxis correspond to Confirm byLocalID, iAxis,
DFB_DPUPLS_DPUDRI_DPUDRA_ERR
the module that is not the PU and the corresponding
_NOT_SUPPORT_MODULE
module. module.
DFB_DPUPLS_DPUDRI_DPUDRA_ERR_ Confirm if iAxis input
iAxis input error
INVALID_AXIS value is correct.
DFB_DPUPLS_DPUDRI_DPUDRA_ERR_ Confirm if diTarSpeed
diTarSpeed input error
INVALID_TARSPEED input value is correct.
Close the function block,
DFB_DPUPLS_DPUDRI_DPUDRA_ERR_ Exceed the positive limit position
set to run to the opposite
POSITIVELIMIT_EXCEEDED setting
direction and restart.
Close the function block,
DFB_DPUPLS_DPUDRI_DPUDRA_ERR_ Exceed the negative limit position
set to run to the opposite
NEGATIVELIMIT_EXCEEDED setting
direction and restart.
Confirm if byLocalID
DFB_DPUZRN_ERR_INVALID_MODULE byLocalID input error
input value is correct.
byLocalID and iAxis correspond to Confirm byLocalID, iAxis,
DFB_DPUZRN_ERR_NOT_SUPPORT_MODUL
the module that is not the PU and the corresponding
E
module. module.
Confirm if iAxis input
DFB_DPUZRN_ERR_INVALID_AXIS iAxis input error
value is correct.
Confirm if iMode input
DFB_DPUZRN_ERR_INVALID_MODE iMode input error
value is correct.
Confirm if diTarSpeed
DFB_DPUZRN_ERR_INVALID_TARSPEED diTarSpeed input error
input value is correct.
Confirm if iJogSpeed
DFB_DPUZRN_ERR_INVALID_JOGSPEED iJogSpeed input error
input value is correct.

21 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Description Cause of Error Corrective Action


Confirm if byLocalID
DFB_DPUJOG_ERR_INVALID_MODULE byLocalID input error
input value is correct.
byLocalID and iAxis correspond to Confirm byLocalID, iAxis,
DFB_DPUJOG_ERR_NOT_SUPPORT
the module that is not the PU and the corresponding
_MODULE
module. module.
Confirm if iAxis input
DFB_DPUJOG_ERR_INVALID_AXIS iAxis input error
value is correct.
Confirm if diJogSpeed
DFB_DPUJOG_ERR_INVALID_JOGSPEED diJogSpeed input error
input value is correct.
Close the function block,
DFB_DPUJOG_ERR_POSITIVELIMIT Exceed the positive limit position
set to run to the opposite
_EXCEEDED setting
direction and restart.
Close the function block,
DFB_DPUJOG_ERR_NEGATIVELIMI Exceed the negative limit position
set to run to the opposite
T_EXCEEDED setting
direction and restart.
Confirm if byLocalID
DFB_DPUMPG_ERR_INVALID_MODULE byLocalID input error
input value is correct.
byLocalID and iAxis correspond to Confirm byLocalID, iAxis,
DFB_DPUMPG_ERR_NOT_SUPPORT
the module that is not the PU and the corresponding
_MODULE
module. module.
After the DPUCNT
DFB_DPUMPG_ERR_BEUSED_BY The pin is currently being used by the
function block is closed,
_DPUCNT DPUCNT function block.
re-trigger DPUMPG.
Confirm if iAxis input
DFB_DPUMPG_ERR_INVALID_AXIS iAxis input error
value is correct.
Confirm if byLocalID
DFB_DPUCNT_ERR_INVALID_MODULE byLocalID input error
input value is correct.
Confirm byLocalID and
DFB_DPUCNT_ERR_NOT_SUPPORT The module corresponding to
the corresponding
_MODULE byLocalID is not the PU module.
module.
After other function
The pin is currently being used by
DFB_DPUCNT_ERR_BEUSED_BY_OTHER blocks are closed, re-
other function blocks.
trigger DPUCNT.
DFB_DMPID_ERR_NOT_SUPPORT Module does not support this Confirm if the module is
_MODULE instruction. the TC module.
DFB_DMPID_ERR_INVALID_GROUP Group number or module number Confirm if the input pin is
_OR_MODULE_ID setting error in the correct range.
Check if the module in
No response from module,
DFB_DMPID_ERR_COMMUNICAION the device area is
communication time-out
properly connected.
Confirm if the input
DFB_DMPID_ERR_NO_CHANNEL Channel setting error
parameter is correct.
The channel is running the PID Confirm if the PID
DFB_DMPID_ERR_CHANNEL_IS_
function, and repeating designation is function is open and is
RUNNING_PID
not allowed. been Run.
DFB_DHCCNT_ERR_NOT_SUPPORT Module does not support this Confirm if the module is
_MODULE instruction. the HC module.
DFB_DHCCNT_ERR_INVALID_INPUT_ When updating parameter to the Confirm if the input pin is
VALUE_TO_HC_MODULE module, module response error. in the correct range.
DFB_DHCCNT_ERR_COMMUNICAION No response from module, Check if the module in
communication time-out the device area is
properly connected.
DFB_DHCCNT_ERR_HC_MODULE_ Module configuration setting error Confirm if the setting
CONFIG_ERROR parameter of the input
device is correct.

21 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Description Cause of Error Corrective Action


DFB_DHCCNT_ERR_NO_CHANNEL HC module does not have this Confirm if the used
counter channel. channel number is the
module support number.
DFB_DHCCNT_ERR_INTERFACE_OF_ Input interface is not selected, Confirm if the channel
CHANNEL_IS_DISABLE instruction operation is not allowed. input interface enable the
corresponding functions.
DFB_DHCCNT_ERR_INVALID_ACTION usiAction value is invalid. Confirm if the input pin
_VALUE usiAction is correct.
DFB_DHCCNT_ERR_CHANNEL_IS The module channel is running the Confirm if the HC
_RUNNING_CNT counting function, and repeating counting function is
designation is not allowed. enabled and is running.
DFB_DHCCAP_ERR_NOT_SUPPORT Module does not support this Confirm if the module is
_MODULE instruction. the HC module.
DFB_DHCCAP_ERR_INVALID_INPUT When updating parameters to the Confirm if the input pin is
_VALUE_TO_HC_MODULE module, module response error. in the correct range.
DFB_DHCCAP_ERR_COMMUNICAION No response from module, Check if the module in
communication time-out the device area is
properly connected.
DFB_DHCCAP_ERR_HC_MODULE Module configuration setting error Confirm if the setting
_CONFIG_ERROR parameter of the input
device is correct.
DFB_DHCCAP_ERR_NO_CHANNEL HC module does not have this Confirm if the used
counter channel. channel number is the
module support number.
DFB_DHCCAP_ERR_INTERFACE_OF Input interface is not selected, Confirm if the channel
_CHANNEL_IS_DISABLE instruction operation is not allowed. input interface enable the
corresponding functions.
DFB_DHCCAP_ERR_INVALID_TRGSEL_VALU byTrgSel value is invalid. Confirm if input pin
E byTrgSel is correct.
DFB_DHCCAP_ERR_CHANNEL_IS_RUNNING The module channel is running the Confirm if the HC capture
_CAP capture function, and repeating function is enabled and is
designation is not allowed. running.
Confirm the input value is
DFB_HCDO_ERR_INVALID_MODULE byLocalID input error
correct.
Confirm the module to
byLocalID corresponds to a module
DFB_HCDO_ERR_NOT_SUPPORT_MODULE which the function block
that is not the HC module.
corresponds.
After other function
HC module is current being used by
DFB_HCDO_ERR_BEUSED_BY_OTHER_DFB blocks are closed, re-
other function blocks.
trigger HCDO.
Confirm the input value is
DFB_DHCCMP_ERR_INVALID_MODULE byLocalID input error
correct.
Confirm the module to
DFB_DHCCMP_ERR_NOT_SUPPORT_MODU byLocalID corresponds to a module
which the function block
LE that is not the HC module.
corresponds.
Confirm the input value is
DFB_DHCCMP_ERR_INVALID_CHNO usiChannelNo input error
correct.
Confirm the input value is
DFB_DHCCMP_ERR_INVALID_ACTION1 iActionValue1 input error
correct.
Confirm the input value is
DFB_DHCCMP_ERR_INVALID_YNO1 iY_OutputNo1 input error
correct.
Confirm the input value is
DFB_DHCCMP_ERR_INVALID_ACTION2 iActionValue2 input error
correct.
Confirm the input value is
DFB_DHCCMP_ERR_INVALID_YNO2 iY_OutputNo2 input error
correct.

21 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Description Cause of Error Corrective Action


DFB_DHCCMP_ERR_INVALID_INTERRUPTN Confirm the input value is
iInterruptNo1 input error
O1 correct.
DFB_DHCCMP_ERR_INVALID_INTERRUPTN Confirm the input value is
iInterruptNo2 input error
O2 correct.
Confirm the input value is
DFB_DHCCMPT_ERR_INVALID_MODULE byLocalID input error
correct.
Confirm the module to
DFB_DHCCMPT_ERR_NOT_SUPPORT_MOD byLocalID corresponds to a module
which the function block
ULE that is not the HC module.
corresponds.
Confirm the input value is
DFB_DHCCMPT_ERR_INVALID_CHNO usiChannelNo input error
correct.
DFB_DHCCMPT_ERR_INVALID_COMPARELE Confirm the input value is
iCompareLength input error
NGTH correct.
DFB_DHCCMPT_ERR_INVALID_COMPARETA Confirm the input value is
aCompareValue input error
BLE correct.
DFB_DHCCMPT_ERR_INVALID_ACTIONTABL Confirm the input value is
aAction input error
E correct.
Confirm the input value is
DFB_DHCCMPT_ERR_INVALID_YNOTABLE aY_OutputNo input error
correct.
DFB_DHCCMPT_ERR_INVALID_INTERRUPTN Confirm the input value is
aInterruptNo input error
OTABLE correct.
Confirm the input value is
DFB_DHCMEAS_ERR_INVALID_MODULE byLocalID input error
correct.
Confirm the module to
DFB_DHCMEAS_ERR_NOT_SUPPORT_MOD byLocalID corresponds to a module
which the function block
ULE that is not the HC module.
corresponds.
Confirm the input value is
DFB_DHCMEAS_ERR_INVALID_CHNO usiChannelNo input error
correct.
DFB_DHCMEAS_ERR_INVALID_PULSEPERR Confirm the input value is
udiPulsePerRev input error
EV correct.
DFB_DHCMEAS_ERR_INVALID_SAMPLINGTI Confirm the input value is
iSamplingTime input error
ME correct.
DFB_DHCMEAS_ERR_INVALID_AVERAGETI Confirm the input value is
iMovingAvgWindow input error
MES correct.
Confirm whether the
DFB_DADLOG_ERR_INVALID_GROUP byRemoteID input error input value of
byRemoteID is correct.
Confirm the module
DFB_DADLOG_ERR_NOT_SUPPORT_MODU The module corresponding to
corresponding to the
LE byLocalID is not an AD module
function block
Confirm whether the
DFB_DADLOG_ERR_INVALID_MODULE byLocalID input error
input value is correct.
Confirm whether the
DFB_DADLOG_ERR_INVALID_POINTS iTotalPoints typo
input value is correct.
Confirm whether the
DFB_DADLOG_ERR_INVALID_CHNO usiChannelNo input error
input value is correct.
Confirm whether the
DFB_DADLOG_ERR_INVALID_MODE iMode input error
input value is correct.
Confirm whether the
DFB_DADLOG_ERR_INVALID_PERIOD iPeriod input error
input value is correct.
Confirm whether the
DFB_DADPEAK_ERR_INVALID_GROUP byRemoteID input error input value of
byRemoteID is correct.

21 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 6

Description Cause of Error Corrective Action


Confirm the module
DFB_DADPEAK_ERR_NOT_SUPPORT_MOD The module corresponding to
corresponding to the
ULE byLocalID is not an AD module
function block.
Confirm whether the
DFB_DADPEAK_ERR_INVALID_MODULE byLocalID input error
input value is correct.
Confirm whether the
DFB_DADPEAK_ERR_INVALID_CHNO usiChannelNo input error
input value is correct.
The COM port No. exceeds range (1, Check whether the
DFB_SCMRS_ERR_INVALID_COMPORT
2, 11, 12, 21, 22, 31, 32). entered value is correct.
DFB_SCMRS_ERR_SCM_WITH_SPECIFIED_ The COM port No. is specified. The Check the target module
COMPORT_NOT_EXIST SCM module does not exist. of the FB
The COM port No. is specified. This
DFB_SCMRS_ERR_INVALID_FUNCTION_CAR Check the target module
SCM module function card is not AS-
D_TYPE_WITH_SPECIFIED_COMPORT of the FB
F232 / AS-F485 / AS-F422.
The specified COM port No. has Check whether the
DFB_SCMRS_ERR_SPECIFIED_COMPORT_A
been used by other SCMRS entered value is correct
LREADY_EXECUTING_ANOTHER_SCMRS
instructions.
DFB_SCMRS_ERR_WRITE_LENGTH_EXCEE uiWriteLen is set to be less than 0 or Check whether the
D_SETTING_RANGE_0_200 greater than 200. entered value is correct
DFB_SCMRS_ERR_RESERVED - -
Check whether the
DFB_SCMRS_ERR_INVALID_RXMODE RxMode setting out of range (0~9)
entered value is correct
The receiving mode of RxMode is set Check whether the
DFB_SCMRS_ERR_SPECEFIC_RXLENGTH_ to 6 or 8 or 9, and the length entered value is correct
EXCEED_SETTING_RANGE_1_198 specified by uiSpecificRxLen is less
than 1 or greater than 198.
DFB_SCMRS_ERR_RESERVED2 - -
DFB_SCMRS_ERR_COMMUNICATION_WITH Communication with the AS00SCM Check whether the
_MODULE_TIMEOUT module timed out. module is functioning
DFB_SCMRS_ERR_MODULE_REPORTS_AN_ Check whether the
AS00SCM module response error
ERROR module is functioning
Exceed the communication time-out
DFB_SCMRS_ERR_RXMODE_CONDITION_N Check whether the
period but still unable to reach the
OT_FINISHED_TIMEOUT entered value is correct
end condition.
DFB_SCMRS_ERR_RECEIVE_DATA_LENGTH The received data exceeds the Check whether the
_EXCEED_198_BYTE maximum length of 198 characters. received data is correct
DFB_SCMRS_ERR_PROTOCOL_NOT_SCMR The communication protocol is not Check the protocol
S COMRS. settings

21 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

Chapter 7 Modbus Communication Instructions

22 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

7.1 DFB_COMRS
DFB_COMRS: Send and receive communication data via the COM port.

FB/FC Instruction Graphic Expression ST Language

DFB_COMRS (
bExecute:= ,
byComPort:= ,
RxMode:= ,
ParaSet:= ,
FB DFB_COMRS
bDone=> ,
bBusy=> ,
bError=> ,
ErrorId=> ,
uiRcvLen=>);

• Input

Setting Value
Name Function Data Type
(Default value)

Run the function block.


bExecute (Triggered by the rising- BOOL True/False (False)
edge)

byComPort* COM port number BYTE (0xFF)

RxMode Receiving mode DFB_COMRS_MODE (NO_RECEIVING)

ParaSet COM port parameters DFB_COMRS_SET_VALUE (COMRS_SET_VALUE)

Note: You need to configure the settings based on the definitions of COM port numbers varied from model to
model.

 DFB_COMRS_MODE

Name Description

No receiving data mode:


NO_RECEIVING After the packet is sent, the receiving task is complete. Then the completion
flag is set to True.

22 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

Name Description

Discontinuous time mode:


When the interval between receiving packets is longer than the specified
DISCONTINUOUS_TIME time, the receiving task is complete. Then the completion flag is set to True.
The discontinuous time for receiving the packet can be set via
ParaSet.uiDiscontinuousTime.(*1)

Specific end character mode:


When a specific character is received, the data receiving is complete. Then
the completion flag is set to True.
SPECIFIC_END_CHAR The end character and the length can be set via ParaSet.pSpecificEndChar
and ParaSet.byEndCharAmt.
(*1,*2)

Specific start character and discontinuous time mode:


When a specific character is received, starts to receive the packet, and
when the packet interval is longer than the specified time, the receiving task
SPECIFIC_START_CHAR_ is complete.
AND_DISCONTINUOUS_ The start character and the length can be configured via
TIME ParaSet.pSpecificStartChar and ParaSet.byStartCharAmt while the
discontinuous time can be set via ParaSet.uiDiscontinuousTime.
(*1,*2)

Specific start character and end character mode:


When a specific character is received, starts to receive the packet. The
receiving task is not complete until receive an end character.
SPECIFIC_START_CHAR_ The start character and the length can be set via
AND_SPECIFIC_END_ ParaSet.pSpecificStartChar and ParaSet.byStartCharAmt.
CHAR The end character and the length can be set via ParaSet.pSpecificEndChar
and ParaSet.byEndCharAmt.
(*1,*2)

Specific length mode:


SPECIFIC_LENGTH A specific quantity of data is received and the receiving task is complete.
The packet length can be set via ParaSet.uiSetVarue.
Note:
*1: When the received data length reaches the size defined in uiReadBufSize, the receiving of data is completed.
*2: The data length includes both start and end characters.

 COMRS_SET_VALUE

Setting Value
Name Function Data Type
(Default value)
The length of packet to be
uiWriteLen sent UINT 0–1000(0)
(Unit: Byte)
The memory address of
pWriteBuf POINTER TO BYTE --
packet to be sent

22 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

Setting Value
Name Function Data Type
(Default value)
The memory address of
pReadBuf POINTER TO BYTE --
packet to be stored
The memory size of packet
uiReadBufSize to be stored UINT 1–1,000 (100)
(Unit: Byte)
Packet interval
uiDiscontinuousTime UINT 2–3,000 (2)
(Unit: ms)
BYTE
byStartCharAmt Size of the start character 1–255 (1)
(Unit: Byte)
Memory address of the start
pSpecificStartChar POINTER TO BYTE Memory address (0)
character
BYTE
byEndCharAmt Size of the end character 1–255 (1)
(Unit: Byte)
Memory address of the end
pSpecificEndChar POINTER TO BYTE Memory address (0)
character
UINT
uiSpecificRxLen Specified receiving length 1–1000 (1)
(Unit: Byte)

T#0ms–
tTimeout Communication time-out TIME T#49d17h2m47s295ms(T#100ms)
T#0ms: No time-out

• Output

Output Range(Default
Name Function Data Type
value)
bDone FB is completed. BOOL True/False (False)
True when the instruction is
bBusy BOOL True/False (False)
running
bError True if an error occurs BOOL True/False (False)
Indicates the error code if an DFB_COM_ERROR_
ErrorID (DFB_UNDEFINED)
error occurs. CODE
UINT
uiRcvLen The length of the data received (0)
(Unit: Byte)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bDone  When FB is completed  When bExecute shifts to False
 When the running of FB is completed
bBusy  When FB starts  bExecute shifts to False and the running
of FB is completed.
bError  When bExecute shifts to False

22 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

Name Timing for shifting to True Timing for shifting to False


 When an error occurs during the running
ErrorID
or there are incorrect input values

• Timing Diagram

• Function
The FB instruction (DFB_COMRS) is used for sending communication data. You must finish the configuration of
COM port of CPU and add Delta_Modbus_Master_COM_Port device before using this instruction (For more
details, refer to chapter 9.2 Serial Port Communication in AX-3 Series Operational Manual).

• Programming Example
This example used DFB_COMRS to send COM communication data.

For AX-3 series controller, the definition of COM port name can be found in Library Manager as shown below.

22 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

• Supported Products

 AX series
Note 1: In the AX-8 series, only AX-864E30xE2T is supported.
Note 2: AX-332E (Library firmware version: 1.0.6.0 and later).

• Library

 DL_COM.library
Note: From version 1.0.6.0, library DL_COM_AX3 is changed to DL_COM.

22 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

7.2 DFB_ModbusComChannel
DFB_ModbusComChannel: Modbus Slave COM Port Channel control instruction.

FB/FC Instruction Graphic Expression ST Language

DFB_ModbusComChannel(
Slave:= ,
bExecute:= ,
bAbort:= ,
DFB_ iChannelIndex:= ,
FB
ModbusComChannel bBusy=> ,
bDone=> ,
bError=> ,
bAborted=> ,
ModbusError=> );

• In/ Outs

Setting Value
Name Function Data Type
(Default value)
Delta Modbus slave
Slave DFB_ModbusComSlave --
device

• Input

Setting Value
Name Function Data Type
(Default value)
Run the function block.
bExecute BOOL True/False (False)
(Rising-edge triggered)
bAbort No function BOOL --
0–9
iChannelIndex Channel index INT
(0)

• Output

Name Function Data Type Output Range(Default value)


True when the
bBusy BOOL True/False (False)
instruction is running
The running of FB is
bDone BOOL True/False (False)
complete.
bError True if an error occurs BOOL True/False (False)
bAborted No function BOOL --
DL_MB_ERROR_CODE
ModbusError Error code DFB_MB_ERROR_CODE
(UNDEFINED)

22 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

 Output Updating Timing

Name Timing for shifting to True Timing for shifting to False


bDone  When the running of FB is complete  When bExecute shifts to False
 When the running of FB is complete
bBusy  When the running of FB starts  bExecute shifts to False and the
running of FB is completed.
bError  When an error occurs during the running
 When bExecute shifts to False
ModbusError or there are incorrect input values

• Timing Diagram

• Function
When the trigger mode of the Modbus slave channel is set to Application, the Modbus request action will be
triggered by DFB_ModbusComChannel.

Note:
1. For more details of Modbus slave COM port configuration, you can refer to chapter 9.2 Serial
Communication in AX-3 Series Operational Manual.
2. While using, the channel must be set to Enable.

• Programming Example
This example uses DFB_ModbusComChannel to trigger data exchange with Modbus COM port communication.

22 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

*Note: The input of Slave would be the name of Modbus slave device.

• Supported Products

 AX-3, AX-864E30xE2T, AX-C


Note: AX-332E, AX-864E30xE2T, AX-C (Library firmware version: 1.0.6.0 and later)

• Library

 DL_ModbusComMaster.library
Note: From version 1.0.6.0, library DL_ModbusComMaster_AX3 is changed to DL_ModbusComMaster.

22 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

7.3 DFB_ModbusRequest
DFB_ModbusRequest: Modbus communication commands.

FB/FC Instruction Graphic Expression ST Language

DFB_ModbusRequest(
byComPort:= ,
bExecute:= ,
bAbort:= ,
usiSlaveAddr:= ,
uiFunctionCode:= ,
uiReadOffset:= ,
uiReadLen:= ,
uiWriteOffset:= ,
DFB_
FB uiWriteLen:= ,
ModbusRequest
tTimeout:= ,
pWriteBuf:= ,
pReadBuf:= ,
transmission:= ,
bBusy=> ,
bDone=> ,
bError=> ,
bAborted=> ,
ModbusErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
byComPort*1 COM port number BYTE (0xFF)
Run the function block.
bExecute BOOL True/False (False)
(Rising-edge triggered)
bAbort No function BOOL --
usiSlaveAddr Slave station number USINT 1~247
Supported function codes:
0x01: Read Coils
0x02: Read Discrete Inputs
0x03: Read Holding Registers
0x04: Read Input Registers
uiFunctionCode Modbus function code DFB_MB_FUNC_CODE 0x05: Write Single Coil
0x06: Write Single Register
0x0F: Write Multiple Coils
0x10: Write Multiple Registers
0x17: Read/Write Multiple
Registers (0x03)
The start address of 0–65535
uiReadOffset UINT
memory to be read. (0)

22 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

Setting Value
Name Function Data Type
(Default value)
Coil: 1–1920
The data length of the
uiReadLen UINT Register: 1–120
memory to be read.
(1)
The start address of
uiWriteOffset UINT 0–65535(0)
memory to be written.
Coil: 1–1920
The data length of the
uiWriteLen*5 UINT Register: 1–120
memory to be written
(1)
T#0ms–T#49d17h2m47s295ms
Communication time-
tTimeout*2 TIME 0: No time-out
out
(T#100ms)
The memory address
pWriteBuf POINTER TO BYTE --
of data to be sent.
The memory address
pReadBuf POINTER TO BYTE --
of data to be stored.
0: ASCII
DFB_MB_
Transmission*3 Transmission mode 1: RTU
TRANSMISSION
(ASCII)

*Note:
1. You need to configure the settings based on the definitions of COM port numbers varied from model to model.
2. The time-out should be greater than the Cycle time set in mdbus Task.
3. When the transmission mode is set to RTU, the data bit of Modbus COM port must be set to 8.
4. If uiReadLen is set to 0, the Modbus read command will not be sent.
5. If uiWriteLen is set to 0, the Modbus write command will not be sent.

• Output

Name Function Data Type Output Range(Default value)


True when the
bBusy BOOL True/False (False)
instruction is running
The running of FB is
bDone BOOL True/False (False)
completed.
bError True if an error occurs BOOL True/False (False)
bAborted No function BOOL --
DL_MB_ERROR_CODE
ModbusError Error code DFB_MB_ERROR_CODE
(DFB_UNDEFINED)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bDone  When the running of FB is complete  When bExecute shifts to False
bBusy  When the running of FB starts  When the running of FB is complete

23 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

 bExecute shifts to False and the running of


FB is completed.
bError  When an error occurs during the
running or there are incorrect input  When bExecute shifts to False
ModbusError values

• Timing Diagram

• Function
The FB instruction (DFB_ModbusRequest) is used for sending Modbus communication data. You must finish the
configuration of COM port of CPU and add Delta_Modbus_Master_COM_Port device before using this
instruction. (For more details, refer to chapter 9.2 Serial Port Communication in AX-3 Series Operational Manual.)

• Programming Example
This example uses DFB_ModbusRequest to send Modbus commands for reading a 10-word long data (Holding
Registers) in the slave station (Slave address = 2), which the start address is 0x0000.

• Supported Products

 AX-3, AX-864E30xE2T, AX-C

23 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

Note: AX-332E, AX-864E30xE2T, AX-C (Library firmware version: 1.0.6.0 or later)

• Library

 DL_ModbusComMaster.library
Note: From version 1.0.6.0, library DL_ModbusComMaster_AX3 is changed to DL_ModbusComMaster.

23 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

7.4 DFB_ModbusRequest2
DFB_ModbusRequest2: Modbus communication commands.

FB/FC Instruction Graphic Expression ST Language

DFB_ModbusRequest2(
bExecute:= ,
bAbort:= ,
byComPort:= ,
usiSlaveAddr:= ,
ModbusCommand:= ,
tResponseTimeout:= ,
uiSendTimeout:= ,
DFB_
FB pSendData:= ,
ModbusRequest2
pRecvData:= ,
transmission:= ,
bDone=> ,
bBusy=> ,
bError=> ,
bAborted=> ,
uiDataLength=> ,
ModbusErrorCode=> );

• Input

Setting Value
Name Function Data Type
(Default value)
Run the function block.
bExecute BOOL True/False (False)
(Rising-edge triggered)
bAbort No function BOOL --
byComPort*1 COM port number BYTE (0xFF)
usiSlaveAddr Slave station number USINT 1~247
DFB_MODBUS_
ModbusCommand Modbus parameter setting --
COMMAND
T#0ms–
T#49d17h2m47s295ms
tResponseTimeout*2 Communication time-out TIME
0: No time-out
(T#100ms)
uiSendTimeout No function UINT (0)
The memory address of data to
pSendData POINTER TO BYTE --
be sent
The memory address of
pRecvData POINTER TO BYTE --
received data to be stored
0: ASCII
DFB_MB_
Transmission*3 Transmission mode 1: RTU
TRANSMISSION
(ASCII)

23 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

*Note:
1. You need to configure the settings based on the definitions of COM port numbers varied from model to
model.
2. The time-out should be greater than the Cycle time set in mdbus Task.
3. When the transmission mode is set to RTU, the data bit of Modbus COM port must be set to 8.

• DFB_MODBUS_COMMAND

Name Function Data Type Output Range(Default value)


Supported function code:
0x01: Read Coils
0x02: Read Discrete Inputs
0x03: Read Holding Registers
0x04: Read Input Registers
DFB_MB_FUNC_
uiFunctionCode Modbus function code 0x05: Write Single Coil
CODE
0x06: Write Single Register
0x0F: Write Multiple Coils
0x10: Write Multiple Registers
0x17: Read/Write Multiple Registers
(0x03)
The start address of 0–65535
uiReadOffset UINT
memory to be read. (0)
Coil: 1–1920
The data length of the
uiReadLen UINT Register: 1–120
memory to be read.
(1)
The start address of 0–65535
uiWriteOffset UINT
memory to be written. (0)
Coil: 1–1920
The data length of the
uiWriteLen UINT Register: 1–120
memory to be written
(1)

• Output

Name Function Data Type Output Range(Default value)


True when the
bBusy BOOL True/False (False)
instruction is running
The running of FB is
bDone BOOL True/False (False)
complete.
bError True if an error occurs. BOOL True/False (False)
bAborted No function BOOL --
The received data BYTE
uiDataLength (0)
length (Unit: BYTE)
DL_MB_ERROR_CODE
ModbusError Error code DFB_MB_ERROR_CODE
(DFB_UNDEFINED)

 Outputs Updating Timing

23 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

Name Timing for shifting to True Timing for shifting to False


bDone  When the running of FB is complete  When bExecute shifts to False
 When the running of FB is completed
bBusy  When the running of FB starts
 bExecute shifts to False.
bError  When an error occurs during the
running or there are incorrect input  When bExecute shifts to False
ModbusError values

• Timing Diagram

• Function
The FB instruction (DFB_ModbusRequest2) is used for sending Modbus communication data. You must finish
the configuration of COM port of CPU and add Delta_Modbus_Master_COM_Port device before using this
instruction. (For more details, Refer to chapter 9.2 “Serial Port Communication” in AX-3 Series Operational
Manual.)

• Programming Example
This example uses DFB_ModbusRequest2 to send Modbus commands for reading a 100-WORD long data
(Holding Registers) in the slave station (Slave address = 2), which the start address is 0x0000.

23 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

• Supported Products

 AX-3, AX-864E30xE2T, AX-C


Note: AX-332E, AX-864E30xE2T, AX-C (Library firmware version: 1.0.6.0 or later)

• Library

 DL_ModbusComMaster.library
Note: From version 1.0.6.0, library DL_ModbusComMaster_AX3 is changed to DL_ModbusComMaster.

23 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

7.5 Error codes and Troubleshooting

• DFB_COM_ERROR_CODE

Description Cause of Error Corrective Action


DFB_NO_ERROR No errors. --
 Check whether the setting for time-out is
appropriate or not.
DFB_RESPONSE_TIMEOUT Slave response time-out
 Check on the correctness of
communication wiring.
DFB_REQUEST_FAILED_
COM Port errors Contact us directly.
TO_SEND
Check on the correctness of the COM port
DFB_INVALID_COMPORT COM port setting errors
settings.
Check if the below parameter settings are
Invalid memory address for correct.
DFB_INVALID_BUFFER
sending and receiving data.  ParaSet.pWriteBuf
 ParaSet.pReadBuf
Check if the below parameter settings are
correct.
DFB_INVALID_LENGTH Invalid data length setting  ParaSet.uiReadLen
 ParaSet.uiReadBufSize
 ParaSet.uiWriteLen
DFB_NO_MASTER_ Delta_Modbus_Master_COM_Port Check if Delta_Modbus_Master_COM_Port
CONFIG device does not exist. device have been added to the device tree.
DFB_MEMORY_NOT_ Check if the program size exceeds the
Not enough system memory
ENOUGH allowable limit.
Invalid receiving mode set in
DFB_INVALID_MODE Check if the RxMode setting is correct.
DFB_COMRS.
Check if the below parameter settings are
correct.
 ParaSet.tTimeout
DFB_INVALID_SETTING Invalid parameter setting  ParaSet.uiDiscontinuousTime
 ParaSet.byEndCharAmt
 ParaSet.byStartCharAmt
 ParaSet.uiSpecificRxLen
Check if the below parameter settings are
DFB_INVALID_CHAR_ Invalid memory address of correct.
BUFFER characters.  ParaSet.pSpecificStartChar
 ParaSet.pSpecificEndChar
Undefined or has not yet been Wait for the running of FB instruction being
DFB_UNDEFINED
Run. completed.

• DFB_MB_ERROR_CODE

Description Cause of Error Corrective Action


DFB_NO_ERR No errors -
Check on the correctness of
DFB_ILLEGAL_FUNCTION Unsupported function code
the function code you’re using.
Check on the correctness of
DFB_ILLEGAL_DATA_ Illegal memory address to write
memory address you intend to
ADDRESS and read.
write and read.
23 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

Description Cause of Error Corrective Action


Check if the slave wires
DFB_ILLEGAL_DATA_ Illegal data values responded
function normally as well as the
VALUE by slave.
proper wiring.
DFB_SLAVE_DEVICE_ Check slave settings and
Slave failure
FAILURE statuses.
Slave has received request, but
DFB_ACKNOWLEDGE N/A
it takes longer to handle.
DFB_SLAVE_DEVICE_
Slave is busy. N/A
BUSY
DFB_GATEWAY_PATH_ Check Gateway configuration,
Wrong Gateway path
UNAVAILABLE or Gateway is busy.
Check if the slave wires
DFB_GATEWAY_DEVICE_FAILED_TO_RESPO Slave device in Gateway fails
function normally as well as the
ND to respond.
proper wiring.
 Check if the duration set
for the time-out is less
DFB_RESPONSE_ No response from slave in than the responded time of
TIMEOUT time. slave.
 Check on the correctness
of the wiring.
Check on the correctness of
DFB_RESPONSE_CRC_ Illegal data values responded
data format responded by
ERROR by slave. (Invalid check code)
slave.
Illegal data values responded Check on the correctness of
DFB_RESPONSE_
by slave. (Invalid station data format responded by
WRONG_SLAVE
number) slave.
DFB_RESPONSE_ Illegal data values responded Check on the correctness of
WRONG_ by slave. (Invalid function data format responded by
FUNCTIONCODE code) slave.
DFB_REQUEST_FAILED_TO_SEND Failed to send data. Contact the vendor directly.
Illegal data values responded Check on the correctness of
DFB_RESPONSE_
by slave. (Non-standard data format responded by
INVALID_PROTOCOL
Modbus format) slave.
Check on the correctness of
DFB_RESPONSE_ Illegal data values responded
data format responded by
INVALID_HEAD by slave. (Invalid data length)
slave.
Invalid index of the slave Check if the index of slave
DFB_INVALID_CHANNEL_INDEX
channel channel is correct.
The trigger mode of slave
Make sure the trigger mode
DFB_CHANNEL_SETTING_NOT_SUPPORT channel is not set to
has been set to “Application”.
“Application”.
Invalid COM port number of Check if the COM port number
DFB_INVALID_COMPORT
the controller. is correct.
Check if the below parameter
settings are correct.
ModbusRequest:
 pWriteBuf
Invalid memory address setting  pReadBuf
DFB_INVALID_BUFFER
to send and receive data. ModbusRequest2:
 ModbusCommand.pWrite
Buf
 ModbusCommand.pRead
Buf
Check if the below parameter
DFB_INVALID_LENGTH Invalid data length setting.
settings are correct.

23 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 7

Description Cause of Error Corrective Action


ModbusRequest:
 uiWriteLen
 uiReadLen
ModbusRequest2:
 ModbusCommand.uiWrite
Len
 ModbusCommand.uiRead
Len
DFB_INVALID_SLAVE_ Make sure the station number
Invalid slave station number.
ADDRESS is set to be within 1~247.

Invalid setting for Check if the setting value of


DFB_INVALID_FUNCTION_CODE
uiFunctionCode. uiFunctionCode is correct,
Make sure that
DFB_NO_MASTER_ Delta_Modbus_Master_COM_ Delta_Modbus_Master_COM_
CONFIG Port device does not exist. Port device has been added to
the device tree.
DFB_MB_ERROR_CODE_MEMORY_NOT_EN Check if the program size
Not enough system memory.
OUGH exceeds the allowable limit.
Undefined or has not yet been Wait for the running of FB
DFB_UNDEFINED
Run. instruction being completed.

23 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

Chapter 8 Network Communication Instructions

24 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

8.1 DFB_TCP_Client
DFB_TCP_Client: TCP socket client instruction.

FB/FC Instruction Graphic Expression ST Language

DFB_TCP_Client(
bEnable:= ,
SocketInfo:= ,
bSend:= ,
bRecvRestart:= ,
bBusy=> ,
FB DFB_ TCP_Client bConnected=> ,
bSent=> ,
bRcvd=> ,
bError=> ,
ErrorID=> ,
Status=> ,
uiRcvdLen=> );

• Input

Setting Value
Name Function Data Type
(Default value)

bEnable Run the function block. BOOL True/False (False)


*1*2
Connection information on tcpClientSocketInfo
SocketInfo --
Server
Send data packets. BOOL True/False (False)
bSend
(Rising-edge triggered)
Restart to receive data True/False (False)
bRecvRestart packets. *2 BOOL
(Rising-edge triggered)

*1 As soon as this function block is running, TCP connection will start to be created. Once connected, the output
bConnected would be ON.
*2 After the function block is running, it starts receiving data packets. When the data receiving is completed and
stopped, bRcvd would be ON. If you shift bRecvRestart to ON, the FB will restart to receive data.

 tcpClientsocketInfo

Setting Value
Name Function Data Type
(Default value)
byIPAddr Server’s IP address ARRAY [0..3] OF BYTE --

0: Use a random port number


uiLPort Communication ports UINT 0–65535
on local device
(0)

24 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

Setting Value
Name Function Data Type
(Default value)
0: Illegal
uiRPort Communication ports UINT 1–65535
on remote device
(0)

0: No time-out
uiTimeout Response time-out UINT 1–65535
(Unit: ms)
(0)

0: No time-out
The time that the
uiKeepAliveTimeout socket keeps alive. UINT 1–65535
(Unit: sec) (0)

True/False (False)
True:
When connection time-out or
failed, it would try to rebuilt the
bReconnect Auto-reconnect BOOL connection automatically.
function
False:
When connection time-out or
failed, the output bError would
be ON.

pSendBuf The memory address POINT TO BYTE --


of data to be sent
0–8192
uiSendLen The length of data to UINT
be sent (Unit: Byte) (0)

The memory address


pRecvBuf where the received POINT TO BYTE --
data to be stored.
The memory size of
0–8192
uiRecvBufSize received data UINT
(0)
(Unit: Byte)

uiSetValue The setting value of UINT (0)


recvCondition

recvCondition Conditions for data DFB_SOCK_RECV_MODE ( DFB_SOCKET_NO_RECEVING )


receiving completion

 DFB_SOCK_RECV_MODE

24 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

Name Description
DFB_SOCK_MODE_NO_REC
No receiving data mode.
EVING
Specific data length mode:
DFB_SOCK_MODE_SPECIFI A specific quantity of data is received and the receiving task is completed.
C_LENGTH The data length can be specified via uiSetValue.
(Unit: Byte)
Specific end character mode:
The data received ends with a specific character (1 Byte).
DFB_SOCK_MODE_SPECIFI
The end character can be configured via uiSetValue.
C_SINGLE_CHAR
e.g.: If uiSetValue is set to 16#00000D0A, the end character would be
16#0A.(*1*2)
Specific two end characters mode:
The data received ends with the two specific characters (2 Bytes)
DFB_SOCK_RECV_MODE_D
The end character can be configured via uiSetValue
FB_SOCK_MODE_SPECIFIC
_TWO_CHARS e.g.: If uiSetValue is set to 16#00000D0A, the end characters would be
16#0D0A.
(*1*2)
Specific start character and end character mode:
The data received starts with a specific character, and ends with a specific
DFB_SOCK_RECV_MODE_D character.
FB_SOCK_MODE_SPECIFIC
Both the start and the end character can be configured via uiSetValue.
_START_CHAR_AND_SPECI
FIC_END_CHAR e.g.: If uiSetValue is set to 16#00003A0A, the start character would be 16#3A
and the end character is 16#0A.
(*1*2)

DFB_SOCK_RECV_MODE_D Any length mode:


FB_SOCK_MODE_ANY_LEN The receiving ends with a complete data of any length.
GTH (*1)

*1: When the length of received data reaches the limit set in pRecvLen, the receiving task would be completed.
*2: The data length includes both start and end characters.

• Output

Name Function Data Type Output Range(Default value)


True when the instruction is BOOL
bBusy True/False (False)
running.

bConnected TCP is connected. BOOL True/False (False)

bSent Sending complete BOOL True/False (False)

bRcvd Receiving complete BOOL True/False (False)

bError True if an error occurs BOOL True/False (False)

Indicates the error code if DFB_SOCKET_ERROR


ErrorID (DFB_SOCK_NO_ERROR)
an error occurs.

24 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

Name Function Data Type Output Range(Default value)


The running status of DFB_SOCKET_STATUS
Status (SOCKET_CLOSED)
socket
UINT
uiRcvLen The length of received data (0)
(Unit: Byte )

 DFB_SOCKET_STATUS

Name Description Applicable Protocol


SOCKET_CLOSED SOCKET connection is closed. TCP / UDP

SOCKET_CONNECTING SOCKET is connecting. TCP

SOCKET_CONNECTED SOCKET is connected. TCP

SOCKET_SENDING SOCKET is sending the data packet. TCP / UDP

SOCKET_SENT SOCKET has sent the data packet. TCP / UDP

SOCKET_RECEIVED SOCKET has received the data packet. TCP / UDP

SOCKET_ERROR SOCKET has errors. TCP / UDP

SOCKET_ABORTED SOCKET connection is interrupted. TCP

SOCKET_READY SOCKET connection is ready. UDP

• Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


 When bEnable shifts to True  When bEnable shifts to False
bBusy
 When bSend shifts to True  When the task is completed
 When bEnable shifts to False
bConnected  When the TCP connection is created  When the TCP connection is interrupted
on the server side
 When bEnable shifts to False
bSent  When a data packet is sent over TCP
 When bSend shifts to True
 When bEnable shifts to False
bRcvd  When a data packet is received over TCP
 When bRecvRestart shifts to True
 When an error occurs during running or the
bError  When bEnable shifts to False
input value of the instruction is incorrect

• Timing Diagram

24 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

• Function
Use the FB instruction (DFB_TCP_Client) to create TCP connection so as to send or receive TCP data
packets.

Note: DFB_TCP_Client, DFB_TCP_Server, and DFB_UDP_Socket instructions can be used in a maximum of


32 groups at the same time.

• Programming Example
This example uses the FB instruction (DFB_TCP_Client) and Server (IP address: 192.168.1.111, Port: 25000)
to establish connection and send 200 Bytes packet. It is expected that Server will send back the same 200
Bytes package. After Server has finished sending back the package, 200 Bytes package will be resent.

24 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

• Supported Products

 AX-3, AX-864E30xE2T

24 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

Note: AX-332E, AX-864E30xE2T (Library firmware version: 1.0.6.0 or later)

• Library

 DL_EthernetLib.library
Note: From version 1.0.6.0, library DL_ EthernetLib_AX3 is changed to DL_EthernetLib.

24 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

8.2 DFB_TCP_Server
DFB_TCP_Server: TCP socket server instruction

FB/FC Instruction Graphic Expression ST Language

DFB_TCP_Server(
bEnable:= ,
SocketInfo:= ,
bSend:= ,
bRecvRestart:= ,
bBusy=> ,
FB DFB_ TCP_Server bConnected=> ,
bSent=> ,
bRcvd=> ,
bError=> ,
ErrorID=> ,
Status=> ,
uiRcvdLen=> );

• Input

Setting Value
Name Function Data Type
(Default value)

bEnable Run the function block. BOOL True/False (False)


*1*2
Connection tcpServerSocketInfo
SocketInfo --
information on Server
Send data packets. BOOL True/False (False)
bSend
(Rising-edge triggered)
Restart to receive data True/False (False)
bRecvRestart packets.*2 BOOL
(Rising-edge triggered)

*1 As soon as this function block is running, TCP connection will start to be created. Once connected, the output
bConnected would be ON.
*2 After the function block is running, it starts receiving data packets. When the data receiving is completed and
stopped, bRcvd would be ON. If you shift bRecvRestart to ON, the FB will restart to receive data.

 tcpServersocketInfo

Setting Value
Name Function Data Type
(Default value)
The IP address on
byIPAddr Client side allowed to ARRAY [0..3] OF BYTE [0.0.0.0]: No limit.
be connected.
0: Illegal values.
uiLPort Communication ports UINT
on local device 1–65535

24 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

Setting Value
Name Function Data Type
(Default value)
(0)

0: No time-out.
Communication time-
uiTimeout out UINT 1–65535
(Unit: ms) (0)

The time that the 0: No time-out.


uiKeepAliveTimeout connection keeps UINT 1–65535
alive.
(Unit: sec ) (0)

pSendBuf The memory address POINT TO BYTE --


of data to be sent
0–8192
uiSendLen The length of data to UINT
be sent (Unit: Byte) (0)

The memory address


pRecvBuf where the received POINT TO BYTE --
data to be stored
The memory size of
0–8192
uiRecvBufSize received data UINT
(0)
(Unit: Byte)

uiSetValue The setting value of UINT (0)


recvCondition

recvCondition Conditions for data DFB_SOCK_RECV_MODE ( DFB_SOCKET_NO_RECEVING )


receiving completion

 DFB_SOCK_RECV_MODE

Name Description
DFB_SOCK_MODE_NO_RECEVING No receiving data mode.
DFB_SOCK_MODE_SPECIFIC_LENGTH Specific data length mode:
A specific quantity of data is received and
the receiving task is completed.
The data length can be specified via
uiSetValue.
(Unit: Byte)
DFB_SOCK_MODE_SPECIFIC_SINGLE_CHAR Specific end character mode:
The data received ends with a specific
character (1 Byte).
The end character can be configured via
uiSetValue.
e.g.: If uiSetValue is set to 16#00000D0A,

24 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

the end character would be 16#0A.(*1*2)


DFB_SOCK_RECV_MODE_DFB_SOCK_MODE_ Specific two end characters mode:
SPECIFIC_TWO_CHARS The data received ends with the two specific
characters (2 Bytes)
The end character can be configured via
uiSetValue
e.g.: If uiSetValue is set to 16#00000D0A,
the end characters would be 16#0D0A.

DFB_SOCK_RECV_MODE_DFB_SOCK_MODE_SPECIFIC Specific start character and end character


mode:
_START_CHAR_AND_SPECIFIC_END_CHAR
The data received starts with a specific
character, and ends with a specific
character.
Both the start and the end character can be
configured via uiSetValue.
e.g.: If uiSetValue is set to 16#00003A0A,
the start character would be 16#3A and the
end character is 16#0A. (*1*2)
DFB_SOCK_RECV_MODE_DFB_SOCK_MODE_ANY_LENGTH Any length mode:
The receiving ends with a complete data of
any length. (*1)

*1: When the length of received data reaches the limit set in pRecvLen, the receiving task would be completed.
*2: The data length includes both start and end characters.

• Output

Name Function Data Type Output Range(Default value)


True when the BOOL
bBusy True/False (False)
instruction is running

bConnected TCP is connected. BOOL True/False (False)

bSent Sending completed BOOL True/False (False)

bRcvd Receiving completed BOOL True/False (False)

bError True if an error occurs BOOL True/False (False)

Indicates the error DFB_SOCKET_ERROR


ErrorID (DFB_SOCK_NO_ERROR)
code if an error occurs.
The running status of DFB_SOCKET_STATUS
Status (SOCKET_CLOSED)
socket
UINT
The length of received (0)
uiRcvLen
data (Unit: Byte )

 DFB_SOCKET_STATUS

25 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

Name Description Applicable Protocol


SOCKET_CLOSED SOCKET connection is closed. TCP / UDP

SOCKET_CONNECTING SOCKET is connecting. TCP

SOCKET_CONNECTED SOCKET is connected. TCP

SOCKET_SENDING SOCKET is sending the data packet. TCP / UDP

SOCKET_SENT SOCKET has sent the data packet. TCP / UDP

SOCKET_RECEIVED SOCKET has received the data packet. TCP / UDP

SOCKET_ERROR SOCKET has errors. TCP / UDP

SOCKET_ABORTED SOCKET connection is interrupted. TCP

SOCKET_READY SOCKET connection is ready. UDP

• Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


 When bEnable shifts to True  When bEnable shifts to False
bBusy
 When bSend shifts to True  When the task is complete
 When bEnable shifts to False
bConnected  When the TCP connection is created  When the TCP connection is interrupted on
the server side
 When bEnable shifts to False
bSent  When a data packet is sent over TCP
 When bSend shifts to True
 When a data packet is received over  When bEnable shifts to False
bRcvd
TCP  When bRecvRestart shifts to True
 When an error occurs during running or
bError the input value of the instruction is  When bEnable shifts to False
incorrect

• Timing Diagram

25 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

• Function
Use the FB instruction (DFB_TCP_Server) to create TCP connection so as to send or receive TCP data packets.

Note: DFB_TCP_Client, DFB_TCP_Server, and DFB_UDP_Socket instructions can be used in a maximum of


32 groups at the same time.

• Programming Example
 This example uses the FB instruction (DFB_TCP_ Server) to open TCP (Port: 20000) and restrict the IP
address of Client to be 192.168.1.111, while expecting to receive the package of 200 Bytes data length.
After receiving is finished, the same 200 Bytes package will be sent back.

25 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

• Supported Products

 AX-3, AX-864E30xE2T
Note: AX-332E, AX-864E30xE2T (Library firmware version: 1.0.6.0 or later)

• Library

25 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

 DL_EthernetLib.library
Note: From version 1.0.6.0, library DL_ EthernetLib_AX3 is changed to DL_EthernetLib.

25 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

8.3 DFB_UDP_Socket
DFB_UDP_Socket: UDP socket instruction

FB/FC Instruction Graphic Expression ST Language

DFB_UDP_Socket(
bEnable:= ,
RemoteInfo:= ,
bSend:= ,
bRecvRestart:= ,
bBusy=> ,
FB DFB_ UDP_Socket
bSent=> ,
bRcvd=> ,
bError=> ,
ErrorID=> ,
Status=> ,
uiRcvdLen=> );

• Input

Setting Value (Default


Name Function Data Type
Value)
Run the function block.
Enable BOOL True/False (False)

Connection information of
SocketInfo udpSocketInfo --
socket
Send data packets.
bSend BOOL True/False (False)
(Rising-edge triggered)
Restart to receive data
bRecvRestart packets*2 BOOL True/False (False)
(Rising-edge triggered)

*1 After the function block is running, it starts receiving data packets. When the data receiving is completed and
stopped, bRcvd would be ON. If you shift bRecvRestart to ON, the FB will restart to receive data.

 udpSocketInfo

Name Function Data Type Setting Value (Default value)

byIPAddr The slave IP address ARRAY [0..3] OF BYTE [0.0.0.0]: No limit.


allowed to be connected
0: Use a random port number to
send data packets.
uiLPort(*1) Communication ports UINT
on local device 0–65535
(0)

0: Receive data packets from a


uiRPort(*1*2) Communication ports UINT
on remote device random port.

25 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

Name Function Data Type Setting Value (Default value)


1–65535
(0)

pSendBuf The memory address of POINT TO BYTE --


data to be sent

uiSendLen The length of data to be UINT 0–8192


sent (Unit: Byte)
The memory address
pRecvBuf where the received data POINT TO BYTE --
to be stored
The memory size of
0–8192
uiRecvBufSize received data UINT
(0)
(Unit: Byte)

uiSetValue The setting value of UINT (0)


recvCondition

recvCondition Conditions for data DFB_SOCK_RECV_MODE ( DFB_SOCKET_NO_RECEVING )


receiving completion

*1: The values of uiLPort and uiRPort cannot be 0 at the same time.
*2: UDP data packets are not allowed to be sent when uiRPort is set to 0.

 DFB_SOCK_RECV_MODE

Name Description
DFB_SOCK_MODE_NO_RECEVING No receiving data mode.
Specific data length mode:
A specific quantity of data is
received and the receiving task
DFB_SOCK_MODE_SPECIFIC_LENGTH is completed.
The data length can be
specified via uiSetValue.
(Unit: Byte)
Specific end character mode:
The data received ends with a
specific character (1 Byte).
The end character can be
configured via uiSetValue.
DFB_SOCK_MODE_SPECIFIC_SINGLE_CHAR e.g.: If uiSetValue is set to
16#00000D0A, the end
character would be
16#0A.(*1*2)
Specific two end characters
mode:
DFB_SOCK_RECV_MODE_DFB_SOCK_MODE_SPECIFIC_TWO_CHARS The data received ends with
the two specific characters (2
Bytes)
The end character can be

25 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

configured via uiSetValue


e.g.: If uiSetValue is set to
16#00000D0A, the end
characters would be 16#0D0A.
(*1*2)
Specific start character and end
character mode:
The data received starts with a
specific character, and ends
with a specific character.
Both the start and the end
DFB_SOCK_RECV_MODE_DFB_SOCK_MODE_SPECIFIC_START_CHAR_ character can be configured via
uiSetValue.
AND_SPECIFIC_END_CHAR e.g.: If uiSetValue is set to
16#00003A0A, the start
character would be 16#3A and
the end character is 16#0A.
(*1*2)
Any length mode:
DFB_SOCK_RECV_MODE_DFB_SOCK_MODE_ANY_LENGTH The receiving ends with a
complete data of any
length.(*1)

*1: When the length of received data reaches the limit set in pRecvLen, the receiving task would be completed.
*2: The data length includes both start and end characters.

• Output

Name Function Data Type Output Range(Default value)


True when the BOOL
bBusy True/False (False)
instruction is running

bSent TCP is connected. BOOL True/False (False)

bRcvd Sending complete BOOL True/False (False)

bError Receiving complete BOOL True/False (False)

ErrorID True if an error occurs DFB_SOCKET_ERROR (DFB_SOCK_NO_ERROR)

Indicates the error DFB_SOCKET_STATUS


Status (SOCKET_CLOSED)
code if an error occurs.
UINT
The running status of (0)
uiRcvLen
socket (Unit: Byte )

 DFB_SOCKET_STATUS

25 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

Name Description Applicable Protocol


SOCKET_CLOSED SOCKET connection is closed. TCP / UDP

SOCKET_CONNECTING SOCKET is connecting. TCP

SOCKET_CONNECTED SOCKET is connected. TCP

SOCKET_SENDING SOCKET is sending the data packet. TCP / UDP

SOCKET_SENT SOCKET has sent the data packet. TCP / UDP

SOCKET_RECEIVED SOCKET has received the data packet. TCP / UDP

SOCKET_ERROR SOCKET has errors. TCP / UDP

SOCKET_ABORTED SOCKET connection is interrupted. TCP

SOCKET_READY SOCKET connection is ready. UDP

• Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


 When bEnable shifts to False
bBusy  When bSend shifts to True
 When the task is completed
 When the UDP data packet has been  When bEnable shifts to False
bSent
sent successfully  When bSend shifts to True
 When the UDP data packet has been  When bEnable shifts to False
bRcvd
received  When bRecvRestart shifts to True
 When an error occurs during running or
bError the input value of the instruction is  When bEnable shifts to False
incorrect

25 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

• Timing Diagram

• Function
Use the FB instruction (DFB_UDP_Socket) to send or receive UDP data packets.

Note: DFB_TCP_Client, DFB_TCP_Server, and DFB_UDP_Socket instructions can be used in a maximum of


32 groups at the same time.

• Programming Example
This example uses the FB instruction (DFB_UDP_Socket) to send 200 the package of 200 Bytes data length
to the device (IP address: 192.168.1.111, Port: 30001) from UDP (Port: 30000). It is expected that the same
package will be replied. After the device has finished returning the same package, 200 Bytes package will be
resent.

25 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

• Supported Products

 AX-3, AX-864E30xE2T
Note: AX-332E, AX-864E30xE2T (Library firmware version: 1.0.6.0 or later)

• Library

 DL_EthernetLib.library
Note: From version 1.0.6.0, library DL_ EthernetLib_AX3 is changed to DL_EthernetLib.

26 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

8.4 DFB_ModbusTCPChannel
DFB_ModbusTCPChannel: Modus TCP slave Channel control instruction

FB/FC Instruction Graphic Expression ST Language

DFB_ModbusTCPChannel(
slave:= ,
bExecute:= ,
bAbort:= ,
DFB_ iChannelIndes:= ,
FB
ModbusTCPChannel bBusy=> ,
bDone=> ,
bError=> ,
bAborted=> ,
ModbusError=> );

• In/ Outs

Name Function Data type Setting value (Default value)

Slave Delta Modbus TCP slave DFB_ModbusTCPSlave --


device

• Input

Name Function Data type Setting value (Default value)


Run the function block. BOOL
bExcute True/False (False)
(Rising-edge triggered)

bAbort No function BOOL --

INT 0–99
iChannelIndex Channel number
(0)

• Output

Name Function Data type Output range (Default value)


The FB instruction is BOOL
bBusy True/False (False)
running.
The FB instruction BOOL
bDone True/False (False)
running is complete.

bError FB instruction error flag BOOL True/False (False)

bAborted No function BOOL --

DFB_MB_ERROR_CODE DL_MB_ERROR_CODE
ModbusError Error codes
(UNDEFINED)

26 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

• Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


 When FB instruction running is
bDone  When bExecute shifts to False
completed
 When FB instruction running is complete
bBusy  When FB instruction running starts
 When bExecute shifts to False
bError  When an error occurs during running or
the input value of the instruction is  When bExecute shifts to False
ModbusError incorrect

• Timing Diagram

• Function
When the trigger mode of the Modbus slave channel is set to Application, the Modbus TCP request action can
be triggered by DFB_ModbusTCPChannel.

Note1: For more details of Modbus TCP slave configuration, Refer to chapter 9.3 “Ethernet Communication” in
AX-3 Series Operational Manual.
Note 2: While using, the channel must be set to Enable.
Note 3: DFB_ModbusTCPChannel and DFB_ModbusTCPRequest instructions can be used in a maximum of
32 groups at the same time.

• Programming Example

26 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

This example uses DFB_ModbusTCPChannel to trigger channel 0 of Modbus TCP Slave.

*Note: The input of Slave would be the name of Delta_Modbus_TCP_Slave device.

• Supported Products

 AX-3, AX-864E30xE2T, AX-C


Note: AX-332E, AX-864E30xE2T, AX-C (Library firmware version: 1.0.6.0 or later)

• Library

 DL_ModbusTCPMaster.library
Note: From version 1.0.6.0, library DL_ModbusTCPMaster _AX3 is changed to DL_ ModbusTCPMaster.

26 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

8.5 DFB_ModbusTCPRequest
DFB_ModbusTCPRequest: Mobus TCP instruction.

FB/FC Instruction Graphic Expression ST Language

DFB_ModbusTCPRequest(
slave:=
bExecute:= ,
bAbort:= ,
usiUnitID:= ,
ModbusCommand:= ,
DFB_
FB pSendData:= ,
ModbusTCPRequest
pRecvData:= ,
bBusy=> ,
bDone=> ,
bError=> ,
bAborted=> ,
ModbusError=> );

• In/ Outs

Name Function Data type Setting value (Default value)

Slave Delta Modbus TCP DFB_ModbusTCPSlave --


slave device

• Input

Name Function Data type Setting value (Default value)


Run the function block.
bExecute BOOL True/False (False)
(Rising-edge triggered)

bAbort No function BOOL --

usiSlaveAddr Slave station number USINT 1~247

ModbusCommand Modbus parameter setting ModbusCommand --

The memory address of


pSendData POINTER TO BYTE --
data to be sent

The memory address of


pRecvData POINTER TO BYTE --
received data to be stored

 Modbus Command

Name Function Data Type Output Range(Default value)

FunctionCode Modbus function codes DFB_MB_FUNC_CODE Supported function codes:

26 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

Name Function Data Type Output Range(Default value)


0x01: Read Coils
0x02: Read Discrete Inputs
0x03: Read Holding Registers
0x04: Read Input Registers
0x05: Write Single Coil
0x06: Write Single Register
0x0F: Write Multiple Coils
0x10: Write Multiple Registers
0x17:Read/Write Multiple Registers
( 0x03 )

The start address of 0–65535.


uiReadOffset UINT
memory to be read. (0)

Coil: 1–1992
The data length of the
uiReadLen UINT Register: 1–124.
memory to be read.
(1)

The start address of 0–65535.


uiWriteOffset UINT
memory to be written. (0)

Coil: 1–1960
The data length of the
uiWriteLen UINT Register: 1–122.
memory to be written
(1)

• Output

Name Function Data Type Output Range(Default value)


True when the BOOL
bBusy True/False (False)
instruction is running
The running of FB is BOOL
bDone True/False (False)
completed.

bError True if an error occurs BOOL True/False (False)

bAborted No function BOOL --

DFB_MB_ERROR_CODE DL_MB_ERROR_CODE
ModbusError Error code
(DFB_UNDEFINED)

 Output Updating Timing

26 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

Name Timing for shifting to True Timing for shifting to False


bDone  When the running of FB is completed  When bExecute shifts to False
 When the running of FB is completed
bBusy  When FB instruction running starts
 When bExecute shifts to False
bError  When an error occurs during the
running conditions or there are invalid  When bExecute shifts to False
ModbusError input values

• Timing Diagram

• Function
The FB instruction (DFB_ModbusTCPRequest) is used for sending Modbus communication data. You must
finish the configuration of Delta_Modbus_TCP_Master and Delta_Modus_TCP_Slave before using this
instruction. (For more details, refer to chapter 9.3 Ethernet Communication in AX-3 Series Operational
Manual.)

Note: DFB_ModbusTCPChannel and DFB_ModbusTCPRequest instructions can be used in a maximum of


32 groups at the same time.

• Programming Example
 This example uses DFB_ModbusTCPRequest to send standard Modbus command (0x17) for reading a
100-word long data in the slave station (Delta_Modbus_TCP_Slave), which the start address is 0x0000,
and writing a data of 100-word long to the start address 0x0100 in the memory.

26 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

• Supported Products

 AX-3, AX-864E30xE2T, AX-C


Note: AX-332E, AX-864E30xE2T, AX-C (Library firmware version: 1.0.6.0 or later)

• Library

 DL_ModbusTCPMaster.library
Note: From version 1.0.6.0, library DL_ModbusTCPMaster _AX3 is changed to DL_ ModbusTCPMaster.

26 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

8.6 DFB_SetIPConfig
DFB_SetIPConfig: Set the controller network configuration.

FB/FC Instruction Graphic Expression ST Language

DFB_SetIPConfig (
bExecute:= ,
byLanPort:= ,
strIPAddress:= ,
strSubMask:= ,
FB DFB_SetIPConfig
strGateway:= ,
bDone=> ,
bBusy=> ,
bError=> ,
eErrorID=>);

• Input

Name Function Data Type Setting Value (Default Value)


Run the function block.
bExecute BOOL True/False (False)
(Rising-edge triggered)
byLanPort Lan port Byte (1)
strIPAddress IP address String(15) (‘192.168.1.5’)
strMask Network mask String(15) (‘255.255.255.0’)
strGateway Gateway address String(15) (‘192.168.1.1’)

• Output

Name Function Data Type Setting Value (Default Value)

The running of FB is
bDone BOOL True/False (False)
complete.

bBusy The FB instruction is BOOL True/False (False)


running.
bError FB instruction error BOOL True/False (False)

DFB_SOCKET_ERROR
eErrorID Error code DFB_SOCKET_ERROR
(DFB_SOCK_NO_ERROR)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bDone  When the running of FB is complete  When bExecute shifts to False

bBusy  When the running of FB is complete


 When FB instruction running starts
 When bExecute shifts to False

26 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

bError
 When an error occurs during the running
 When bExecute shifts to False
ModbusError or there are incorrect input values

• Timing Diagram

• Function
You can set the network configuration of the AX series controller by DFB_SetIPConfig.
Note 1: If the controller has multiple independent network ports, the ports must be set to different domains,
such as 192.168.1.x and 192.168.2.y.
Note 2: If the AX controller network configuration is set by DFB_SetIPConfig, and the input parameter
strGateway is not set or set to 0.0.0.0, the GateWay setting of the AX controller will be cleared.
Note 3: If Enable Gateway and DNS Setting of the network port does not work, you cannot change the
gateway setting by DFB_SetIPConfig.

• Programming Example
In this example, the FB instruction (DFB_SetIPConfig) sets the IP address of the X1 network port of the
controller to 192.168.1.15.

26 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

• Supported Products

 AX-3 series (firmare v1.0.6.0 and later), AX-864E30xE2T


Note: AX-332E (firmware 1.0.5.8 and later)
AX-332E, AX-864E30xE2T (Library firmware version: 1.0.6.0 or later)

• Library

 DL_EthernetLib.library (v1.0.5.1 and later).

27 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

8.7 Error Codes and Troubleshooting


DFB_SOCKET_ERROR

Description Cause of Error Corrective Action


DFB_SOCK_ERR_NO_ERROR No errors. --

DFB_SOCK_ERR  Check if the server exists.


Socket connection failed.
_INITIALIZE_FAILED  Make sure the server configuration is correct.

DFB_SOCK_ERR
Socket connection refused. Make sure the server configuration is correct.
_CONNREFUSED

 Make sure the internet connection is normal.


DFB_SOCK_ERR TIMEDOUT Server time-out error
 Make sure the server configuration is correct.

DFB_SOCK_ERR Socket has not been  Wait for Socket being connected.
NOTCONNECTED connected.  Make sure the server configuration is correct.

FB instruction has not yet


DFB_SOCK_ERR CLOSED Make sure the input bEnable is ON.
effective.

DFB_SOCK_ERR Invalid setting values for FB


Check if the setting value of uiSetValue is correct.
INVALID_SETTING instruction.

Make sure the memory addresses given to


DFB_INVALID_BUFFER Invalid memory address
pSenbuf and pRecvbuf are correct.

Invalid setting value for data Make sure the input values of uiSendLen and
DFB_INVALID_LENGTH
length uiRecvLen are correct.

DFB_IP_ERR Invalid IP setting Make sure the IP setting is correct.

DFB_IP_SET_ERR Setting IP fail --

DFB_MASK_ERR Invalid Mask setting Make sure the Mask setting is correct.

DFB_MASK_SET_ERR Setting Mask fail --

DFB_GATEWAY_ERR Invalid Gateway setting Make sure the Gateway setting is correct.

• DFB_MB_ERROR_CODE

Description Cause of Error Corrective Action

DFB_NO_ERROR No errors --

Check on the correctness of


DFB_ILLEGAL_FUNCTION Unsupported function code. the function code you’re
using.

27 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

Description Cause of Error Corrective Action

Check on the correctness of


Illegal memory address to
DFB_ILLEGAL_DATA_ADDRESS memory address you intend
write and read.
to write and read.

Check if the slave wires


Illegal data values
DFB_ILLEGAL_DATA_VALUE function normally as well as
responded by slave.
the proper wiring.

DFB_SALVE_DEVICE_
Check slave settings and
Slave failure
FAILURE statuses.

Slave has received request,


DFB_ACKNOWLEDGE but it takes longer to N/A
handle.

DFB_SLAVE_DEVICE_
Slave is busy. N/A
BUSY

Check Gateway
DFB_GATEWAY_PATH_UNAVAILABLE Wrong Gateway path configuration, or Gateway is
busy.
DFB_GATEWAY_DEVICE_FAILED_TO_RESPON Check if the slave wires
Slave device in Gateway
function normally as well as
D fails to respond.
the proper wiring.
 Check if the duration
set for the time-out is
less than the
No response from slave in
DFB_RESPONSE_TIMEOUT responded time of
time. slave.
 Check on the
correctness of the
wiring.
Illegal data values Check on the correctness of
DFB_RESPONSE_CRC_ERROR responded by slave. (Invalid data format responded by
check code) slave.

Illegal data values Check on the correctness of


DFB_RESPONSE_WRONG_SLAVE responded by slave. (Invalid data format responded by
station number) slave.

Illegal data values Check on the correctness of


DFB_RESPONSE_WRONG_FUNCTIONCODE responded by slave. (Invalid data format responded by
function code) slave.

DFB_REQUEST_FAILED_TO_SEND Failed to send data. Contact the vendor directly.

27 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

Description Cause of Error Corrective Action

Illegal data values Check on the correctness of


DFB_RESPONSE_INVALID_PROTOCOL responded by slave. (Non- data format responded by
standard Modbus format) slave.

Illegal data values Check on the correctness of


DFB_RESPONSE_INVALID_HEAD responded by slave. (Invalid data format responded by
data length) slave.

Invalid index of the slave Check if the index of slave


DFB_INVALID_CHANNEL_INDEX
channel channel is correct.

The trigger mode of slave Make sure the trigger mode


DFB_CHANNEL_SETTING_NOT_SUPPORT channel is not set to has been set to
“Application”. “Application”.

Check the correctness of


DFB_INVALID_SLAVE Slave configuration error. DFB_ModbusTCPRequest
Slave configuration.

Check if the settings of


Invalid memory address
pWriteBuf and pReadBuf of
DFB_INVALID_BUFFER setting to send and receive
DFB_ModbusTCPRequest
data.
are correct.

Check if the settings of


uiReadLen and uiWriteLen
DFB_INVALID_LENGTH Invalid data length setting. of
DFB_ModbusTCPRequest
are correct.

Check if the settings of


Invalid slave station usiSlaveAddr of
DFB_INVALID_SLAVE_ADDRESS
number. DFB_ModbusTCPRequest
are correct.

DFB_INVALID_ Function block does not Check function block


FUNCTION_CODE support this function code. settings.

Check if Ethernet Adapter


DFB_NO_ETHERNET_ Ethernet Adapter device
device has been added to
CONFIG does not exist.
the device tree.

Delta_Modbus_TCP_Maste Check if
DFB_NO_MASTER_CONFIG
r device does not exist. Delta_Modbus_TCP_Maste

27 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 8

Description Cause of Error Corrective Action

r device has been added to


the device tree.

Not enough system Check if the program size


DFB_MEMORY_NOT_ENOUGH
memory exceeds the limit

 Check if the setting of


Modbus TCP Slave is
DFB_CONNECTION_
TCP connection time-out. correct.
TIMEOUT  Check on the
correctness of the
wiring
Check if the setting of
DFB_CONNECTION_
TCP connection failed. Modbus TCP Slave is
FAILED
correct.

Undefined or has not yet Wait for the running of the


DFB_UNDEFINED
been Run. FB instruction completed.

27 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 9

Chapter 9 Instructions for Reading and Writing a Memory


Card

27 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 9

9.1 DFB_MemoryRead
DFB_MemoryRead: Read a memory card.

FB/FC Instruction Graphic Expression ST Language

DFB_MemoryRead(
bExecute:= ,
FileInfo:= ,
FB DFB_MemoryRead bDone=> ,
bBusy=> ,
bError=> ,
ErrorID=> );

• Input

Setting Value
Name Function Data Type
(Default value)
Run the function block.
bExecute BOOL True/False (False)
(Triggered when True)
Parameter setting for
FileInfo DFB_READ_FILE_INFO
reading a file.

 DFB_READ_FILE_INFO

Name Function Data Type Setting Value (Default value)


sFilePath The name of the file to read. STRING (‘’)
DFB_DATA_MODE. ASCII_MODE
DFB_DATA_
wDataMode ASCII CODE / BINARY mode DFB_DATA_MODE.BINARY_MODE
MODE
(DFB_DATA_MODE.ASCII_MODE)
The display mode of data to be DFB_ASCIISHOW_MODE.DECIMAL
DFB_ASCII
wAsciiShowMode read. DFB_ASCIISHOW_MODE.HEX
SHOW_MODE
(Deximal/ Hexadecimal) (DFB_ASCIISHOW_MODE.DECIMAL)
DFB_DEC_DATATYPE.BYTE_SIZE
DFB_DEC_DATATYPE.WORD_SIZE
DFB_DEC_DATATYPE.DWORD_SIZE
DFB_DEC_DATATYPE.LWORD_SIZE
DFB_DEC_DATATYPE.SINT_SIZE
DFB_DEC_DATATYPE.USINT_SIZE
wAsciiDec Data type of the variables to be DFB_DEC_
DFB_DEC_DATATYPE.INT_SIZE
DataType read. DATATYPE
DFB_DEC_DATATYPE.UINT_SIZE
DFB_DEC_DATATYPE.DINT_SIZE
DFB_DEC_DATATYPE.UDINT_SIZE
DFB_DEC_DATATYPE.LINT_SIZE
DFB_DEC_DATATYPE.ULINT_SIZE
DFB_DEC_DATATYPE.REAL_SIZE

27 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 9

Name Function Data Type Setting Value (Default value)


DFB_DEC_DATATYPE.LREAL_SIZE
(DFB_DEC_DATATYPE.BYTE_SIZE)
The address of the start position
dwRead
to read the memory card’s DWORD (0)
StartPos
data.*
dwElement The length of the data in the 1–25,000
DWORD
Length controller’s memory card.* (0)
The address of the destination
POINTER TO
pDestination to store the controller’s memory NULL
BYTE
data.
*Note: The unit is defined in DFB_READ_FILE_INFO.wAsciiDecDataType.

• Output

Name Function Data type Output range (Default value)


The FB instruction
bDone BOOL True/False (False)
running is completed.
The FB instruction is
bBusy BOOL True/False (False)
running.
FB instruction error
bError BOOL True/False (False)
flags.
DL_MEMRW_ERROR
ErrorID Error codes DL_MEMRW_ERROR
(DFB_NO_ERR)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bDone  When FB instruction running is completed.  When bExecute shifts to False.
 When FB instruction running is
bBusy  When FB instruction running starts. completed.
 When bExecute shifts to False.
bError  When an error occurs during running or the
 When bExecute shifts to False.
ErrorID input value of the instruction is incorrect.

• Timing Diagram

27 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 9

• Function
Use the FB instruction (DFB_MemoryRead) to store the retrieved memory card data in the controller’s memory.

• Programming Example
This example uses the FB instruction (DFB_MemoryRead) to read the content of Test.csv file in the memory
card and store the data in the controller’s WORD-type array variable (ar_wVar0).

The content of Test.csv file in the memory card is shown as follows.

Values displayed in the Test.csv file


0 1 2 3 4 5

Read the four consecutive data starting from data 0 in the Test.csv file via the FB instruction(DFB_MemoryRead),
then store the retrieved data in the variable array(ar_wVar0), which the result would be ar_wVar0 := [0,1,2,3].

• Supported Products

 AX-3 series

• Library

 DL_MemRW_AX3.library

27 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 9

9.2 DFB_MemoryWrite
DFB_MemoryWrite: Write a memory card.

FB/FC Instruction Graphic Expression ST Language

DFB_MemoryWrite (
bExecute:= ,
FileInfo:= ,
FB DFB_MemoryWrite bDone=> ,
bBusy=> ,
bError=> ,
ErrorID=> );

• Input

Setting Value
Name Function Data Type
(Default value)
Run the function block.
bExecute BOOL True/False (False)
(Rising-edge triggered)
Parameter setting for
FileInfo DFB_WRITE_FILE_INFO
reading a file

 DFB_WRITE_FILE_INFO

Name Function Data Type Setting Value (Default value)


The name of the file
sFilePath STRING (‘’)
to create
DFB_DATA_MODE.ASCII_MODE
ASCII CODE /
wDataMode DFB_DATA_MODE DFB_DATA_MODE.BINARY_MODE
BINARY mode
(DFB_DATA_MODE.ASCII_MODE)
The display mode of DFB_ASCIISHOW_MODE.DECIMAL
data to be written. DFB_ASCIISHOW_ DFB_ASCIISHOW_MODE.HEX
wAsciiShowMode
(Deximal/ MODE (DFB_ASCIISHOW_MODE.DECIMAL)
Hexadecimal)
DFB_DEC_DATATYPE.BYTE_SIZE
DFB_DEC_DATATYPE.WORD_SIZE
DFB_DEC_DATATYPE.DWORD_SIZE
DFB_DEC_DATATYPE.LWORD_SIZE
Data type of the DFB_DEC_DATATYPE.SINT_SIZE
wAsciiDecData
variables to be DFB_DEC_DATATYPE DFB_DEC_DATATYPE.USINT_SIZE
Type
written DFB_DEC_DATATYPE.INT_SIZE
DFB_DEC_DATATYPE.UINT_SIZE
DFB_DEC_DATATYPE.DINT_SIZE
DFB_DEC_DATATYPE.UDINT_SIZE
DFB_DEC_DATATYPE.LINT_SIZE

27 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 9

Name Function Data Type Setting Value (Default value)


DFB_DEC_DATATYPE.ULINT_SIZE
DFB_DEC_DATATYPE.REAL_SIZE
DFB_DEC_DATATYPE.LREAL_SIZE
(DFB_DEC_DATATYPE.BYTE_SIZE)
DFB_ACCESS_MODE.NEW
DFB_ACCESS_MODE.APPEND
The access mode of DFB_
wAccessMode DFB_ACCESS_MODE.OVERWRITE
the file to be created ACCESS_MODE
DFB_ACCESS_MODE.INSERT
(DFB_ACCESS_MODE.NEW)
wCarriageReturn CRLF character* WORD (0)
The address of the
start position to write
dwWriteStartPos DWORD (0)
the memory card’s
data*
The length of the
data to write to the 1–25,000
dwElementLength DWORD
controller’s memory (0)
card*
The memory
address for the
pSource POINTER TO BYTE NULL
controller to store
the data
*Note: The unit is defined DFB_WRITE_FILE_INFO.wAsciiDecDataType.

• Output

Name Function Data type Output range (Default value)


The FB instruction
bDone BOOL True/False (False)
running is completed.
The FB instruction is
bBusy BOOL True/False (False)
running.
FB instruction error
bError BOOL True/False (False)
flags.
DL_MEMRW_ERROR
ErrorID Error codes DL_MEMRW_ERROR
(DFB_NO_ERR)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bDone  When FB instruction running is completed.  When bExecute shifts to False.
 When FB instruction running is
bBusy  When FB instruction running starts. completed.
 When bExecute shifts to False.
bError  When bExecute shifts to False.

28 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 9

Name Timing for shifting to True Timing for shifting to False


 When an error occurs during running or
ErrorID the input value of the instruction is
incorrect.

• Timing Diagram

• Function
Write the internal data of the controller to the memory card via the FB instruction (DFB_MemoryWrite).

• Programming Example
This example uses the FB instruction (DFB_MemoryWrite) to write the WORD-type array variable to the memory
card.

Suppose that the written data is ar_wVar0: ARRAY [0..3] OF WORD := [0,1,2,10]. After open the .csv file in the
memory card, the content would be displayed as follows.

28 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 9

Values displayed in the Test.csv file


0 1 2 10
*Note:
1. In case of wDataMode = DFB_DATA_MODE.ASCII_MODE, the controller would write the content of array
ar_wVar0 to the memory card in ASCII CODE format.
2. If wAsciiDecDataType: = DFB_DEC_DATATYPE.WORD_SIZE, the data length would be WORD in the CSV
file.

• Supported Products

 AX-3 series

• Library

 DL_MemRW_AX3.library

28 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 9

9.3 Error Codes and Troubleshooting

Description Cause of Error Corrective Action


DFB_NO_ERR No errors. -
DFB_MEMREAD_ERR_ Check external SD card
Internal errors.
FAILED Contact us directly
DFB_MEMREAD_ERR_ Invalid parameter Check if the input parameters are
PARAMETER inputs. correct.
The instruction cannot
DFB_MEMREAD_ERR_ be Run owning to the
Reboot the controller.
NOTINITIALIZED component has not
been initialized.
DFB_MEMREAD_ERR_ Check if the firmware and the library
Wrong version.
VERSION version are supported.
Reset the controller to default (Reset
DFB_MEMREAD_ERR_
Operation time-out. Origin). If the problem remains, Contact
TIMEOUT
us directly.
Reset the controller to default (Reset
Origin). Then download the project
DFB_MEMREAD_ERR_
Insufficient memory. again after compressing the program. If
NOBUFFER
the problem remains, Contact us
directly.
DFB_MEMREAD_ERR_ The program is
Reboot the controller.
PENDING pending for running.
Reset the controller to default (Reset
DFB_MEMREAD_ERR_ Too many pending
Origin). If the problem remains, Contact
NUMPENDING programs.
us directly.
DFB_MEMREAD_ERR_ The function does not Check if the firmware and the library
NOTIMPLEMENTED exist. version are supported.
DFB_MEMREAD_ERR_ Check if the firmware and the library
Incorrect ID.
INVALIDID version are supported.
Check the data type of inputs and reset
DFB_MEMREAD_ERR_ the controller to default (Reset Origin). If
Integer overflow.
OVERFLOW the problem remains, Contact us
directly.
Reset the controller to default (Reset
Origin). Then download the project
DFB_MEMREAD_ERR_ The buffer size is too
again after compressing the program. If
BUFFERSIZE small.
the problem remains, Contact us
directly.。
1. Confirm if the controller and library
versions support the object
2. Confirm whether the file exists.
The object does not
DFB_MEMREAD_ERR_NO_OBJECT 3. Confirm whether the value meets the
exist.
specification
4. Confirm whether the starting position
is greater than the length of the data
Reset the controller to default (Reset
Origin). Then download the project
DFB_MEMREAD_ERR_NOMEMORY Insufficient memory. again after compressing the program. If
the problem remains, Contact us
directly.。
DFB_MEMREAD_ERR_ Check if the firmware and the library
Duplicate object name.
DUPLICATE version are supported.
Reset the controller to default (Reset
DFB_MEMREAD_ERR_ Memory overwrite
Origin). Then download the project
MEMORY_OVERWRITE error.
again after compressing the program. If

28 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 9

Description Cause of Error Corrective Action


the problem remains, Contact us
directly.。
DFB_MEMREAD_ERR_ Invalid handle for the Check if the firmware and the library
INVALID_HANDLE object. version are supported.
DFB_MEMREAD_ERR_ The end of the object Check if the firmware and the library
END_OF_OBJECT has been reached. version are supported.
Check if the firmware and the library
DFB_MEMREAD_ERR_NO_CHANGE No changes happened.
version are supported.
DFB_MEMREAD_ERR_ Invalid or unknown Check if the firmware and the library
INVALID_INTERFACE interface version are supported.
DFB_MEMREAD_ERR_ The function is not Check if the firmware and the library
NOT_SUPPORTED supported. version are supported.
No rights to access the Check if the firmware and the library
DFB_MEMREAD_ERR_NO_ACCESS_RIGHTS
operation. version are supported.
Reset the controller to default (Reset
Origin). Then download the project
DFB_MEMREAD_ERR_ Exceeds the limited
again after compressing the program. If
OUT_OF_LIMITS sources.
the problem remains, Contact us
directly.
Reset the controller to default (Reset
Remaining entries that
Origin). Then download the project
DFB_MEMREAD_ERR_ could not be
again after compressing the program. If
ENTRIES_REMAINING transmitted because of
the problem remains, Contact us
the buffer limitation.
directly.
DFB_MEMREAD_ERR_ Invalid online session
Log in again or reboot the controller.
INVALID_SESSION_ID ID.
DFB_MEMREAD_ERR_
Exception occurs. Check the error log.
EXCEPTION
DFB_MEMWRITE_ERR_ 1. Check the external SD card
Internal error
FAILED 2. Contact the original manufacturer
DFB_MEMWRITE_ERR_ Confirm whether the input parameters
Input parameter error
PARAMETER are correct.
The instruction cannot
be Run because the
DFB_MEMWRITE_ERR_
element initialization Restart the controller.
NOTINITIALIZED
has not been
completed
DFB_MEMWRITE_ERR_ Check if the firmware and the library
Wrong version
VERSION version are supported.
Restore the controller to factory settings
DFB_MEMWRITE_ERR_
Execution time out (Reset Origin). If the problem persists,
TIMEOUT
Contact us directly.
Reset the controller to default (Reset
Origin). Then download the project
DFB_MEMWRITE_ERR_
Insufficient memory again after compressing the program. If
NOBUFFER
the problem remains, Contact us
directly.
DFB_MEMWRITE_ERR_
Program to be Run Restart the controller.
PENDING
Restore the controller to factory settings
DFB_MEMWRITE_ERR_ Too many programs in
(Reset Origin). If the problem persists,
NUMPENDING Run query Contact us directly.
DFB_MEMWRITE_ERR_ Check if the firmware and the library
No such function
NOTIMPLEMENTED version are supported.
DFB_MEMWRITE_ERR_ Check if the firmware and the library
Incorrect ID
INVALIDID version are supported.

28 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C h a pt er 9

Description Cause of Error Corrective Action


Restore the controller to factory settings
DFB_MEMWRITE_ERR_
Value out of range (Reset Origin). If the problem persists,
OVERFLOW
Contact us directly.
Reset the controller to default (Reset
Origin). Then download the project
DFB_MEMWRITE_ERR_
Memory size too small again after compressing the program. If
BUFFERSIZE
the problem remains, Contact us
directly.
DFB_MEMWRITE_ERR_ 1. Check the external SD card
No such object
NO_OBJECT 2. Contact the original manufacturer
Reset the controller to default (Reset
Origin). Then download the project
DFB_MEMWRITE_ERR_
Insufficient memory again after compressing the program. If
NOMEMORY
the problem remains, Contact us
directly.
DFB_MEMWRITE_ERR_ Check if the firmware and the library
Duplicate object name
DUPLICATE version are supported.
Reset the controller to default (Reset
Origin). Then download the project
DFB_MEMWRITE_ERR_ The memory exceeds
again after compressing the program. If
MEMORY_OVERWRITE the writable range
the problem remains, Contact us
directly.
DFB_MEMWRITE_ERR_ Check if the firmware and the library
Invalid object
INVALID_HANDLE version are supported.
The maximum range of
DFB_MEMWRITE_ERR_ Check if the firmware and the library
the object has been
END_OF_OBJECT version are supported.
reached
DFB_MEMWRITE_ERR_ Check if the firmware and the library
No change
NO_CHANGE version are supported.
DFB_MEMWRITE_ERR_ Invalid or unknown Check if the firmware and the library
INVALID_INTERFACE interface version are supported.
DFB_MEMWRITE_ERR_ This feature is not Check if the firmware and the library
NOT_SUPPORTED supported version are supported.
DFB_MEMWRITE_ERR_NO_ Not authorized to Run Check if the firmware and the library
ACCESS_RIGHTS this command version are supported.
Reset the controller to default (Reset
Origin). Then download the project
DFB_MEMWRITE_ERR_ Exceeded limited
again after compressing the program. If
OUT_OF_LIMITS resources
the problem remains, Contact us
directly.
Reset the controller to default (Reset
Origin). Then download the project
DFB_MEMWRITE_ERR_ Unable to transmit due
again after compressing the program. If
ENTRIES_REMAINING to limited resources
the problem remains, Contact us
directly.
DFB_MEMWRITE_ERR_
Invalid online ID Restart the controller.
INVALID_SESSION_ID
DFB_MEMWRITE_ERR_ An exception error
Confirm the error log.
EXCEPTION occurred

28 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 0

Chapter 10 High Speed Output Instructions

The instructions in this chapter apply to the built-in DO output of the host, and your can generate PWM signals
through the instructions.

FB/FC Description Library


To generate a frequency-adjustable pulse width
DFB_PWM DL_BuiltInIO_AX3 / DL_BuiltInIO
modulated output signal

28 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 0

10.1 DFB_PWM
DFB_PWM: DFB_PWM is used to generate Pulse-width modulation output signals which is frequency-adjustable.

FB/FC Instruction Graphic Expression

FB DFB_PWM

ST Language
DFB_PWM_instance (
bEnable:=,
Pin:=,
Period:=
PeriodUnitType:=,
leDuty:=,
bValid =>,
bBusy =>,
bError =>,
ErrorID =>
);

• Input Pins

Setting Value
Name Function Data Type Effective time
(Default value)
Run the
instruction
True/False
bEnable when bEnable BOOL -
(True)
changes from
False to True.
PWM output 0~7 When bEnable is
Pin DFB_PWM_OUTPUT_PIN
pins number (OUT00) TRUE.
MicroSecond or
PWM period When bEnable is
PeriodUnitType DFB_PWM_PERIOD_UNIT MilliSecond
unit TRUE.
(MicroSecond)
MicroSecond :1~65535
When bEnable is
Period PWM period UINT MilliSecond :1~42949
TRUE.
(1)
Continuously
PWM duty
lrDuty LREAL 0~100 (0) effective when
cycle
bEnable is TRUE.
Note: AX-332E only support scope: 0-3
AX-332E only support scope: MicroSecond: 1000-2000, MilliSecond: 1-20

28 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 0

• Output Pins

Output Value Range


Name Function Data Type
(Default value)
Function block output is
bValid BOOL True/False (False)
valid.
Function block is being
bBusy BOOL True/False (False)
busy.
bError Function block error BOOL True/False (False)
DFB_HSIO_ERROR
ErrorID Error ID DFB_HSIO_ERRO*
(DFB_HSIO_NO_ERR)
*Note: DMC_ERROR:Enumeration (Enum)

 Output Updating Timing

Name Timing for shifting to True Timing for shifting to False


 When bExecute shifts to True.  When bError shifts to True.
bValid
 When bEnable shifts to False.
 When bExecute shifts to True.  When bError shifts to True.
bBusy
 When bEnable shifts to False.
bError  When instruction input parameter is illegal,  When bExecute shifts to False.
or an error occurs during instruction
ErrorID running.

• Timing Diagram

bEnable

bValid

bBusy

bError

• Function
 Will generate a square wave signals of specified frequency and duty cycle which can be used to control
plant that needs to receive continuously changing physical quantities.
 This function only supports output contacts.
 Firmware needs to be V1.01.0 or later.

• Troubleshooting

28 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 0

If an error occurs during the running of the instruction, Error will change to True, and the axis motion will stop. Refer
to ErrorID (Error Code) to address the problem.

• Programming Example
This programming example uses 8 sets of PWM output sine wave PWM, and the phase of each set is 45
degrees, which will make OUT LED appear water lamp behavior on the machine. The speed and direction are
determined by the size and sign of "F_SIN_Hz" respectively.

 Variable Declaration

VAR CONSTANT
M_PI : LREAL := 3.14159265358979323846;
END_VAR

VAR
F_SIN_Hz : LREAL := 0.3;
T_SIN_ms : LREAL;
tms : UDINT := 0;

i : UINT;
PWM : ARRAY[0..7] OF DFB_PWM;
END_VAR

 Program

FOR i := 0 TO 7 BY 1 DO
PWM[i].bEnable := TRUE;
PWM[i].Pin := i;
PWM[i].PeriodUnitType := DFB_PWM_PERIOD_UNIT.MicroSecond; //usec
PWM[i].Period := 100;
PWM[i].lrDuty := 100.0*(0.5*SIN(2*M_PI*tms/T_SIN_ms + i*2*M_PI/8)+0.5);

PWM[i]();
END_FOR

IF 0.0 = F_SIN_Hz THEN


F_SIN_Hz := 1.0;
END_IF

T_SIN_ms := TO_DINT(1000/F_SIN_Hz);
tms := tms + 1;
IF tms >= ABS(T_SIN_ms) THEN
tms := 0;
END_IF

• Supported Products

 AX-3 series (except for AX-300)

28 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 0

• Library

 DL_BuiltInIO.library
Note: From version 1.0.5.0, library DL_BuiltInIO_AX3 is changed to DL_BuiltInIO.

29 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 0

10.2 Error Codes and Troubleshooting


Cause of
Description Corrective Action
Error
Firmware
DFB_PWM_UNSUPPORT_FW_VERSION does not Update firmware
match.
Pin number
DFB_PWM_PIN_ID_OVER_RANGE Enter an appropriate pin ID
out of range
Do not enter the pin ID that has
DFB_PWM_THIS_PIN_ID_IS_USED_ON_OTHER_PWM_FB Reused pin
been used.
DFB_PWM_PERIOD_UNIT_IS_NO_DEFINITION Wrong unit Enter an appropriate period unit
Period out of
DFB_PWM_PERIOD_OVER_RANGE Enter an appropriate period value
range

29 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 11

Chapter 11 Additional Instructions

29 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 11

11.1 DFC_LogGetSize
DFC_LogGetSize: Read the size of controller’s log files.

FB/FC Instruction Graphic Expression ST Language

DFC_LogGetSize(
FC DFC_LogGetSize dwLogNum:= ,
ErrorID=> );

• Input

Setting Value
Name Function Data Type
(Default value)
0: Calculate the current data size of all log
The number of the
dwLogNum* DWORD files in the controller.
target log files.
(0)
*Note: Data types such as BYTE, WORD and DWORD can be used for dwLogNum input. Currently only supports
mode0.

• Output

Name Function Data type Output range (Default value)


DFC_LOG_ Data size of the log files. DWORD 0–65536
GETSIZE (The parameter is returned) (Unit: BYTE) (0)
DL_LOGDMP_ERR
ErrorID Error codes DL_LOGDMP_ERROR
(DFC_NO_ERROR)

• Function
After Runs the function (DFC_LogGetSize), the data size of the current log files will be calculated.
• Programming Example
This example uses the FC instruction (DFC_LogGetSize) to read the data size of the current log files of the
controller.

• Supported Products

29 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 11

 AX-3 series, AX-864E30xE2T


Note: AX-332E, AX-864E30xE2T (Library firmware version: 1.0.7.0 or later)

• Library

 DL_LogDmp_AX3.library

29 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 11

11.2 DFB_LogDump
DFB_LogDump: Read the log files of the controller.

FB/FC Instruction Graphic Expression ST Language

DFB_LogDump(
bExecute:= ,
pDmpPos:= ,
dwLogNum:= ,
FB DFB_ LogDump dwDmpLength:= ,
bDone=> ,
bBusy=> ,
bError=> ,
ErrorID=> );

• Input

Setting Value
Name Function Data Type
(Default value)
Run the function block.
bExecute (Triggered by the rising- BOOL True/False (False)
edge)
The memory address for POINTER TO
pDmpPos (0)
controller’s storage BYTE
The number of the target 0: Read all the current log files of the
dwLogNum*1 DWORD
log files to read controller (0)
The size of the target log
dwDmpLength*2 DWORD (0)
files to read
*Note:
1. Data types such as BYTE, WORD, and DWORD can be used for dwLogNum input. Currently only supports
mode0.
2. When the input length of dwDmpLength is greater than the length of the pDmpPos data type, an Exception
error will occur.

• Output

Name Function Data type Output range (Default value)


The FB instruction
bDone BOOL True/False (False)
running is completed.
The FB instruction is
bBusy BOOL True/False (False)
running.
FB instruction error
bError BOOL True/False (False)
flags
DL_LOGDMP_ERROR
ErrorID Error codes DL_LOGDMP_ERROR
(DFB_NO_ERR)

 Outputs Updating Timing

29 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 11

Name Timing for shifting to True Timing for shifting to False


bDone  When FB instruction running is completed  When bExecute shifts to False
 When FB instruction running is
bBusy  When FB instruction running starts completed
 When bExecute shifts to False
bError  When an error occurs during running or
the input value of the instruction is  When bExecute shifts to False
ErrorID incorrect

• Timing Diagram

• Function
Use the FB instruction (DFB_LogDump) to read the log files of the controller.

• Programming Example
This example uses the FB instruction (DFB_LogDump) to read the log files in the PLC and store the files in
Byte array variable (ar_byVar) in the ASCII format.

• Supported Products

 AX-3 series, AX-864E30xE2T


Note: AX-332E, AX-864E30xE2T (Library firmware version: 1.0.7.0 or later)

• Library

29 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 11

 DL_LogDmp_AX3.library

29 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 11

11.3 Error Codes and Troubleshooting

• DL_LOGDMP_ERROR

Description Cause of Error Corrective Action


DFB_NO_ERR No errors. -
DFB_DMP_ERR_FAILED Internal errors. Contact us directly
DFB_DMP_ERR_
Invalid parameter inputs. Check if the input parameters are correct.
PARAMETER
The instruction cannot be
DFB_DMP_ERR_ Run owning to the
Reboot the controller.
NOTINITIALIZED component has not been
initialized.
DFB_DMP_ERR_ Check if the firmware and the library version
Wrong version.
VERSION are supported.
Reset the controller to default (Reset
DFB_DMP_ERR_
Operation time-out. Origin). If the problem remains, Contact us
TIMEOUT
directly.
Reset the controller to default (Reset
DFB_DMP_ERR_ Origin). Then download the project again
Insufficient memory.
NOBUFFER after compressing the program. If the
problem remains, Contact us directly.
DFB_DMP_ERR_ The program is pending for
Reboot the controller.
PENDING running.
Reset the controller to default (Reset
DFB_DMP_ERR_ Too many pending
Origin). If the problem remains, Contact us
NUMPENDING programs.
directly.
DFB_DMP_ERR_ The function does not Check if the firmware and the library version
NOTIMPLEMENTED exist. are supported.
DFB_DMP_ERR_ Check if the firmware and the library version
Incorrect ID.
INVALIDID are supported.
Check the data type of inputs and reset the
DFB_DMP_ERR_
Integer overflow. controller to default (Reset Origin). If the
OVERFLOW
problem remains, Contact us directly.
Reset the controller to default (Reset
DFB_DMP_ERR_ Origin). Then download the project again
The buffer size is too small. after compressing the program. If the
BUFFERSIZE
problem remains, Contact us directly.。
DFB_DMP_ERR_NO_ Check if the firmware and the library version
The object does not exist.
OBJECT are supported.
Reset the controller to default (Reset
DFB_DMP_ERR_ Origin). Then download the project again
Insufficient memory.
NOMEMORY after compressing the program. If the
problem remains, Contact us directly.。
DFB_DMP_ERR_ Check if the firmware and the library version
Duplicate object name.
DUPLICATE are supported.
Reset the controller to default (Reset
DFB_DMP_ERR_ Origin). Then download the project again
Memory overwrite error. after compressing the program. If the
MEMORY_OVERWRITE
problem remains, Contact us directly.。
Invalid handle for the Check if the firmware and the library version
DFB_DMP_ERR_INVALID_HANDLE
object. are supported.

29 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 11

Description Cause of Error Corrective Action


The end of the object has Check if the firmware and the library version
DFB_DMP_ERR_END_OF_OBJECT
been reached. are supported.
DFB_DMP_ERR_NO_ Check if the firmware and the library version
No changes happened.
CHANGE are supported.
Invalid or unknown Check if the firmware and the library version
DFB_DMP_ERR_INVALID_INTERFACE
interface are supported.
DFB_DMP_ERR_NOT_ The function is not Check if the firmware and the library version
SUPPORTED supported. are supported.
DFB_DMP_ERR_NO_ No rights to access the Check if the firmware and the library version
ACCESS_RIGHTS operation. are supported.
Reset the controller to default (Reset
Exceeds the limited Origin). Then download the project again
DFB_DMP_ERR_OUT_OF_LIMITS
sources. after compressing the program. If the
problem remains, Contact us directly.。
Remaining entries that Reset the controller to default (Reset
could not be transmitted Origin). Then download the project again
DFB_DMP_ERR_ENTRIES_REMAINING
because of the buffer after compressing the program. If the
limitation. problem remains, Contact us directly.。
DFB_DMP_ERR_INVALID_SESSION_ID Invalid online session ID. Log in again or reboot the controller.
DFB_DMP_ERR_
Exception occurs. Check the error log.
EXCEPTION
DFC_GETSIZE_ERR_FAILED Internal errors. Contact us directly
DFC_ GETSIZE _ERR_
Invalid parameter inputs. Check if the input parameters are correct.
PARAMETER
The instruction cannot be
DFC_ GETSIZE _ERR_ Run owning to the
Reboot the controller
NOTINITIALIZED component has not been
initialized.
DFC_ GETSIZE _ERR_ Check if the firmware and the library version
Incorrect version.
VERSION are supported.
Reset the controller to default (Reset
DFC_ GETSIZE _ERR_
Operation time-out. Origin). If the problem remains, Contact us
TIMEOUT
directly.
Reset the controller to default (Reset
DFC_ GETSIZE _ERR_ Origin). Then download the project again
Insufficient memory.
NOBUFFER after compressing the program. If the
problem remains, Contact us directly.
DFC_ GETSIZE _ERR_ The program is pending
Reboot the controller
PENDING for running.
Reset the controller to default (Reset
DFC_ GETSIZE _ERR_ Too many pending
Origin). If the problem remains, Contact us
NUMPENDING programs.
directly.
DFC_ GETSIZE _ERR_ The function does not Check if the firmware and the library version
NOTIMPLEMENTED exist. are supported.
DFC_ GETSIZE _ERR_ Check if the firmware and the library version
Incorrect ID.
INVALIDID are supported.
Check the data type of inputs and reset the
DFC_ GETSIZE _ERR_
Integer overflow. controller to default (Reset Origin). If the
OVERFLOW
problem remains, Contact us directly.
Reset the controller to default (Reset
DFC_ GETSIZE _ERR_ Origin). Then download the project again
The buffer size is too small.
BUFFERSIZE after compressing the program. If the
problem remains, Contact us directly.

29 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 11

Description Cause of Error Corrective Action


DFC_ GETSIZE _ERR_NO_ Check if the firmware and the library version
The object does not exist
OBJECT are supported.
Reset the controller to default (Reset
DFC_ GETSIZE _ERR_ Origin). Then download the project again
Insufficient memory
NOMEMORY after compressing the program. If the
problem remains, Contact us directly.
DFC_ GETSIZE _ERR_ Check if the firmware and the library version
Duplicate object name
DUPLICATE are supported.
Reset the controller to default (Reset
DFC_ GETSIZE _ERR_ Origin). Then download the project again
Memory overwrite error
MEMORY_OVERWRITE after compressing the program. If the
problem remains, Contact us directly.
DFC_ GETSIZE _ERR_INVALID Invalid handle for the Check if the firmware and the library version
_HANDLE object are supported.
DFC_ GETSIZE _ERR_END_OF The end of the object has Check if the firmware and the library version
_OBJECT been reached. are supported.
DFC_ GETSIZE _ERR_NO_ Check if the firmware and the library version
No changes happened.
CHANGE are supported.
DFC_ GETSIZE _ERR_INVALID Invalid or unknown Check if the firmware and the library version
_INTERFACE interface are supported.
DFC_ GETSIZE _ERR_NOT_ The function is not Check if the firmware and the library version
SUPPORTED supported. are supported.
DFC_ GETSIZE _ERR_NO_ No rights to access the Check if the firmware and the library version
ACCESS_RIGHTS operation. are supported.
Reset the controller to default (Reset
DFC_ GETSIZE _ERR_OUT Exceeds the limited Origin). Then download the project again
_OF_LIMITS sources. after compressing the program. If the
problem remains, Contact us directly.
Remaining entries that Reset the controller to default (Reset
DFC_ GETSIZE _ERR_ENTRIES could not be transmitted Origin). Then download the project again
_REMAINING because of the buffer after compressing the program. If the
limitation. problem remains, Contact us directly.
DFC_ GETSIZE _ERR_INVALID
Invalid online session ID. Log in again or reboot the controller.
_SESSION_ID
DFC_ GETSIZE _ERR_
Exception occurs. Check the error log.
EXCEPTION

• DFB_FTP_CLIENT_ERROR

Description Cause of Error Corrective Action


DFB_NO_ERR No errors. -
Confirm whether the SD card is
DFB_SD_CARD_NOT_FOUND No SD card
inserted into the SD card slot
Reset the controller to default (Reset
DFB_CONNECT_TIMEOUT Operation time-out. Origin). If the problem remains,
Contact us directly.
Check if the Function block
DFB_INPUT_ERROR Parameter error
parameters are correct.
Confirm whether the idle time of the
DFB_NOT_CONNECT Disconnected FTP client exceeds the time-out setting
of the FTP server.

30 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 11

Description Cause of Error Corrective Action


Confirm whether the FTP server
DFB_CMD_ERROR FTP Client command running error supports the current command
operation.
DFB_OPEN_FILE_ERROR Open file error Confirm whether the file is normal.
DFB_WRITE_FILE_ERROR Error writing to file Confirm whether the file is normal.
DFB_CREATE_FILE_ERROR File creation error Confirm whether the file is normal.
DFB_READ_FILE_ERROR Error reading file Confirm whether the file is normal.
The selected memory space is not
DFB_NOT_SUPPORT_MEM Select the correct memory space.
supported
Confirm that the login account
DFB_LOGIN_FAIL FTP server login failed
password is correct.
Wait for the running of FB instruction
DFB_UNDEFINE Undefined or has not yet been Run.
being completed.

30 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 2

Chapter 12 SNTP Instructions

30 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 2

12.1 SNTPGetUTCTime
SNTPGetUTCTime: Read the current time of the NTP/SNTP server.

FB/FC Instruction Graphic Expression ST Language

SNTPGetUTCTime(
xRun:= ,
sSNTPServer:= ,
sOwnIP:= ,
uiSNTPPort:= ,
uiOwnPort:= ,
udiTimeout:= ,
FB SNTPGetUTCTime
eNTPVersion:= ,
xDone=> ,
xBusy=> ,
xError=> ,
eError=> ,
uliTimestamp=> ,
uliReceiveClientTS=> );

• Input

Setting Value
Name Function Data Type
(Default value)

Run the function block.


xRun BOOL Tr u e / F a l s e ( F a l s e )
(Rising-edge triggered)

The IP address of the


sSNTPServer STRING (255) (‘’)
NTP/SNTP server

The IP address of the


sOwnIP STRING (255) (0.0.0.0’)
controller

The UDP port number of


uiSNTPPort UINT (0)
the NTP/SNTP server

uiOwnPort PLC UDP Port number UINT (0)

The communication time- UDINT


udiTimeout (1000)
out value (ms)

eNTPVersion The NTP version NTP_VERSION (V3)

30 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 2

 NTP_VERSION

Name Description

V3 NTPv3

V4 NTPv4

• Output

Setting Value
Name Function Data Type
(Default value)

The FB instruction
xDone BOOL Tr u e / F a l s e (False)
running is completed.

The FB instruction is
xBus y BOOL Tr u e / F a l s e (False)
running.

xError FB instruction error BOOL Tr u e / F a l s e (False)

ERROR
eError Error codes ERROR
(NO_ERR)

The UTC time of the ULINT


u i Ti m e s t a m p --
NTP/SNTP server (ms)

The UTC time of the ULINT


uiReceiveClientTS --
controller (ms)

• Function
The FB instruction (SNTPGetUTCTime) is used for reading the UTC time of the NTP/SNTP server.
• Programming Example

In this example, the FB instruction reads the the SNTP controller (192.168.1.95) UTC time sets this time to the
controller (when bVar = Ture) via the instruction (SystimeRTCSet).

Note: You can use the FC instruction (SeparateDateTime) of Util.Library to convert the timestamp value of the
NTP/SNTP server to IEC time format to confirm the time of its return.

30 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 2

N o t e : When using this function block, you need to add the library name of the function block. (such as
SNTP.SNTPGetUTCTime).

• Supported Products

 AX-3 series (firmware v1.0.5.8 and later)

• Library

 SNTP Service SL.library v1.1.0.0

30 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 2

12.2 SNTPServer
SNTPServer: Turn on the SNTP service.

FB/FC Instruction Graphic Expression ST Language

SNTPServer(
xActivate:= ,
uiOwnPort:= ,
FB SNTPServer
sOwnIP:= ,
xError=> ,
eError=> );

• Input

Setting Value
Name Function Data Type
(Default value)
Run the function block.
xActive BOOL True/False (False)
(Rising-edge triggered)
The UDP Port number of
uiOwnPort UINT -
the controller
The IP address of the
sOwnIP STRING (255) (0.0.0.0’)
controller

• Output

Setting Value
Name Function Data Type
(Default value)

xError FB instruction error BOOL True/False (False)

ERROR
eError Error Code ERROR
(NO_ERR)

• Function
The FB instruction(NTPServer) is used to start the SNTP server of the controller.

• Programming Example

30 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 2

In this example, the FB instruction (NTPServer) starts the SNTP server function of the controller.

Note: When using this function block, you need to add the library name of the function block.(such as
SNTP.SNTPServer).

• Supported Products

 AX-3 series (firmware v1.0.5.8 and later)

• Library

 SNTP Service SL.library v1.1.0.0

30 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 2

12.3 Error Codes

Name Description
NO_ERROR No errors

TIME_OUT NTP/SNTP server response time-out

INIT_ERROR Initialization failed


SEND_ERROR Failed to send
RECEIVE_ERROR Failed to receive
CAN_NOT_GET_SYSTIME The current controller UTC time cannot be read.
SERVER_REFUSED_REQUEST NTP/SNTP sends KoD messages
INVALID_LICENSE Invalid license

30 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 3

Chapter 13 Util Library Instructions

30 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 3

13.1 SeparateDateTime
SeparateDateTime: Conver the timestamp to IEC time format.

FB/FC Instruction Graphic Expression ST Language

SeparateDateTi
me(uliDateTime:= ,
SeparateDate
FC eWeekDay=> ,
Time
datDate=> ,
todTime=> )

• Input

Setting Value
Name Function Data Type
(Default value)
The timestamp data ULINT
uiDateTime --
that will be converted (sec)

• Output

Setting Value
Name Function Data Type
(Default value)
eWeekDay The weekday for that date WEEKDAY --
datDate Date (Year:Month:Date) DATE --
todTime Time (Hour:Minute:Second) TOD --

 WEEKDAY

Name Description
UNKNOWN --
MONDAY Monday
TUESDAY Tuesday
WEDNESDAY Wednesday

THURSDAY Thursday

FRIDAY Friday

SATURDAY Saturday

SUNDAY Sunday

31 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 3

• Function

The FC instruction (SeparateDateTime) is used to convert the timestamp to the IEC time format.

• Programming Example

In this example, the FC command (SeparateDateTime) converts 86,400,000 ms (1 day) to IEC time, and the
converted date is "1970-1-2" and the time is "00:00:00".

• Supported Products

 AX-3 series

• Library

 Util.library

311
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 3

13.2 Error Codes


Name Description
NO_ERROR No errors
WRONG_CONFIGUTATION NTP/SNTP server response time-out
RTC_HIGHRES_NOT_SUPPORTED --
SYS_TIMEZONE_NOT_SUPPORTED The timezone is not supported.

31 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 4

Chapter 14 MEMUtils Library Instructions

31 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 4

14.1 MemCpy
MemCpy: Copy the source address to the destination address.

FB/FC Instruction Graphic Expression ST Language

MemCpy(
pbyDest:= ,
FC MemCpy
pbySrc:= ,
dwSize:= );

• Input

Setting Value
Name Function Data Type
(Default value)
The destination
pbyDest POINTER TO BYTE --
address
pbySrc The source address POINTER TO BYTE --
The length of the data 1–4294967295
dwSize DWORD
to be copied Positive integer (0)

• Function
This FC instruction is used to copy the source address (pSrc) value to the specified destination address
(pDest), and the length of the copied data is determined by the input parameter dwSize (in Byte).

• Programming Example
In this example, MemCpy copies the value of Var_1(pbySrc) to the Var_2 (pbyDest) address, and the copy
length is set to 80 in dwSize.

• Supported Products

31 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 4

 AX series

• Libray

 MEMUtils.library

31 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 4

14.2 MemSet
MemSet: Set the source address range.

FB/FC Instruction Graphic Expression ST Language

MemSet(
pbyBuffer:= ,
FC MemSet
byValue:= ,
dwSize:= )

• Input

Setting Value
Name Function Data Type
(Default value)
pbyBuffer The destination
POINTER TO BYTE --
address
byValue Value POINTER TO BYTE --
The length of the data 1–4294967295
dwSize DWORD
to be set Positive integer (0)

• Function
After running this instruction, byValue is written to the value set by the destination address (pbyBuffer), and
the length of the address is determined by the input parameter dwSize (in bytes).

• Programming Example
 Example 1
 Use MemSet to write 0(byValue) to the value set by %MW1000 (pbyBuffer). If the length of the
address is 20, the pbyBuffer range is %MW1000~%MW1009.

31 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 4

 Example 2

 Use MemSet to write 0(byValue) to the value of Var_1(pbyBuffer). The length of the input is
determined by dwSize, and the Array size can be obtained by SIZEOF(Var_1).

• Supported Products

 AX series

• Libray

 MEMUtils.library

31 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 4

14.3 Error Codes

Name Description
NO_ERROR No errors

31 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 5

Chapter 15 SysTimeRtc Library Instructions

31 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 5

15.1 SysTimeRtcHighResGet
SysTimeRtcHighResGet: Get the UTC time of the controller.

FB/FC Instruction Graphic Expression

FC SysTimeRtcHighResGet

ST Language

SysTimeRtcHighResGet(
pTimestamp:=
);

• Input

Setting Value
Name Function Data Type
(Default value)
pTimestamp System time SYSTIME --
SysTimeRtcHighResGet Error code RTS_IEC_RESULT --

• Function
This function is supported in AX-3 series (except for AX-332) controllers with device description version
1.0.4.0 and later.
After running this instruction, the UTC time in the controller is obtained, and then output to the
pTimestamp parameter.

• Programming Example

32 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 5

Use SysTimeRtcHighResGet to output the controller's time to the SysTime variable via pTimestamp.

• Supported Products

 AX series

• Libray

 SysTimeRtc.library

32 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 5

15.2 SysTimeRtcConvertHighResToDate
SysTimeRtcConvertHighResToDate: Convert the time obtained by SysTimeRtcHighResGet to date info.

FB/FC Instruction Graphic Expression

FC SysTimeRtcConvertHighResToDate

ST Language

SysTimeRtcConvertHighResToDate(
pTimestamp:= ,
pDate:=
);

• Input

Setting Value
Name Function Data Type
(Default value)
pTimestamp PLC system time SYSTIME --
pDate Date info SYSTIMEDATE --
SysTimeRtcHighResGet Error code RTS_IEC_RESULT --

• Function
When this instruction is running, the controller time obtained by SysTimeRtcHighResGet can be parsed
into date info and output to the pDate parameter.

• Programming Example
Use SysTimeRtcConvertHighResToDate to parse the controller time obtained by SysTimeRtcHighResGet into
date info, and pDate is output to TimeVar.

32 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 5

• Supported Products

 AX series

• Libray

 SysTimeRtc.library

32 3
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 5

15.3 Error Codes

Name Description
NO_ERROR No errors

32 4
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 6

Chapter 16 DL_SysInfo Library Instructions

32 5
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 6

16.1 DFC_GetPLCErrorID
DFC_GetPLCErrorID: Get the errors of the current controller itself.

FB/FC Instruction Graphic Expression

FC DFC_GetPLCErrorID

ST Language

DFC_GetPLCErrorID (
);

• Input

Setting Value
Name Function Data Type
(Default value)
Read the current error
DFB_GetPLCErrorID DWORD 0–65535
ID of the PLC.

• Function
This function reads the 16#140E~16#2203 errors of PLC, refer to AX-3 Series Operation Manual A.2
Troubleshooting of CPU Modules for details.

• Programming Example
Use DFC_GetPLCErrorID to read the error ID of the system error.

• Supported Products

32 6
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 6

Controller Firmware version Library version


AX-3 1.0.7.0 and later 1.0.0.0
AX-332 1.0.6.3 and later 1.0.0.0
AX-C 1.0.3.8 and later 1.0.0.0
AX-8 Linux 1.0.5.11 and later 1.0.0.0
AX-864E30CE2T 1.0.1.12 and later 1.0.0.0

• Libray
 DL_SysInfo.library

32 7
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 6

16.2 DFC_ReadBatteryLowStatus
DFC_ReadBatteryLowStatus: Get the current battery status.

FB/FC Instruction Graphic Expression

FC DFC_ReadBatteryLowStatus

ST Language

DFC_ReadBatteryLowStatus (
);

• Input

Setting Value
Name Function Data Type
(Default value)
Read the current
DFC_
battery status of the DWORD 0–1 (0)
ReadBatteryLowStatus
PLC.

• Function
This function gets whether the system battery status is in low voltage.
0 indicates that the battery is normal.
1 indicates that the battery is abnormal.

• Programming Example
Use DFC_ReadBatteryLowStatus to read whether the system battery status is normal.

• Supported Products

32 8
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 6

Controller Firmware version Library version


AX-3 1.0.7.0 and later 1.0.0.0
AX-332 1.0.6.3 and later 1.0.0.0
AX-C 1.0.3.8 and later 1.0.0.0
AX-8 Linux 1.0.5.11 and later 1.0.0.0
AX-864E30CE2T 1.0.1.12 and later 1.0.0.0

• Libray

 DL_SysInfo.library

32 9
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 6

16.3 DFB_HWInfo
DFB_HWInfo: Get the hardware information of the current PLC.

FB/FC Instruction Graphic Expression

FB DFB_HWInfo

ST Language
DFB_HWInfo(
bEnable:= ,
bValid=> ,
bBusy=> ,
dwErrorID=> ,
hwinfo=>
);

• Input

Setting Value
Name Function Data Type
(Default value)
Start the FB. True/False
bEnable BOOL
(False)

• Output

Setting Value
Name Function Data Type
(Default value)
True when the parameter to be
bValid BOOL True/False (False)
read is correct
True when the instruction is
bBusy BOOL True/False (False)
running
When an error occurs, the error DFB_HWINFO_ERROR
dwErrorID DFB_HWINFO_ERROR
code is recorded. (DFB_NO_ERROR)
hwinfo System hardware information AX_HWINFO AX_HWINFO*
Note: AX_HWINFO : Struct
AX-332
Name Function Data Type Unit AX-3 AX-5 AX-C
AX-8
Time of the
strBootTime system that has STRING(31) s V V V V
been running
33 0
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 6

AX-332
Name Function Data Type Unit AX-3 AX-5 AX-C
AX-8
on the current
power-up
Array [0..7]
strCPUFrequency CPU frequency OF MHz V V V V
STRING(11)
CPU Array [0..7]
iCPUTemperature °C V V V
temperature OF INT
Array [0..7]
byCPUUsage CPU usage rate % V V V V
OF BYTE
Launch Array [0..7]
bIsDHCP_GLAN - V V
DHCP_GLAN OF BOOL
CPU memory
wMemSize WORD MB V V V
size
CPU memory
byMemUsage BYTE % V V V
usage
strProductName Product name STRING(31) - V V V V
Product serial
strSerialNumber STRING(31) - V V V V
number
Array [0..3]
strSDPath Micor SD path OF - V V V V
STRING(31)
Array [0..7]
strUDiskPath USB path OF - V V
STRING(31)

 Outputs Updating Timing

Name Timing for shifting to True Timing for shifting to False


bValid  When the parameter to be read is correct  When bExecute shifts to False
bBusy  When the instruction is running  When dwErrorID is not 0
dwErrorID  When an error occurs during the running or  When bEnable shifts from True to False
ErrorCode there are incorrect input values (Error code is cleared)

• Function
This function gets information about the controller.

• Programming Example
Use DFB_HWInfo to get information about the controller.

33 1
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 6

• Supported Products

Controller Firmware version Library version


AX-3 1.0.7.0 and later 1.0.0.0
AX-332 1.0.6.3 and later 1.0.0.0
AX-C 1.0.3.8 and later 1.0.0.0
AX-8 Linux 1.0.5.11 and later 1.0.0.0
AX-864E30CE2T 1.0.1.12 and later 1.0.0.0

• Libray

 DL_SysInfo.library

33 2
AX S er i es - St an d ar d In s tr uc t io ns M a nu a l C ha pt er 1 6

16.4 Error Codes

Name Description
NO_ERROR No errors

33 3
Industrial Automation Headquarters
Delta Electronics, Inc.
Taoyuan Technology Center
No.18, Xinglong Rd., Taoyuan District,
Taoyuan City 330477, Taiwan
TEL: +886-3-362-6301 / FAX: +886-3-371-6301

Asia EMEA
Delta Electronics (Shanghai) Co., Ltd. Delta Electronics (Netherlands) B.V.
No.182 Minyu Rd., Pudong Shanghai, P.R.C. Sales: [email protected]
Post code : 201209 Marketing: [email protected]
TEL: +86-21-6872-3988 / FAX: +86-21-6872-3996 Technical Support: [email protected]
Customer Service: 400-820-9595 Customer Support: [email protected]
Service: [email protected]
Delta Electronics (Japan), Inc. TEL: +31(0)40 800 3900
Industrial Automation Sales Department
2-1-14 Shibadaimon, Minato-ku Delta Electronics (Netherlands) B.V.
Tokyo, Japan 105-0012 Automotive Campus 260, 5708 JZ Helmond, The Netherlands
TEL: +81-3-5733-1155 / FAX: +81-3-5733-1255 Mail: [email protected]
TEL: +31(0)40 800 3900
Delta Electronics (Korea), Inc. Delta Electronics (Netherlands) B.V.
1511, 219, Gasan Digital 1-Ro., Geumcheon-gu,
Coesterweg 45, D-59494 Soest, Germany
Seoul, 08501 South Korea
Mail: [email protected]
TEL: +82-2-515-5305 / FAX: +82-2-515-5302
TEL: +49 2921 987 238
Delta Energy Systems (Singapore) Pte Ltd. Delta Electronics (France) S.A.
4 Kaki Bukit Avenue 1, #05-04, Singapore 417939 ZI du bois Challand 2, 15 rue des Pyrénées,
TEL: +65-6747-5155 / FAX: +65-6744-9228 Lisses, 91090 Evry Cedex, France
Mail: [email protected]
Delta Electronics (India) Pvt. Ltd. TEL: +33(0)1 69 77 82 60
Plot No.43, Sector 35, HSIIDC Gurgaon,
PIN 122001, Haryana, India Delta Electronics Solutions (Spain) S.L.U
TEL: +91-124-4874900 / FAX: +91-124-4874945 Ctra. De Villaverde a Vallecas, 265 1º Dcha Ed.
Hormigueras – P.I. de Vallecas 28031 Madrid
Delta Electronics (Thailand) PCL. TEL: +34(0)91 223 74 20
909 Soi 9, Moo 4, Bangpoo Industrial Estate (E.P.Z), Carrer Llacuna 166, 08018 Barcelona, Spain
Pattana 1 Rd., T.Phraksa, A.Muang, Mail: [email protected]
Samutprakarn 10280, Thailand Digitized Automation for a Changing World
TEL: +66-2709-2800 / FAX: +66-2709-2827 Delta Electronics (Italy) S.r.l.
Via Meda 2–22060 Novedrate(CO)
Delta Electronics (Australia) Pty Ltd.
Unit 2, Building A, 18-24 Ricketts Road,
Mount Waverley, Victoria 3149 Australia
Piazza Grazioli 18 00186 Roma Italy
Mail: [email protected]
TEL: +39 039 8900365
DIADesigner - AX Series Standard
Instructions Manual
Mail: [email protected]
Delta Energy System LLC
TEL: +61-1300-335-823 / +61-3-9543-3720
Vereyskaya Plaza II, office 112 Vereyskaya str.
17 121357 Moscow Russia
Americas Mail: [email protected]
TEL: +7 495 644 3240
Delta Electronics (Americas) Ltd.
5101 Davis Drive, Research Triangle Park, NC 27709, U.S.A. Delta Greentech Elektronik San. Ltd. Sti. (Turkey)
TEL: +1-919-767-3813 / FAX: +1-919-767-3969 Şerifali Mah. Hendem Cad. Kule Sok. No:16-A
34775 Ümraniye – İstanbul
Delta Electronics Brazil Ltd. Mail: [email protected]
Estrada Velha Rio-São Paulo, 5300 Eugênio de TEL: + 90 216 499 9910
Melo - São José dos Campos CEP: 12247-004 - SP - Brazil
TEL: +55-12-3932-2300 / FAX: +55-12-3932-237 Eltek Dubai (Eltek MEA DMCC)
OFFICE 2504, 25th Floor, Saba Tower 1,
Delta Electronics International Mexico S.A. de C.V. Jumeirah Lakes Towers, Dubai, UAE
Gustavo Baz No. 309 Edificio E PB 103 Mail: [email protected]
Colonia La Loma, CP 54060 TEL: +971(0)4 2690148
Tlalnepantla, Estado de México
TEL: +52-55-3603-9200

*We reserve the right to change the information in this manual without prior notice. DIAS-Manual-0025-EN
2023/05/11 www.deltaww.com

You might also like