manual version 2 - esco-da.be hitachi/software/actcom/manuals/actwin...actwin communications is a...

30
Manual Version 2.0 2001-06-14

Upload: lamhuong

Post on 13-Apr-2018

304 views

Category:

Documents


16 download

TRANSCRIPT

Page 1: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

Manual Version 2.0

2001-06-14

Page 2: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 2 of 30

Table of contents: 1 ActWin Communications .................................................................4 2 ActCom ..............................................................................................5

2.1 ActCom Methods .........................................................................................................5 2.2 ActComH - Hitachi H-series RS232 communication OCX ........................................6

2.2.1 Supported PLC types:............................................................................................6 2.2.2 Supported addresses:.............................................................................................6 2.2.3 Properties...............................................................................................................6

2.3 ActComETH - Ethernet communication OCX for Hitachi EH-150, H302 –H4010 series and Horner Electric communication module ...............................................................7

2.3.1 Supported PLC types.............................................................................................7 2.3.2 Supported addresses:.............................................................................................7 2.3.3 Properties...............................................................................................................7

2.4 ActComE - Hitachi E-series RS232 communication OCX .........................................8 2.4.1 Supported PLC types:............................................................................................8 2.4.2 Supported addresses ..............................................................................................8 2.4.3 Properties...............................................................................................................8

2.5 Code examples for Visual Basic ..................................................................................9 2.5.1 Code example for Visual Basic .............................................................................9 2.5.2 Example 1, Display the PLC real time clock seconds in a form. ........................10 2.5.3 Example 2, Block read and write ........................................................................11 2.5.4 Example 3. Excel and Visual Basic for Application...........................................12

3 ActServ – DDE Communication with the H and EH series ...... 13 3.1 General DDE..............................................................................................................13 3.2 Installation of AcServ ................................................................................................14

3.2.1 System requirement .............................................................................................14 3.2.2 Program installation ............................................................................................14 3.2.3 License files.........................................................................................................14 3.2.4 Copying of ActServ files.....................................................................................14

3.3 Starting ActServ.........................................................................................................15 3.4 Commands .................................................................................................................15

3.4.1 File - Clear log.....................................................................................................15 3.4.2 File - Log to file ..................................................................................................16 3.4.3 File – Exit ............................................................................................................16 3.4.4 PLC – Connect ....................................................................................................17 3.4.5 PLC – Status........................................................................................................17 3.4.6 Options – Communications .................................................................................18 3.4.7 Help - About ActServ..........................................................................................19

3.5 Help for Excel Users..................................................................................................20 3.5.1 Excel function .....................................................................................................20 3.5.2 Excel macro (VBA).............................................................................................21 3.5.3 VBA - Monitor....................................................................................................21 3.5.4 VBA - TaskCode .................................................................................................24

4 Appendix A - Communication error codes.................................. 27 4.1 Error codes for OCX drives (ActCom) ......................................................................27

Page 3: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 3 of 30

4.1.1 Error handling .....................................................................................................27 4.2 Error codes for DDE drive (ActServ) ........................................................................28

5 Appendix B – TaskCode´s to be used in ActServ....................... 29 5.1 Monitor Specified I/O or memory .............................................................................29 5.2 Set/Reset Specific I/O ................................................................................................29 5.3 I/O Codes and I/O Numbers .....................................................................................30

Page 4: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 4 of 30

1 ActWin Communications ActWin Communications is a group of utility programs for communication with Hitachi PLC-systems. The purpose of the programs is to be used together with PC based systems designed by the user. Some programs can be used together with modern SCADA-system. ActCom is a series of communication components for the user, who develops programs on a PC in C++ or in Visual Basic. For Win 95/98/NT/2000. ActOPC. OPC is the new standard to connect management/business systems with information from the factory floor. Traditionally every software application has developed its own interface against the industrial process. OPC eliminates this as it is a general standard interface, which easily is connects the HMI-system, SCADA-systems and other control applications with the process. For Win 95/98/NT. ActServ. Simple communication routine to be used together with Microsoft Excel. E.g. in an Excel window a value can easily be monitored. Through using the macro language in Excel (Visual Basic for Applications – VBA) automatic reading and writing in the PLC can be performed from e.g. Excel. För Windows 3.1 och Windows 95/98/NT. Driver Comment Version no. ActComH Hitachi H-series RS232 communication OCX 1.5 ActComETH Hitachi Ethernet board for EH-150 or LAN-ETH for large

H-series communication OCX 1.5

ActComE Hitachi E-series RS232 communication OCX (COM2-protocol only)

1.2

ActServ Hitachi H-series RS232 communication DE 1.1

Page 5: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 5 of 30

2 ActCom 2.1 ActCom Methods The following methods can be used in the ActCom drives. Methods Comment long ReadAddressBin(BSTR Address) Read the value of the PLC memory address. long ReadAddressBCD(BSTR Address) Read the value of a PLC memory address as

BCD coded. void WriteAddressBin(BSTR Address, long Value)

Write a new value in the PLC memory address.

void WriteAddressBCD(BSTR Address, long Value)

Write the BCD value in the PLC memory address.

VARIANT ReadBlockBin(BSTR StartAddress, short Size)

Read a continues range of addresses and return the values in an array. (Not in ActComE)

VARIANT ReadBlockBCD(BSTR StartAddress, short Size)

Read a continues range of addresses and return the BCD values in an array. (Not in ActComE)

void WriteBlockBin(BSTR StartAddress, VARIANT ValueArray)

Write the passed array with values to a continues range of addresses. (Not in ActComE)

void WriteBlockBCD(BSTR StartAddress, VARIANT ValueArray)

Write the passed array with BCD values to a continues range of addresses. (Not in ActComE)

B STR ReadBlockString(BSTR StartAddress, short Size)

Read a continues range of addresses and return the values as a comma separated string. (Not in ActComE and ActComH)

void WriteBlockString(BSTR StartAddress, BSTR ValueString)

Write the comma separated string with values to a continues range of addresses. (Not in ActComE and ActComH)

boolean Open() Open the communication void Close() Close the communication and release the

communication port

Page 6: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 6 of 30

2.2 ActComH - Hitachi H-series RS232 communication OCX 2.2.1 Supported PLC types: PLC type Comment HB-series Max 19 200 baud H200 series Max 19 200 baud H300-H2002 Max 19 200 baud Micro EH Max 38 400 baud EH150 series Max 38 400 baud 2.2.2 Supported addresses: X, Y, R, L, M, WX, WY, WR, WL, WM, DX, DY, DR, DL, DM, TC (Double word, DX, DY... are not available on all PLC types, please check PLC manual) 2.2.3 Properties Properties Comment Default BaudRate The communication speed used. 19 200 CommPort The communication port used. 1 StationNo Station number -1 The property StatioNo shall normally be set to –1 if you have a normal point to point communication. In a multidrop network shall you set the StationNo to the correct networked node before you start the communication with the nod.

Page 7: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 7 of 30

2.3 ActComETH - Ethernet communication OCX for Hitachi EH-150, H302 –H4010 series and Horner Electric communication module

2.3.1 Supported PLC types PLC type Comment EH-150 EH-ETH H-252 HE150ETN150 or HE150ETN160 H302 –H4010 LAN-ETH 2.3.2 Supported addresses: X, Y, R, L, M, WX, WY, WR, WL, WM, DX, DY, DR, DL, DM, TC (Double word, DX, DY... are not available on all PLC types, please check PLC manual. For Horner module HE150ETN150 or HE150ETN160 is only WL and L available.) 2.3.3 Properties Properties Comment IPAddress The TCP/IP address of the Horner module PortNumber The port number used

Page 8: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 8 of 30

2.4 ActComE - Hitachi E-series RS232 communication OCX 2.4.1 Supported PLC types: PLC type Comment EC All EC and EC2 types, COM2-

protocol EM3 COM2-protocol only 2.4.2 Supported addresses X, Y, M, WX, WY, WM, VX, VY, VM, T/C 2.4.3 Properties Properties Comment BaudRate The communication speed used CommPort The communication port used

Page 9: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 9 of 30

2.5 Code examples for Visual Basic 2.5.1 Code example for Visual Basic Open a new project in Visual Basic (Standard EXE).

After this set up can you start the programming as the examples below.

Right Mouse Click with pointer over the toolbar and select “components”. Check the component you want to add “ActWin Communication LAN-ETH, Hitachi H-series” in this case, click the Apply button, click the OK button, and the control is added to the toolbar

Click (mark) the component on the toolbar and insert it to your form.

Mark the component in the form. The properties for the component will appear. If you are in an Ethernet system set the IP address and the port number. If you use serial communication set the communication port and Baud rate. If you use multidrop set the node number. The node number shall in point to point systems (RS-232) always be set to –1.

Page 10: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 10 of 30

2.5.2 Example 1, Display the PLC real time clock seconds in a form. Create a form with a label, a text control, the ActCom-H control and a timer control as the picture below shows. The timer and ActCom-H control are only visible at design time and will therefore not show up when we run the program.

In the property window set for the ActCom-H control the correct COM port and baudrate, like 1 and 19200. For the Timer control set the interval to 1000ms. Double click on the timer control to add the Timer1_Timer event. Timer1_Timer: In the Timer event we read the real time clock second va lue (address WRF00F) and assign the text field with the value returned. We use the ReadAddressBCD because the RTC store the values in BCD format. Private Sub Timer1_Timer() On Error GoTo skip ' get value from RTC second Text1.Text = ActComH1.ReadAddressBCD("WRF00F") skip: ' display error to user Text2.Text = Error End Sub

Page 11: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 11 of 30

2.5.3 Example 2, Block read and write Create a form with a listbox, two buttons (called ReadBlock and WriteBlock) an edit control and the ActCom-H control.

Add the following soubroutines: Private Sub ReadBlock_Click() On Error GoTo skip Value = ActComHE1.ReadBlockBin("WM10", 10) List1.Clear For Each data In Value List1.AddItem (CStr(data)) Next skip: Text1.Text = Error End Sub Private Sub WriteBlock_Click() Dim data(9) As Long On Error GoTo skip

Page 12: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 12 of 30

For i = 0 To 9 data(i) = i Next i ActComHE1.WriteBlockBin "WM10", data skip: Text1.Text = Error End Sub 2.5.4 Example 3. Excel and Visual Basic for Application When using a OCX in Excel must you in VBA create a user form. Step 1. Create a form. Step 2. Write the code that reads from the PLC. Write the value in cell A1 of the Excel sheet and in the form.

Private Sub CommandButton1_Click() Value = ActComETH1.ReadAddressBin("WR110") Cells(1, 1) = Value TextBox1.Text = Value End Sub Private Sub CommandButton2_Click() End End Sub

Step 3. Call the form from a VBA macro.

Sub Read() ' ' Read Macro ' UserForm1.Show ' End Sub

Page 13: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 13 of 30

3 ActServ – DDE Communication with the H and EH series

3.1 General DDE

Dynamic Data Exchange (DDE) is a uniformed and standardized way for Windows programs to exchange data. A program either a: DDE-server, supplier of data DDE-client, user of data or both. ActServ is a DDE-server for the Hitachi’s H-series. ActServ makes it possible for DDE-client programs to read and write data to and from a Hitachi H-series PLC. This data can then be presented to the user in different ways. In Microsoft Excel the data can be presented as values, tables or diagrams and macros can be used to control the action of the PLC. ActServ supports multiple sessions with several client programs accessing one local connected PLC. ActServ also supports Network-DDE on Windows for Workgroups, so that information can be shared across a PC-network. With ActServ you can monitor data from the following PLC data areas: X, WX, Y, WY, M, WM, R, WR, L, WL, TC See the H-series manual for connecting the PLC to the PC and on addresses and special registers. ActServ does not support double word addressing. This manual assumes that the reader have a basic knowledge about how to use Windows and the Hitachi H-series PLC.

Page 14: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 14 of 30

3.2 Installation of AcServ This chapter explain how to install the program

3.2.1 System requirement

• The minimum system for running ActServ is: • IBM-PC, 386SX or better or 100% compatible • Windows 3.1 or better • 500 kB free disk space • 2MB free RAM • diskette station • One free communication port (COM1-COM4)

3.2.2 Program installation The installation program is a Windows program. Run INSTALL.EXE on the floppy from the program manager or the file manager and it will copy the necessary files to your hard disk. It will also create a Actsip group in your program manager with an ActServ icon.

3.2.3 License files To use ActServ, a valid license file must be in the same directory as ActServ. Without a valid license file, ActServ starts in demo mode. In demo mode ActServ will only run in 5 minutes and it is not possible to use the Hi-Protocol task code special service. You can still monitor values and do all the other operations mentioned in this manual. If the program starts up in demo mode (indicated by a message box) and you know that you have bought a full version the license files may reside on a separate license disk, please install this disk in the same directory as ActServ and try again.

3.2.4 Copying of ActServ files Application developers may copy and redistribute the license files together with their application. You may not copy or distribute the supplied files if it is not part of a application that is using ActServ. If you have received these files as part of an application, please do not contact Actron directly for support but contact the original application developer.

Page 15: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 15 of 30

3.3 Starting ActServ Start ActServ from the Actsip group in the program manager. This will run ActServ minimized (i.e. as an icon on the bottom of the screen). Double click on the ActServ icon the see the log window:(If you instead see an error message about missing license files see “License files” on page 14 for information.) This ActServ is connected to a H200 PLC through COM2 and is communicating at 19200 baud. The PLC is in RUN.

3.4 Commands 3.4.1 File - Clear log Clear the logging area in the window.

or

Page 16: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 16 of 30

3.4.2 File - Log to file Writes the log to a file. This will not clear the log.

Enter the file name and press OK. The default name is ACTSERV.LOG and is created in the current working directory. Any current file will be overwritten.

3.4.3 File – Exit Exit the application.

Page 17: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 17 of 30

3.4.4 PLC – Connect Try to connect to a PLC. Only available if ”Disconnected”.

or

If ActServ loses the connection to a PLC during monitoring, ActServ will try to reconnect.

3.4.5 PLC – Status Get PLC status. Only available if ”Connected”

or

This dialog can not be used to monitor PLC status. To update the information the dialog must be closed and reopened.

Page 18: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 18 of 30

3.4.6 Options – Communications Set communication parameters and monitor timing.

Select the used port and baud rate. This information will be saved and used the next time ActServ is started.

Poll time is how often ActServ checks the communication when no monitoring is active. This time is also used when ActServ tries to reconnect when communication is lost.

Page 19: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 19 of 30

Monitor delay is the delay time between two monitor actions. This time should be set as high as possible to reduce system load.

3.4.7 Help - About ActServ Display copyright notice and licensed user of this ActServ copy.

or

The About dialog

The Info button display information about the distributor of ActServ.

NOTE: Do not change communication parameters when ActServ is in monitor mode.

Page 20: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 20 of 30

3.5 Help for Excel Users It is possible to access the PLC in two different ways from Excel, either as a function in a cell or from a macro module. When you automate your data reading with an Excel macro can one of two different functions be used: Monitor to read a few memory cells at a time or TaskCode to read a specific number of consecutive memory cells. Observe that if you use the function TaskCode Excel may misinterpret the information and translated it to a number format that’s impossible to use (the contains of the read operation can by Excel be translated into a Scientific format).

3.5.1 Excel function The format of a Excel function for DDE is

=Service|Topic!Item

where Service is ”ActServ” and Topic is ”Monitor”, Item is the IO-point or memory address to be monitored.

Example: To monitor the RealTimeClock seconds at WRF00F (see H-series manual for special register addresses), enter the following function in cell A1, “=ActServ|Monitor!WRF00F”:

NOTE: Normally all PLC word addresses is read as binary data (0 - 65535) with the exception of the Real Time Clock in the PLC (WRF00B - WRF00F). ActServ knows that these addresses have a BCD format and converts automatically

NOTE: The character between Service and Topic is a ”pipe” or "broken bar" character, normally entered as Alt+Ctrl+< on a Swedish keyboard.

Page 21: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 21 of 30

3.5.2 Excel macro (VBA) Normally macros is invoked by a user action, like pushing a button. To communicate with ActServ in an VBA, Visual Basic for Applications, macro three steps is involved: Creating a channel to ActServ Request or send data to ActServ Close the channel Error handling should also be use so that the macro or Excel don't stop or crash.

3.5.3 VBA - Monitor

When you only need to view a few memory positions can you use the monitor topic to read the memory contents. This type of reading is slow, but good if you have to read a few bytes on different locations.

Macro to read a input module (PIM) as a word

Line 1 Defining the name of the subroutine. Line 4 Defining where to go if an error occurs, in this case the channel is just closed. Line 7 Creating a channel to ActServ. Line 10 Request data for PLC address WX10 using the channel created on line 7. Line 13 Place the data in cell A1, DDERequest always return an array but only the first

element is used. Line 17 Close the channel to ActServ. After this no DDE request can be made. Line 19 Subroutine ends

1 Sub ReadWX10() 2 3 ' close channel if an error occur 4 On Error GoTo ErrorHandler 5 6 ' open channel to ActServ 7 channel = Application.DDEInitiate("ActServ", "Monitor") 8 9 ' read WX10, place in data(1) 10 data = Application.DDERequest(channel, "WX10") 11 12 ' place data in cell A1 13 Let Cells(1, 1) = data(1) 14 15 ErrorHandler: 16 ' close channel 17 Application.DDETerminate channel 18 19 End Sub

Page 22: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 22 of 30

There are several Excel files on the distribution diskette that can be used as a start for your own macros.

NOTE: If the Hi-Protocol task codes are used in the wrong way information and/or

program in the PLC may be lost.

RunSlow are a template file to be used to receive information from the PLC in monitor mode.

Macro to read memory or I/O-position, with monitor topic.

'***************************************************************** '* Macro RunSlow, Version 1.0 '* Macro created 95-10-25 by Bengt Stener, Actron AB '* '* Sub RunSlow() ' close if we get an error On Error GoTo ErrorHandler 'open an channel to ActServ channel = Application.DDEInitiate("ActServ", "Monitor") '**************************************************************** '* * '* * '* Your application program * '* * '* * '**************************************************************** GoTo Closing ErrorHandler: MsgBox ("An error occurred, closing channel to ActServ") Closing: ' close channel Application.DDETerminate channel End Sub

Page 23: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 23 of 30

An example on the application program can be as below, a routine that reads 100 WM words.

' loop and get For i = 0 To 99 ' construct the address string WmAddress = "WM" + Hex(i) ' place the string in cell A1 Cells(1, 1) = WmAddress ' get data from PLC, (array returned) data = Application.DDERequest(channel, WmAddress) ' place data in A2... Cells(i + 2, 1) = data(1) Next i

Page 24: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 24 of 30

3.5.4 VBA - TaskCode

You must use the topic ”TaskCode” when you need to transfer large data areas. In this mode can you read and write larger areas in the PLC, the maximum number of bytes that you can transfer in Excel is 255 bytes of code, as each byte is transferred into two ASCII character is that maximum 125 ”reel” bytes.

Template macro to read memory or I/O-positions, with TaskCode topic.

'***************************************************************** '* Macro RunMaster, Version 1.0 '* Macro created 95-10-25 by Bengt Stener, Actron AB '* '* Sub RunMaster() ' If an error occur close channel On Error GoTo ErrorHandler ' Open an channel to ActServ ("ActServ TaskCode topic") channel = Application.DDEInitiate("ActServ", "TaskCode") ' free any occupation hold (task code 17 sub code 01) ' if successful return is empty Data = Application.DDERequest(channel, "1701") ' get one read occupation (task code 16 sub code 01) ' if successful return program version as hex number Data = Application.DDERequest(channel, "1601") '**************************************************************** '* * '* * '* Your application program * '* * '* * '**************************************************************** 'Ready GoTo Closing ErrorHandler: ' Indicate error to operator Application.StatusBar = "Error in communication with PLC" MsgBox ("An error occurred, closing channel to ActServ") Closing: ' closing the channel Application.DDETerminate channel Application.StatusBar = False End Sub

Page 25: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 25 of 30

You can use the template above and in the position of the stars include you application. The application example is to read the CPU time and display it in a message box.

Example on the application program

The example shows how you use the VBA command MID to split the incoming data.

data = Application.DDERequest(channel, "1800") ' Split input data Year = Mid(data(1), 1, 5) Month = Mid(data(1), 6, 2) Date = Mid(data(1), 8, 2) Day = Mid(data(1), 10, 2) Hour = Mid(data(1), 12, 2) Minute = Mid(data(1), 14, 2) Second = Mid(data(1), 16, 2) Answer = MsgBox("Klockan är " & Hour & ":" & Minute & " " & GetDay(Day) _ & " den " & Date & "/" & Month & "-" & (Year * 1000), _ vbOKOnly, "PLC Tid och datum.")

MID(string, offset-number,number-of-characters) - MID returns the number of characters specified from a string, beginning with the character position specified in the argument.

Page 26: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 26 of 30

StoreOffset = 2 For Counter = 0 To 320 ReadData = Counter * 50 If ReadData = 0 Then Data = _ Application.DDERequest(channel, "400A000000" + "32") If ReadData >= 16 And ReadData < 256 Then Data = _ Application.DDERequest(channel, "400A0000" + Hex(ReadData) + "32") If ReadData >= 256 And ReadData < 4096 Then Data = _ Application.DDERequest(channel, "400A000" + Hex(ReadData) + "32") If ReadData >= 4096 Then Data = _ Application.DDERequest(channel, "400A00" + Hex(ReadData) + "32") For BlockCount = 0 To 9 For InCount = 0 To 4 ' get the sub string GetData = InCount + (BlockCount * 5) SubString = Mid(Data(1), (GetData * 4) + 1, 4) If InCount = 0 Then IN0 = "&H" + SubString If InCount = 1 Then IN1 = "&H" + SubString If InCount = 2 Then IN2 = "&H" + SubString If InCount = 3 Then IN3 = "&H" + SubString If InCount = 4 Then IN4 = "&H" + SubString ' indekera läsning Application.StatusBar = _ "Reading from PLC. Takes about 5 Minutes " _ + Hex("&H" + (Counter)) Next InCount Cells((Counter * 10) + BlockCount + StoreOffset, 1) = Hex(IN0) Cells((Counter * 10) + BlockCount + StoreOffset, 2) = Hex(IN1) Cells((Counter * 10) + BlockCount + StoreOffset, 3) = Hex(IN2) Cells((Counter * 10) + BlockCount + StoreOffset, 4) = Hex(IN3) Cells((Counter * 10) + BlockCount + StoreOffset, 5) = Hex(IN4) Next BlockCount Next Counter

Page 27: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 27 of 30

4 Appendix A - Communication error codes 4.1 Error codes for OCX drives (ActCom) 4.1.1 Error handling Each method will throw an error if parameters are invalid or the communication fails. If the error is not handled in the subroutine a runtime-error will occur and the application will stop. To handle the error each subroutine should have an On Error GoTo statement before any methods is called. See example below: Private Sub Command1_Click() On Error GoTo skip ActComH1.WriteAddressBin "WM100", 200 skip: Text2.Text = Error End Sub The Error variable will contain a description of the error and can be displayed as a help to the developer/user. Error Comment CTL_E_DEVICEUNAVAILABLE Unable to connect to the PLC, check

TCP/IP address and port CTL_E_INVALIDPATTERNSTRING Invalid PLC address used CTL_E_INVALIDPROPERTYARRAYINDEX Read/Write block size is to large CTL_E_BADRECORDLENGTH Invalid array passed to WriteBlock

method CTL_E_DEVICEIOERROR Many different errors, but all related to

execution of task code (syntax, timeout, PLC occupation, PLC status etc)

CTL_E_OUTOFMEMORY Out of memory

Page 28: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 28 of 30

4.2 Error codes for DDE drive (ActServ) The error code is displayed in the log as a hexadecimal number.

Error Code Description 0x01 PLC parity error 0x02 PLC checksum error 0x03 PLC framing error 0x04 PLC overrun error 0x05 Protocol error 0x06 ASCII error 0x07 Receiver buffer error 0x08 Receiver time-out 0x11 Undefined task code 0x12 Selection error 0x14 Address error 0x15 Wrong number of steps 0x16 Wrong IO code 0x17 IO number error 0x18 Data write error 0x1A Memory error 0x20 Monitor in progress (warning) 0x31 ROM memory 0x33 Read occupation in write 0x34 Write occupation in read 0x35 Debug mode 0x36 Max. read occupation 0x37 Not occupied 0x38 Occupation error 0x3A RAM memory error 0x3B CPU in RUN 0x3C Operation error 0x3E Combined error 0x50 PLC busy 0x80 Network error 0xD0 Communication port closed 0xD1 Communication queue full 0xD2 Transmission time-out 0xD3 Shutdown in progress 0xDF Application shutdown 0xE1 ActServ parity error 0xE2 ActServ checksum error 0xE3 ActServ framing error 0xE4 ActServ overrun error 0xE7 ActServ receive buffer overflow 0xE8 ActServ time-out 0xE9 Break received 0xEA Transmit buffer full 0xFF Operation canceled

Page 29: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 29 of 30

5 Appendix B – TaskCode´s to be used in ActServ In Hitachi HI-protocol is every digit transmitted as a one byte ASCII character.

5.1 Monitor Specified I/O or memory

This task reads data of consecutive number of points (words) starting with the specified address.

The message to the PLC contains:

1. TaskCode, 40 or A0 2. I/O code (memory name) 3. I/O number (start position in the

memory) 4. Number of points (1 to 240) or number of words ( 1 to 120).

Note. Excel is limited to transmit only 255 characters.

The response message from the PLC contains:

1. Normal end response (00) 2. TaskCoe, 40. 3. Monitor data

5.2 Set/Reset Specific I/O

This task writes a consecutive number of words (bytes)

Format of Request message to the PLC:

1. TaskCode 42 o A2 2. I/O code (memory name) 3. I/O number (start position in

the memory) 4. Number of points to write 5. Data to be forcibly output to the memory (2-byte ASCII code)

Format of response message from the PLC contains:: 1. Normal end response (00) 2. TaskCode, 42.

CodeNo.of

point40 From

address

24000 Monitor data

3I/OCode42 From

address DataNo.

4200

Page 30: Manual Version 2 - esco-da.be Hitachi/Software/ActCom/Manuals/ActWin...ActWin Communications is a group of utility programs for communication with Hitachi PLC ... PLC types, please

ActWin Communication Page 30 of 30

5.3 I/O Codes and I/O Numbers All I/O numbers should be specified in hexadecimal.

I/O, Memory I/O Code

(in Hex) I/O Number

WX 08 U S m, r St S m WY 09 U S m, r St S m WR 0A 0 - 3FF (C3FF), F000 - F1FF WL 0B 0 - 3FF, 1000 - 13FF WM 0C 0 - 3FF

U - Unit number 0 to F S - Slot number 0 to F m - Word number in module 0 to F r - Master remote station number 1 to 8 St - Slave remote station number 0 to F