EMD8216 Ethernet Digital I/O module - automation.com.tw

185
EMD8216 Ethernet Digital I/O module Software Manual (V1.7) 健昇科技股份有限公司 JS AUTOMATION CORP. 新北市汐止區中興路 100 6 6F., No.100, Zhongxing Rd., Xizhi Dist., New Taipei City, Taiwan TEL+886-2-2647-6936 FAX+886-2-2647-6940 http://www.automation.com.tw E-mail[email protected]

Transcript of EMD8216 Ethernet Digital I/O module - automation.com.tw

Page 1: EMD8216 Ethernet Digital I/O module - automation.com.tw

EMD8216

Ethernet Digital I/O module

Software Manual (V1.7)

健昇科技股份有限公司

JS AUTOMATION CORP.

新北市汐止區中興路 100號 6樓

6F., No.100, Zhongxing Rd., Xizhi Dist., New Taipei City, Taiwan

TEL:+886-2-2647-6936

FAX:+886-2-2647-6940

http://www.automation.com.tw

E-mail:[email protected]

Page 2: EMD8216 Ethernet Digital I/O module - automation.com.tw

1

Correction record

Version Record

1.0 EMD8216.dll v1.0

1.1 for driver 1.2 up

1. EMD8216_standalone_config_set and EMD8216_standalone_config_read add a

variable number

2. Modify the IO state description: change „low‟ to „inactive‟ and „high‟ to „active‟

1.2 Add Modbus function and descriptions

1.3 1. Add new functions

EMD8216_dll_version_read

EMD8216_subnet_mask_set

EMD8216_subnet_mask_read

EMD8216_counter_mask_read

EMD8216_standalone_V_config_set

EMD8216_standalone_V_config_read

EMD8216_standalone_config_clear

EMD8216_D2D_config_set

EMD8216_D2D_config_read

EMD8216_D2D_connection_clear

EMD8216_D2D_connection_state_read

EMD8216_WDT_set_new replace EMD8216_WDT_set

EMD8216_WDT_read_new replace EMD8216_WDT_read

2. Add 9.3 Remote configure

3. Add 9.4 Virtual I/O and broken line state configuration

4. Add and Modify Standalone mode application examples (chapt.10)

5. Add and Modify EMD8216 communication commands (chapt.11.5)

6. Modify How to install the software of EMD8216 (chapt.1)

7. Modify Where to find the file you need (chapt.2)

8. Modify EMD8216 Language support (chapt.4)

1.4 1. Add new chapter 7 Using the EMD module

2. Add and Modify Modbus register in Chapter 16

3. Add new function in Chapter 8

EMD8216_default_gateway_change

EMD8216_default_gateway_read

EMD8216_inport_debounce_set

EMD8216_inport_debounce_read

4. Add new UDP command in Section 5 of Chapter 11

DEFAULT_GATEWAY_SET

DEFAULT_GATEWAY_READ

1.5 Delete Appendix: EasyConfig manual (chapt.17)

1.6 1. 1 Add new function in Chapter 8

Page 3: EMD8216 Ethernet Digital I/O module - automation.com.tw

2

EMD8216_D2D_keep_alive_time_set

EMD8216_D2D_keep_alive_time_read

EMD8216_network_config_change

EMD8216_network_config_read

1.7 1. Modify EMD8216_D2D_keep_alive_time_set, the parameter must even number.

2. Modify D2D_CONFIG_SET,CONNECTION_CLEAR add need reboot note

3. Modify EMD8216_D2D_config_set,EMD8216_D2D_connection_clear add need

reboot note

4. Modify EMD8216_D2D_connection_state_read add state 0x7,

NEED_REBOOT_FOR_NEW_CONFIG

5. Modify CONNECTION_STATE_READ add state 0x7,

NEED_REBOOT_FOR_NEW_CONFIG

Page 4: EMD8216 Ethernet Digital I/O module - automation.com.tw

3

Contents

1. How to install the software of EMD8216 ....................................................................................... 8

2. Where to find the file you need ....................................................................................................... 9

3. About the EMD8216 software ...................................................................................................... 10

3.1 What you need to get started ............................................................................................... 10

3.2 Software programming choices ........................................................................................... 10

4. EMD8216 Language support ........................................................................................................ 11

4.1 Building applications with the EMD8216 software library ................................................. 11

4.2 EMD8216 Windows Libraries ............................................................................................. 11

5. Basic concept of the remote digital I/O module .......................................................................... 12

5.1 I/O communicate via Ethernet ............................................................................................. 12

5.2 Standalone I/O controller ..................................................................................................... 12

5.3 Virtual IO ............................................................................................................................. 13

5.4 Work as SCADA I/O module ............................................................................................... 13

5.5 Types of I/O classified by isolation ..................................................................................... 13

5.6 Types of Output classified by driver device ........................................................................ 13

5.7 Protection of output transient on inductive load .................................................................. 14

5.8 Inrush current consideration ................................................................................................ 15

6. Function format and language difference ................................................................................... 16

6.1 Function format.................................................................................................................... 16

6.2 Variable data types ............................................................................................................... 17

6.3 Programming language considerations ................................................................................ 18

7. Using the EMD module ................................................................................................................. 20

7.1 Flow chart of application implementation using DLL......................................................... 21

8. Software overview and dll function .............................................................................................. 23

8.1 Initialization and close ......................................................................................................... 23

EMD8216_initial ................................................................................................................. 24

EMD8216_close .................................................................................................................. 25

EMD8216_firmware_version_read ..................................................................................... 25

EMD8216_dll_version_read ................................................................................................ 25

EMD8216_subnet_mask_set ............................................................................................... 26

EMD8216_subnet_mask_read ............................................................................................. 26

8.2 Digital I/O ............................................................................................................................ 27

EMD8216_port_config_set ................................................................................................. 29

EMD8216_port_config_read ............................................................................................... 29

EMD8216_inport_debounce_set ......................................................................................... 30

EMD8216_inport_debounce_read ....................................................................................... 30

EMD8216_port_polarity_set ............................................................................................... 31

EMD8216_port_polarity_read ............................................................................................. 31

EMD8216_port_set .............................................................................................................. 32

Page 5: EMD8216 Ethernet Digital I/O module - automation.com.tw

4

EMD8216_port_read ........................................................................................................... 33

EMD8216_point_config_set ................................................................................................ 34

EMD8216_point_config_read ............................................................................................. 34

EMD8216_point_polarity_set ............................................................................................. 35

EMD8216_point_polarity_read ........................................................................................... 35

EMD8216_point_set ............................................................................................................ 36

EMD8216_point_read ......................................................................................................... 37

8.3 Counter function .................................................................................................................. 38

EMD8216_counter_mask_set .............................................................................................. 38

EMD8216_counter_mask_read ........................................................................................... 39

EMD8216_counter_enable .................................................................................................. 39

EMD8216_counter_disable ................................................................................................. 39

EMD8216_counter_read ...................................................................................................... 40

EMD8216_counter_clear ..................................................................................................... 40

8.4 Miscellaneous function ........................................................................................................ 41

EMD8216_socket_port_change........................................................................................... 41

EMD8216_network_config_change .................................................................................... 42

EMD8216_network_config_read ........................................................................................ 43

EMD8216_IP_change .......................................................................................................... 44

EMD8216_reboot ................................................................................................................ 44

EMD8216_default_gateway_change ................................................................................... 45

EMD8216_default_gateway_read ....................................................................................... 45

8.5 Software key function .......................................................................................................... 46

EMD8216_security_unlock ................................................................................................. 46

EMD8216_security_status_read .......................................................................................... 47

EMD8216_password_change .............................................................................................. 47

EMD8216_password_set_default ........................................................................................ 47

8.6 WDT (watch dog timer) ....................................................................................................... 48

EMD8216_WDT_set ........................................................................................................... 48

EMD8216_WDT_read......................................................................................................... 49

EMD8216_WDT_set_new .................................................................................................. 50

EMD8216_WDT_read_new ................................................................................................ 51

EMD8216_WDT_enable ..................................................................................................... 52

EMD8216_WDT_disable .................................................................................................... 52

8.7 Standalone function ............................................................................................................. 53

EMD8216_standalone_enable ............................................................................................. 55

EMD8216_standalone_disable ............................................................................................ 55

EMD8216_standalone_V_config_set .................................................................................. 56

EMD8216_standalone_V_config_read ............................................................................... 59

EMD8216_standalone_config_set ....................................................................................... 61

EMD8216_standalone_config_read .................................................................................... 63

Page 6: EMD8216 Ethernet Digital I/O module - automation.com.tw

5

EMD8216_standalone_config_clear ................................................................................... 65

8.8 Remote output control (Device to device control)............................................................... 66

EMD8216_D2D_config_set ................................................................................................ 67

EMD8216_D2D_config_read .............................................................................................. 68

EMD8216_D2D_connection_clear ..................................................................................... 69

EMD8216_D2D_connection_state_read ............................................................................. 69

EMD8216_D2D_keep_alive_time_set ................................................................................ 70

EMD8216_D2D_keep_alive_time_read ............................................................................. 70

9. User configuration utility of Standalone mode ............................................................................ 71

9.1 Overview of user configuration utility................................................................................. 71

9.2 Configure a command .......................................................................................................... 72

9.3 Remote configure ................................................................................................................. 75

9.4 Virtual I/O and broken line state configuration ................................................................... 76

9.5 Edit function ........................................................................................................................ 77

9.6 Upload program and Power on enable ................................................................................. 78

9.7 Download program .............................................................................................................. 79

9.8 Save or load program with PC ............................................................................................. 80

9.9 Run/Stop standalone function .............................................................................................. 80

10. Standalone mode application examples ....................................................................................... 81

10.1 Example 1: Monitoring input if condition meets, trigger output ......................................... 81

10.2 Example 2: Monitoring the input if condition meets, delay to trigger output ..................... 82

10.3 Example 3: Monitoring the input if condition meets, output pulse ..................................... 83

10.4 Example 4: Monitoring the input if condition meets, output periodically and stop by some

special input condition ....................................................................................................... 84

10.5 Example 5: Don‟t care the input if standalone enabled, trigger output with delay ............. 86

10.6 Example 6: Don‟t care the input if standalone enabled, trigger pulse ................................. 87

10.7 Example 7: Don‟t care the inputs if standalone enabled, output periodically and stop if

input condition meets. ........................................................................................................ 88

10.8 Example 8: Monitoring input if condition meets, trigger remote output ............................. 90

10.9 Example 9: Monitoring input if condition meets, trigger output complex .......................... 91

10.10 Integration example ............................................................................................................. 93

11. Communication protocol ............................................................................................................... 96

11.1 Host to module command format ........................................................................................ 96

11.2 Module to host command format ......................................................................................... 99

11.3 Definition of IP header ....................................................................................................... 100

11.4 Definition of UDP header .................................................................................................. 100

11.5 EMD8216 communication commands .............................................................................. 101

MODULE_TYPE_READ ................................................................................................. 101

REBOOT ........................................................................................................................... 102

SOCKET_PORT_CHANGE ............................................................................................. 103

PASSWORD_CHANGE ................................................................................................... 104

Page 7: EMD8216 Ethernet Digital I/O module - automation.com.tw

6

PASSWORD_RESTORE .................................................................................................. 105

IP_CHANGE ..................................................................................................................... 106

FIRMWARE_VERSION_READ ...................................................................................... 107

SUBNET_MASK_SET ..................................................................................................... 108

SUBNET_MASK_READ ................................................................................................. 109

DEFAULT_GATEWAY_SET ............................................................................................ 110

DEFAULT_GATEWAY_READ ........................................................................................ 111

NETWORK_CONFIG_SET ............................................................................................. 112

NETWORK_CONFIG_READ .......................................................................................... 113

INPUT_DEBOUNCE_SET ............................................................................................... 114

INPUT_DEBOUNCE_READ ........................................................................................... 115

COUNTER_MASK_SET .................................................................................................. 116

COUNTER_MASK_READ .............................................................................................. 117

COUNTER_MODE_ENABLE ......................................................................................... 118

COUNTER_MODE_DISABLE ........................................................................................ 119

IN_COUNTER_READ ..................................................................................................... 120

POINT_COUNTER_CLEAR ............................................................................................ 121

MULTIPLE_COUNTER_CLEAR .................................................................................... 122

PORT_CONFIG_SET ....................................................................................................... 123

PORT_CONFIG_READ .................................................................................................... 124

PORT_SET ........................................................................................................................ 125

PORT_READ..................................................................................................................... 126

POLARITY_SET............................................................................................................... 127

POLARITY_READ ........................................................................................................... 128

POINT_CONFIG_SET ...................................................................................................... 129

POINT_CONFIG_READ .................................................................................................. 130

POINT_SET....................................................................................................................... 131

POINT_READ ................................................................................................................... 132

POINT_POLARITY_SET ................................................................................................. 133

POINT_POLARITY_READ ............................................................................................. 134

MULTI_POINT_SET ........................................................................................................ 135

MULTI_POINT_READ .................................................................................................... 136

STANDALONE_ENABLE ............................................................................................... 138

STANDALONE_DISABLE .............................................................................................. 139

STANDALONE_CONFIG_SET ....................................................................................... 140

STANDALONE_CONFIG_READ ................................................................................... 142

STANDALONE_CONFIG_NEW_SET ............................................................................ 144

STANDALONE_CONFIG_NEW_READ ........................................................................ 146

STANDALONE_CONFIG_CLEAR ................................................................................. 149

WDT_ENABLE................................................................................................................. 150

WDT_DISABLE ............................................................................................................... 151

Page 8: EMD8216 Ethernet Digital I/O module - automation.com.tw

7

WDT_SET ......................................................................................................................... 152

WDT_READ ..................................................................................................................... 154

D2D_CONFIG_SET .......................................................................................................... 156

D2D_CONFIG_READ ...................................................................................................... 157

D2D_KEEP_ALIVE_SET................................................................................................. 158

D2D_KEEP_ALIVE_READ ............................................................................................. 159

CONNECTION_CLEAR .................................................................................................. 160

CONNECTION_STATE_READ ....................................................................................... 161

12. DLL list ......................................................................................................................................... 162

13. EMD8216 Status(Error codes) summary................................................................................... 164

13.1 EMD8216 Status(Error codes) table .................................................................................. 164

14. UDP communication command list ............................................................................................ 166

15. Error codes table for UDP Success_flag .................................................................................... 169

16. Modbus ......................................................................................................................................... 171

16.1 Input register: (function code is 04) ................................................................................... 171

16.2 Configure Register: (function code is 03、06、16).......................................................... 172

16.3 WDT Register: (function code is 03、06、16) ................................................................. 172

16.4 Counter Register: (function code is 03、06、16) ............................................................. 173

16.5 Debounce Register: (function code is 03、06、16).......................................................... 173

16.6 Output register: (function code is 01、05、15) ................................................................ 174

16.7 Input register: (function code is 02) ................................................................................... 175

16.8 Modbus TCP/IP ................................................................................................................. 176

Page 9: EMD8216 Ethernet Digital I/O module - automation.com.tw

8

1. How to install the software of EMD8216

Please visit our website to download or open the DVD come with the EMD8216 module from

directory .. \download\Supplemental_technical_data\

“Step by step installation of EMD module.pdf” document for module installation and download or go to

directory .. \download\Manual_Driver\EthernetModule\EasyConfig to load and install the

“EasyConfig.exe” program, a configuration and monitoring software for single or gang configuration.

The ether net module cannot found by OS as PCI cards. You can just install the driver without the

module installed. Execute the file ..\EMD8216\Software\WinXP_7_10\ or if you download from website

please execute the file EMD8216_Install(Vx.x_yyyymm)*1

.exe to install the driver, API and demo

program automatically.

*1

Vx.x- version yyyy-year mm- month

Page 10: EMD8216 Ethernet Digital I/O module - automation.com.tw

9

2. Where to find the file you need

WinXP/7 and up

In WinXP/7 and later system, the demo program can be setup by

EMD8216_Install(Vx.x_yyyymm)*1

.exe.

If you use the default setting*2

, a new directory ..\JS Automation\EMD8216 will generate to put

the associate files.

..\JS Automation\EMD8216\API (header files and lib files for VB,VC,BCB,C#,VB.net)

..\JS Automation\EMD8216\API\x64 (for x64 system, header files and lib files for

VC,BCB,C#,VB.net)

..\JS Automation\EMD8216\Driver (copy of driver code)

..\JS Automation\EMD8216\exe (demo program and source code)

The dll is located at windows_folder*3

\system.

For your easy startup, the demo program with source code demonstrates the card functions and help

file.

*1

Vx.x- version yyyy-year mm- month *2

in Windows 32-bit system, the default directory at “C:\Program Files”

in Windows 64-bit system, the default directory at “C:\Program Files (x86)” *3

windows_folder : windows install path(usually at “c:\windows\”)

Page 11: EMD8216 Ethernet Digital I/O module - automation.com.tw

10

3. About the EMD8216 software

EMD8216 software includes a set of dynamic link library (DLL) based on socket that you can

utilize to control the interface functions.

Your EMD8216 software package includes setup driver, test program that help you how to setup

and run appropriately, as well as an executable file which you can use to test each of the EMD8216

functions within Windows‟ operation system environment.*1

3.1 What you need to get started

To set up and use your EMD8216 software, you need the following:

EMD8216 software

EMD8216 hardware

3.2 Software programming choices

You have several options to choose from when you are programming EMD8216 software. You can

use Borland C/C++, Microsoft Visual C/C++, Microsoft Visual Basic, or any other Windows-based

compiler that can call into Windows dynamic link libraries (DLLs) for use with the EMD8216 software.

*1

The standalone mode is recommended to edit by using the demo program.

Page 12: EMD8216 Ethernet Digital I/O module - automation.com.tw

11

4. EMD8216 Language support

The EMD8216 software library is a DLL used with WinXP/7 and up. You can use these DLL with

any Windows integrating development environment that can call Windows DLLs.

4.1 Building applications with the EMD8216 software library

The EMD8216 function reference section contains general information about building EMD8216

applications, describes the nature of the EMD8216 functions used in building EMD8216 applications,

and explains the basics of making applications using the following tools:

Applications tools

Microsoft Visual C/C++

Borland C/C++

Microsoft Visual C#

Microsoft Visual Basic

Microsoft VB.net

If you are not using one of the tools listed, consult your development tool reference manual for

details on creating applications that call DLLs.

4.2 EMD8216 Windows Libraries

The EMD8216 for Windows function library is a DLL called EMD8216.dll. Since a DLL is used,

EMD8216 functions are not linked into the executable files of applications. Only the information about

the EMD8216 functions in the EMD8216 import libraries is stored in the executable files.

Import libraries contain information about their DLL-exported functions. They indicate the

presence and location of the DLL routines. Depending on the development tools you are using, you can

make your compiler and linker aware of the DLL functions through import libraries or through function

declarations.

Refer to Table 4.2.1 to determine to which files you need to link and which to include in your

development to use the EMD8216 functions in EMD8216.dll.

Header Files and Import Libraries for Different Development Environments

Language Header File Import Library

Microsoft Visual C/C++ EMD8216.h EMD8216VC.lib

Borland C/C++ EMD8216.h EMD8216BC.lib

Microsoft Visual C# EMD8216.cs

Microsoft Visual Basic EMD8216.bas

Microsoft VB.net EMD8216.vb

Table 4.2.1

Page 13: EMD8216 Ethernet Digital I/O module - automation.com.tw

12

5. Basic concept of the remote digital I/O module

5.1 I/O communicate via Ethernet

The remote digital I/O is the function extension of the card type digital I/O. If the under control

target is at a long distance away, the card type device is limited by the wiring, it is very difficult to go

far away but the Ethernet remote digital I/O will do.

JS automation keeps the remote digital I/O function as close to the card type digital I/O as possible.

Users can port their application from card to remote or from remote to card at the shortest working time.

ethernet

remote I/O module

The module response or be commanded by the controller through Ethernet by UDP protocol. As a

member on the Ethernet, it must have a distinguished IP and a predefined port. At factory, we set the

default IP at 192.168.0.100 and the port at 6936 for the remote module. In spite of the IP addresses are

same on the products shipped, JS Automation do provide a configuration program which enables you to

connect the modules (without configured). The program scans all the on line modules and list the IP and

socket. You can change on them on line. (refer the Ethernet Configuration using the EasyConfig

software)

If you want to control the module through internet, you must configure your network to pass the

message to the module, say, your gateway allows the message from outside to go to the module and also

the message from the module can go out to the internet. Please check with your internet engineer to set

up the environment.

5.2 Standalone I/O controller

The upgrade version of EMD8216 module has add new function to work as Ethernet controlled

standalone controller, it can be download program or monitoring via Ethernet in standalone mode or

fully controlled via Ethernet. The EMD8216 provide internal timer to incorporate with the input and

output that enables you to assign output delay or pulse on special input condition.

On the above figure, input condition can be mask or set to “True” to trigger timer and then timer

can work in pulse mode, delay mode or cyclic mode to trigger output. In this configuration, you can

program to process the I/O as you need and the standalone mode will work as a small PLC.

Page 14: EMD8216 Ethernet Digital I/O module - automation.com.tw

13

5.3 Virtual IO

The EMD module has a special function call Virtual IO, it is an internal register, you can take it

as input if you assign the input data to it or take it as output, if you assign the output data to it. The

most valuable function is that the virtual IO can be a composed result of some input or output (may

be real IO or Virtual IO) and then trigger the communication to transmit information to other

modules. This is the very important base of device to device control function. Please refer the

Section 9.4 Virtual I/O and broken line state configuration.

5.4 Work as SCADA I/O module

There are many SCADA software on the market, they provide the Modbus protocol to

communicate with the devices. The Ethernet I/O modules also provide the standard Modbus protocol

that enables the modules to talk with the SCADA software. The detail of SCADA configuration, please

refer the SCADA software manual provided from the software company. (refer Chapter16 Modbus)

5.5 Types of I/O classified by isolation

If the system and I/O are not electrically connected, we call it is isolated. There are many kinds of

isolation: by transformer, by photo-coupler, by magnetic coupler,… Any kind of device, they can break

the electrical connection without breaking the signal is suitable for the purpose.

Currently, photo-coupler isolation is the most popular selection, isolation voltage up to 2000V or

over is common. But the photo-coupler is limited by the response time, the high frequency type cost a

lot. The new selection is magnetic coupler, it is design to focus on high speed application.

The merit of isolation is to avoid the noise from outside world to enter the module, if the noise

comes into module without elimination, the system maybe get “crazy” by the noise disturbance. Of

course the isolation also limits the versatile of programming as input or output at the same pin as the

TTL does. Owing to isolation the inter-connection of input device and module may extend to several

meters without any problem.

The non-isolated type is generally the TTL level input/output. The ground and power source of the

input/output port come from the system. Generally you can program as input or output at the same pin as

you wish. The connection wiring is limited to 50cm or shorter (depends on the environmental noise

condition).

5.6 Types of Output classified by driver device

There are several devices used as output driver, the relay, transistor or MOS FET, SCR and SSR.

Relay is electric-mechanical device, it life time is about 1,000,000 times of switching. But on the other

hand it has many selections such as high voltage or high current. It can also be used to switch DC load or

AC load. For the practical application, using relay to switch an inductive load is common but the surge

voltage and current during on or off will damage the relay contact and shorten its life.

Page 15: EMD8216 Ethernet Digital I/O module - automation.com.tw

14

Transistor and MOS FET are basically semi-permanent devices. If you have selected the right

ratings, it can work without switching life limit. But the transistor or MOS FET can only work in DC

load condition.

The transistor or MOS FET also have another option is source or sink. For PMOS or PNP transistor

is source type device, the load is one terminal connects to output and another connects to common

ground, but NPN or NMOS is one terminal connects to output and the other connects to VCC+. If you

are concerned about hazard from high DC voltage while the load is floating, please choose the

source type driver device.

SCR (or triac) is seldom direct connect to digital output, but his relative SSR is the most often

selection. In fact, SSR is a compact package of trigger circuit and triac. You can choose zero cross

trigger (output command only turn on the output at power phase near zero to eliminate surge) or direct

turn on type. SSR is working in AC load condition.

5.7 Protection of output transient on inductive load

No matter what type of the output driver, to switch the inductive load is potentially to induce

transient high voltage. The induced high voltage will reach several KV even the load voltage only

several volts. Semiconductor driver will punched through by the high voltage to cause the output a fatal

error, even the rely contact can also results in micro-weld akin to spot welding. This will cause the relay

contact welding together (always make) or bad conduction (always break) or abnormally make or break.

Owing to the popular wiring board driver components can be NMOS, PMOS or relay. The former two

are semiconductor type and limit to DC load. The relay output may be AC or DC load, we will put

emphasis on relay and apply the result to NMOS and PMOS.

Protection Connection Comments Design Note

A

Leakage current to load

maybe cause malfunction.

The effective release time

will be lengthened.

Energy stored in the coil will be

dissipated by R and coil resistance.

R: 0.5-1Ohm per 1V contact voltage

C: 0.5-1uF per 1A current

Use capacitor voltage of 200-300V

and non-polarized type (AC

capacitor) for DC operating voltage.

If AC operating condition, the

capacitor should at least 20% higher

than working voltage.

B

The effective release time

will be lengthened.

C

To prevent the excess high

voltage to damage the

contact.

There only slightly release

delay at the release time.

ZNR rated voltage must select at

least 20% higher than the working

voltage.

Selection of power of ZNR

depends on the operation frequency,

higher frequency needs larger power

Page 16: EMD8216 Ethernet Digital I/O module - automation.com.tw

15

D

one.

If possible, the diagram D is better

than diagram C.

E

The effective release time

will be lengthened longer

than RC snubber.

Energy stored in the coil will

dissipate by coil resistance.

(Only for DC working voltage)

If possible, the diagram F is better

than diagram E.

F

fig. 5.7.1 Protection of output transient

The above list and example schematics show the possible solutions to protect the relay contact, it can

also apply to NMOS or PMOS as they can only switch the DC working voltage.

5.8 Inrush current consideration

Inrush current (input surge current or switch-on surge) is the maximum, instantaneous input current

drawn by an electrical device when first turned on.

The wiring board provides interface devices to drive the target under control device but the type of

load, its inrush current and operating frequency are key factors to the contact life. You must take the

inrush current into consideration to keep the interface in adequate working condition and life.

The following table gives you the design hints for your reference. Please note that a more conservative

design will keep the drive circuit in a safer operating environment.

Type of load Inrush current

Resistive load Same as steady state current

Solenoid load 10-20 times of steady state current

Motor load 5-10 times of steady state current

Incandescent lamp load 10-15 times of steady state current

Mercury lamp load ~3 times of steady state current

Sodium vapor lamp load 1-3 times of steady state current

Capacitive load 20-40 times of steady state current

Transformer load times of steady state current

Page 17: EMD8216 Ethernet Digital I/O module - automation.com.tw

16

6. Function format and language difference

6.1 Function format

Every EMD8216 function is consist of the following format:

Status = function_name (parameter 1, parameter 2, … parameter n);

Each function returns a value in the Status global variable that indicates the success or failure of

the function. A returned Status equal to zero that indicates the function executed successfully. A

non-zero status indicates failure that the function did not execute successfully because of an error, or

executed with an error (refer Chapt.13 EMD8216 Status(Error codes) summary)

Note : Status is a 32-bit unsigned integer.

The first parameter to almost every EMD8216 function is the parameter CardID which is set by

EMD8216_initial. You can utilize multiple devices with different card ID within one application; to do

so, simply pass the appropriate CardID to each function.

Page 18: EMD8216 Ethernet Digital I/O module - automation.com.tw

17

6.2 Variable data types

Every function description has a parameter table that lists the data types for each parameter. The

following sections describe the notation used in those parameter tables and throughout the manual for

variable data types.

Primary Type Names

Name Description Range C/C++ Visual BASIC Pascal

(Borland Delphi)

u8 8-bit

ASCII character

0 to 255 char Not supported by BASIC. For

functions that require character

arrays, use string types instead.

Byte

i16 16-bit

signed integer

-32,768

to 32,767

short Integer

(for example: deviceNum%)

SmallInt

u16 16-bit

unsigned integer

0 to 65,535 unsigned

short for

32-bit

compilers

Not supported by BASIC. For

functions that require unsigned

integers, use the signed integer

type instead. See the i16

description.

Word

i32 32-bit

signed integer

-2,147,483,648 to

2,147,483,647

long Long (for example: count&) LongInt

u32 32-bit

unsigned integer

0 to

4,294,967,295

unsigned

long

Not supported by BASIC. For

functions that require unsigned

long integers, use the signed

long integer type instead. See

the i32 description.

Cardinal (in 32-bit

operating

systems). Refer to

the i32

description.

f32 32-bit

single-precision

floating-point

value

-3.402823E+38 to

3.402823E+38

float Single (for example: num!) Single

f64 64-bit

double-precision

floating-point

value

-1.797685123862315

E+308 to

1.797685123862315E

+308

double Double (for example: voltage

Number)

Double

Table 6.2.1

Page 19: EMD8216 Ethernet Digital I/O module - automation.com.tw

18

6.3 Programming language considerations

Apart from the data type differences, there are a few language-dependent considerations you need

to be aware of when you use the EMD8216 API. Read the following sections that apply to your

programming language.

Note : Be sure to include the declaration functions of EMD8216 prototypes by including the

appropriate EMD8216 header file in your source code. Refer to Chapter 4. EMD8216 Language

support for the header file appropriate to your compiler.

6.3.1 C/C++

For C or C++ programmers, parameters listed as Input/Output parameters or Output parameters are

pass-by-reference parameters, which means a pointer points to the destination variable should be passed

into the function. For example, the read port function has the following format:

Status = EMD8216_port_read (u32 CardID, u8 port, u8 *data);

where CardID and port are input parameters, and data is an output parameter.

To use the function in C language, consider the following example:

u32 CardID=0

u8 port=0 ; //assume CardID is 0 and port also 0

u8 data,

u32 Status;

Status = EMD8216_port_read ( CardID, port, &data);

6.3.2 Visual basic

The file EMD8216.bas contains definitions for constants required for obtaining LSI Card

information and declared functions and variable as global variables. You should use these constants

symbols in the EMD8216.bas, do not use the numerical values.

In Visual Basic, you can add the entire EMD8216.bas file into your project. Then you can use any of the

constants defined in this file and call these constants in any module of your program. To add the

EMD8216.bas file for your project in Visual Basic 4.0, go to the File menu and select the Add File...

option. Select EMD8216.bas, which is browsed in the EMD8216\API directory. Then, select Open to

add the file to the project.

To add the EMD8216.bas file to your project in Visual Basic 5.0 and 6.0, go to the Project menu

and select Add Module. Click on the Existing tab page. Select EMD8216.bas, which is in the

EMD8216\API directory. Then, select Open to add the file to the project.

If you want to use under .NET environment, please download “

Page 20: EMD8216 Ethernet Digital I/O module - automation.com.tw

19

6.3.3 Borland C++ builder

To use Borland C++ builder as development tool, you should generate a .lib file from the .dll file by

implib.exe.

implib EMD8216bc.lib EMD8216.dll

Then add the EMD8216bc.lib to your project and add

#include “EMD8216.h” to main program.

Now you may use the dll functions in your program. For example, the Read Input function has the

following format:

Status = EMD8216_port_read (CardID, port, &data);

where CardID and port, are input parameters, and data is an output parameter. Consider the following

example:

u32 CardID=0;

u8 port=0 ; //assume CardID is 0 and port also 0

u8 data,

u32 Status;

Status = EMD8216_port_read (CardID, port, &data);

* If you are using Delphi, please refer to http://www.drbob42.com/headconv/index.htm for more

detail about the difference of C++ and Delphi.

Page 21: EMD8216 Ethernet Digital I/O module - automation.com.tw

20

7. Using the EMD module

To use the EMD module as a control device of your system, there are many approaches to

implement the functions you need. Choose any of the followings depends on your system architecture.

1. As a slave device of PC (master) and control through the DLL‟s of the module.

2. As a slave device of PC (especially under SCADA software) and control through Modbus

protocol.

3. As a standalone device. (The module can be monitored by PC)

The following list you must read paragraphs of different working mode.

Working mode Basic Advanced

slave device of PC using

DLL

8.1 Initialization and close

8.2 Digital I/O

8.3 Counter function

8.4 Miscellaneous function

8.5 Software key function

8.6 WDT (watch dog timer)

slave device of PC using

Modbus

16. Modbus

Standalone mode 9. User configuration utility of

Standalone mode

10. Standalone mode

application examples

8.7 Standalone function

8.8 Remote output control

(Device to device control)

Page 22: EMD8216 Ethernet Digital I/O module - automation.com.tw

21

7.1 Flow chart of application implementation using DLL

fig. 7.1.1 main flow

fig. 7.1.2 various operation modules

Page 23: EMD8216 Ethernet Digital I/O module - automation.com.tw

22

fig. 7.1.3 standalone operation modules

fig. 7.1.4 WDT operation modules

fig. 7.1.5 IP, socket port and password setting

Page 24: EMD8216 Ethernet Digital I/O module - automation.com.tw

23

8. Software overview and dll function

These topics describe the features and functionality of the EMD8216 module and the detail of the

dll function.

8.1 Initialization and close

You need to initialize system resource and port and IP each time you run your application,

EMD8216_initial( ) will do.

Once you want to close your application, call

EMD8216_close( ) to release all the resource.

To check the firmware version,

EMD8216_firmware_version_read( ) will do.

To check the dll verion,

EMD8216_dll_version_read( )

To change the subnet mask use

EMD8216_subnet_mask_set*1

and read use

EMD8216_subnet_mask_read

*1

Command concerning the system rebooting, please wait for about 10s to precede the next

communication.

Page 25: EMD8216 Ethernet Digital I/O module - automation.com.tw

24

EMD8216_initial

Format: u32 status = EMD8216_initial(u32 CardID, u8 IP_address[4], u16 host_port,

u16 remote_port, u16 timeout_ms, u8 *module_type)

Purpose: To map IP and PORT of an existing EMD8216 to a specified CardID number.

Parameters:

Input:

Name Type Description

CardID u32 0~1999

Assign CardID to the EMD8216 of a

corresponding IP address.

IP_address[4] u8 4 words of IP address, Default:192.168.0.100

For example:

if IP address is “192.168.0.100” then

IP_address[0]=192

IP_address[1]=168

IP_address[2]=0

IP_address[3]=100

host_port u16 Assign a communicate port of host PC

0: assign by os

Default: 15120

remote_port u16 Assign a communicate port of EMD8216

Default: 6936

timeout_ms u16 Assign the max delay time of EMD8216

response message,1000~10000ms.

Output:

Name Type Description

module_type u8 Get the module type of EMD8216

3: 16 I/O (EMD8216)

Page 26: EMD8216 Ethernet Digital I/O module - automation.com.tw

25

EMD8216_close

Format: u32 status =EMD8216_close (u32 CardID)

Purpose: Release the EMD8216 resource when closing the Windows applications.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

EMD8216_firmware_version_read

Format: u32 status =EMD8216_firmware_version_read(u32 CardID, u8 data[2])

Purpose: Read the firmware version.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

Output:

Name Type Description

data[2] u8 the firmware version x.y

x = data[1]

y = data[0]

For example:

if firmware version is V1.34 then

data[1] = 0x01

data[0] = 0x34

EMD8216_dll_version_read

Format: u32 status =EMD8216_dll_version_read(u8 *maj_ver,u8 *sub_ver)

Purpose: Read dll version.

Parameters:

Output:

Name Type Description

maj_ver u8 major version

sub_ver u8 sub version

Page 27: EMD8216 Ethernet Digital I/O module - automation.com.tw

26

EMD8216_subnet_mask_set

Format: u32 status =EMD8216_subnet_mask_set(u32 CardID, u8 subnet_mask[4])

Purpose: set the subnet mask

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

subnet_mask[4] u8 4 byte of subnet mask, Default:255.255.255.0

For example:

if subnet_mask is “255.255.255.0” then

subnet_mask[0]=255

subnet_mask[1]=255

subnet_mask[2]=255

subnet_mask[3]=0

EMD8216_subnet_mask_read

Format: u32 status =EMD8216_subnet_mask_read(u32 CardID, u8 subnet_mask[4])

Purpose: read the subnet mask

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

Output:

Name Type Description

subnet_mask[4] u8 4 byte of subnet mask, Default:255.255.255.0

For example:

if subnet_mask is “255.255.255.0” then

subnet_mask[0]=255

subnet_mask[1]=255

subnet_mask[2]=255

subnet_mask[3]=0

Page 28: EMD8216 Ethernet Digital I/O module - automation.com.tw

27

8.2 Digital I/O

Physical port

Physical port is the port supports real input or output function.

On physical port input and output polarity setting can give you the logic polarity as you need. Say,

you use the positive logic in your application program and the input maybe short to ground as active,

change the polarity to take the short to ground (active) input to be read as logic „1‟.

Each digital I/O point can be configured as input or output. If it is configured as input, the input

level can work up to the external terminal voltage Ve (not exceed the output buffer rating 45Vdc).

If it is configured as output, the output buffer can drive up to 450ma peak current and steady state

up to 45ma, the working voltage up to 45Vdc. You can see the circuit diagram as follows.

Virtual port

Virtual port is the port that has input or output data but do not have the real input or output. But you

can map the real input or real output to it. The virtual ports can also map as real input or output of

another modules. The module has 2 virtual ports (16bits). (Refer Section 8.7 Standalone function)

First of all, each port must configure as input or output(physical port only)

EMD8216_port_config_set( ) and read back to verify by

EMD8216_port_config_read( )

Input and output polarity setting can give you the logic polarity as you need. Say, you use the

positive logic in your application program and the input maybe short to ground as active, change the

polarity to take the short to ground (active) input to be read as logic „1‟.

To set the input and output polarity(physical port only)

EMD8216_port_polarity_set( ) and to read back the setting by

EMD8216_port_polarity_read( )

Before using an input port, if you already know the maximum response time of the input signal you

can setup the debounce time to filter out the undesired noise signal and get a noise-free signal. If you do

not know the exact response, please use the conservative setting.

Use EMD8216_inport_debounce_set( )to configure the debounce time.

EMD8216_inport_debounce_read( )to read back the configuration data.

To control the output, use

Page 29: EMD8216 Ethernet Digital I/O module - automation.com.tw

28

EMD8216_port_set( )

To read input or output register status use

EMD8216_port_read( )

To configure a point as input or output, use

EMD8216_point_config_set( ) and read back to verify by

EMD8216_point_config_read( )

To set the input and output polarity by point

EMD8216_point_polarity_set( ) and to read back the setting by

EMD8216_point_polarity_read( )

To control a point of output, use

EMD8216_point_set( )

To read a point data of input or output register, use

EMD8216_point_read( )

Note: EMD8216 has 16 programmable IO’s, each point can be an input or an output depends

on the configuration.

Both modules have the 2 virtual port, VIO_07~VIO_00, VIO_17~VIO_10

Page 30: EMD8216 Ethernet Digital I/O module - automation.com.tw

29

EMD8216_port_config_set

Format: u32 status = EMD8216_port_config_set(u32 CardID, u8 port, u8 config)

Purpose: Set the Configuration of the I/O port.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

config u8 Configure the IO as input or output

bit7:

1: IO_n7 as input

0: IO_n7 as output

bit0:

1: IO_n0 as input

0: IO_n0 as output

EMD8216_port_config_read

Format: u32 status = EMD8216_port_config_read(u32 CardID, u8 port, u8 *config)

Purpose: Read back the Configure of the I/O port.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

Output:

Name Type Description

config u8 Configure the IO as input or output

bit7:

1:IO_n7 as input

0:IO_n7 as output

bit0:

1:IO_n0 as input

0:IO_n0 as output

Page 31: EMD8216 Ethernet Digital I/O module - automation.com.tw

30

EMD8216_inport_debounce_set

Format: u32 status = EMD8216_inport_debounce_set(u32 CardID, u8 port,

u8 debounce_time)

Purpose: Set the input port debounce time.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 Port number (only valid for port configured as

input)

0: IO_07~IO_00

1: IO_17~IO_10

debounce_time u8 Debounce time on 5ms time base

1: 5ms (default)

2: 10ms

3: 15ms

200: 1000ms (max)

EMD8216_inport_debounce_read

Format: u32 status = EMD8216_inport_debounce_read(u32 CardID, u8 port,

u8 *debounce_time)

Purpose: Read back the debounce time of the input port.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 Port number (only valid for port configured as

input)

0: IO_07~IO_00

1: IO_17~IO_10

Output:

Name Type Description

debounce_time u8 Debounce time on 5ms time base

1: 5ms (default)

2: 10ms

3: 15ms

200: 1000ms (max)

Page 32: EMD8216 Ethernet Digital I/O module - automation.com.tw

31

EMD8216_port_polarity_set

Format: u32 status = EMD8216_port_polarity_set(u32 CardID, u8 port, u8 data)

Purpose: Set the I/O port polarity.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

data u8 b7:

0: normal polarity of IO_n7

1: invert polarity of IO_n7

b0:

0: normal polarity of IO_n0

1: invert polarity of IO_n0

EMD8216_port_polarity_read

Format: u32 status = EMD8216_port_polarity_read(u32 CardID, u8 port, u8 *data)

Purpose: Read back the polarity setting of the I/O port.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

Output:

Name Type Description

data u8 b7:

0: normal polarity of IO_n7

1: invert polarity of IO_n7

b0:

0: normal polarity of IO_n0

1: invert polarity of IO_n0

Page 33: EMD8216 Ethernet Digital I/O module - automation.com.tw

32

EMD8216_port_set

Format: u32 status = EMD8216_port_set(u32 CardID, u8 port, u8 data)

Purpose: Set the output port data.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

2: VIO_07~VIO_00

3: VIO_17~VIO_10

data u8 b7:

0: inactive of IO_n7 or VIO_n7

1: active of IO_n7 or VIO_n7

b0:

0: inactive of IO_n0 or VIO_n0

1: active of IO_n0 or VIO_n0

Note: An output channel is active may be output high or low depends on the polarity it is

configured. Say polarity is normal, active means output high and polarity is invert will have active

output to be low state.

Page 34: EMD8216 Ethernet Digital I/O module - automation.com.tw

33

EMD8216_port_read

Format: u32 status = EMD8216_port_read(u32 CardID, u8 port, u8 *data)

Purpose: Read back the data of the I/O port.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

2: VIO_07~VIO_00 (virtual port0)

3: VIO_17~VIO_10 (virtual port1)

Output:

Name Type Description

data u8 b7:

0: inactive of IO_n7 or VIO_n7

1: active of IO_n7 or VIO_n7

b0:

0: inactive of IO_n0 or VIO_n0

1: active of IO_n0 or VIO_n0

Page 35: EMD8216 Ethernet Digital I/O module - automation.com.tw

34

EMD8216_point_config_set

Format: u32 status =EMD8216_point_config_set(u32 CardID, u8 port, u8 point, u8 config)

Purpose: Set bit configuration of I/O point

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

point u8 point number

7:IO_n7

..

0: IO_n0

config u8 1: input 0: output

Note: An output channel is active may be output high or low depends on the polarity it is

configured. Say polarity is normal, active means output high and polarity is invert will have active

output to be low state.

EMD8216_point_config_read

Format: u32 status =EMD8216_point_config_read(u32 CardID, u8 port, u8 point,

u8 *config)

Purpose: Read bit configuration of I/O point.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

point u8 point number

7:IO_n7

..

0: IO_n0

Output:

Name Type Description

config u8 1: input 0: output

Page 36: EMD8216 Ethernet Digital I/O module - automation.com.tw

35

EMD8216_point_polarity_set

Format: u32 status = EMD8216_point_polarity_set(u32 CardID, u8 port, u8 point,

u8 state)

Purpose: Set the I/O point polarity.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by

EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

point u8 point number

7:IO_n7

..

0: IO_n0

state u8 1 : invert 0 : normal.

Note: An output channel is active may be output high or low depends on the polarity it is

configured. Say polarity is normal, active means output high and polarity is invert will have active

output to be low state.

EMD8216_point_polarity_read

Format: u32 status = EMD8216_point_polarity_read(u32 CardID, u8 port, u8 point,

u8 *state)

Purpose: Read back the polarity setting of the I/O point.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

point u8 point number

7:IO_n7

..

0: IO_n0

Output:

Name Type Description

state u8 1 : invert 0 : normal.

Page 37: EMD8216 Ethernet Digital I/O module - automation.com.tw

36

EMD8216_point_set

Format: u32 status =EMD8216_point_set(u32 CardID, u8 port, u8 point, u8 state)

Purpose: Set bit status of output point

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

2: VIO_07~VIO_00(virtual port0)

3: VIO_17~VIO_10(virtual port1)

point u8 point number

7: IO_n7 or VIO_n7

..

0: IO_n0 or VIO_n0

state u8 1 : active 0 : inactive

Note: An output channel is active may be output high or low depends on the polarity it is

configured. Say polarity is normal, active means output high and polarity is invert will have active

output to be low state.

Page 38: EMD8216 Ethernet Digital I/O module - automation.com.tw

37

EMD8216_point_read

Format: u32 status =EMD8216_point_read(u32 CardID, u8 port, u8 point, u8 *state)

Purpose: Read bit state of I/O point.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

2: VIO_07~VIO_00(virtual port0)

3: VIO_17~VIO_10(virtual port1)

point u8 point number

7: IO_n7 or VIO_n7

..

0: IO_n0 or VIO_n0

Output:

Name Type Description

state u8 1 : active 0 : inactive

Page 39: EMD8216 Ethernet Digital I/O module - automation.com.tw

38

8.3 Counter function

You can use the digital input as a low speed counter (no more than 100pps). First you can set which

input channel you will want to work as counter by:

EMD8216_counter_mask_set( ) then enable the function by

EMD8216_counter_enable( ) and any time to stop by

EMD8216_counter_disable( ).

To read the mask value by

EMD8216_counter_mask_read( )

To read the counter value by

EMD8216_counter_read( ) and use

EMD8216_counter_clear( ) to clear counter.

Each point configured as input can work as low frequency counter (max 100Hz, 50% duty). The

remote I/O module will count the input signal for you without any attention to the signal transition.

EMD8216_counter_mask_set

Format: u32 status = EMD8216_counter_mask_set(u32 CardID, u8 port, u8 channel);

Purpose: To set the counter channel mask.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

channel u8 b7 ~ b0,

b7:

0: IO_n7 counter disable

1: IO_n7 counter enable

b0:

0: IO_n0 counter disable

1: IO_n0 counter enable

Page 40: EMD8216 Ethernet Digital I/O module - automation.com.tw

39

EMD8216_counter_mask_read

Format: u32 status = EMD8216_counter_mask_read(u32 CardID, u8 port, u8 *channel);

Purpose: To read the counter channel mask.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

Output:

Name Type Description

channel u8 b7 ~ b0,

b7:

0: IO_n7 counter disable

1: IO_n7 counter enable

b0:

0: IO_n0 counter disable

1: IO_n0 counter enable

EMD8216_counter_enable

Format: u32 status = EMD8216_counter_enable(u32 CardID);

Purpose: To enable the counter.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

EMD8216_counter_disable

Format: u32 status = EMD8216_counter_disable(u32 CardID);

Purpose: To disable the counter.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

Page 41: EMD8216 Ethernet Digital I/O module - automation.com.tw

40

EMD8216_counter_read

Format: u32 status = EMD8216_counter_read(u32 CardID, u8 port, u32 counter[8]);

Purpose: To read all the counter value.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

Output:

Name Type Description

counter[8] u32 counter value

counter[0] for IO_n0

counter[7] for IO_n7

EMD8216_counter_clear

Format: u32 status = EMD8216_counter_clear(u32 CardID, u8 port, u8 channel);

Purpose: To reset the counter value.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

port u8 port number

0: IO_07~IO_00

1: IO_17~IO_10

channel u8 b7~b0,

b7:

0: no function

1: clear IOx7 counter

b0:

0: no function

1: clear IOx0 counter

Page 42: EMD8216 Ethernet Digital I/O module - automation.com.tw

41

8.4 Miscellaneous function

The module IP and communication port must be confirmed with the gateway and software to ensure

the correct Ethernet communication.

To change the communication port as you need by:

EMD8216_socket_port_change( )*1

To change and read back network config settings(IP、subnet mask and default gateway) by:

EMD8216_network_config_change( )*1

(Recommend, because it validate IP、gateway and

subnet mask)

EMD8216_network_config_read( )

To change IP,

EMD8216_IP_change( )*1

(Not recommend, because it doesn’t validate IP、gateway and

subnet mask)

To reboot EMD8216 module for module alarm or to validate the system configuration change by:

EMD8216_reboot( )*1

To change default gateway and read back default gateway by:

EMD8216_default_gateway_change( )*1

(Not recommend, because it doesn’t validate IP、

gateway and subnet mask)

EMD8216_default_gateway_read( )

*1

Command concerning the system rebooting, please wait for about 10s to precede the next

communication.

EMD8216_socket_port_change

Format: u32 status = EMD8216_socket_port_change (u32 CardID, u16 remote_port);

Purpose: To change the communicate port number of EMD8216.

After using this function, please wait for reboot (about 10s) to validate the change.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

remote_port u16 The new port number to be set

Page 43: EMD8216 Ethernet Digital I/O module - automation.com.tw

42

EMD8216_network_config_change

Format: u32 status = EMD8216_network_config_change (u32 CardID, u8 IP[4],

u8 mask[4], u8 gateway[4]);

Purpose: Set IP address、subnet mask and default gateway to EMD8216

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

IP[4] u8 The new IP to be set to the module.

For example:

if set IP address to “192.168.0.100” then

IP[0]=192

IP[1]=168

IP[2]=0

IP[3]=100

mask[4] u8 4 byte of subnet mask, Default:255.255.255.0

For example:

if set subnet mask to “255.255.255.0” then

mask[0]=255

mask[1]=255

mask[2]=255

mask[3]=0

gateway[4] u8 The new default gateway to be set to the

module.

For example:

if set default gateway to “192.168.0.1” then

gateway[0]=192

gateway[1]=168

gateway[2]=0

gateway[3]=1

Page 44: EMD8216 Ethernet Digital I/O module - automation.com.tw

43

EMD8216_network_config_read

Format: u32 status = EMD8216_network_config_read (u32 CardID, u8 IP[4], u8 mask[4],

u8 gateway[4]);

Purpose: Read back IP address、subnet mask and default gateway of EMD8216

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

Output:

Name Type Description

IP[4] u8 Read the IP address from the module.

For example:

if read back IP address is “192.168.0.100”

then

IP[0]=192

IP[1]=168

IP[2]=0

IP[3]=100

mask[4] u8 Read the subnet mask from the module.

For example:

if read back subnet mask is “255.255.255.0”

then

mask[0]=255

mask[1]=255

mask[2]=255

mask[3]=0

gateway[4] u8 Read the default gateway from the module.

For example:

if read back default gateway is “192.168.0.1”

then

gateway[0]=192

gateway[1]=168

gateway[2]=0

gateway[3]=1

Page 45: EMD8216 Ethernet Digital I/O module - automation.com.tw

44

EMD8216_IP_change

Format: u32 status = EMD8216_IP_change (u32 CardID, u8 IP[4]);

Purpose: To change the communicate IP of EMD8216.

After using this function, please wait for reboot(about 10s) to validate the change.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

IP[4] u8 The new IP to be set

EMD8216_reboot

Format : u32 status = EMD8216_reboot(u32 CardID);

Purpose: To reboot EMD8216(about 10s).

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

Note:

Command concerning the system rebooting, please wait for about 10s to proceed the next

communication.

Page 46: EMD8216 Ethernet Digital I/O module - automation.com.tw

45

EMD8216_default_gateway_change

Format: u32 status = EMD8216_default_gateway_change (u32 CardID, u8 new_IP[4]);

Purpose: Read back default gateway of EMD8216.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

new_IP[] u8 The new default gateway to be set to the

module.

For example:

if default gateway is “192.168.0.1” then

new_IP[0]=192

new_IP[1]=168

new_IP[2]=0

new_IP[3]=1

EMD8216_default_gateway_read

Format: u32 status = EMD8216_default_gateway_read (u32 CardID, u8 new_IP[4]);

Purpose: Read back default gateway of EMD8216

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

Output:

Name Type Description

new_IP[4] u8 Read the default gateway from the module.

For example:

if read back default gateway is “192.168.0.1”

then

new_IP[0]=192

new_IP[1]=168

new_IP[2]=0

new_IP[3]=1

Page 47: EMD8216 Ethernet Digital I/O module - automation.com.tw

46

8.5 Software key function

Software key is used to protect the modification of IO state and system configuration by

un-authorized person.

To operate the EMD8216, you must unlock the module first by

EMD8216_security_unlock( )

To verify the lock status by

EMD8216_security_status_read( )

You can change password for your convenience by

EMD8216_password_change( ) *2

If you forget the password you set, you can recover the factory default password by:

EMD8216_password_set_default( ) *2

*2

Command concerning the system rebooting, please wait for about 10s to proceed the next

communication.

EMD8216_security_unlock

Format: u32 status = EMD8216_security_unlock(u32 CardID, u8 password[8])

Purpose: To unlock security function and enable the further operation.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

password[8] u8 The password previous set (ASCII)

Use a-z,A-Z,0-9 characters.

For example:

u8 password[8] = {'1','2','3','4','5','6','7','8'};

u8 password[8] = {'1','2','3','a‟,

'A‟,NULL,NULL,NULL};

default :

password[8] = {'1','2','3','4','5','6','7','8'};

Page 48: EMD8216 Ethernet Digital I/O module - automation.com.tw

47

EMD8216_security_status_read

Format: u32 status = EMD8216_security_status_read(u32 CardID, u8 *lock_status);

Purpose: To read security status for checking if the card security function is unlocked.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

Output:

Name Type Description

lock_status u8 0: security unlocked

1: locked

EMD8216_password_change

Format: u32 status = EMD8216_password_change(u32 CardID, u8 old_password[8],

u8 password[8])

Purpose: To replace old password with new password.

After using this function, please wait for reboot(about 10s) to validate the change.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

old_password [8] u8 The previous password (ASCII)

password[8] u8 The new password to be set (ASCII)

EMD8216_password_set_default

Format: u32 status = EMD8216_password_set_default(u32 CardID)

Purpose: Set password to default.

After using this function, please wait for reboot (about 10s) to validate the change.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

default :

password[8] = {'1','2','3','4','5','6','7','8'};

Page 49: EMD8216 Ethernet Digital I/O module - automation.com.tw

48

8.6 WDT (watch dog timer)

In the industrial environment, we want the controller work as stable as possible but we are not God;

we cannot always put the controller by guess. To ensure the controller will not harm to the system or

human, people always put a WDT to monitor the controller, if the controller runs in abnormal state the

system will fail to reset WDT then WDT will latch the system to prevent further harm. EDM8216 also

provide the WDT function, which will detect the Ethernet connection state, once the connection is fail

for a predefined period, the module will output the predefined status to the ports. You can enable or

disable as your application required.

Use EMD8216_WDT_set( ) to set up the WDT timer and the output state if the Ethernet connection

fail to communicate.

EMD8216_WDT_read( ) to read back the configuration.

Use EMD8216_WDT_set_new( ) to set up the WDT timer and the output state (with mask off) if

the Ethernet connection fail to communicate.

EMD8216_WDT_read_new( ) to read back the configuration.

To enable the WDT function to monitor the communication (you must periodically communicate

with the remote I/O module to keep it alive) by:

EMD8216_WDT_enable( ) and disable by:

EMD8216_WDT_disable( ).

Note: WDT will be disabled while the application is closed.

EMD8216_WDT_set

Format: u32 status = EMD8216_WDT_set(u32 CardID, u16 time, u8 state[2])

Purpose: Set WDT (watch dog timer) configuration.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

time u16 Set the WDT wait time.(10~10000) based on

0.1 sec time base.

default: 10 (1s)

state[2] u8 Set the output default state while the

connection failed.

state[0]: OUT07~OUT00 predefined state

while connection fail.

state[1]: OUT17~OUT10 predefined state

while connection fail.

Note: The predefined outputs will be complied with the polarity it is configured.

Page 50: EMD8216 Ethernet Digital I/O module - automation.com.tw

49

EMD8216_WDT_read

Format : u32 status = EMD8216_WDT_read(u32 CardID, u16 *time, u8 state[2],

u8 *enable)

Purpose: Read back WDT(watch dog timer) configuration.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

Output:

Name Type Description

time u16 read the WDT wait time.

state[2] u8 state[0]: OUT07~OUT00 predefined state

while connection fail.

state[1]: OUT17~OUT10 predefined state

while connection fail.

enable u8 0: disable

1: enable

Page 51: EMD8216 Ethernet Digital I/O module - automation.com.tw

50

EMD8216_WDT_set_new

Format: u32 status = EMD8216_WDT_set_new(u32 CardID, u16 time, u8 state[4],

u8 mask[4], u8 power_on)

Purpose: Set WDT (watch dog timer) configuration.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

time u16 Set the WDT wait time.(10~10000) based on

0.1 sec time base.

default: 10 (1s)

state[4] u8 Set the output default state, the state will keep

while the connection failure.

state[0]: IO_07~IO_00 predefined state at

connection fail.

state[1]: IO_17~IO_10 predefined state at

connection fail.

state[2]: VIO_07~VIO_00 predefined state at

connection fail.

state[3]: VIO_17~VIO_10 predefined state at

connection fail.

mask[4] u8 select the point which you want keep the state

while the connection failure.

mask[0]: IO_07~IO_00 predefined mask on at

connection fail.

mask[1]: IO_17~IO_10 predefined mask on at

connection fail.

mask[2]: VIO_07~VIO_00 predefined mask

on at connection fail.

mask[3]:V IO_17~VIO_10 predefined mask

on at connection fail.

power_on u8 0: power on do not run WDT mode (default)

1: power on run WDT mode

Note: The predefined outputs will be complied with the polarity it is configured.

Page 52: EMD8216 Ethernet Digital I/O module - automation.com.tw

51

EMD8216_WDT_read_new

Format: u32 status = EMD8216_WDT_read_new(u32 CardID, u16 *time, u8 state[4],

u8 mask[4], u8 *enable, u8 *power_on)

Purpose: Read back WDT(watch dog timer) configuration.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

Output:

Name Type Description

time u16 read the WDT wait time.

state[4] u8 Set the output default state, the state will keep

while the connection failure.

state[0]: IO_07~IO_00 predefined state at

connection fail.

state[1]: IO_17~IO_10 predefined state at

connection fail.

state[2]: VIO_07~VIO_00 predefined state at

connection fail.

state[3]:V IO_17~VIO_10 predefined state at

connection fail.

mask[4] u8 select the point which you want keep the state

while the connection failure.

mask[0]: IO_07~IO_00 predefined mask on at

connection fail.

mask[1]: IO_17~IO_10 predefined mask on at

connection fail.

mask[2]: VIO_07~VIO_00 predefined mask

on at connection fail.

mask[3]: VIO_17~VIO_10 predefined mask

on at connection fail.

enable u8 0: disable

1: enable

power_on u8 0: power on do not run WDT mode (default)

1: power on run WDT mode

Page 53: EMD8216 Ethernet Digital I/O module - automation.com.tw

52

EMD8216_WDT_enable

Format: u32 status = EMD8216_WDT_enable(u32 CardID)

Purpose: enable WDT(watch dog timer) .

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

EMD8216_WDT_disable

Format: u32 status = EMD8216_WDT_disable(u32 CardID)

Purpose: disable WDT (watch dog timer) .

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

Page 54: EMD8216 Ethernet Digital I/O module - automation.com.tw

53

8.7 Standalone function

The above mentioned functions are majorly support for master slave control model which needs the

Ethernet always active. The standalone mode is the application extension of EMD8216 module; it can

work as I/O controller with or without the Ethernet existing.

The standalone mode consists of 3 function blocks: input block, control block(input to output

relationship) and output block.

fig. 8.7.1 Standalone mode function block diagram

8.7.1 Input block

There are 3 types of inputs, physical, virtual and special inputs.

No matter it is physical, virtual or special input, it controls the action of control block.

Physical input

The input of the module which physical device is connected, i.e. IN7 ~IN0 for EMD8208 and

IN3~IN0 for EMD8204.

Virtual input

The logic layer input, no external wire to connect (VIO_17~VIO_10, VIO_07~VIO_00).

Input can be masked to select the desire points (both Physical or Virtual input) and state to trigger

control.

Special input

There are two special input triggers in Standalone mode (fig. 8.7.1 Standalone mode function

block diagram).

Page 55: EMD8216 Ethernet Digital I/O module - automation.com.tw

54

-- startup: an always true input while the module power up and ready to run standalone mode.

-- communication broken: it will be true if the Ethernet communication is broken.

8.7.2 Control block

There are several control modes to generate output:

- If working in delay mode, the output will not trigger until the timer time up.

- If working in pulse mode, the output will trigger immediately while the input condition meets

but inactive while timer time up.

- If working in periodic mode, the output will toggle at each timer time up then timer reloads

itself for next toggle until stop periodic out (timer off).

- If working in bypass mode, there is no interaction of timer to generate output (output

immediately).

- If working in Remote output control mode, the output will trigger the remote module via

Ethernet.

8.7.3 Output block

Physical output, the output of the module is used to control the external devices. For EMD8204

OUT3~OUT0 are physical output and EMD8208 are OUT7~OUT0.

Virtual output, the logic layer output, they are common to Virtual input. (i.e. the virtual inputs are

also virtual outputs)

If we use the device to device function, the outputs maybe the remote module‟s physical or virtual

outputs. The output mode can be active or inactive and toggle, if toggle mode, the output will change

state each tine the logical result of the input is true.

8.7.4 Standalone mode startup

When the module is programmed in standalone mode, a virtual startup input will be true at module

ready to run standalone mode. The typical application, say, you want to generate a square wave. Now

program the control mode as “Startup Input action and periodic out”, you will get a square wave at

designated point while the module works in standalone mode.

8.7.5 Communication broken

A special status bit called communication broken can be used to detect the PC to module or module

to module communication. It can be used to generate an output or a device to device control.

8.7.6 DLL of standalone function

If you have preprogrammed step sequence command in the module, you can command it to start by:

EMD8216_standalone_enable( ) and stop by

EMD8216_standalone_disable( )

Page 56: EMD8216 Ethernet Digital I/O module - automation.com.tw

55

There are total 32 steps can be programmed, to program the step sequence command,

EMD8216_standalone_V_config_set( ) and you can read back for verification by

EMD8216_standalone_V_config_read( )

The old DLL function

EMD8216_standalone_config_set( ) and

EMD8216_standalone_config_read( ) are preserved for old version.

To clear all the saved step sequence command of the module,

EMD8216_standalone_config_clear( )

We strongly recommend you to program the stand alone mode with the demo program, it is

an easy and visual programming interface and also download the command to test with it. After

program verified you can save the code for your application to download in your application by

the above command.

EMD8216_standalone_enable

Format: u32 status =EMD8216_standalone_enable(u32 CardID)

Purpose: Enable standalone mode, run standalone program sequences immediately.

Parameters:

Input:

Name Type Description

CardID u32 0~255

CardID assigned by EMD8216_initial

EMD8216_standalone_disable

Format: u32 status =EMD8216_standalone_disable(u32 CardID)

Purpose: Disable standalone mode, stop standalone program sequences immediately.

Parameters:

Input:

Name Type Description

CardID u32 0~255

CardID assigned by EMD8216_initial

Page 57: EMD8216 Ethernet Digital I/O module - automation.com.tw

56

EMD8216_standalone_V_config_set

Format: u32 status =EMD8216_standalone_V_config_set(u32 CardID, u8 step_number,

_V_StandaloneData data[32], u8 standalone_state)

Purpose: To configure the process command.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

step_number u8 Number of function

data[32] _V_StandaloneData struct V_StandaloneData{

u32 timer_value;

u8 in_virtual_point_bit[2];

u8 in_virtual_state_bit[2];

u8 in_point_bit[2];

u8 in_state_bit[2];

u8 remote_detection [4];

u8 control_mode;

u8 out_mode;

u8 out_virtual_point_bit[2];

u8 out_point_bit[2];

}

timer_value: set timer value

// timer tick is 100ms per tick

// control_mode = delay / periodic out

// setting value is delay timer

// control_mode = pulse out

// setting value is active time of pulse

// if timer_value = 10 ,

// the delay time is 10 * 100 ms = 1000 ms

in_virtual_point_bit: select the virtual point

that you want to see the state

//[0].b7 ~ b0 = VIO_07 ~ VIO_00

//[1].b7 ~ b0 = VIO_17 ~ VIO_10

in_virtual_state_bit:

//set virtual IO state

//0: inactive, 1:active

//[0].b7 ~ b0 = VIO_07 ~ VIO_00

//[1].b7 ~ b0 = VIO_17 ~ VIO_10

Page 58: EMD8216 Ethernet Digital I/O module - automation.com.tw

57

in_point_bit: select the input point which you

want to watch the state.

//[0].b7 ~ b0 = IO07 ~ IO00

//[1].b7 ~ b0 = IO17 ~ IO10

in_state_bit:

//set input state

//0: inactive, 1:active

//[0].b7 ~ b0 = IO07 ~ IO00

//[1].b7 ~ b0 = IO17 ~ IO10

remote_detection

//detection the connection status from remote to

//the module

//1: enable 0: disable

//[0] : detect remote module0

//[1] : detect remote module1

//[2] : detect remote module2

//[3] : detect remote module3

control_mode

// 0x0 = Bypass,

// 0x1 = Input action and delay out

// 0x2 = Input action and pulse out

// 0x3 = Input action and periodic out

//0x4 = Startup action and delay out

// 0x5 = Startup action and pulse out

// 0x6 = Startup action and periodic out

// 0x7 = Stop periodic out

// 0x10 = send to remote module0

// 0x11 = send to remote module1

// 0x12 = send to remote module2

// 0x13 = send to remote module3

out_mode

// control_mode = Bypass,

// 0x0= INACTIVE, 0x1= ACTIVE,

// 0x2=Change state(toggle)

// control_mode = delay out,

// 0x0= INACTIVE, 0x1= ACTIVE,

// 0x2=Change state

// control_mode = pulse out,

// 0x0 = L_PULSE, 0x1 = H_PULSE

Page 59: EMD8216 Ethernet Digital I/O module - automation.com.tw

58

// control_mode = periodic out,

// 0x2 = Change state

// control_mode = remote control,

// 0x0= INACTIVE, 0x1= ACTIVE

out_virtual_point_bit

//[0].b7 ~ b0 = VIO_07 ~ VIO_00

//[1].b7 ~ b0 = VIO_17 ~ VIO_10

//virtual output may be on the module itself or

the

// remote module. If control_mode is

// configured as send to remote module.

//The output will be on the remote.

out_point_bit

//[0].b7 ~ b0 = OUT_07 ~ OUT_00

//[1].b7 ~ b0 = OUT_17 ~ OUT_10

//output may be on the module itself or the

// remote module. If control_mode is

// configured as send to remote module. The

// output will be on the remote.

//The point will be limited by the designated

//module.

standalone_state u8 0: power on do not run standalone mode (default)

1: power on run standalone mode

Page 60: EMD8216 Ethernet Digital I/O module - automation.com.tw

59

EMD8216_standalone_V_config_read

Format: u32 status =EMD8216_standalone_V_config_read(u32 CardID, u8 *step_number,

_V_StandaloneData data[32], u8 *enable, u8 *standalone_state)

Purpose: To read back the pre-propgrammed standalone process command.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

Output:

Name Type Description

step_number u8 Number of function

data[32] _V_StandaloneData struct V_StandaloneData{

u32 timer_value;

u8 in_virtual_point_bit[2];

u8 in_virtual_state_bit[2];

u8 out_virtual_point_bit[2];

u8 in_point_bit[2];

u8 in_state_bit[2];

u8 out_point_bit[2];

u8 control_mode;

u8 out_mode;

u8 disconnect_mask[4];

}

in_point_bit: select the input point that you want to

see the state

//[0].b7 ~ b0 = IO07 ~ IO00

//[1].b7 ~ b0 = IO17 ~ IO10

in_state_bit: set input state

in_virtual_point_bit: select the virtual point that

you want to see the state

//[0].b7 ~ b0 = VIO_07 ~ VIO_00

//[1].b7 ~ b0 = VIO_17 ~ VIO_10

in_virtual_state_bit: set virtual state

control_mode: select control mode

// 0x0 = Bypass,

// 0x1 = Input action and delay out,

Page 61: EMD8216 Ethernet Digital I/O module - automation.com.tw

60

// 0x2 = Input action and pulse out

// 0x3 = Input action and periodic out

//0x4 = Timer action and delay out

// 0x5 = Timer action and pulse out

// 0x6 = Timer action and periodic out

// 0x7 = Timer off

// 0x8 = send to remote module0

// 0x9 = send to remote module1

// 0xA = send to remote module2

// 0xB = send to remote module3

timer_value: set timer value

// timer tick is 100ms per tick

// control_mode = delay / periodic out

// setting value is delay timer

// control_mode = pulse out

// setting value is active time of pulse

// if timer_value = 10 ,

// the delay time is 10 * 100 ms = 1000 ms

out_point_bit: select the output point that you want

to see the state

//[0].b7 ~ b0 = IO07 ~ IO00

//[1].b7 ~ b0 = IO17 ~ IO10

out_mode: select output mode

// control_mode = Bypass,

// 0x0= INACTIVE, 0x1= ACTIVE,

// 0x2=Change

// control_mode = remote control,

// 0x0= INACTIVE, 0x1= ACTIVE,

// control_mode = delay out,

// 0x0= INACTIVE, 0x1= ACTIVE,

// 0x2=Change

// control_mode = pulse out,

// 0x0 = L_PULSE, 0x1 = H_PULSE

// control_mode = periodic out,

// 0x2 = Change

enable u8 0: currently is standalone disabled

1: currently is standalone enabled

standalone_state u8 0: power on do not run standalone mode (default)

1: power on run standalone mode

Page 62: EMD8216 Ethernet Digital I/O module - automation.com.tw

61

EMD8216_standalone_config_set

Format: u32 status =EMD8216_standalone_config_set(u32 CardID, u8 step_number,

_StandaloneData data[32], u8 standalone_state)

Purpose: To configure the process command.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

step_number u8 Number of data[ ]

data[32] _StandaloneData typedef struct _StandaloneData{

u16 in_point_bit;

u16 in_state_bit;

u16 timer_value;

u16 out_point_bit;

u8 timer_mode;

u8 out_mode;

}

in_point_bit

//b7 ~ b0 = IO07 ~ IO00

//b15 ~ b8 = IO17 ~ IO10

in_state_bit

//set input state

timer_mode

// 0x0 = Unused,

// 0x1 = Input action and delay out,

// 0x2 = Input action and pulse out

// 0x3 = Input action and periodic out

// 0x4 = Timer action and delay out

// 0x5 = Timer action and periodic out

// 0x6 = Timer off

timer_value

// timer tick is 5ms per tick

// timer_mode = delay / periodic out

// setting value is delay timer

// timer_mode = pulse out

// setting value is active time of pulse

// if timer_value = 10 ,

// the delay time is 10 * 5 ms = 50 ms

out_point_bit

//b7 ~ b0 = IO07 ~ IO00

Page 63: EMD8216 Ethernet Digital I/O module - automation.com.tw

62

//b15 ~ b8 = IO17 ~ IO10

out_mode

// 0x0=inactive,

// 0x1=active,

// 0x2=Change

standalone_state u8 0: power on do not run standalone mode (default)

1: power on run standalone mode

Page 64: EMD8216 Ethernet Digital I/O module - automation.com.tw

63

EMD8216_standalone_config_read

Format: u32 status =EMD8216_standalone_config_read(u32 CardID, u8 *step_number,

_StandaloneData data[32], u8 *enable, u8 *standalone_state)

Purpose: To read back the pre-programmed standalone process command.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

Output:

Name Type Description

step_number u8 Number of data[ ]

data[32] _StandaloneData typedef struct _StandaloneData{

u16 in_point_bit;

u16 in_state_bit;

u16 timer_value;

u16 out_point_bit;

u8 timer_value;

u8 out_mode;

}

in_point_bit

//b7 ~ b0 = IO07 ~ IO00

//b15 ~ b8 = IO17 ~ IO10

in_state_bit

//input state set

timer_mode

// 0x0 = Unused,

// 0x1 = Input action and delay out,

// 0x2 = Input action and pulse out

// 0x3 = Input action and periodic out

// 0x4 = Timer action and delay out

// 0x5 = Timer action and periodic out

// 0x6 = Timer off

timer_value

// timer tick is 5ms per tick

// timer_mode = delay / periodic out

// setting value is delay timer

// timer_mode = pulse out

// setting value is active time of pulse

// if timer_value = 10 ,

// the delay time is 10 * 5 ms = 50 ms

out_point_bit

Page 65: EMD8216 Ethernet Digital I/O module - automation.com.tw

64

//b7 ~ b0 = IO07 ~ IO00

//b15 ~ b8 = IO17 ~ IO10

out_mode

// 0x0=inactive,

// 0x1=active,

// 0x2=Change (toggle)

enable u8 0: currently is standalone disabled

1: currently is standalone enabled

standalone_state u8 0: power on do not run standalone mode

(default)

1: power on run standalone mode

Page 66: EMD8216 Ethernet Digital I/O module - automation.com.tw

65

EMD8216_standalone_config_clear

Format: u32 status =EMD8216_standalone_config_clear(u32 CardID)

Purpose: clear the standalone step program.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

Note:

1. The Standalone Data is any array of 32 elements in which each element is a command of process.

Each time you configure, you must prepare the 32 elements. If the command data is null (all

elements are “0” in any of the 32 elements), the controller will take it as end of process.

2. Although the Standalone Data consist of 32 (max) elements, you also need to specify the number

of the elements to accelerate the speed of instruction loading process (if less than 32, it will

spend less time).

3. Standalone_state is used for configuring the function after the power-on. If standalone_state=1,

after power on, the controller will run the pre-programmed command until it is commanded to

stop from Ethernet interface or power off.

4. If any error code occurs before command to run, please check the error and correct before

running.

Special note on periodic output and stop periodic output

If the output is configured as periodic out, there are three possible situations to stop the output.

1. Stop by module power off.

2. Stop by disable standalone mode.

3. Stop by command with control mode „stop periodic out‟ that follows the periodic output.

At the stop periodic out, the output state will be fixed at inactive.

Page 67: EMD8216 Ethernet Digital I/O module - automation.com.tw

66

8.8 Remote output control (Device to device control)

Remote output control is used for device to device control, i.e. a device can generate a command to

trigger the other modules (i.e. remote module).

Let‟s take 2 modules as example; module A wants to monitor the Ethernet communication from

remote module 0 and input from a smoke sensor, if any of the conditions is active, the module A will

output alarm on point OUT0 and trigger the module B (maybe far away to generate alarm on pint OUT0).

The program is very simple, refer 10.10 Integration example

Before you send command to the remote module, the information of the remote module must setup

ready by: EMD8216_D2D_config_set( ) and read back for verification by

EMD8216_D2D_config_read( )

To stop and clear the configuration (for new configuration) by

EMD8216_D2D_connection_clear( )

To check the connection status by

EMD8216_D2D_connection_state_read( )

For the D2D connection status monmitoring, the master module will try to get response from the

under monitor device at certain period. To change the monitoring period by

EMD8216_D2D_keep_alive_time_set( ) and verify the keep alive time by

EMD8216_D2D_keep_alive_time_read( )

Page 68: EMD8216 Ethernet Digital I/O module - automation.com.tw

67

EMD8216_D2D_config_set

Format: u32 status =EMD8216_D2D_config_set(u32 CardID, u8 remote_ID,

u8 IP_address[4], u8 password[8], u16 remote_port, u8 remote_type)

Purpose: To configure the basic communication information of the remote module.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

remote_ID u8 0~3, assign the ID of remote modules

IP_address[4] u8 4 bytes of IP address of remote module

(which is already or will be set by

EMD8216_change_IP)

For example:

if IP address is “192.168.0.100” then

IP_address[0]=192

IP_address[1]=168

IP_address[2]=0

IP_address[3]=100

password[8] u8 the logging password of the remote module

remote_port u16 Assign a communicate port of the remote

module (the remote module is already or will

be set by EMD8216_change_socket_port)

Default: 6936

remote_type u8 type of remote module

// 1 : EMD8204, 2 : EMD8208,

// 3 : EMD8216, 4 : EMC8485,

// 5 : EMC8432, 6 : EMA8314R,

// 7 : EMA8308, 8 : EMA8308D,

// 9 : PC

Note: after use EMD8216_D2D_config_set or EMD8216_D2D_connection_clear must reboot the

module.

Page 69: EMD8216 Ethernet Digital I/O module - automation.com.tw

68

EMD8216_D2D_config_read

Format: u32 status =EMD8216_D2D_config_read(u32 CardID, u8 remote_ID,

u8 IP_address[4], u16 *remote_port, u8 *remote_type)

Purpose: To read the basic communication information of the remote module.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

remote_ID u8 0~3

Output:

Name Type Description

IP_address[4] u8 4 bytes of IP address of remote module

(which is already or will be set by

EMD8216_change_IP)

For example:

if IP address is “192.168.0.100” then

IP_address[0]=192

IP_address[1]=168

IP_address[2]=0

IP_address[3]=100

remote_port u16 The communicate port of the remote module

(the remote module is already or will be set by

EMD8216_change_socket_port)

Default: 6936

remote_type u8 // 1 : EMD8204, 2 : EMD8208,

// 3 : EMD8216, 4 : EMC8485,

// 5 : EMC8432, 6 : EMA8314R,

// 7 : EMA8308, 8 : EMA8308D,

// 9 : PC

Page 70: EMD8216 Ethernet Digital I/O module - automation.com.tw

69

EMD8216_D2D_connection_clear

Format: u32 status =EMD8216_D2D_connection_clear(u32 CardID, u8 state[4])

Purpose: To clear the connect information. It will disconnect before clear.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

state[4] u8 state[n] : remote n connection state

If set to 1: it will clear the connect

information and disable the connection.

Note: If the module is in standalone mode enabled state, the connection clear command is valid.

Note: after use EMD8216_D2D_connection_clear must reboot the module.

EMD8216_D2D_connection_state_read

Format: u32 status =EMD8216_D2D_connection_state_read(u32 CardID, u8 state[4],

u8 error_state[4])

Purpose: Read the connect state.

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

Output:

Name Type Description

state[4] u8 connection state

state[n] : remote n connection state

= 0x0, REMOTE_UNUSED

= 0x1, CONNECTED

= 0x2, RE_CONNECTION

= 0x3, DISCONNECTION

= 0x4, WAIT_RESPOND

= 0x5, WAIT_TO_SEND

= 0x6, SEND_TO_HOST

= 0x7, NEED_REBOOT_FOR_NEW_CONFIG

error_state[4] u8 error_state[n] : (n: remote_ID)

Reference to 15 Error codes table for UDP

Success_flag

Page 71: EMD8216 Ethernet Digital I/O module - automation.com.tw

70

EMD8216_D2D_keep_alive_time_set

Format: u32 status =EMD8216_D2D_keep_alive_time_set(u32 CardID, u32 cycle_time)

Purpose: set the D2D device alive monitoring cycle time

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

cycle_time u32 set the detect package cycle time

default: 10 s

range : 10,12,14…. 60000 s

Note:use the EMD8216_D2D_keep_alive_time_set function, it will trigger to send a detect

package immediately then wait the keep alive time to send the second and forth.

EMD8216_D2D_keep_alive_time_read

Format: u32 status =EMD8216_D2D_keep_alive_time_read(u32 CardID, u32 &cycle_time)

Purpose: read the D2D device alive monitoring cycle time

Parameters:

Input:

Name Type Description

CardID u32 CardID assigned by EMD8216_initial

Output:

Name Type Description

cycle_time u32 set the detect package cycle time

default: 10 s

Page 72: EMD8216 Ethernet Digital I/O module - automation.com.tw

71

9. User configuration utility of Standalone mode

Sometime you want to use the standalone mode without coding a program, it is easy to use the user

configuration utility comes with the driver CD.

9.1 Overview of user configuration utility

-- After you have installed the driver and the demonstration program, run the EMD8216 demo

program.

-- You must configure the I/O‟s as you need. Say which one is used as input and which one used as output.

fig. 9.1.1 I/O config panel

-- Open the standalone mode configuration window. EMD8216 -> Special -> Standalone.

fig. 9.1.2 Standalone mode configuration panel

From the above diagram, you will see

Block1: control mode operation mode and time constant setting.

Block2: standalone mode command input configuration.

Block3: command edit function, add/ delete/insert.

Block4: standalone mode command output configuration.

Block5: standalone mode command upload /download, start/stop.

Block6: power on standalone mode enable/ disable.

Page 73: EMD8216 Ethernet Digital I/O module - automation.com.tw

72

9.2 Configure a command

Basically, a command is consist of input point and its state (on the left side, block2); next, the

control operation mode, time constant (on the middle, block 1) and finally the output mode and output

points (on the right side, block 4). The input and output block will update as the current command line

highlighted.

Generally we configure the input first.

-- input configuration

fig. 9.2.1 Input block

From the above diagram, check the input point and its state which the current command will take

care.

The above diagram shown that if you want the input monitor IN01 active and IN02 inactive as

trigger source of the command. You can select and configure any of the inputs to monitor as trigger

source.

Input debounce frequency is 100Hz, response faster than 100Hz maybe ignore as noise by the

EMD8216 module.

Page 74: EMD8216 Ethernet Digital I/O module - automation.com.tw

73

-- control_mode configuration

fig. 9.2.2 Control mode block

If the inputs meet the condition you configured, it will trigger the timer to operate. The time

provides several kinds of working mode:

working mode explanation

ByPass bypass the input trigger to output, timer do no work.

Input action and delay out input trigger the timer to work as delay timer

(time up triggers output)

Input action and pulse out input trigger the timer to work as pulse timer

(timing the output duty)

Input action and periodic out input trigger the timer to work as periodic timer

(time up toggles output and reload to run)

Startup action and delay out startup triggers the timer to work as delay timer (time up

triggers output)

Startup action and pulse out startup triggers the timer to work as pulse timer (timing the

output duty)

Startup action and periodic

out

startup triggers the timer to work as periodic timer (time up

toggles output and reload to run)

Stop periodic out periodic out is stopped just followed by this command

Send to remote module0 input trigger to remote module0 output, timer do not work.

Send to remote module1 input trigger to remote module1 output, timer do not work.

Send to remote module2 input trigger to remote module2 output, timer do not work.

Send to remote module3 input trigger to remote module3 output, timer do not work.

*The timer is based on 100ms time base, less than 5ms or not the multiples of 100ms is

impossible to implement.

Page 75: EMD8216 Ethernet Digital I/O module - automation.com.tw

74

-- Output configuration

fig. 9.2.3 Out mode block

The timer depending on its working mode controls the output. The output can be configured as

inactive , active or toggle.

control mode output

mode explanation

Bypass

inactive output inactive level

active output active level

Change output toggles

Input action and delay out

inactive output inactive level

active output active level

Change output toggles

Input action and pulse out

L-pulse output inactive pulse (  ̄|__| ̄ )

H-pulse output active pulse ( _| ̄|_ )

Input action and periodic out Change output toggles

Startup action and delay out

inactive output inactive level

active output active level

Change output toggles

Startup action and pulse out L-pulse output inactive pulse (  ̄|__| ̄ )

H-pulse output active pulse ( _| ̄|_ )

Startup action and periodic out Change output toggles

Stop periodic out none output reset to its normal state

Send to remote

module0 ~ module3

inactive Remote output inactive

active Remote output active

Page 76: EMD8216 Ethernet Digital I/O module - automation.com.tw

75

9.3 Remote configure

Each module can control 4 remote modules. To use the device to device communication, you must

setup the basic information of each remote module then select control mode to send to remote module to

control its output or virtual IO.

-- Open the remote configuration window. EMD8216 -> Special -> Standalone -> Remote

config.

fig. 9.3.1 Remote configuration block

From the above diagram, you will see

ID : remote module index.

IP: remote module IP address.

Remote port: remote module socket port, default is 6936.

password: remote module connection password, default is “12345678”.

Type: remote module type.

Connection state: after the above information filled, the demo program will try to connect the

remote module and display its connection state in this column.

returned error code: if the remote has connection error, the returned code will be displayed in this

column for you to debug. Error code refers Chapt. 15 Error codes table for UDP Success_flag.

Page 77: EMD8216 Ethernet Digital I/O module - automation.com.tw

76

9.4 Virtual I/O and broken line state configuration

Virtual VIO_00 ~ VIO_17can be input or output since it is the virtual IO port. You can trigger the

virtual IO of the remote module and then the remote module takes the virtual IO as input to decide the

output with its local inputs or other virtual IO from different modules. The modules on the Ethernet

connection will work as a big controller.

To detect the connection of remote modules, the broken line detection function will be easy with

the special input; you can monitor the broken line status to generate an alarm or take some action.

fig. 9.4.1 Virtual IO and broken line block

Page 78: EMD8216 Ethernet Digital I/O module - automation.com.tw

77

9.5 Edit function

To provide a good edit environment, some functions of editing are necessary: insert, add, change,

delete and delete all are provided.

fig. 9.5.1 Edit function

1: Insert: insert a new command above the high lighted bar in the table.

2: Add: add a new command

3: Change: modify the existing command line

4: Del: delete the highlighted command line

5: Del all: clear all the commands

Page 79: EMD8216 Ethernet Digital I/O module - automation.com.tw

78

9.6 Upload program and Power on enable

Power on enable function will determine the module to standby mode or run the stored

pre-programmed command steps. If enabled, run the step command, else keep Ethernet connection

alive for communication only.

There are totally 32 commands can be execute in EMD8216 module, after you edit the step

command sequence, you can upload to the module to store and execute immediately or store it and

execute on next power on or command to run via Ethernet.

To run after upload, you should push the run button (on the right of upload button).

To run at the next power on, or power on to run, select power on enable (checkbox under run

button).

To command to run/stop via Ethernet, you can use the DLL function

EMD8216_standalone_enable( ) to run immediately or stop immediately by

EMD8216_standalone_disable( ).

To command the power on standalone mode on/off by EMD8216_standalone_V_config_set( )

to set the standalone_state to determine power on to run standalone mode or not.

fig. 9.6.1 Upload and Power on anable

Page 80: EMD8216 Ethernet Digital I/O module - automation.com.tw

79

9.7 Download program

If you have connected PC with EMD8216 module via Ethernet, you can download the stored

program to PC from the module. After downloading, you can save files to PC. (refer 9.8 Save or

load program with PC).

fig. 9.7.1 Download

Page 81: EMD8216 Ethernet Digital I/O module - automation.com.tw

80

9.8 Save or load program with PC

You can save the under edit or finished program to PC by click the File->Save to save the file

as a specific file name and place.

To retrieve the stored program from PC by click File->Load and select the file you want to

retrieve.

fig. 9.8.1 Save or load program from PC

9.9 Run/Stop standalone function

Standalone mode can Run or Stop by the button as following shown.

fig. 9.9.1 Run or Stop standalone mode

Whether the module standalone mode is enabled or disabled can be verified shown on the

main form.

fig. 9.9.2 Run / Stop indication

Page 82: EMD8216 Ethernet Digital I/O module - automation.com.tw

81

10. Standalone mode application examples

10.1 Example 1: Monitoring input if condition meets, trigger output

fig. 10.1.1 Example 1, block diagram and timing

Say, you want to watch IN10 inactive, IN11 and IN12 active to trigger output OUT00 to inactive.

Program as the following shown.

fig. 10.1.2 Example 1 program

Note: The output change state (form active to inactive or inactive to active depends on your program)

only if the input condition meet and if not meet, keep the previous state.

Page 83: EMD8216 Ethernet Digital I/O module - automation.com.tw

82

10.2 Example 2: Monitoring the input if condition meets, delay to trigger output

fig. 10.2.1 Example 2, block diagram and timing

Say, you want to watch IN10 and IN13 are inactive and IN11 and IN12 are active to trigger output

OUT00 to inactive. Program as the following shown.

fig. 10.2.2 Example 2 program

Note: While the delay interval is in progress, no further condition meet triggers will be valid.

Page 84: EMD8216 Ethernet Digital I/O module - automation.com.tw

83

10.3 Example 3: Monitoring the input if condition meets, output pulse

fig. 10.3.1 Example 3, block diagram and timing

Say, you want to watch IN10 and IN12 is active and IN14 is inactive to trigger output OUT00 and

OUT01 to H-pulse. Program as the following shown.

fig. 10.3.2 Example 3 program

Page 85: EMD8216 Ethernet Digital I/O module - automation.com.tw

84

10.4 Example 4: Monitoring the input if condition meets, output periodically and stop by some

special input condition

fig. 10.4.1 Example 4, block diagram and timing

Page 86: EMD8216 Ethernet Digital I/O module - automation.com.tw

85

Say, you want to watch IN10 is inactive and IN12 is active to trigger output OUT00 to toggle.

Program as the following shown.

fig. 10.4.2 Example 4 program

Then, if we want IN10 is inactive and IN11 is active to trigger to stop the timer. Program as the

following shown.

fig. 10.4.3 Example 4 program-1

Page 87: EMD8216 Ethernet Digital I/O module - automation.com.tw

86

10.5 Example 5: Don‟t care the input if standalone enabled, trigger output with delay

fig. 10.5.1 Example 5, block diagram and timing

Say, don‟t care any input just output OUT01 active as the standalone mode enabled. Program as the

following shown.

fig. 10.5.2 Example 5 program

Page 88: EMD8216 Ethernet Digital I/O module - automation.com.tw

87

10.6 Example 6: Don‟t care the input if standalone enabled, trigger pulse

fig. 10.6.1 Example 6, block diagram and timing

Say, don‟t care any input just output OUT00 Low-pulse as the standalone mode enabled. Program

as the following shown.

fig. 10.6.2 Example 6 program

Page 89: EMD8216 Ethernet Digital I/O module - automation.com.tw

88

10.7 Example 7: Don‟t care the inputs if standalone enabled, output periodically and stop if input

condition meets.

fig. 10.7.1 Example 7, block diagram and timing

The above diagram shows the output will be active while standalone mode is enabled, if the

standalone mode is disabled, the output will be reset. Another method to stop the periodic working

output is to use some input to trigger to stop it. Please refer the diagram as follows.

fig. 10.7.2 Example 7 program

Page 90: EMD8216 Ethernet Digital I/O module - automation.com.tw

89

fig. 10.7.3 Example 7, timing of stop standalone mode

Say, start the periodic output on the standalone mode enabled and stop the output on IN13 and

IN14 are active. The program is shown as followings.

fig. 10.7.4 Example 7, program of stop standalone mode

Page 91: EMD8216 Ethernet Digital I/O module - automation.com.tw

90

10.8 Example 8: Monitoring input if condition meets, trigger remote output

fig. 10.8.1 Example 8, block diagram and timing

Say, you want to watch IN0 is active and remote module 1 is line broken to trigger remote

module0‟s output OUT0 to active. Program as the following shown.

fig. 10.8.2 Example 8 program

Please note that you must already configure the remote module information before using the send to

remote Control mode (refer 8.8 Remote output control (Device to device control)).

Page 92: EMD8216 Ethernet Digital I/O module - automation.com.tw

91

10.9 Example 9: Monitoring input if condition meets, trigger output complex

fig. 10.9.1 Example 9, block diagram and timing

Program as the following shown.

fig. 10.9.2 Example 9 program-1

Page 93: EMD8216 Ethernet Digital I/O module - automation.com.tw

92

Then, you can to watch virtual IO00 is active to trigger output OUT_00 to H-pulse. Program as the

following shown.

fig. 10.9.3 Example 9 program-2

Page 94: EMD8216 Ethernet Digital I/O module - automation.com.tw

93

10.10 Integration example

On a 2 or more modules system, module A put at field site is in charge of monitoring the Ethernet

from remote module (say, another Ethernet module C at ip:192.168.0.101 for example) and a smoke

sensor (or other many inputs but we take one for example). At office another Module B

(ip:192.168.0.118 for example) is used to receive abnormal event trigger to alarm for the technician.

While smoke sensor detection is active, the module A needs to generate alarm and also the office

site(module B) must alarm. But if only line(module C) broken, the office site(module B) must flash light

(0.5s on/off flash) and field site no signal out.

Let us assign the I/O points as follows:

Field site, Module A(ip:192.168.0.116) :

IN0 : smoke sensor input

OUT0 : (local) alarm from smoke sensor

Office site, Module B(remote1, ip:192.168.0.118):

OUT0 : smoke alarm from Module A

OUT1 : flash alarm of broken line of module

Virtual IO0 : event trigger of Module C broken line from module A

Remote site, Module C(remote0, ip:192.168.0.101):

(I/O not specified but only monitoring connection)

To do the device to device control, the first thing to do is to setup the remote information to the

device (host) which will generate the trigger signal, current example is the module A. Module B and C

are the remote modules.

fig. 10.10.1 Remote configuration information for the module A

Page 95: EMD8216 Ethernet Digital I/O module - automation.com.tw

94

fig. 10.10.2 Input monitoring and its output (program on module A)

Note: Owing to the input condition meets will trigger the output (else keep the previous output state),

you need to monitor the input active and input inactive to trigger the output.

fig. 10.10.3 Input monitoring and output to trigger remote Module B output (program on module

A)

Page 96: EMD8216 Ethernet Digital I/O module - automation.com.tw

95

fig. 10.10.4 Broken line monitoring and its output (program on module A)

fig. 10.10.5 Virtual input monitoring to trigger toggle output (program on module B)

Page 97: EMD8216 Ethernet Digital I/O module - automation.com.tw

96

11. Communication protocol

Although the dll have provide various function for the user, which enables the users to take the

EMD module as if it is a non-Ethernet I/O interface. But some users may want to code their own

software from the Ethernet basic functions; this chapter provides the detail of the communication

protocol.

11.1 Host to module command format

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Ethernet Header (14 Bytes)

0x10 IP Header (20 Bytes)

0x20 UDP Header (8 Bytes)

0x30 UDP data, _EMD8216_Send_UDP (48 Bytes) 0x40

0x50

As shown above, the command format from PC to module is an UDP format, the first 14 bytes is

the Ethernet header next comes the 20 bytes is the IP header, the next 8 byes is the UDP header then

follows 48 bytes UDP data. The UDP data, EMD8216_data is defined as follows:

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 CardName (7 Bytes) Password (8 Bytes) C 0x10

_SEND_DATA (32 Bytes) 0x20

typedef struct

{

u8 CardName[7]; // CardName={'E','M','D','8','2','1','6'}

u8 Password[8]; // Password,8 words

u8 Command;

union

{

u8 data_b[32]; //Data for byte

u16 data_w[16]; //Data for word

u32 data_l[8]; //Data for long

u8 IP[4]; //Data for IP Address

u16 socket_port; //Data for Socket Port

u8 New_password[8]; //Data for New password,8 words

u8 Port_Value[2]; //Data for Port Value

u8 Point_value[3]; //Data for Point Select

struct _WDT_Data WDT; // WDT data

struct _STANDALONE_DATA standalone_data; // maximum 25 byte

struct _NEW_ST_DATA new_st_data; // maximum 25 byte

struct _MULTI multi; // multi point R/W

struct _D2D_CONFIG D2D_config; // host device config data

struct _D2D_STATE D2D_state; // host device connect state

// and error code

Page 98: EMD8216 Ethernet Digital I/O module - automation.com.tw

97

}_SEND_DATA;

}_EMD8216_Send_UDP;

typedef struct

{

u16 Timer_value; // WDT timer value

u16 output; // WDT timer out, output data

u8 state; // 1: WDT Enable, 0: WDT Disable

u8 state_2; // check DLL is new

u16 virtual_output; // WDT timer out, virtual output data

u16 output_mask[2]; // select output point to control

u16 power_on; // 1: when power on, then WDT enable

}_WDT_Data;

typedef struct

{

u8 function_index; // start function index

u8 function_number; // be used max function number

struct

{

u8 timer_mode[2]; // set timer mode

u16 timer_value[2]; // set timer value

u16 input_point[2]; // choose input point00 ~ 17

u16 input_state[2]; // set input state

u16 output_point[2]; // choose output point00 ~ 17

u8 out_mode[2]; // set out mode

}function_data;

u8 standalone_state;

u8 power_on_state;

}_STANDALONE_DATA;

typedef struct

{

u8 function_index; // start function index

u8 function_number; // be used max function number

u8 standalone_state;

u8 power_on_state;

struct

{

u8 control_mode; // set control mode

u8 out_mode; // set out mode

u8 timer_value[4]; // set timer value

u16 input_point[2]; // choose input point00 ~ 17

u16 input_state[2]; // set input state

u16 output_point[2]; // choose output point00 ~ 17

u8 disconect_mask[4]; // set disconect mask

}config_data;

}_NEW_ST_DATA;

Page 99: EMD8216 Ethernet Digital I/O module - automation.com.tw

98

typedef struct

{

u8 point[4]; // choose points

u8 state[4]; // points state

}_MULTI;

typedef struct

{

u8 IP[4]; // host IP address

u8 password[8]; // host device password

u16 host_port; // host device socket port

u8 card_type; // host device type, other: error

// 1: EMD8204, 2: EMD8208, 3: EMD8216

// 4: EMC8432, 5: EMC8485, 6: EMA8314R

// 7: EMA8308, 8: EMA8308D,9: PC

u8 host_ID; // host device ID, 0~3

}_D2D_CONFIG;

typedef struct

{

u8 connection_state[4]; // connection state and mask

u8 connection_ERROR_code[4]; // host device communication error

}_D2D_STATE;

Page 100: EMD8216 Ethernet Digital I/O module - automation.com.tw

99

11.2 Module to host command format

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Ethernet Header (14 Bytes)

0x10 IP Header (20 Bytes)

0x20 UDP Header (8 Bytes)

0x30 UDP data, EMD_RECEIVE(34 Bytes)

0x40

As shown above, the command format from module to host is an UDP format, the first 20 bytes is

the IP header, the next 8 byes is the UDP header then follows 34 bytes UDP data. The UDP data,

_EMD8216_Receive_UDP is defined as follows:

_EMD8216_Receive_UDP (byte size)

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 _RECEIVE_DATA structure (32 Bytes)

0x10

0x20 S C

typedef struct

{

union

{

u8 data_b[32]; //Data for byte

u16 data_w[16]; //Data for word

u32 data_l[8]; //Data for long

u8 Card_Type; //Data for Card Type

u8 Port_Value[2]; //Data for Port Value

u8 Point_value[3]; //Data for Point Select

u8 Version[2]; //Data for firmware version

u8 counter[8][4]; //Data for in Counter value

struct _WDT_Data WDT; //Data for WDT data

struct _STANDALONE_DATA standalone_data; // maximum11byte

struct _NEW_ST_DATA new_st_data; // maximum25byte

struct _MULTI multi; // multi point R/W

struct _D2D_CONFIG D2D_config; // host device config data

struct _D2D_STATE D2D_state; // host device connect state

// and error code

}Data;

u8 Success_flag;

u8 Command;

}_EMD8216_Receive_UDP;

Page 101: EMD8216 Ethernet Digital I/O module - automation.com.tw

100

11.3 Definition of IP header

The IP header is defined as follows:

struct ipheader

{

u8 ip_hl:4; // ┬this means that each member is 4 bits

u8 ip_v:4; // ┘

u8 ip_tos; // type of service

u16 ip_len; // IP header total length

u16 ip_id; // identification

u16 ip_off; // fragment offset

u8 ip_ttl; // time to live

u8 ip_p; // protocol

u16 ip_sum; // header checksum

u32 ip_src; // source ip address

u32 ip_dst; // destination ip address

}; /* total ip header length: 20 bytes (=160 bits) */

11.4 Definition of UDP header

The UDP header is defined as follows:

struct udpheader

{

u16 uh_sport; // source port number

u16 uh_dport; // destination port number

u16 uh_len; // UDP package length

u16 uh_check; // UDP checksum

}; /* total udp header length: 8 bytes (=64 bits) */

Page 102: EMD8216 Ethernet Digital I/O module - automation.com.tw

101

11.5 EMD8216 communication commands

MODULE_TYPE_READ

Function: ask the EMD8216 module type

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ Unused C

0x10 Unused

0x20

Usage:

member type description

C u8 Command = 0x1, get card type

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 T Unused

0x10

0x20 S C

Usage:

member type description

T u8 Type = 0x03,

0x03 is EMD8216

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 Command = 0x1, get card type

Page 103: EMD8216 Ethernet Digital I/O module - automation.com.tw

102

REBOOT

Function: reboot EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ Unused C

0x10 Unused

0x20

Usage:

member type description

C u8 Command = 0x2, reboot

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 Command = 0x2, reboot

Page 104: EMD8216 Ethernet Digital I/O module - automation.com.tw

103

SOCKET_PORT_CHANGE

Function: change socket port of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 soc_port Unused

0x20

Usage:

member type description

password[8] u8 Current password

C u8 Command = 0x3, change socket port

soc_port u16 Socket port assign to the module

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 Command = 0x3, change socket port

Page 105: EMD8216 Ethernet Digital I/O module - automation.com.tw

104

PASSWORD_CHANGE

Function: change password of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 New Password (8 Bytes) Unused

0x20

Usage:

member type description

password[8] u8 Current password

C u8 Command = 0x4, change password

New_password[8] u8 New password assign to the module

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 Command = 0x4, change password

Page 106: EMD8216 Ethernet Digital I/O module - automation.com.tw

105

PASSWORD_RESTORE

Function: restore password to default : „1‟,‟2‟,‟3‟,‟4‟,‟5‟,‟6‟,‟7‟,‟8‟ of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ Unused C

0x10 Unused

0x20

Usage:

member type description

C u8 Command = 0x5, restore password

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 Command = 0x5, restore password

Page 107: EMD8216 Ethernet Digital I/O module - automation.com.tw

106

IP_CHANGE

Function: change IP of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 New IP (4 Bytes) Unused

0x20

Usage:

member type description

password[8] u8 Current password

C u8 Command = 0x6, change IP

New IP[4] u8

New IP address to be set

For example:

new_IP[4] = {0xC0, 0xA8, 0x00, 0x64}, 192.168.0.100

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 Command = 0x6, change IP

Page 108: EMD8216 Ethernet Digital I/O module - automation.com.tw

107

FIRMWARE_VERSION_READ

Function: read the firmware version of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 Current password

C u8 Command = 0x7, get firmware version

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Version Unused

0x10

0x20 S C

Usage:

member type description

Version u16 See Firmware version table.

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 Command = 0x7, get firmware version

Firmware version:

High Byte Low Byte

Bit 7 ~ 4 Bit 3 ~ 0 Bit 7 ~ 4 Bit 3 ~ 0

0x0 0x1 0x2 0x3

Main version Sub version Special edition code

※1:Version number is shown as hexadecimal code, when you read 0x0123, the version numbers v01.2

and special code 3.

Page 109: EMD8216 Ethernet Digital I/O module - automation.com.tw

108

SUBNET_MASK_SET

Function: set subnet mask of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Subnet mask (4 Bytes) Unused

0x20

Usage:

member type description

password[8] u8 Current password

C u8 Command = 0x8, set subnet mask

Subnet mask[4] u8

New subnet mask to be set

For example:

mask[4] = {0xFF, 0xFF, 0xFF, 0x00}, 255.255.255.0

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 Command = 0x8, set subnet mask

Page 110: EMD8216 Ethernet Digital I/O module - automation.com.tw

109

SUBNET_MASK_READ

Function: read the subnet mask of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 Current password

C u8 Command = 0x9, read subnet mask

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Subnet mask (4 Bytes) Unused

0x10

0x20 S C

Usage:

member type description

subnet_mask[4] u8

Subnet mask data read

New subnet mask to be set

For example:

mask[4] = {0xFF, 0xFF, 0xFF, 0x00}, 255.255.255.0

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP

Success_flag)

C u8 Command = 0x9, read subnet mask

Page 111: EMD8216 Ethernet Digital I/O module - automation.com.tw

110

DEFAULT_GATEWAY_SET

Function: set default gateway of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Default gateway

0x20

Usage:

member type description

password[8] u8 Current password

C u8 Command = 0xA, set default gateway

new_gateway[4] u8

New default gateway to be set

For example:

gateway[4] = {0xC0, 0xA8, 0x00, 0x01}, 192.168.0.1

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 Command = 0xA, set default gateway

Page 112: EMD8216 Ethernet Digital I/O module - automation.com.tw

111

DEFAULT_GATEWAY_READ

Function: read the default gateway of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 Current password

C u8 Command = 0xB, read default gateway

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Default gateway Unused

0x10

0x20 S C

Usage:

member type description

gateway[4] u8

Default gateway data read

For example:

gateway[4] = {0xC0, 0xA8, 0x00, 0x01}, 192.168.0.1

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP

Success_flag)

C u8 Command = 0xB, read default gateway

Page 113: EMD8216 Ethernet Digital I/O module - automation.com.tw

112

NETWORK_CONFIG_SET

Function: set network configure of EMD8216 module (recommend)

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 New IP New subnet mask Default gateway

0x20 Unused

Usage:

member type description

password[8] u8 Current password

C u8 Command = 0xC, set network configure

new_IP[4] u8

New IP to be set

For example:

IP[4] = {0xC0, 0xA8, 0x00, 0x64}, 192.168.0.100

new_mask[4] u8

New subnet mask to be set

For example:

mask[4] = {0xFF, 0xFF, 0xFF, 0x00}, 255.255.255.0

new_gateway[4] u8

New default gateway to be set

For example:

gateway[4] = {0xC0, 0xA8, 0x00, 0x01}, 192.168.0.1

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 Command = 0xC, set network configure

Page 114: EMD8216 Ethernet Digital I/O module - automation.com.tw

113

NETWORK_CONFIG_READ

Function: read the network configure of EMD8216 module (recommend)

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 Current password

C u8 Command = 0xD, read network configure

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 IP Subnet mask Default gateway

0x10

0x20 S C

Usage:

member type description

IP[4] u8

IP data read

For example:

IP[4] = {0xC0, 0xA8, 0x00, 0x64}, 192.168.0.100

mask[4] u8

Subnet mask data read

For example:

mask[4] = {0xFF, 0xFF, 0xFF, 0x00}, 255.255.255.0

gateway[4] u8

Default gateway data read

For example:

gateway[4] = {0xC0, 0xA8, 0x00, 0x01}, 192.168.0.1

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 Command = 0xD, read network configure

Page 115: EMD8216 Ethernet Digital I/O module - automation.com.tw

114

INPUT_DEBOUNCE_SET

Function: set the input port debounce time of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 P0 P1 Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0xF0, set the input port debounce time

P0 u8

port_value[0], port0 (IO_0m) debounce time on 5ms time base

1: 5ms

2: 10ms

200: 1000ms (max)

P1 u8

port_value[1], port1 (IO_1m) debounce time on 5ms time base

1: 5ms

2: 10ms

200: 1000ms (max)

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0xF0, set the input port debounce time

Page 116: EMD8216 Ethernet Digital I/O module - automation.com.tw

115

INPUT_DEBOUNCE_READ

Function: read back the input port debounce time of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0xF1, read back the input port debounce time

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 P0 P1 Unused

0x10

0x20 S C

Usage:

member type description

P0 u8

port_value[0], port0 (IO_0m) debounce time on 5ms time base

1: 5ms

2: 10ms

200: 1000ms (max)

P1 u8

port_value[1], port1 (IO_1m) debounce time on 5ms time base

1: 5ms

2: 10ms

200: 1000ms (max)

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0xF1, read back the input port debounce time

Page 117: EMD8216 Ethernet Digital I/O module - automation.com.tw

116

COUNTER_MASK_SET

Function: set the counter input mask (enable or disable counter function per channel) of EMD8216

module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port mask

Unused 0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x20, set counter input mask

port u8 0: input port0, i.e. select IO_0m

1: input port1, i.e. select IO_1m

mask u8

b7: 0, port bit7 (IO_n7) counter function is disabled

1, port bit7 (IO_n7) counter function is enabled

b0: 0, port bit0 (IO_n0) counter function is disabled

1, port bit0 (IO_n0) counter function is enabled

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x20, set counter mask

Page 118: EMD8216 Ethernet Digital I/O module - automation.com.tw

117

COUNTER_MASK_READ

Function: read the counter input mask (enable or disable counter function per channel) of

EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x26, read counter input mask

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 P0 P1 Unused

0x10

0x20 S C

Usage:

member type description

P0 u8

bit7: 0, input port0 (IO_07) counter function is disabled

1, input port0 (IO_07) counter function is enabled

bit0: 0, input port0 (IO_00) counter function is disabled

1, input port0 (IO_00) counter function is enabled

P1 u8

bit7: 0, input port0 (IO_17) counter function is disabled

1, input port0 (IO_17) counter function is enabled

bit0: 0, input port0 (IO_10) counter function is disabled

1, input port0 (IO_10) counter function is enabled

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x26, read counter mask

Page 119: EMD8216 Ethernet Digital I/O module - automation.com.tw

118

COUNTER_MODE_ENABLE

Function: global enable counter function of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x21, global counter function enable

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x21, global counter function enable

Page 120: EMD8216 Ethernet Digital I/O module - automation.com.tw

119

COUNTER_MODE_DISABLE

Function: global disable counter function of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x22, global counter function disable

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x22, global counter function disable

Page 121: EMD8216 Ethernet Digital I/O module - automation.com.tw

120

IN_COUNTER_READ

Function: read the counter data on the fly of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x23,read counter value

port u8

Select port number

0: choose port 0, i.e. select IO_0m

1: choose port 1, i.e. select IO_1m

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 In_counter [0] In_counter [1] In_counter [2] In_counter [3]

0x10 In_counter [4] In_counter [5] In_counter [6] In_counter [7]

0x20 S C

Usage:

member type description

In_counter [0]

~

In_counter [7]

u32 counter value for input IO_n0 ~ n7, n is port number assigned

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP

Success_flag)

C u8 command= 0x23,read counter value

Page 122: EMD8216 Ethernet Digital I/O module - automation.com.tw

121

POINT_COUNTER_CLEAR

Function: clear counter data per channel of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port point Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x24, clear counter value

port u8

Select port number n

0: choose port 0, i.e. select IO_0m

1: choose port 1, i.e. select IO_1m

point u8

7: IO_n7 counter value is cleared

0: IO_n0 counter value is cleared

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x24, clear counter value

Page 123: EMD8216 Ethernet Digital I/O module - automation.com.tw

122

MULTIPLE_COUNTER_CLEAR

Function: clear multiple counter data of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port point Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x25, clear multiple counter value

port u8

Select port number n

0: choose port 0, i.e. select IO_0m

1: choose port 1, i.e. select IO_1m

point u8

bit7: 1, IO_n7 counter value is cleared

0, IO_n7 counter value is unchanged

bit0: 1, IO_n0 counter value is cleared

0, IO_n0 counter value is unchanged

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x25, clear multiple counter value

Page 124: EMD8216 Ethernet Digital I/O module - automation.com.tw

123

PORT_CONFIG_SET

Function: configure as input or output per channel of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port C Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x30, set port IO configuration

port u8

Select port number n

0: choose port 0, i.e. select IO_0m

1: choose port 1, i.e. select IO_1m

config u8

bit7: 0, configure IO_n7 as output

1, configure IO_n7 as input

bit0: 0, configure IO_n0 as output

1, configure IO_n0 as input

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x30, set port IO configuration

Page 125: EMD8216 Ethernet Digital I/O module - automation.com.tw

124

PORT_CONFIG_READ

Function: read back the configuration per channel of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x31, read port IO configuration

port u8

Select port number n

0: choose port 0, i.e. select IO_0m

1: choose port 1, i.e. select IO_1m

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 port C Unused

0x10 0x20 S C

Usage:

member type description

port u8 duplication from the request command

config u8

bit7: 0, configure IO_n7 as output

1, configure IO_n7 as input

bit0: 0, configure IO_n0 as output

1, configure IO_n0 as input

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x31, read port IO configuration

Page 126: EMD8216 Ethernet Digital I/O module - automation.com.tw

125

PORT_SET

Function: set the output state per channel of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port state

Unused 0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x32, set port output state

port u8

Select port number n

0: choose port 0, i.e. select IO_0m

1: choose port 1, i.e. select IO_1m

2: choose VIO_0m port

3: choose VIO_1m port

state u8

I/O state (only valid for pins configured as outputs)

bit 7:

0: IO_n7 (or VIO_n7) output inactive

1: IO_n7 (or VIO_n7) output active

….

bit 0:

0: IO_n0 (or VIO_n0) output inactive

1: IO_n0 (or VIO_n0) output active

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x32, set port output state

Page 127: EMD8216 Ethernet Digital I/O module - automation.com.tw

126

PORT_READ

Function: read the port state per channel of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x33, read port state

port u8

Select port number n

0: choose port 0, i.e. select IO_0m

1: choose port 1, i.e. select IO_1m

2: choose VIO_0m port

3: choose VIO_1m port

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 port state Unused

0x10

0x20 S C

Usage:

member type description

port u8 duplication from the request command

state u8

I/O state (only valid for pins configured as outputs or VIO)

bit 7:

0: IO_n7 (or VIO_n7) output inactive

1: IO_n7 (or VIO_n7) output active

….

bit 0:

0: IO_n0 (or VIO_n0) output inactive

1: IO_n0 (or VIO_n0) output active

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x33, read port state

Page 128: EMD8216 Ethernet Digital I/O module - automation.com.tw

127

POLARITY_SET

Function: set the I/O polarity per channel of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port pol Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x34, set IO polarity

port u8

Select port number n

0: choose port 0, i.e. select IO_0m

1: choose port 1, i.e. select IO_1m

pol u8

bit7: 0, high active (normal) for IO_n7

1, low active (invert) for IO_n7

bit0: 0, high active (normal) for IO_n0

1, low active (invert) for IO_n0

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x34, set IO polarity

Page 129: EMD8216 Ethernet Digital I/O module - automation.com.tw

128

POLARITY_READ

Function: read the I/O polarity per channel of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x35, read IO polarity

port u8

Select port number n

0: choose port 0, i.e. select IO_0m

1: choose port 1, i.e. select IO_1m

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 port pol Unused

0x10

0x20 S C

Usage:

member type description

port u8 duplication from the request command

pol u8

I/O polarity

bit 7:

0: IO_n7 normal polarity

1: IO_n7 invert polarity …. bit 0:

0: IO_n0 normal polarity

1: IO_n0 invert polarity

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x35, read IO polarity

Note: An output channel is active may be output high or low depends on the polarity it is

configured. Say polarity is normal, active means output high and polarity is invert will have active

output to be low state.

Page 130: EMD8216 Ethernet Digital I/O module - automation.com.tw

129

POINT_CONFIG_SET

Function: configure channel as input or output of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port point Con

Unused 0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x36, set IO channel configuration

port u8

Select port number n

0: choose port 0, i.e. select IO_0m

1: choose port 1, i.e. select IO_1m

point u8

7: select IO_n7

0: select IO_n0

Con u8 0: configure as output

1: configure as input

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x36, set IO channel configuration

Page 131: EMD8216 Ethernet Digital I/O module - automation.com.tw

130

POINT_CONFIG_READ

Function: read back the channel configuration of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port point

Unused 0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x37, read IO channel configuration

port u8

Select port number n

0: choose port 0, i.e. select IO_0m

1: choose port 1, i.e. select IO_1m

point u8

7: select IO_n7

0: select IO_n0

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 port point con Unused

0x10

0x20 S C

Usage:

member type description

port u8 duplication from the request command

point u8 duplication from the request command

config u8 0: configure as output

1: configure as input

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x37, read IO channel configuration

Page 132: EMD8216 Ethernet Digital I/O module - automation.com.tw

131

POINT_SET

Function: set the output state of a channel of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port point state

Unused 0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x38, set point state

port u8

Select port number n

0: choose port 0, i.e. select IO_0m

1: choose port 1, i.e. select IO_1m

2: choose VIO_0m port

3: choose VIO_1m port

point u8

7: select IO_n7 (or VIO_n7)

0: select IO_n0 (or VIO_n0)

state u8

point state set:

0: inactive

1: active

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x38, set point state

Page 133: EMD8216 Ethernet Digital I/O module - automation.com.tw

132

POINT_READ

Function: read the channel state of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port point

Unused 0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x39, read point state

port u8

Select port number n

0: choose port 0, i.e. select IO_0m

1: choose port 1, i.e. select IO_1m

2: choose VIO_0m port

3: choose VIO_1m port

point u8

7: select IO_n7 (or VIO_n7)

0: select IO_n0 (or VIO_n0)

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 port point state Unused

0x10 0x20 S C

Usage:

member type description

port u8 duplication from the request command

point u8 duplication from the request command

state u8

point state set:

0: inactive

1: active

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x39, read point state

Page 134: EMD8216 Ethernet Digital I/O module - automation.com.tw

133

POINT_POLARITY_SET

Function: set the I/O polarity of a channel of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port point Pol

Unused 0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x3A, set point polarity

port u8

Select port number n

0: choose port 0, i.e. select IO_0m

1: choose port 1, i.e. select IO_1m

point u8

point selection

7: select IO_n7

0: select IO_n0

pol u8

point polarity

0: normal polarity

1: invert polarity

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x3A, set point polarity

Page 135: EMD8216 Ethernet Digital I/O module - automation.com.tw

134

POINT_POLARITY_READ

Function: read the channel polarity of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 port point

Unused 0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x3B, read point polarity

port u8

Select port number n

0: choose port 0, i.e. select IO_0m

1: choose port 1, i.e. select IO_1m

point u8

point selection

7: select IO_n7

0: select IO_n0

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 port point Pol Unused

0x10

0x20 S C

Usage:

member type description

port u8 duplication from the request command

point u8 duplication from the request command

pol u8

point polarity

0: normal polarity

1: invert polarity

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x3B, read point polarity

Page 136: EMD8216 Ethernet Digital I/O module - automation.com.tw

135

MULTI_POINT_SET

Function: set the I/O state of multi point of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 choose_point [4] set_state [4]

0x20 Unused

Usage:

member type description

password[8] u8 current password

C u8 command= 0x3C, set/reset multi points

choose_point[4] u8

point selection

choose_point [0]: select IO_0m

choose_point [1]: select IO_1m

choose_point [2]: select VIO_0m

choose_point [3]: select VIO_1m

bit7 for IO_n7 (or VIO_n7)

bit0 for IO_n0 (or VIO_n0)

Any bit set to 1, means this bit is chosen to set/reset its state

say choose_point [1]=0x3, menas IO_11 and IO_10 is chosen to

set/reset its state

set_state[4] u8

point state set

set_state [0]: state data for IO_0m

set_state [1]: state data for IO_1m

set_state [2]: state data for VIO_0m

set_state [3]: state data for VIO_1m

bit7 for IO_n7 (or VIO_n7)

bit0 for IO_n0 (or VIO_n0)

Any bit = 0: inactive, = 1: active

say set_state[1]=0x5 and if choose_point [1]=0x3, we only want the

IO_11 and IO_10 to set the state and the final result will

IO_11=0x0 and IO_10=0x1 other bits do not change.

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x3C, set/reset multi points

Page 137: EMD8216 Ethernet Digital I/O module - automation.com.tw

136

MULTI_POINT_READ

Function: set the I/O state of multi point of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 choose_point [4] Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x3D, read state of multi points

choose_point[4] u8

point selection

choose_point [0]: select IO_0m

choose_point [1]: select IO_1m

choose_point [2]: select VIO_0m

choose_point [3]: select VIO_1m

bit7 for IO_n7 (or VIO_n7)

bit0 for IO_n0 (or VIO_n0)

Any bit set to 1, means this bit is chosen to set/reset its state

say choose_point [2]=0x30, menas VIO_05 and VIO_04 is chosen to

read its state

Page 138: EMD8216 Ethernet Digital I/O module - automation.com.tw

137

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 choose_point [4] set_state [4]

0x10 Unused

0x20 S C

Usage:

member type description

choose_point[4] u8 duplication from the request command

set_state[4] u8

point state set

set_state [0]: state data for IO_0m

set_state [1]: state data for IO_1m

set_state [2]: state data for VIO_0m

set_state [3]: state data for VIO_1m

bit7 for IO_n7 (or VIO_n7)

bit0 for IO_n0 (or VIO_n0)

Any bit = 0: inactive, = 1: active

say set_state[1]=0x3 and if in request command choose_point [1]=0x3,

we only want the IO_11 and IO_10 to read the state and the final result

will

IO_11=0x1 and IO_10=0x1 other bits are trivial.

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP

Success_flag)

C u8 command= 0x3D, read state of multi points

Page 139: EMD8216 Ethernet Digital I/O module - automation.com.tw

138

STANDALONE_ENABLE

Function: enable standalone mode operation of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x50, enable standalone mode

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x50, enable standalone mode

Page 140: EMD8216 Ethernet Digital I/O module - automation.com.tw

139

STANDALONE_DISABLE

Function: disable standalone mode operation of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x51, disable standalone mode

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x51, disable standalone mode

Page 141: EMD8216 Ethernet Digital I/O module - automation.com.tw

140

STANDALONE_CONFIG_SET

Function: configure standalone mode operation of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 index num T_mode[2] Timer_value [2] Input_point [2] Input_state [2]

0x20 Output_point[2] Out_mode [2] S_EN Unused

Usage:

member type description

password[8] u8 current password

C u8 command= 0x52, configure standalone mode

index u8 command line index of current communication. Actually one

communication data will carry 2 commands. The index is the first

command‟s line number.

allowable range: 0 ~ 31 (command line index)

num u8 Numbber of standalone mode total commands.

allowable range: 1 ~ 32 (commands)

t_mode[2]

u8 timer working mode of current command:

=0x0 :timer unused

=0x1 : Input action and delay out,

=0x2 : Input action and pulse out

=0x3 : Input action and periodic out

=0x4 : Timer action and delay out

=0x5 : Timer action and pulse out

=0x6 : Timer action and periodic out

=0x7 : Timer off

timer_value[2]

u16 time constant based on 5ms click tick.

allowable range: 1 ~ 65535 (5ms ~ 327675ms)

input_point[2]

u16 The input points your process wants to watch.

The high byte data (b7~b0) is IO_17 ~ IO_10, low byte data (b7~b0) is

IO_07 ~ IO_00

0: inactive 1: active

input_state[2]

u16 The input states that your process will trigger timer or output.

The high byte data (b7~b0) is the state of IO_17 ~ IO_10, low byte data

(b7~b0) is the state of IO_07 ~ IO_00

0: inactive 1: active

output_point[2]

u16 The output states that your process will trigger while the input states

meet your preset.

The high byte data (b7~b0) is the state of IO_17 ~ IO_10, low byte data

(b7~b0) is the state of IO_07 ~ IO_00

0: inactive 1: active

output_mode[2]

u8 output modes, which depends on the timer mode set.

Refer Output mode table

s_en u8 =0x0 : power on standalone mode disabled

=0x1 : power on standalone mode enabled

Note: The communication data will maximum carry 2 commands, the first command consists of:

timer_mode[0], timer_value[0], input_point[0], input_state[0], output_point[0], output_mode[0]; the

Page 142: EMD8216 Ethernet Digital I/O module - automation.com.tw

141

second command consist of: timer_mode[1], timer_value[1], input_point[1], input_state[1],

output_point[1], output_mode[1].

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x52, configure standalone mode

Page 143: EMD8216 Ethernet Digital I/O module - automation.com.tw

142

STANDALONE_CONFIG_READ

Function: read back standalone commands from EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 index

Unused 0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x53, read configuration of standalone mode

index u8

command line index of current communication. Actually one

communication data will carry 2 commands. The index is the first

command‟s line number.

allowable range: 0 ~ 31 (command line index)

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 index num t_mode[2] timer_value [2] input_point [2] input_state [2]

0x10 output_point [4] out_mode [2] S_EN Unused

0x20 S C

Usage:

member type description

index u8 duplication from the request command

num u8 Number of standalone mode total commands.

allowable range: 1 ~ 32 (commands)

t_mode[2] u8

timer working mode of current command:

=0x0 :timer unused

=0x1 : Input action and delay out,

=0x2 : Input action and pulse out

=0x3 : Input action and periodic out

=0x4 : Timer action and delay out

=0x5 : Timer action and pulse out

=0x6 : Timer action and periodic out

=0x7 : Timer off

Page 144: EMD8216 Ethernet Digital I/O module - automation.com.tw

143

timer_value[2] u16 time constant based on 5ms click tick.

allowable range: 1 ~ 65535 (5ms ~ 327675ms)

input_point[2] u16

The input points your process wants to watch.

The high byte data (b7~b0) is IO_17 ~ IO_10, low byte data (b7~b0) is

IO_07 ~ IO_00

0: inactive 1: active

input_state[2] u16

The input states that your process will trigger timer or output.

The high byte data (b7~b0) is the state of IO_17 ~ IO_10, low byte data

(b7~b0) is the state of IO_07 ~ IO_00

0: inactive 1: active

output_point[2] u16

The output states that your process will trigger while the input states

meet your preset.

The high byte data (b7~b0) is the state of IO_17 ~ IO_10, low byte data

(b7~b0) is the state of IO_07 ~ IO_00

0: inactive 1: active

output_mode[2] u8 output modes, which depends on the timer mode set.

Refer Output mode table

s_en u8 =0x0 : power on standalone mode disabled

=0x1 : power on standalone mode enabled

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP

Success_flag)

C u8 command= 0x53, read configuration of standalone mode

Output mode table

Output

mode

Timer mode Unused (0x0)

Input action and delay out (0x1)

Timer action and delay out (0x4)

Input action and pulse out (0x2)

Timer action and pulse out (0x5)

Input action and periodic out (0x3)

Timer action and periodic out (0x6)

0x0 output inactive inactive state pulse Unused

0x1 output active active state pulse

0x2 output change state Unused output change state

Page 145: EMD8216 Ethernet Digital I/O module - automation.com.tw

144

STANDALONE_CONFIG_NEW_SET

Function: set standalone commands from EMD8216 module (new function)

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 index num N/A PoEn C_m O_m Timer_value [4] Input_point [4] In_state [4]

0x20 In_state [4] Output_point [4] disconect_mask [4] Unused

Usage:

member type description

password[8] u8 current password

C u8 command= 0x54, configure standalone mode (new function)

index u8

command line index of current communication. The index is the

command‟s line number.

allowable range: 0 ~ 31 (command line index)

num u8 Number of standalone mode total commands.

allowable range: 1 ~ 32 (commands)

PoEn u8

power_on_state

0: power on standalone mode is disabled

1: power on standalone mode is enabled

C_m u8

control mode of current command:

=0x0 : timer unused, bypass

=0x1 : Input action and delay out,

=0x2 : Input action and pulse out

=0x3 : Input action and periodic out

=0x4 : Timer action and delay out

=0x5 : Timer action and pulse out

=0x6 : Timer action and periodic out

=0x7 : Timer off

=0x8 : send to remote module0

=0x9 : send to remote module1

=0xA : send to remote module2

=0xB : send to remote module3

O_m output modes, which depends on the C_m set.

Refer New output_mode table

Page 146: EMD8216 Ethernet Digital I/O module - automation.com.tw

145

timer_value[4] u8

time constant based on 100ms click tick.

allowable range: 1 ~ (100ms ~ 100* ms)

timer_value[0] is the LSB, timer_value[3] is the MSB.

1. if control_mode = delay / periodie out, value is setting delay

time

2. control _mode = pulse out, value is setting pulse width

3. control _mode = send to remote 0~3, value is unused

input_point[4] u8

The input points your process wants to watch.

input_point[0] choose physical IO_07~IO_00,

input_point[1] choose physical IO_17~IO_10,

input_point[2] choose virtual VIO_07~VIO_00,

input_point[3] choose virtual VIO_17~VIO_ 10.

any bit 0: inactive 1: active

input_state[4] u8

The input states that your process will trigger timer or output.

input_state[0] is state of physical IO_07~IO_00,

input_state[1] is state of physical IO_17~IO_10,

input_state[2] is state of virtual VIO_07~VIO_00,

input_state[3] is state of virtual VIO_17~VIO_ 10.

any bit 0: inactive 1: active

output_point[4] u8

The output states that your process will trigger while the input states

meet your preset.

output_point[0] choose physical IO_07~IO_00,

output_point[1] choose physical IO_17~IO_10,

output_point[2] choose virtual VIO_07~VIO_00,

output_point[3] choose virtual VIO_17~VIO_ 10.

any bit 0: inactive 1: active

disconnect_mask[4] u8

disconnect_mask[0]

=1, while disconnect of remote0 triggers output

=0, no response

disconect_mask[3]

=1, while disconnect of remote3 triggers output

=0, no response

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x54, configure standalone mode (new function)

Page 147: EMD8216 Ethernet Digital I/O module - automation.com.tw

146

STANDALONE_CONFIG_NEW_READ

Function: read standalone commands from EMD8216 module (new function)

Remote to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 index

Unused 0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x55, read standalone mode (new function)

index u8

command line index of current communication. The index is the

command‟s line number.

allowable range: 0 ~ 31 (command line index)

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 index num En PoEn C_m O_m timer_value [4] input_point [4] in_state [4]

0x10 in_state [4] output_point [4] disconect_mask [4] Unused

0x20 S C

Usage:

member type description

index u8 duplication from request command

num u8 Number of standalone mode total commands.

allowable range: 1 ~ 32 (commands)

En u8

current state of standalone mode

1: standalone is enabled,

0: standalone is disabled

PoEn u8

power_on_state

0: power on standalone mode is disabled

1: power on standalone mode is enabled

Page 148: EMD8216 Ethernet Digital I/O module - automation.com.tw

147

C_m u8

control mode of current command:

=0x0 : timer unused, bypass

=0x1 : Input action and delay out,

=0x2 : Input action and pulse out

=0x3 : Input action and periodic out

=0x4 : Timer action and delay out

=0x5 : Timer action and pulse out

=0x6 : Timer action and periodic out

=0x7 : Timer off

=0x8 : send to remote module0

=0x9 : send to remote module1

=0xA : send to remote module2

=0xB : send to remote module3

O_m output modes, which depends on the C_m set.

Refer New output_mode table

timer_value[4] u8

time constant based on 100ms click tick.

allowable range: 1 ~ (100ms ~ 100* ms)

timer_value[0] is the LSB, timer_value[3] is the MSB.

1. if control_mode = delay / periodie out, value is setting delay time

2. control _mode = pulse out, value is setting pulse width

3. control _mode = send to remote 0~3, value is unused

input_point[4] u8

The input points your process wants to watch.

input_point[0] choose physical IO_07~IO_00,

input_point[1] choose physical IO_17~IO_10,

input_point[2] choose virtual VIO_07~VIO_00,

input_point[3] choose virtual VIO_17~VIO_ 10.

any bit 0: inactive 1: active

input_state[4] u8

The input states that your process will trigger timer or output.

input_state[0] is state of physical IO_07~IO_00,

input_state[1] is state of physical IO_17~IO_10,

input_state[2] is state of virtual VIO_07~VIO_00,

input_state[3] is state of virtual VIO_17~VIO_ 10.

any bit 0: inactive 1: active

Page 149: EMD8216 Ethernet Digital I/O module - automation.com.tw

148

output_point[4] u8

The output states that your process will trigger while the input states

meet your preset.

output_point[0] choose physical IO_07~IO_00,

output_point[1] choose physical IO_17~IO_10,

output_point[2] choose virtual VIO_07~VIO_00,

output_point[3] choose virtual VIO_17~VIO_ 10.

any bit 0: inactive 1: active

disconnect_mask[4] u8

disconnect_mask[0]

=1, while disconnect of remote0 triggers output

=0, no response

disconect_mask[3]

=1, while disconnect of remote3 triggers output

=0, no response

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP

Success_flag)

C u8 command= 0x55, read standalone mode (new function)

New output_mode table

O_m

C_m (control_mode) Unused

Input action and delay out

Timer action and delay out

(0x0、0x1、0x4)

Input action and pulse out

Timer action and pulse out

(0x2、0x5)

Input action and periodic out

Timer action and periodic out

(0x3、0x6)

send to remote module0

…..

send to remote module3

(0x8 ~ 0xB)

0x0 output inactive inactive state pulse Unused

output inactive

0x1 output active active state pulse output active

0x2 output change state Unused output change state Unused

Page 150: EMD8216 Ethernet Digital I/O module - automation.com.tw

149

STANDALONE_CONFIG_CLEAR

Function: clear all standalone configuration

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x56, clear all standalone configuration

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x56, clear all standalone configuration

Page 151: EMD8216 Ethernet Digital I/O module - automation.com.tw

150

WDT_ENABLE

Function: enable WDT (watchdog timer) operation of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x60, enable WDT function

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x60, enable WDT function

Page 152: EMD8216 Ethernet Digital I/O module - automation.com.tw

151

WDT_DISABLE

Function: disable WDT (watchdog timer) operation of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x61, disable WDT function

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x61, disable WDT function

Page 153: EMD8216 Ethernet Digital I/O module - automation.com.tw

152

WDT_SET

Function: setup WDT (watchdog timer) operation of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Timer_value PHY_output state [2] Vir_output output_mask[2] power_on

0x20 Unused

Usage:

member type description

password[8] u8 current password

C u8 command= 0x62, set WDT function

timer_value u16 WDT time constant at 0.1second time base

allowable range: 10 (1.0s) ~ 10000 (1000.0s)

PHY_output u16

PHY output state while WDT time out

bit0: 0: IO_00 is inactive at WDT time out

1: IO_00 is active at WDT time out

bit7: 0: IO_07 is inactive at WDT time out

1: IO_07 is active at WDT time out

bit8: 0: IO_10 is inactive at WDT time out

1: IO_10 is active at WDT time out

Bit15: 0: IO_17 is inactive at WDT time out

Bit15:1: IO_17 is active at WDT time out

state[2] u8 state[0]=0x00

state[1]=0xFF

vir_output u16

virtual output state while WDT time out

bit0: 0: VIO_00 is inactive at WDT time out

1: VIO_00 is active at WDT time out

bit7: 0: VIO_07 is inactive at WDT time out

1: VIO_07 is active at WDT time out

bit8: 0: VIO_10 is inactive at WDT time out

1: VIO_10 is active at WDT time out

Bit15: 0: VIO_17 is inactive at WDT time out

Bit15:1: VIO_17 is active at WDT time out

Page 154: EMD8216 Ethernet Digital I/O module - automation.com.tw

153

output_mask[2] u16

output_mask[0]; mask of physical output while WDT is occurs

bit0: 0, IO_00 keeps the state as WDT not occurs

1, IO_00 follows the state as PHY_output defined

bit7: 0: IO_07 keeps the state as WDT not occurs

1: IO_07 follows the state as PHY_output defined

bit8: 0: IO_10 keeps the state as WDT not occurs

1: IO_10 follows the state as PHY_output defined

Bit15: 0: IO_17 keeps the state as WDT not occurs

1: IO_17 follows the state as PHY_output defined

output_mask[1]: mask of virtual output while WDT is occurs

bit0: 0, VIO_00 keeps the state as WDT not occurs

1, VIO_00 follows the state as vir_output defined

bit7: 0: VIO_07 keeps the state as WDT not occurs

1: VIO_07 follows the state as vir_output defined

bit8: 0: VIO_10 keeps the state as WDT not occurs

1: VIO_10 follows the state as vir_output defined

Bit15: 0: VIO_17 keeps the state as WDT not occurs

1: VIO_17 follows the state as vir_output defined

power_on u16 =1, WDT is power_on enabled

=0, WDT is power_on disabled

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x62, set WDT function

Page 155: EMD8216 Ethernet Digital I/O module - automation.com.tw

154

WDT_READ

Function: read WDT (watchdog timer) counter of EMD8216 module

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x63, read WDT counter and configuration

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 timer_value PHY_output state[2] vir_output output_mask[2] power_on

0x10 Unused

0x20 S C

Usage:

member type description

timer_value u16 WDT time constant at 0.1second time base

allowable range: 10 (1.0s) ~ 10000 (1000.0s)

PHY_output u16

PHY output state while WDT time out

bit0: 0: IO_00 is inactive at WDT time out

1: IO_00 is active at WDT time out

bit7: 0: IO_07 is inactive at WDT time out

1: IO_07 is active at WDT time out

bit8: 0: IO_10 is inactive at WDT time out

1: IO_10 is active at WDT time out

Bit15: 0: IO_17 is inactive at WDT time out

Bit15:1: IO_17 is active at WDT time out

state[2] u8 state[0]=0x00

state[1]=0xFF

Page 156: EMD8216 Ethernet Digital I/O module - automation.com.tw

155

vir_output u16

virtual output state while WDT time out

bit0: 0: VIO_00 is inactive at WDT time out

1: VIO_00 is active at WDT time out

bit7: 0: VIO_07 is inactive at WDT time out

1: VIO_07 is active at WDT time out

bit8: 0: VIO_10 is inactive at WDT time out

1: VIO_10 is active at WDT time out

Bit15: 0: VIO_17 is inactive at WDT time out

Bit15:1: VIO_17 is active at WDT time out

output_mask[2] u16

output_mask[0]; mask of physical output while WDT is occurs

bit0: 0, IO_00 keeps the state as WDT not occurs

1, IO_00 follows the state as PHY_output defined

bit7: 0: IO_07 keeps the state as WDT not occurs

1: IO_07 follows the state as PHY_output defined

bit8: 0: IO_10 keeps the state as WDT not occurs

1: IO_10 follows the state as PHY_output defined

Bit15: 0: IO_17 keeps the state as WDT not occurs

1: IO_17 follows the state as PHY_output defined

output_mask[1]: mask of virtual output while WDT is occurs

bit0: 0, VIO_00 keeps the state as WDT not occurs

1, VIO_00 follows the state as vir_output defined

bit7: 0: VIO_07 keeps the state as WDT not occurs

1: VIO_07 follows the state as vir_output defined

bit8: 0: VIO_10 keeps the state as WDT not occurs

1: VIO_10 follows the state as vir_output defined

Bit15: 0: VIO_17 keeps the state as WDT not occurs

1: VIO_17 follows the state as vir_output defined

power_on u16 =1, WDT is power_on enabled

=0, WDT is power_on disabled

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP

Success_flag)

C u8 command= 0x63, read WDT counter and configuration

Page 157: EMD8216 Ethernet Digital I/O module - automation.com.tw

156

D2D_CONFIG_SET

Function: To register remote Ethernet module information to local device.

※ Need reboot module!!

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 IP [ 4 ] Password [ 8 ] remote_port type ind

0x20 Unused

Usage:

member type description

password[8] u8 current password

C u8 command= 0x70, register remote Ethernet module information to local

device

IP[4] u8 remote module IP address, if remote module at 192.168.0.100,

IP[4] = {192,168,0,100}

password[8] u8 remote module password

remote_port u16 remote module socket port, default at port 6936

type u8

remote module type,

1 : EMD8204, 2 : EMD8208, 3 : EMD8216, 4 : EMC8485,

5 : EMC8432, 6 : EMA8314R, 7 : EMA8308, 8 : EMA8308D,

9 : PC

idx u8 0~3, remote module index (ID)

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Host IP [ 4 ] Host Password [ 8 ] remote_port type ind

0x10 Unused

0x20 S C

Usage:

member type description

Host IP[4] u8

duplication from the request command

Host

password[8] u8

remote_port u16

type u8

idx u8

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x70, register remote Ethernet module information to local

device

Page 158: EMD8216 Ethernet Digital I/O module - automation.com.tw

157

D2D_CONFIG_READ

Function: To read the remote Ethernet module information registered to local device.

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

ind

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x71, read remote Ethernet module information registered

to local device

idx u8 0~3, remote module index (ID)

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 IP [ 4 ] Password [ 8 ] remote_port type ind

0x10 Unused

0x20 S C

Usage:

member type description

IP[4] u8 remote module IP address, if remote module at 192.168.0.100,

IP[4] = {192,168,0,100}

password[8] u8 remote module password

remote_port u16 remote module socket port, default at port 6936

type u8

remote module type,

1 : EMD8204, 2 : EMD8208, 3 : EMD8216, 4 : EMC8485,

5 : EMC8432, 6 : EMA8314R, 7 : EMA8308, 8 : EMA8308D,

9 : PC

idx u8 0~3, remote module index (ID)

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP

Success_flag)

C u8 command= 0x71, read remote Ethernet module information registered to

local device

Page 159: EMD8216 Ethernet Digital I/O module - automation.com.tw

158

D2D_KEEP_ALIVE_SET

Function: Set the interval for sending packets to confirm the connection with the remote device.

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Delay_Time Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 Command = 0x72, Set the interval for sending packets to confirm the

connection with the remote device

Delay_time u32 10 ~ 60000 ̧unit is second, Delay_time must be multiple of two

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 Command = 0x72, Set the interval for sending packets to confirm the

connection with the remote device

Page 160: EMD8216 Ethernet Digital I/O module - automation.com.tw

159

D2D_KEEP_ALIVE_READ

Function: Read the interval for sending packets to confirm the connection with the remote device.

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 Command = 0x73, Read the interval for sending packets to confirm the

connection with the remote device

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Delay_Time Unused

0x10

0x20 S C

Usage:

member type description

Delay_time u32 10 ~ 60000 ̧unit is second, Delay_time must be multiple of two

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 Command = 0x73, Read the interval for sending packets to confirm the

connection with the remote device

Page 161: EMD8216 Ethernet Digital I/O module - automation.com.tw

160

CONNECTION_CLEAR

Function: To clear the connect information. It will disconnect before clear※.

※ When command to clear connection, the registered data of connection will be cleared and this

will cause the break of connection. To prevent the abnormal function, if standalone mode is

enabled, clear connection will be disabled.

※ Need reboot module!!

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 connection_state [4] Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x74, Clear the connect information. It will disconnect

before clear.

connection_abort[4] u8

connection_abort [0]

= 0x1, host0 connection aborted.

= 0x0, None

connection_abort [3]

= 0x1, host3 connection aborted.

= 0x0, None

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 Unused

0x10

0x20 S C

Usage:

member type description

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP Success_flag)

C u8 command= 0x74, Clear the connect information. It will disconnect before

clear.

Page 162: EMD8216 Ethernet Digital I/O module - automation.com.tw

161

CONNECTION_STATE_READ

Function: Read the connect state.

Host to Ethernet module (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 „E‟ „M‟ „D‟ „8‟ „2‟ „1‟ „6‟ password (8 Bytes) C

0x10 Unused

0x20

Usage:

member type description

password[8] u8 current password

C u8 command= 0x75, Read the connect state.

Ethernet module to Host (UDP data):

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF

0x00 connection_state [4] ERROR_code [4]

0x10

0x20 S C

Usage:

member type description

connection_state[4] u8

[0 ~ 3] is remote module ID,

State value:

= 0x0, REMOTE_UNUSED

= 0x1, CONNECTED

= 0x2, RE_CONNECTION

= 0x3, DISCONNECTION

= 0x4, WAIT_RESPOND

= 0x5, WAIT_TO_SEND

= 0x6, SEND_TO_HOST

= 0x7, NEED_REBOOT_FOR_NEW_CONFIG

ERROR_code[4] u8 [0 ~ 3] is remote module ID

Error code.

S u8

Success_flag:

= 0x63 //command successful

≠ 0x63 //command fail (refer Error codes table for UDP

Success_flag)

C u8 command= 0x75, Read the connect state.

Page 163: EMD8216 Ethernet Digital I/O module - automation.com.tw

162

12. DLL list

Function Name Description

1. EMD8216_initial( ) Assign IP and port to existing module

2. EMD8216_close( ) EMD8216 close to release resource

3. EMD8216_firmware_version_read( ) Read the firmware version

4. EMD8216_dll_version_read( ) Read dll version.

5. EMD8216_subnet_mask_set( ) Set the subnet mask

6. EMD8216_subnet_mask_read( ) Read the subnet mask

7. EMD8216_port_config_set( ) Set the Configure of the I/O port.

8. EMD8216_port_config_read( ) Read back the Configure of the I/O port.

9. EMD8216_inport_debounce_set( ) Set the input port debounce time.

10. EMD8216_inport_debounce_read( ) Read back the debounce time of the input port.

11. EMD8216_port_polarity_set( ) Set the I/O port polarity.

12. EMD8216_port_polarity_read( ) Read back the polarity setting of the I/O port

13. EMD8216_port_set( ) Set the output port data.

14. EMD8216_port_read( ) Read back the data of the I/O port.

15. EMD8216_point_config_set( ) Set bit configuration of I/O point

16. EMD8216_point_config_read( ) Read bit configuration of I/O point

17. EMD8216_point_polarity_set( ) Set the I/O point polarity.

18. EMD8216_point_polarity_read( ) Read back the polarity setting of the I/O point.

19. EMD8216_point_set( ) Set bit status of output point

20. EMD8216_point_read( ) Read bit state of I/O point.

21. EMD8216_counter_mask_set( ) Set counter channel mask

22. EMD8216_counter_mask_read( ) Read counter channel mask

23. EMD8216_counter_enable( ) Enable counter function

24. EMD8216_counter_disable( ) Disable counter function

25. EMD8216_counter_read( ) Read counter value

26. EMD8216_counter_clear( ) Clear designated counter

27. EMD8216_socket_port_change( ) Change the communication port

28. EMD8216_network_config_change( ) Set IP address、subnet mask and default gateway

29. EMD8216_network_config_read( ) Read IP address、subnet mask and default gateway

30. EMD8216_IP_change( ) Change the IP of EMD8216

31. EMD8216_reboot( ) Reboot EMD8216 module

32. EMD8216_default_gateway_change( ) Change default gateway

33. EMD8216_default_gateway_read( ) Read back default gateway

34. EMD8216_security_unlock( ) Unlock security function

35. EMD8216_security_status_read( ) Read lock status

36. EMD8216_password_change( ) Change password

Page 164: EMD8216 Ethernet Digital I/O module - automation.com.tw

163

37. EMD8216_password_set_default( ) Rest to factory default password

38. EMD8216_WDT_set( ) Set up WDT timer and output states

39. EMD8216_WDT_read( ) Read WDT timer and output state setting

40. EMD8216_WDT_set_new( ) Set up WDT timer and output states

41. EMD8216_WDT_read_new( ) Read WDT timer and output state setting

42. EMD8216_WDT_enable( ) Enable WDT function

43. EMD8216_WDT_disable( ) Disable WDT function

44. EMD8216_standalone_enable( ) Enable standalone mode

45. EMD8216_standalone_disable( ) Disable (stop) standalone mode

46. EMD8216_standalone_V_config_set( ) Set new standalone configuration

47. EMD8216_standalone_V_config_read( ) Read new standalone configuration

48. EMD8216_standalone_config_set( ) Set the standalone configuration

49. EMD8216_standalone_config_read( ) Read the standalone configuration

50. EMD8216_standalone_config_clear( ) Clear standalone configuration

51. EMD8216_D2D_config_set( ) Set the remote configuration

52. EMD8216_D2D_config_read( ) Read the remote configuration

53. EMD8216_D2D_connection_clear( ) Clear the remote configuration setting

54. EMD8216_D2D_connection_state_read( ) Read the remote configuration connection state

55. EMD8216_D2D_keep_alive_time_set( ) set the D2D device alive monitoring cycle time

56. EMD8216_D2D_keep_alive_time_read( ) read the D2D device alive monitoring cycle time

Page 165: EMD8216 Ethernet Digital I/O module - automation.com.tw

164

13. EMD8216 Status(Error codes) summary

13.1 EMD8216 Status(Error codes) table

Status Symbolic Name Description

0 JSDRV_NO_ERROR No error.

1 INITIAL_SOCKET_ERROR Socket can not initialized, maybe Ethernet

hardware problem

2 IP_ADDRESS_ERROR IP address is not acceptable

3 UNLOCK_ERROR Unlock fail

4 LOCK_COUNTER_ERROR Unlock error too many times

5 SET_SECURITY_ERROR Fail to set security

100 DEVICE_RW_ERROR Can not reach module

101 NO_CARD Can not reach module

102 DUPLICATION_ID Card ID already used

300 ID_ERROR Card ID is not acceptable

301 PORT_ERROR Port parameter unacceptable or unreachable

302 IN_POINT_ERROR Input point unreachable

303 OUT_POINT_ERROR Output point unreachable

305 PARAMETERS_ERROR Parameter error

306 CHANGE_SOCKET_ERROR Cannot change socket

307 UNLOCK_SECURITY_ERROR Fail to unlock security

308 PASSWORD_ERROR Password mismatched

309 REBOOT_ERROR Cannot reboot

310 TIME_OUT_ERROR Too long to response

311 CREAT_SOCKET_ERROR Socket cannot create

312 CHANGE_IP_ERROR Change IP error

313 MASK_ERROR Set mask error

314 COUNTER_ENABLE_ERROR Cannot enable counter

315 COUNTER_DISABLE_ERROR Cannot disable counter

316 COUNTER_READ_ERROR Fail to read counter

317 COUNTER_CLEAR_ERROR Fail to clear counter

318 TIME_ERROR Set the time error

320 CARD_VERSION_ERROR Cannot read firmware version

321 STANDALONE_ENABLE_ERROR Cannot enable standalone

322 STANDALONE_DISABLE_ERROR Cannot disable standalone

323 STANDALONE_CONFIG_ERROR Standalone mode configuration error

324 INDEX_ERROR Standalone command index error

325 NUMBER_ERROR Standalone number error

326 TIMER_MODE_ERROR Standalone timer mode error

Page 166: EMD8216 Ethernet Digital I/O module - automation.com.tw

165

327 OUT_MODE_ERROR Standalone output mode error

328 POWER_ON_ERROR Standalone power on error

329 DLL_VERSION_READ_ERROR Standalone DLL version error

340 MODULE_TYPE_ERROR Standalone module type error

341 REMOTE_MODULE_ERROR Standalone remote module error

Page 167: EMD8216 Ethernet Digital I/O module - automation.com.tw

166

14. UDP communication command list

Command R/W Mnemonics Descriptions

0x1 R MODULE_TYPE_READ Read Card Type

0x2 W REBOOT Soft Reboot

0x3 W SOCKET_PORT_CHANGE Change Socket Port

0x4 W PASSWORD_CHANGE Change password

0x5 W PASSWORD_RESTORE Restore password

0x6 W IP_CHANGE Change IP Address

0x7 R FIRMWARE_VERSION_READ Read firmware version

0x8 W SUBNET_MASK_SET Change subnet mask

0x9 R SUBNET_MASK_READ Read subnet mask

0xA W DEFAULT_GATEWAY_SET Change default gateway

0xB R DEFAULT_GATEWAY_READ Read default gateway

0xC W NETWORK_CONFIG_SET Change network setting

0xD R NETWORK_CONFIG_READ Read network setting

0xF0 W INPUT_DEBOUNCE_SET Write input_debounce

0xF1 R INPUT_DEBOUNCE_READ Read input_debounce

0x20 W COUNTER_MASK_SET Write counter mask

0x21 W COUNTER_MODE_ENABLE Enable counter mode

0x22 W COUNTER_MODE_DISABLE Disable counter mode

0x23 R IN_COUNTER_READ Read counter

0x24 W POINT_COUNTER_CLEAR Clear point counter

0x25 W MULTIPLE_COUNTER_CLEAR Clear multi point counter

0x26 R COUNTER_MASK_READ Read counter mask

Page 168: EMD8216 Ethernet Digital I/O module - automation.com.tw

167

0x30 W PORT_CONFIG_SET Set Port config

0x31 R PORT_CONFIG_READ Read Port config

0x32 W PORT_SET Write Port

0x33 R PORT_READ Read Port

0x34 W POLARITY_SET Write Port polarity

0x35 R POLARITY_READ Read Port polarity

0x36 W POINT_CONFIG_SET Set Point config

0x37 R POINT_CONFIG_READ Read Point config

0x38 W POINT_SET Write Point

0x39 R POINT_READ Read Point

0x3A W POINT_POLARITY_SET Write Point polarity

0x3B R POINT_POLARITY_READ Read Point polarity

0x3C W MULTI_POINT_SET Write multi point

0x3D R MULTI_POINT_READ Read multi point

0x50 W STANDALONE_ENABLE Enable standalone

0x51 W STANDALONE_DISABLE Disable standalone

0x52 W STANDALONE_CONFIG_SET Set standalone config

0x53 R STANDALONE_CONFIG_READ Read standalone config

0x54 W STANDALONE_CONFIG_NEW_SET Set new standalone config

0x55 R STANDALONE_CONFIG_NEW_READ Read new standalone config

0x56 W STANDALONE_CONFIG_CLEAR Clear all standalone config

0x60 W WDT_ENABLE Enable WDT

0x61 W WDT_DISABLE Disable WDT

0x62 W WDT_SET Set WDT

0x63 R WDT_READ Read WDT

0x70 W D2D_CONFIG_SET Set host device config

Page 169: EMD8216 Ethernet Digital I/O module - automation.com.tw

168

0x71 R D2D_CONFIG_READ Read host device config

0x72 W D2D_KEEP_ALIVE_SET Set keep-alive delay time

0x73 R D2D_KEEP_ALIVE_READ Read keep-alive delay time

0x74 W CONNECTION_CLEAR Abort and clear Connection

0x75 R CONNECTION_STATE_READ Read Connection state

Page 170: EMD8216 Ethernet Digital I/O module - automation.com.tw

169

15. Error codes table for UDP Success_flag

Error code Symbolic Name Description

99 SUCCESS No Error

Based command Error

100 COMMAND_ERROR Command Error

101 PASSWORD_ERROR Password Error

102 CHANGE_IP_ERROR Set IP value error

out of range

103 CHANGE_SOCKET_ERROR Set socket port error

out of range

106 CARD_TYPE_ERROR Set host config error

out of range

107 CHANGE_MASK_ERROR Change subnet mask error

108 CHANGE_GATEWAY_

ERROR Change default gateway error

IO function R/W Error

120 PORT_ERROR Choose Port error

out of range

121 CHANNEL_ERROR Choose channel error

out of range

122 STATE_ERROR Set state error

State:0 / 1

123 TIMER_VALUE_ERROR Set Timer value error

out of range

124 MODE_ERROR Choose mode error

out of range

Standalone function R/W Error

150 INDEX_ERROR Choose index error

Standalone or Host index error

151 NUMBER_ERROR Standalone number error

Standalone function MAX is 32

152 COMPARE_MODE_ERROR Compare mode error

Choose wrong mode

153 OUT_MODE_ERROR Output mode error

Output mode = 0 or 1

154 INPUT_SETTING_ERROR Input error

Please check input setting

155 OUTPUT_SETTING_ERROR Output error

Please check output setting

156 POWER_ON_ERROR Power on enable error

Power_on = 0 or 1

157 HOST_DEVICE_ERROR Device does not exist

Please check Host config

Page 171: EMD8216 Ethernet Digital I/O module - automation.com.tw

170

158 ST_ENABLE_ERROR Clear connection error

Because standalone is enable

160 CONNECTION_MASK_ERROR Set connection mask error

Can‟t find host device information

Page 172: EMD8216 Ethernet Digital I/O module - automation.com.tw

171

16. Modbus

The Modbus protocol is widely accepted in SCADA application software, the EMD8216 also

provide the protocol that enables the module to connect to existing software without much effort. The

Modbus TCP protocol requires communicating through port 502 as default. The Modbus function code

and the address numbers are list as followings.

16.1 Input register: (function code is 04)

Address

Number

Register

Address

Data

Type R/W Mnemonic Description

30001 0x0000 2 byte RO PHYSICAL

INPUT

Low Byte is Physical IN port0,

High Byte is Physical IN port1

any bit = 1 active state

any bit = 0 inactive state

30002 0x0001 2 byte RO VIRTUAL

INPUT

Low Byte is Virtual IN port0,

High Byte is Virtual IN port1,

any bit = 1 active state

any bit = 0 inactive state

30003 0x0002 2 byte RO COUNTER00_H

Port0 counter data

30004 0x0003 2 byte RO COUNTER00_L

30005 0x0004 2 byte RO COUNTER01_H

30006 0x0005 2 byte RO COUNTER01_L

30007 0x0006 2 byte RO COUNTER02_H

30008 0x0007 2 byte RO COUNTER02_L

30009 0x0008 2 byte RO COUNTER03_H

30010 0x0009 2 byte RO COUNTER03_L 30011 0x000A 2 byte RO COUNTER04_H

30012 0x000B 2 byte RO COUNTER04_L

30013 0x000C 2 byte RO COUNTER05_H

30014 0x000D 2 byte RO COUNTER05_L

30015 0x000E 2 byte RO COUNTER06_H

30016 0x000F 2 byte RO COUNTER06_L

30017 0x0010 2 byte RO COUNTER07_H

30018 0x0011 2 byte RO COUNTER07_L

30019 0x0012 2 byte RO COUNTER10_H

Port1 counter data

30020 0x0013 2 byte RO COUNTER10_L

30021 0x0014 2 byte RO COUNTER11_H

30022 0x0015 2 byte RO COUNTER11_L

30023 0x0016 2 byte RO COUNTER12_H

30024 0x0017 2 byte RO COUNTER12_L

30025 0x0018 2 byte RO COUNTER13_H

30026 0x0019 2 byte RO COUNTER13_L 30027 0x001A 2 byte RO COUNTER14_H

30028 0x001B 2 byte RO COUNTER14_L

30029 0x001C 2 byte RO COUNTER15_H

30030 0x001D 2 byte RO COUNTER15_L

30031 0x001E 2 byte RO COUNTER16_H

30032 0x001F 2 byte RO COUNTER16_L

30033 0x0020 2 byte RO COUNTER17_H

Page 173: EMD8216 Ethernet Digital I/O module - automation.com.tw

172

30034 0x0021 2 byte RO COUNTER17_L

30035 0x0022 2byte RO Firmware version Firmware version = 0x0123, is

V1.23

16.2 Configure Register: (function code is 03、06、16)

Address

Number

Register

Address

Data

Type R/W Mnemonic Description

40001 0x0000 2 byte R/W PORT_CONFIG

0: configured as output

1: configured as input

b0 ~ b7: DIO00 ~ DIO07

b8 ~ b15: DIO10 ~ DIO17

40002 0x0001 2 byte R/W DIO_POLARITY

any bit

= 1 invert the corresponding DIO

= 0 normal the corresponding DIO

16.3 WDT Register: (function code is 03、06、16)

Address

Number

Register

Address

Data

Type R/W Mnemonic Description

40003 0x0002 2 byte R/W WDT_TIMER_CONSTANT

Time = timer_constant *

100(mS)

10 ≦ timer_constant ≦10000

40004 0x0003 2 byte R/W WDT_ENABLE 0: disable 1: enable

40005 0x0004 2 byte R/W WDT_PHY_OUT_STATE

Low Byte is Physical OUT

port 0,

High Byte is Physical OUT

port 1

any bit = 1 active state

any bit = 0 inactive state

40006 0x0005 2 byte R/W WDT_VIR_OUT_STATE

Low Byte is Virtual OUT

port 0,

High Byte is Virtual OUT

port 1,

any bit = 1 active state

any bit = 0 inactive state

40007 0x0006 2 byte R/W WDT_PHY_OUT_MASK

Low Byte is Physical OUT

port 0 mask,

High Byte is Physical OUT

port 1 mask,

any bit = 1 active state

any bit = 0 inactive state

40008 0x0007 2 byte R/W WDT_VIR_OUT_MASK

Low Byte is Virtual OUT

port 0 mask,

High Byte is Virtual OUT

port 1 mask,

any bit = 1 active state

any bit = 0 inactive state

Page 174: EMD8216 Ethernet Digital I/O module - automation.com.tw

173

16.4 Counter Register: (function code is 03、06、16)

Address

Number

Register

Address

Data

Type R/W Mnemonic Description

40009 0x0008 2 byte R/W COUNTER_ENABLE 0: disable 1: enable

40010 0x0009 2 byte W COUNTER_CLEAR

0: unused

1: clear counter

b0 ~ b7: counter00 ~

counter07

b8 ~ b15: counter10 ~

counter17

40011 0x000A 2 byte R/W COUNTER_MASK any bit = 0 mask off the

corresponding counter

16.5 Debounce Register: (function code is 03、06、16)

Address

Number

Register

Address

Data

Type R/W Mnemonic Description

40012 0x000B 2 byte R/W IN_DEBOUNCE

Low Byte is Physical IN

port 0,

High Byte is Physical IN

port 1,

1 ~ 200, debounce time is

5mS ~ 1000mS

Page 175: EMD8216 Ethernet Digital I/O module - automation.com.tw

174

16.6 Output register: (function code is 01、05、15)

Address

Number

Register

Address

Data

Type R/W Mnemonic Description

00001 0x0000 1 bit R/W PHYSICAL_OUTPUT_00

while write

0: output inactive

1: output active

while read

If the point is output

0: output state is inactive

1: output state is active

00002 0x0001 1 bit R/W PHYSICAL_OUTPUT_01

00003 0x0002 1 bit R/W PHYSICAL_OUTPUT_02

00004 0x0003 1 bit R/W PHYSICAL_OUTPUT_03

00005 0x0004 1 bit R/W PHYSICAL_OUTPUT_04

00006 0x0005 1 bit R/W PHYSICAL_OUTPUT_05

00007 0x0006 1 bit R/W PHYSICAL_OUTPUT_06

00008 0x0007 1 bit R/W PHYSICAL_OUTPUT_07

00009 0x0008 1 bit R/W PHYSICAL_OUTPUT_10

00010 0x0009 1 bit R/W PHYSICAL_OUTPUT_11

00011 0x000A 1 bit R/W PHYSICAL_OUTPUT_12

00012 0x000B 1 bit R/W PHYSICAL_OUTPUT_13

00013 0x000C 1 bit R/W PHYSICAL_OUTPUT_14

00014 0x000D 1 bit R/W PHYSICAL_OUTPUT_15

00015 0x000E 1 bit R/W PHYSICAL_OUTPUT_16

00016 0x000F 1 bit R/W PHYSICAL_OUTPUT_17

00017 0x0010 1 bit R/W VIRTUAL_OUTPUT_00

00018 0x0011 1 bit R/W VIRTUAL_OUTPUT_01

00019 0x0012 1 bit R/W VIRTUAL_OUTPUT_02

00020 0x0013 1 bit R/W VIRTUAL_OUTPUT_03

00021 0x0014 1 bit R/W VIRTUAL_OUTPUT_04

00022 0x0015 1 bit R/W VIRTUAL_OUTPUT_05

00023 0x0016 1 bit R/W VIRTUAL_OUTPUT_06

00024 0x0017 1 bit R/W VIRTUAL_OUTPUT_07

00025 0x0018 1 bit R/W VIRTUAL_OUTPUT_10

00026 0x0019 1 bit R/W VIRTUAL_OUTPUT_11

00027 0x001A 1 bit R/W VIRTUAL_OUTPUT_12

00028 0x001B 1 bit R/W VIRTUAL_OUTPUT_13

00029 0x001C 1 bit R/W VIRTUAL_OUTPUT_14

00030 0x001D 1 bit R/W VIRTUAL_OUTPUT_15

00031 0x001E 1 bit R/W VIRTUAL_OUTPUT_16

00032 0x001F 1 bit R/W VIRTUAL_OUTPUT_17

Page 176: EMD8216 Ethernet Digital I/O module - automation.com.tw

175

16.7 Input register: (function code is 02)

Address

Number

Register

Address

Data

Type R/W Mnemonic Description

10001 0x0000 1 bit RO PHYSICAL_INPUT_00

bit = 1 active state

= 0 inactive state

10002 0x0001 1 bit RO PHYSICAL_INPUT_01

10003 0x0002 1 bit RO PHYSICAL_INPUT_02

10004 0x0003 1 bit RO PHYSICAL_INPUT_03

10005 0x0004 1 bit RO PHYSICAL_INPUT_04

10006 0x0005 1 bit RO PHYSICAL_INPUT_05

10007 0x0006 1 bit RO PHYSICAL_INPUT_06

10008 0x0007 1 bit RO PHYSICAL_INPUT_07

10009 0x0008 1 bit RO PHYSICAL_INPUT_10

10010 0x0009 1 bit RO PHYSICAL_INPUT_11

10011 0x000A 1 bit RO PHYSICAL_INPUT_12

10012 0x000B 1 bit RO PHYSICAL_INPUT_13

10013 0x000C 1 bit RO PHYSICAL_INPUT_14

10014 0x000D 1 bit RO PHYSICAL_INPUT_15

10015 0x000E 1 bit RO PHYSICAL_INPUT_16

10016 0x000F 1 bit RO PHYSICAL_INPUT_17

10017 0x0010 1 bit RO VIRTUAL_INPUT_00

10018 0x0011 1 bit RO VIRTUAL_INPUT_01

10019 0x0012 1 bit RO VIRTUAL_INPUT_02

10020 0x0013 1 bit RO VIRTUAL_INPUT_03

10021 0x0014 1 bit RO VIRTUAL_INPUT_04

10022 0x0015 1 bit RO VIRTUAL_INPUT_05

10023 0x0016 1 bit RO VIRTUAL_INPUT_06

10024 0x0017 1 bit RO VIRTUAL_INPUT_07

10025 0x0018 1 bit RO VIRTUAL_INPUT_10

10026 0x0019 1 bit RO VIRTUAL_INPUT_11

10027 0x001A 1 bit RO VIRTUAL_INPUT_12

10028 0x001B 1 bit RO VIRTUAL_INPUT_13

10029 0x001C 1 bit RO VIRTUAL_INPUT_14

10030 0x001D 1 bit RO VIRTUAL_INPUT_15

10031 0x001E 1 bit RO VIRTUAL_INPUT_16

10032 0x001F 1 bit RO VIRTUAL_INPUT_17

Page 177: EMD8216 Ethernet Digital I/O module - automation.com.tw

176

16.8 Modbus TCP/IP

Modbus / TCP protocol use socket port 502 as default port.

Modbus/TCP request and response format:

2 byte 2 byte 2 byte 1 byte 1 byte 1~255 byte

Transaction ID Protocol ID data length Device ID Function code Data

MBAP (ModBus Application Protocol) MODBUS PDU (Protocol Data Unit)

MODBUS/TCP

Transaction ID:when the client needs mass date transfer and do not wait for the server to response one

by one, Transaction IDis required for the server to response accordingly.

Protocol ID:ModBus use 0x0 as default,it reserved as extension.

data length:PDU package length (includes Device ID), PDU protocol maximum allowable length only

255 bytes, it makes High Byte of data length always 0x0.

Device ID:ModBus/TCP protocoldo not need Device ID, fill the field as 0x0 or 0xFF.

Error response format (PDU format):

1 byte 1 byte

Error code Exception code

MODBUS PDU (Protocol Data Unit)

Error code is function code +0x80.

Exception code table:

01 : Illegal Function

02 : Illegal data address

03 : Illegal data value

04 : Slave device failure

08 : Memory parity error

Page 178: EMD8216 Ethernet Digital I/O module - automation.com.tw

177

Func 01 (0x01) Read Coils

This function code is used to read contiguous status of bits in a remote device. The Request PDU

specifies the starting address, i.e. the address of the first bit specified, and the number of bits. In the PDU

Coils are addressed starting at zero. Therefore coils numbered 1-16 are addressed as 0-15.

The bits in the response message are packed as one byte per bit of the data field. Status is indicated

as 1= ON and 0= OFF. The LSB of the first data byte contains the output addressed in the query. The

other bits follow toward the high order end of this byte, and from low order to high order in subsequent

bytes.

If the returned output quantity is not a multiple of eight, the remaining bits in the final data byte

will be padded with zeros (toward the high order end of the byte). The Byte Count field specifies the

quantity of complete bytes of data.

Request

Function code 1 Byte 0x01

Starting Address 2 Bytes 0x0000 ~ 0xFFFF

Quantity of Coil 2 Bytes 1 ~ 2000 (0x0001 ~ 0x07D0)

Response

Function code 1 Byte 0x01

Byte count 1 Byte N*

Coil Status n Bytes n = N or N + 1

*N = Quantity of Input Registers / 8, if the remainder is different of 0 => N = N + 1

Error

Error code 1 Byte 0x81

Exception code 1 Byte 01 or 02 or 03 or 04

Page 179: EMD8216 Ethernet Digital I/O module - automation.com.tw

178

Func 02 (0x02) Read Discrete Inputs

This function code is used to read from 1 to 2000 contiguous status of discrete inputs in a remote

device. The Request PDU specifies the starting address, i.e. the address of the first input specified, and

the number of inputs. In the PDU Discrete Inputs are addressed starting at zero. Therefore Discrete

inputs numbered 1-16 are addressed as 0-15.

The discrete inputs in the response message are packed as one input per bit of the data field. Status

is indicated as 1= ON; 0= OFF. The LSB of the first data byte contains the input addressed in the query.

The other inputs follow toward the high order end of this byte, and from low order to high order in

subsequent bytes.

If the returned input quantity is not a multiple of eight, the remaining bits in the final data byte will

be padded with zeros (toward the high order end of the byte). The Byte Count field specifies the quantity

of complete bytes of data.

Request

Function code 1 Byte 0x02

Starting Address 2 Bytes 0x0000 ~ 0xFFFF

Quantity of Input 2 Bytes 1 ~ 2000 (0x0001 ~ 0x07D0)

Response

Function code 1 Byte 0x02

Byte count 1 Byte N*

Input Status N* + 1 Bytes

*N = Quantity of Input Registers / 8, if the remainder is different of 0 => N = N + 1

Error

Error code 1 Byte 0x82

Exception code 1 Byte 01 or 02 or 03 or 04

Page 180: EMD8216 Ethernet Digital I/O module - automation.com.tw

179

Func 03 (0x03) Read Holding Registers

This function code is used to read the contents of a contiguous block of holding registers in a

remote device. The Request PDU specifies the starting register address and the number of registers. In

the PDU Registers are addressed starting at zero. Therefore registers numbered 1-16 are addressed as

0-15.

The register data in the response message are packed as two bytes per register, with the binary

contents right justified within each byte. For each register, the first byte contains the high order bits and

the second contains the low order bits.

Request

Function code 1 Byte 0x03

Starting Address 2 Bytes 0x0000 ~ 0xFFFF

Quantity of Registers 2 Bytes 1 ~ 125 (0x0001 ~ 0x007D)

Response

Function code 1 Byte 0x03

Byte count 1 Byte 2 x N*

Registers value N* x 2 Bytes

*N = Quantity of Registers

Error

Error code 1 Byte 0x83

Exception code 1 Byte 01 or 02 or 03 or 04

Page 181: EMD8216 Ethernet Digital I/O module - automation.com.tw

180

Func 04 (0x04) Read Input Registers

This function code is used to read input registers in a remote device. The Request PDU specifies the

starting register address and the number of registers.

The register data in the response message are packed as two bytes per register, with the binary

contents right justified within each byte. For each register, the first byte contains the high order bits and

the second contains the low order bits.

Request

Function code 1 Byte 0x04

Starting Address 2 Bytes 0x0000 ~ 0xFFFF

Quantity of Input Registers 2 Bytes 1 ~ 125 (0x0001 ~ 0x007D)

Response

Function code 1 Byte 0x04

Byte count 1 Byte 2 x N*

Input Registers N* x 2 Bytes

*N = Quantity of Input Registers

Error

Error code 1 Byte 0x84

Exception code 1 Byte 01 or 02 or 03 or 04 or 08

Page 182: EMD8216 Ethernet Digital I/O module - automation.com.tw

181

Func 05 (0x05) Write Single Coil

This function code is used to write a single output to either ON or OFF in a remote device. The

requested ON/OFF state is specified by a constant in the request data field. A value of 0xFF00 requests

the output to be ON. A value of 0x0000 requests it to be OFF. All other values are illegal and will not

affect the output.

The Request PDU specifies the address of the coil to be forced. Coils are addressed starting at zero.

Therefore coil numbered 1 is addressed as 0. The requested ON/OFF state is specified by a constant in

the Coil Value field. A value of 0xFF00 requests the coil to be ON. A value of 0x0000 requests the coil

to be off. All other values are illegal and will not affect the coil.

Request

Function code 1 Byte 0x05

Output Address 2 Bytes 0x0000 ~ 0xFFFF

Output Value 2 Bytes 0x0000 / 0xFF00

Response

Function code 1 Byte 0x05

Output Address 2 Bytes 0x0000 ~ 0xFFFF

Output Value 2 Bytes 0x0000 / 0xFF00

Error

Error code 1 Byte 0x85

Exception code 1 Byte 01 or 02 or 03 or 04

Page 183: EMD8216 Ethernet Digital I/O module - automation.com.tw

182

Func 06 (0x06) Write Single Register

This function code is used to write a single holding register in a remote device. The Request PDU

specifies the address of the register to be written. Registers are addressed starting at zero. Therefore

register numbered 1 is addressed as 0.

The normal response is an echo of the request, returned after the register contents have been

written.

Request

Function code 1 Byte 0x06

Register Address 2 Bytes 0x0000 ~ 0xFFFF

Register Value 2 Bytes 0x0000 / 0xFFFF

Response

Function code 1 Byte 0x06

Register Address 2 Bytes 0x0000 ~ 0xFFFF

Register Value 2 Bytes 0x0000 / 0xFFFF

Error

Error code 1 Byte 0x86

Exception code 1 Byte 01 or 02 or 03 or 04

Page 184: EMD8216 Ethernet Digital I/O module - automation.com.tw

183

Func 15 (0x0F) Write Multiple Coils

This function code is used to force each coil in a sequence of coils to either ON or OFF in a remote

device. The Request PDU specifies the coil references to be forced. Coils are addressed starting at zero.

Therefore coil numbered 1 is addressed as 0.

The requested ON/OFF states are specified by contents of the request data field. A logical '1' in a bit

position of the field requests the corresponding output to be ON. A logical '0' requests it to be OFF.

The normal response returns the function code, starting address, and quantity of coils forced.

Request

Function code 1 Byte 0x0F

Starting Address 2 Bytes 0x0000 ~ 0xFFFF

Quantity of Output 2 Bytes 0x0001 ~ 0x07B0

Byte Counter 1 Byte N*

Output Value N* x 1 Byte

*N = Quantity of Output / 8, if the remainder is different of 0 => N = N + 1

Response

Function code 1 Byte 0x0F

Starting Address 2 Bytes 0x0000 ~ 0xFFFF

Quantity of Outputs 2 Bytes 0x0001 ~ 0x07B0

Error

Error code 1 Byte 0x8F

Exception code 1 Byte 01 or 02 or 03 or 04

Page 185: EMD8216 Ethernet Digital I/O module - automation.com.tw

184

Func 16 (0x10) Write Multiple Registers

This function code is used to write a block of contiguous registers in a remote device.

The requested written values are specified in the request data field. Data is packed as two bytes per

register. The normal response returns the function code, starting address, and quantity of registers

written.

Request

Function code 1 Byte 0x10

Starting Address 2 Bytes 0x0000 ~ 0xFFFF

Quantity of Registers 2 Bytes 0x0001 ~ 0x007B

Byte Count 1 Byte 2 x N*

Registers Value N* x 2 Bytes value

*N = Quantity of Registers

Response

Function code 1 Byte 0x10

Starting Address 2 Bytes 0x0000 ~ 0xFFFF

Quantity of Registers 2 Bytes 1 ~ 123 (0x7B)

Error

Error code 1 Byte 0x90

Exception code 1 Byte 01 or 02 or 03 or 04