25
Driver

Indusoft_Modbus.pdf

Embed Size (px)

Citation preview

Page 1: Indusoft_Modbus.pdf

Driver

Page 2: Indusoft_Modbus.pdf

Contents

Page 2

Contents

MODBU DRIVER....................................................................................................... 3Driver specifications.......................................................................................................................................................................4Configuring the device's communication settings.........................................................................................................................6Adding a communication driver to your project............................................................................................................................7Configuring the driver's communication settings.......................................................................................................................... 8

Serial encapsulation for a modem connection.................................................................................................................... 10Serial encapsulation for a TCP/IP or UDP/IP connection................................................................................................... 11

About driver worksheets..............................................................................................................................................................13Adding and configuring a Standard Driver Sheet................................................................................................................13Configuring the Main Driver Sheet...................................................................................................................................... 18

Checking the Driver Runtime task.............................................................................................................................................. 21Troubleshooting............................................................................................................................................................................22Revision history........................................................................................................................................................................... 24

Page 3: Indusoft_Modbus.pdf

MODBU Driver

Page 3

MODBU DriverMODBU Driver for Serial Communication with Devices Using the Modbus Protocol (version 10.4, last revised16 Sep 2010).

The MODBU driver enables communication between the Studio system and remote devices using the Modbusprotocol, according to the specifications discussed in this document.

This document assumes that you have read the "Development Environment" section in the main Studiodocumentation.

This document also assumes that you are familiar with the Microsoft Windows XP/Vista/7 environment.If you are not familiar with Windows, then we suggest using the Help and Support feature (available from theWindows Start menu) as you work through this document.

Page 4: Indusoft_Modbus.pdf

MODBU Driver

Page 4

Driver specificationsThis section identifies all of the software and hardware components required to implement communicationbetween the MODBU driver in Studio and remote devices using the Modbus protocol.

Driver filesThe MODBU driver package comprises the following files, which are automatically installed in the Drv folderof the Studio application directory:

• MODBU.DLL: Compiled driver.

• MODBU.INI: Internal driver file. You must not modify this file.

• MODBU.MSG: Internal driver file defining error messages for the possible error codes. (These error codes aredescribed in detail in the Troubleshooting section.) You must not modify this file.

• MODBU.PDF: This document, which provides complete information about using the driver.

Note: You must use a compatible PDF reader to view the MODBU.PDF file. You can install AcrobatReader from the Studio installation CD, or you can download it from Adobe's website.

You can use the MODBU driver on the following operating systems:

• Windows XP/Vista/7

• Windows Server 2003/2008

• Windows Embedded Compact 5.x/6.x

Device specificationsTo establish communication, your target device must meet the following specifications:

• Manufacturer: Any device using the Modbus protocol for serial communication

• Compatible Equipment: Any device that is compatible with the Modbus protocol

• Programmer Software: It depends on the device

The MODBU driver supports the following device registers:

Supported registers

Register Type Length Write Read Bit Integer Float DWord BCD BCD DW String

0x (Coil Status) 1 Bit + + + - - - - - -

1x (Input Status) 1 Bit - + + - - - - - -

3x (Input Register) 1 Word - + + + + + + + -

4x (Holding Register) 1 Word + + + + + + + + +

Network specificationsTo establish communication, your device network must meet the following specifications:

• Device Communication Port: Modbus Serial Port

• Physical Protocol: RS232/RS845

• Logic Protocol: Modbus

• Device Runtime Software: None

• Specific PC Board: None

• Cable Wiring Scheme: It depends on the device

Page 5: Indusoft_Modbus.pdf

MODBU Driver

Page 5

Conformance testingThe following hardware/software was used for conformance testing:

• Driver Version: 10.4

• Studio Version: 6.1+SP6

• Operating System (development): Windows XP

• Operating System (target): Windows XP, Windows Embedded Compact 6.0

• Equipment: Automation Direct DL05

• Communication Settings:

• Modbus Port: 1

• Baud Rate: 9600

• Protocol: RTU

• Data Bits: 8

• Stop Bits: 1

• Parity: Odd

• COM Port: COM1

• Cable: Use specifications described in the "Network Specifications" section above.

Page 6: Indusoft_Modbus.pdf

MODBU Driver

Page 6

Configuring the device's communication settingsThis section explains how to configure the communication settings for the remote device.

Because there are several brands of equipment that use the Modbus protocol, it is impossible to define astandard device configuration. Therefore, we suggest using the following default configuration:

• Protocol: RTU

• Baud Rate: 9600

• Data Bits: 8

• Stop Bits: 1

• Parity: None

Page 7: Indusoft_Modbus.pdf

MODBU Driver

Page 7

Adding a communication driver to your projectThis section explains how to add a communication driver to your project.

1. On the Insert tab of the ribbon, in the Communication group, click Add/Remove Driver.The Communication Drivers dialog is displayed.

Communication Drivers dialog2. In the Available drivers list, click the communication driver that you want to add.

3. Click Select.The driver is added to the Selected drivers list.

4. Click OK.The Communication Drivers dialog is closed and the selected driver is inserted in the Drivers folder in theProject Explorer.

Page 8: Indusoft_Modbus.pdf

MODBU Driver

Page 8

Configuring the driver's communication settingsThis section explains how to configure the communication settings for the driver.

You must add the communication driver to your project before you can configure its settings. For moreinformation, see Adding a communication driver to your project on page 7.

The general procedure for configuring a driver's communication settings is the same for all drivers. However,the specific settings are different for each driver, depending on the options and protocols used by the targetdevice.

To configure the communication settings:

1. In the Comm tab of the Project Explorer, expand the Drivers folder.The folder contains the drivers that are currently enabled. If you do not see the driver that you want toconfigure, then you need to add it.

2. Right-click the driver that you want to configure, and then click Settings on the shortcut menu.The Communication Settings dialog is displayed.

Communication Settings: MODBU dialog3. From the Serial Encapsulation list, select the type of encapsulation that should be used, and then configure

the port/connection settings as needed.Encapsulation allows raw serial communication to be sent over other types of network connections.

Option Description

None Serial communication is not encapsulated;standard serial port settings are used. Configurethe settings to match the target device.

Modem Encapsulate to send over a dial-up modemconnection. For more information, see Serialencapsulation for a modem connection on page10.

TCP/IP or UDP/IP Encapsulate to send over a TCP/IP or UDP/IPEthernet connection. For more information, seeSerial encapsulation for a TCP/IP or UDP/IPconnection on page 11.

Note: Most of the serial communication drivers should work with every serial encapsulationmode. However, most of the drivers were developed before the serial encapsulation feature wasadded to the software, so they may not have been thoroughly tested. If you have problems withserial encapsulation on a specific driver, please contact Technical Support.

4. Configure the remaining, driver-specific settings as needed.

Page 9: Indusoft_Modbus.pdf

MODBU Driver

Page 9

Driver-specific settings for MODBU

Setting Default Value Possible Values Description

Unsigned (legacy)

Signed (legacy)

Do not use these options. They areincluded only to maintain compatibility witholder versions.

Unsigned Do not allow negative values:

• Integer: 0 to 65535

• DWord: 0 to 4294967295

Signed/Unsigned Unsigned

Signed Allow negative values:

• Integer: -32768 to 32767

• DWord: -2147483648 to2147483647

This setting only works withthe 3X, 4X, DW, DWS, DW3,DW3S, and ID register types.

ASCII Each 8-bit Word is sent as two 4-bit ASCII characters, allowing for a timeinterval between characters without causing errors.

Protocol (ASCII or RTU) RTU

RTU Each 8-bit Word is sent as two 4-bit hexadecimals, allowing for greaterdensity and faster throughput. In most cases, we recommend using thisprotocol.

No Swap or Swap This setting enables or disables the Swap Word order in the Read and Writecommands. Note that it only works with the FP, FPS, FP3, FP3S, DW, DWS,DW3, and DW3S register types.

Swap - Write Type No Swap / WriteItem

Write Item or WriteGroup

This setting chooses the function 0x06 (Preset Single Register) or 0x10(Preset Multiple Registers) to write:

• Write Item:

• Write on tag change (Standard Driver Sheet) and Write (MainDriver Sheet) use the Modbus function 0x06.

• Write Trigger (Standard Driver Sheet) uses the Modbus function0x10.

• Write Group: Any writing in the driver uses the Modbus function 0x10.

For more information about the functions, please consult the Modbus protocoldocumentation.

0 to 512 The nominal size (in Words) of each block of data to be transmitted, asdetermined by the processing capacity of the device. A configured BlockSize of 1 will send one item.

ERO-xxx Address used to set equipment to Local or Remote. (Used for EROequipment only.)

Block Size / (ERO-xxx):MaxGap

64

0 to 512(Max Gap)

This setting is used with Main Driver Sheet and configures the gap sizebetween two addresses that could belong to the same group or blockaccording to the Block Size but, if there are no other I/O addresses betweenthem and their addresses difference is bigger than the gap, then they will endup in separated virtual read groups. This setting can never be higher than theBlock Size.

5. Click OK.The settings are saved and the Communication Settings dialog is closed.

Page 10: Indusoft_Modbus.pdf

MODBU Driver

Page 10

Serial encapsulation for a modem connection

Most of the serial drivers allow the use of modem connections. The modem connection has been designed toenable communications with remote serial devices connected through a phone line. The following diagramprovides one example of applying this solution:

Modem connection

You can enable the modem connection by following the steps below:

1. Right-click on the driver's folder, and then choose Settings from the shortcut menu.

This will give you access to the communication parameters.

2. In the Serial Encapsulation menu, select Modem:

Caution: The Modem option is not supported for Pocket PC v3.00 or older.

The following fields are available:

• Name drop-down list: Select the modem that the driver will use to establish the connection. If you do notknow the modem name, use the Auto Detect option. The Auto Detect 1 will use the first modem available, AutoDetect 2 will use the second, Auto Detect 3 will use the third, and Auto Detect 4 will use the fourth.

• Phone field: Enter a phone number that the driver will use to connect to the remote device. This fieldaccepts tags between curly brackets.

• Settings button: Click on this button to configure the modem settings. The window that displays when youclick on this button depends on the operating system that you are using and on the modem type.

Caution: The settings configured by clicking on this button are not saved with your project. Theinformation is saved on the operating system registry, and they are valid only in the computerthat you are interacting with. If you install your project on another computer, you will have toreconfigure these settings.

Page 11: Indusoft_Modbus.pdf

MODBU Driver

Page 11

• Connection button: Click to open the Connection Control window. The default connection settings shouldsuffice for most of the projects. However, you can take full control over the connection, and also enableincoming calls, by clicking on this button.

Connection Control dialog

• Dial out trigger field: When the value of the tag configured in this field changes, the driver will try toconnect to the remote device. If the connection has already been established, the command is ignored.You do not have to use this field if you are using Auto Connect.

• Hang up trigger field: When the value of the tag configured in this field changes, the driver will disconnectfrom the remote device. If the device is disconnected the command is ignored. You do not have to usethis field if you are using Disconnect call if idle for more than.

• Auto Connect field: When this option is enabled, the driver will try to connect to the remote device beforesending any information. If the connection fails, the next attempt will be made after the Retry Intervalhas expired.

• Disconnect call if idle for more than field: When this option is checked, the driver will automatically disconnectfrom the remote device if no communication is performed after the time you specified.

• Enable incoming calls field: Check this option if you want to enable the driver to receive calls from theremote device. You can use the Hang up trigger to drop the call once it has been established. Noticethat one driver can use both incoming calls and outgoing calls.

• Status area

• Code field: Enter with a tag that will receive one of the following codes when the driver is running:

• 0 = Disconnected

• 1 = Connected

• 2 = Dialing

• 3 = Dropping

• 4 = Closing Line

• Description field: Enter with a tag that will receive a complete description of the current status. Thedescription is associated with the Code field; however, it brings some additional information about thecurrent status.

Serial encapsulation for a TCP/IP or UDP/IP connection

Most of the serial drivers allow the use of TCP/IP or UDP/IP encapsulation. The encapsulation mode hasbeen designed to provide communication with serial devices connected to terminal servers on your ethernetor wireless networks. A terminal server can be seen as a virtual serial port. It converts TCP/IP or UDP/IPmessages on your Ethernet or Wireless network to serial data. Once the message has been converted to a

Page 12: Indusoft_Modbus.pdf

MODBU Driver

Page 12

serial form, you can connect standard devices that support serial communications to the terminal server. Thefollowing diagram provides one example of applying this solution:

Serial encapsulation over a TCP/IP or UDP/IP link

You can enable the encapsulation by following the steps below:

1. Right-click on the driver's folder, and then choose Settings from the shortcut menu.

This will give you access to the communication parameters.

2. In the Serial Encapsulation field, select TCP/IP or UDP/IP:

The following fields are available:

• IP Address field: Specify the IP Address for the Terminal Server. This field accepts tags in curly brackets.

• Port Number field: Enter the TCP/IP or UDP/IP port number.

• Status Tag field: This field is available only when using TCP/IP. The tag on this field receives the value 1when the TCP/IP connection is established; otherwise, it receives 0.

• Server Mode field: The TCP/IP encapsulation allows the Server Mode, making the remote client responsiblefor establishing the connection to enable the communication.

Page 13: Indusoft_Modbus.pdf

MODBU Driver

Page 13

About driver worksheetsLike the other parts of your project, communication with remote devices is controlled by worksheets. Thissection explains how to add worksheets to your project and then configure them to associate project tags withdevice registers.

Each selected driver includes a Main Driver Sheet (MDS) and one or more Standard Driver Sheets (SDS).The Main Driver Sheet is used to define tag/register associations and driver parameters that are in effect atall times, regardless of project behavior. In contrast, Standard Driver Sheets can be inserted to define tag/register associations that are triggered by specific project behaviors.

The configuration of these worksheets is described in detail in the "Communication" chapter of the TechnicalReference Manual, and the same general procedures are used for all drivers. Please review those proceduresbefore continuing.

For the purposes of this document, only MODBU driver-specific parameters and procedures are discussedhere.

Adding and configuring a Standard Driver SheetBy default, a communication driver does not include any Standard Driver Sheets. This section explains how toadd a Standard Driver Sheet to your project and then configure it.

The MODBU driver must be added to the project before you can configure any of its worksheets. For moreinformation, see Adding a communication driver to your project on page 7.

Standard Driver Sheets can be inserted to define additional tag/register associations that are triggered byspecific project behaviors.

Note: Most of the settings on this worksheet are standard for all drivers; for more information aboutconfiguring these settings, see the “Communication” chapter of the Technical Reference Manual. TheStation and I/O Address fields, however, use syntax that is specific to the MODBU driver.

1. Do one of the following.

• On the Insert tab of the ribbon, in the Communication group, click Driver Sheet and then select MODBU fromthe list.

• In the Comm tab of the Project Explorer, right-click the MODBU folder and click Insert on the shortcutmenu.

Page 14: Indusoft_Modbus.pdf

MODBU Driver

Page 14

A new MODBU driver worksheet is inserted into the MODBU folder, and then it is automatically opened forconfiguring.

Standard Driver Sheet

Note: Worksheets are numbered in order of creation, so the first worksheet is MODBU001.drv.

2. Configure the Station and Header fields as described below.Station

Specify the ID number (or node) of the target Modbus device, using the following syntax:

<ID_number>

…where <ID_number> is a value between 0 and 247.

Examples:

57

You can also specify an indirect tag (e.g. {MyStation}), but the tag that is referenced mustfollow the same syntax and contain a valid value.

Note: You cannot leave the Station field blank.

HeaderSpecify the address of the first register of a block of registers on the target device. The addressesdeclared in the body of the worksheet are simply offsets of this Header address. When Readand Write actions are executed for the entire worksheet (using Read Trigger and Write Trigger,respectively), it scans the entire block of registers from the first address to the last.

The Header field uses the following syntax:

<Type>:<AddressBase>

Where:<Type>Register type. Valid values are:

• 0X

Page 15: Indusoft_Modbus.pdf

MODBU Driver

Page 15

• 1X

• STA

• 3X

• 4X

• FP

• FP3

• FP3S

• DW

• FPS

• DWS

• DW3

• DW3S

• BCD

• BCD3

• BCDDW

• BCDDWS

• BCDDW3

• BCDDW3S

• ID

• ST

• STS

<AddressBase>The address of the first register in the block of registers that will be scanned by this worksheet.

After you edit the Header field, the development application checks the syntax to determine if it isvalid. If the syntax is invalid, then the development application automatically inserts a defaultvalue of 0X:0.

You can also specify an indirect tag (e.g. {MyHeader}), but the tag that is referenced must followthe same syntax and contain a valid value.

The following table lists all of the register types and address ranges that are valid for the Headerfield:

Valid addresses for Header field

Register Type SampleHeader

Valid Range of InitialAddresses

Comments

0X 0X:0 Varies according to equipment Coil status: Reads and writes events using Modbus instructions 01,05, and 15.

1X 1X:0 Varies according to equipment Input status: Reads events using Modbus instruction 02.

STA STA:0 Varies according to equipment Exception Status: Reads events using Modbus instruction 07.

3X 3X:0 Varies according to equipment Input register: Reads events using Modbus instruction 04.

4X 4X:0 Varies according to equipment Holding register: Reads and writes events using Modbus instructions03, 06 and 16.

FP FP:0 Varies according to equipment Floating-point value (Holding Register): Reads and writes floating-point values using two consecutive Holding Registers.

Page 16: Indusoft_Modbus.pdf

MODBU Driver

Page 16

Register Type SampleHeader

Valid Range of InitialAddresses

Comments

FPS FPS:0 Varies according to equipment Floating-point value (Holding Register): Reads and writes floating-point values using two consecutive Holding Registers with ByteSwap.

FP3 FP3:0 Varies according to equipment Floating-point value (Input Register): Reads floating-point valuesusing two consecutive Input Registers.

FP3S FP3S:0 Varies according to equipment Floating-point value (Input Register): Reads floating-point valuesusing two consecutive Input Registers with Byte Swap.

DW DW:0 Varies according to equipment Dword value (Holding Register): Reads and writes Dword valuesusing two consecutive Holding Registers.

DWS DWS:0 Varies according to equipment Dword value (Holding Register): Reads and writes Dword valuesusing two consecutive Holding Registers with Byte Swap.

DW3 DW3:0 Varies according to equipment Dword value (Input Register): Reads Dword values using twoconsecutive Input Registers.

DW3S DW3S:0 Varies according to equipment Dword value (Input Register): Reads Dword values using twoconsecutive Input Registers with Byte Swap.

BCD3 BCD3:0 Varies according to equipment BCD value (Input Register): Reads events using Modbus instruction04.

BCD BCD:0 Varies according to equipment BCD value (Holding Register): Reads and writes events usingModbus instructions 03, 06 and 16.

BCDDW BCDDW:0 Varies according to equipment BCD 32-bit integer value (Holding Register): Reads and writes 32-bitinteger values using two consecutive Holding Registers.

BCDDWS BCDDWS:0 Varies according to equipment BCD 32-bit integer value (Holding Register): Reads and writes 32-bit integer values using two consecutive Holding Registers with ByteSwap.

BCDDW3 BCDDW3:0 Varies according to equipment BCD 32-bit integer value (Input Register): Reads 32-bit integer valuesusing two consecutive Input Registers.

BCDDW3S BCDDW3S:0 Varies according to equipment BCD 32-bit integer value (Input Register): Reads 32-bit integer valuesusing two consecutive Input Registers with Byte Swap.

ID ID:0 Varies according to equipment Report Slave ID using Modbus instruction 17.

ST ST:0 Varies according to equipment String value (Holding Register): Reads and writes String values usingconsecutive Holding Registers.

STS STS:0 Varies according to equipment String value (Holding Register): Reads and writes String values usingconsecutive Holding Registers with Byte Swap.

3. For each tag/register association that you want to create, insert a row in the worksheet body and thenconfigure the row's fields as described below.Tag Name

Type the name of the project tag.Address

Specify the address of the associated device register.

For all register types other than ST/STS (String), use the following syntax:{ | { S | U } }AddressOffset{ | .Bit }

For ST/STS (String) register types only, use the following syntax:AddressOffset:Length

Where:Signed/UnsignedOptional parameter used for integer values only. Valid values are S (Signed) and U (Unsigned).If you do not specify this parameter, then the project uses the default from the driver'scommunication settings.AddressOffset

Page 17: Indusoft_Modbus.pdf

MODBU Driver

Page 17

Parameter that is added to the AddressReference parameter of the Header, to compose thespecific address of the register in the block. The sum of the two parameters cannot equal zero(0); Modbus operands must start in an address that is greater than zero.BitUse this optional parameter only for 3X (Input Register) and 4X (Holding Register) types, toindicate which bit on the register will be read from and/or written to.LengthLength of the string (in bytes) to be read or written.

You can also specify an indirect tag (e.g. {MyAddress}), but the tag that is referenced mustfollow the same syntax and contain a valid value.

Note:

• The floating-point value is stored in two consecutive Holding Registers, wherethe address value corresponds to the first Holding Register position. You mustensure that you do not configure a non-existent address, or a conflict willoccur.

• The floating-point values are 4 bytes using 6 significant digits.

• You must not configure a range of addresses greater than the maximum blocksize (data buffer length) supported by the target device. The default block sizeis 64 bytes, but this can be changed in the driver's communication settings.

• For DWord registers (DW, DWS, DW3 and DW3S) using the unsigned option inthe Address field, the associated project tag must be Real type.

Note: Each Standard Driver Sheet can have up to 4096 rows. However, the Read Trigger, EnableRead When Idle, and Write Trigger commands attempt to communicate the entire block of addressesthat is configured in the sheet, so if the block of addresses is larger than the maximum blocksize that is supported by the driver protocol, then you will receive a communication error (e.g.,"invalid block size") during run time. Therefore, the maximum block size imposes a practical limiton the number of rows in the sheet.

For examples of how device registers are specified using Header and Address, see the following table.

Examples of Header and Address fields in Standard Driver Sheet

Device Register Header Address

00001 0X:1 0

00010 0X:0 10

01020 0X:1000 20

10001 1X:1 0

10010 1X:0 10

11020 1X:1000 20

30001 3X:1 0

30010 3X:0 10

31020 3X:1000 20

30000 and 30001 FP3:0 0

31001 and 31000 FP3S:0 1000

40001 4X:1 0

40010 4X:0 10

41020 4X:1000 20

Page 18: Indusoft_Modbus.pdf

MODBU Driver

Page 18

Device Register Header Address

40010 (bit 0) 4X:0 10.0

41010 (bit 7) 4X:1000 10.7

40001 and 40002 FP:1 0

40013 and 40014 FP:0 13

41021 and 41022 FP:1000 21

40001 and 40002 DW:1 0

40013 and 40014 DW:0 13

For more information about the device registers and addressing, please consult the manufacturer'sdocumentation.

4. Save and close the worksheet.

Configuring the Main Driver SheetWhen you add the MODBU driver to your project, the Main Driver Sheet is automatically included in theMODBU folder in the Project Explorer. This section describes how to configure the worksheet.

The MODBU driver must be added to the project before you can configure any of its worksheets. For moreinformation, see Adding a communication driver to your project on page 7.

The Main Driver Sheet is used to define tag/register associations and driver parameters that are in effect at alltimes, regardless of project behavior. The worksheet is continuously processed during project runtime.

Note: Most of the settings on this worksheet are standard for all drivers; for more information aboutconfiguring these settings, see the “Communication” chapter of the Technical Reference Manual. TheStation and I/O Address fields, however, use syntax that is specific to the MODBU driver.

1. Do one of the following.

• On the Insert tab of the ribbon, in the Communication group, click Main Driver Sheet and then select MODBUfrom the list.

• In the Comm tab of the Project Explorer, expand the MODBU folder and then double-click MAIN DRIVERSHEET.

The Main Driver Sheet is displayed.

Main Driver Sheet2. For each tag/register association that you want to create, insert a row in the worksheet body and then

configure the row's fields as described below.

Page 19: Indusoft_Modbus.pdf

MODBU Driver

Page 19

Tag NameType the name of the project tag.

StationSpecify the ID number (or node) of the target Modbus device, using the following syntax:ID_number…where ID_number is a value between 0 and 247.

Examples:

57

You can also specify an indirect tag (e.g. {MyStation}), but the tag that is referenced mustfollow the same syntax and contain a valid value.

Note: You cannot leave the Station field blank.

I/O AddressSpecify the address of the associated device register.

For all register types other than ST/STS (String), use the following syntax:Type:{ | { S | U } }Address{ | .Bit }

For ST/STS (String) register types only, use the following syntax:{ ST | STS }:Address:Length

Where:TypeRegister type. Valid values are:

• 0X

• 1X

• STA

• 3X

• 4X

• FP

• FP3

• FP3S

• DW

• FPS

• DWS

• DW3

• DW3S

• BCD

• BCD3

• BCDDW

• BCDDWS

• BCDDW3

• BCDDW3S

• ID

• ST

Page 20: Indusoft_Modbus.pdf

MODBU Driver

Page 20

• STS

Signed/UnsignedOptional parameter used for integer values only. Valid values are S (Signed) and U (Unsigned).If you do not specify this parameter, then the project uses the default from the driver'scommunication settings.AddressAddress of the device register.BitUse this optional parameter only for 3X (Input Register) and 4X (Holding Register) types, toindicate which bit on the register will be read from and/or written to.LengthLength of the string (in bytes) to be read or written.

Examples:

4X:20

4X:S15

4X:10.7

ST:10:5

You can also specify an indirect tag (e.g. {MyAddress}), but the tag that is referenced mustfollow the same syntax and contain a valid value.

Note:

• For DWord registers (DW, DWS, DW3 and DW3S) using the unsigned option inthe I/O Address field, the associated project tag must be Real type.

• The floating-point values are 4 bytes using 6 significant digits.

Note: The Main Driver Sheet can have up to 32767 rows. If you need to configure more than32767 communication addresses, then either configure additional Standard Driver Sheets orcreate additional instances of the driver.

3. Save and close the worksheet.

Page 21: Indusoft_Modbus.pdf

MODBU Driver

Page 21

Checking the Driver Runtime taskThis section describes how to check the status of the Driver Runtime task in the list of execution tasks.

The Driver Runtime task handles communication with remote devices and the processing of the driverworksheets. By default, the task is configured to start up automatically when the project is run, but you cancheck it for yourself.

1. On the Home tab of the ribbon, in either the Local Management or the Remote Management group (depending onwhere you project server will be running), click Tasks.The Project Status dialog is displayed.

Project Status dialog2. Verify that the Driver Runtime task is set to Automatic.

• If the setting is correct, then proceed to the next step.

• If the Driver Runtime task is set to Manual, select the task and then click Startup to change the task toAutomatic.

3. Click OK to close the Project Status dialog.

Page 22: Indusoft_Modbus.pdf

MODBU Driver

Page 22

TroubleshootingThis section lists the most common errors for this driver, their probable causes, and basic procedures toresolve them.

Checking status codesIf the MODBU driver fails to communicate with the target device, then the database tag(s) that you configuredfor the Read Status and Write Status fields of the driver sheets will receive a status code. Use this status code andthe following tables to identify what kind of failure occurred and how it might be resolved.

Status codes for MODBU driver

Status Code Description Possible Causes Procedure To Solve

0 OK Communication without problems None required

2 Illegal data value Tried to read an address that is not present inthe PLC, such as 49999

Specify a valid address.

3 Invalid data values Specified address does not exist on the deviceso protocol received invalid data

Verify that specified address exists on the device.

4 Equipment failed Equipment failed or out of order Check equipment state.

5 Ack The PLC may be busy and sent this Ack toacknowledge that it received the message butis unable to respond at the time

Wait until the PLC is available again and restart communicatingwith it

6 Equipment in use Command invalid when equipment is in use Studio commands cannot generate this error.

7 Negative Ack Ack action error during communication Check device and Studio Communication Parameters.

8 Memory parity error Invalid Communication Parameter Check driver Communication Parameters.

10 Invalid Header field Specified invalid tag value in Header field Specify a valid Header tag value.

11 Invalid Address field Specified invalid address Specify a valid address.

12 Invalid block size Offset greater than maximum allowed Specify a valid offset or create a new worksheet. Typically,maximum offset is 64.

13 Invalid CRC Invalid CRC in response message • Check the cable wiring.

• Check the station number.

• Check the RTS/CTS configuration.

18 Invalid BCD value Tried reading an invalid BCD value Verify that PLC value is valid.

19 Invalid BCD value Tried writing a negative BCD value Only positive BCD values are valid.

100 Illegal operation Tried to write to read-only addresses (1x and3x)

Writing operations are possible only in Coil Status and HoldingRegisters areas.

-15 Timeout start message

-17 Timeout between Rxcharacters

• Disconnected cables

• PLC is turned off, in stop mode, or inerror mode

• Wrong station number

• Wrong parity

• Wrong RTS/CTS configuration

• Check cable wiring.

• Check the PLC mode — it must be RUN.

• Check the station number.

• Check the RTS/CTS configuration.

• Check the maximum registers configuration.

Common status codes

Status Code Description Possible Causes Procedure To Solve

0 OK Communicating without error. None required.

Page 23: Indusoft_Modbus.pdf

MODBU Driver

Page 23

Status Code Description Possible Causes Procedure To Solve

-15 Timeout waiting for messageto start

• Disconnected cables.

• PLC is turned off, in stop mode, or inerror mode.

• Wrong station number.

• Wrong parity (for serial communication).

• Wrong RTS/CTS configuration (for serialcommunication).

• Check cable wiring.

• Check the PLC mode — it must be RUN.

• Check the station number.

• Increase the timeout in the driver's advanced settings.

• Check the RTS/CTS configuration (for serialcommunication).

Monitoring device communicationsYou can monitor communication status by establishing an event log in Studio's Output window (LogWinmodule). To establish a log for Field Read Commands, Field Write Commands and Serial Communication,right-click in the Output window and select the desired options from the pop-up menu.

You can also use the LogWin module to establish an event log on a remote unit that runs WindowsEmbedded. The log is saved on the unit in the celog.txt file, which can be downloaded later.

If you are unable to establish communication between Studio and the target device, then try instead toestablish communication using the device's own programming software. Quite often, communication isinterrupted by a hardware or cable problem or by a device configuration error. If you can successfullycommunicate using the programming software, then recheck the driver's communication settings in Studio.

Contacting Technical SupportIf you must contact Technical Support, please have the following information ready:

• Operating System and Project Information: To find this information, click Support in the Help tab of theribbon.

• Driver Version and Communication Log: Displays in the Output window (LogWin module) when thedriver is enabled and the project is running is running.

• Device Model and Boards: Consult the hardware manufacturer's documentation for this information.

Page 24: Indusoft_Modbus.pdf

MODBU Driver

Page 24

Revision historyThis section provides a log of all changes made to the driver.

Revision history

DriverVersion

Revision Date Description of Changes Author

2.02 30 Jul 1999 • First driver version

• Driver available for Windows CE

Roberto V. Junior

2.03 13 Dec 1999 Added Read and Write of Floating-point operand Roberto V. Junior

2.04 05 Jun 2000 Added CRC verification of device response Roberto V. Junior

2.05 30 Oct 2000 Added MAIN DRIVER SHEET feature Lourenço Teodoro

2.06 14 Nov 2001 • Added FPS, FP3, and FP3S data type

• Changed Ero functionality

Lourenço Teodoro

2.07 21 Feb 2002 • Added bit read/write to 4x and 3x data type

• Fixed bug that caused 100% CPU usage when a message waswaiting in a timeout situation

• Added a warning message in the LogWin when theAddressReference in Header field plus the lowest AddressOffset inAddress column is equal to zero

Roberto V. Junior

2.08 22 Aug 2003 Added DW data type Eric Vigiani

2.09 11 Dec 2003 • Implemented Signed/Unsigned option by address

• Added DW3 data type

Eric Vigiani

2.10 25 May 2004 Implemented writing group commands when writing FP values Eric Vigiani

2.11 14 Jun 2004 • Added DWS and DW3S data types

• Implemented SwapWord for FP, FPS, FP3, FP3S, DW, DWS, DW3and DW3S

• Changed FP, FPS, FP3, FP3S, DW, DWS, DW3 and DW3S withand without SwapWord to conformance to standards (FPS, FP3S,DWS and DW3S are data types with Byte Swap)

Fábio H.Y. Komura

2.12 03 Sep 2004 Added BCD, BCD3, BCDDW, BCDDWS, BCDDW3 and BCDDW3S datatype.

Fábio H.Y. Komura

2.13 24 Sep 2004 Fixed problem with Parser Address Fábio H.Y. Komura

2.14 19 Jan 2005 Insert String type Leandro Coeli

2.15 19 Feb 2005 Implemented LRC to ASCII communication Leandro Coeli

2.16 26 Apr 2005 Implemented configurable Block Size Leandro Coeli

2.18 12 Jun 2006 • Implemented to check the Station into the Rx messages

• Implemented the Unsigned in all header

• Implemented Block size 1 using MDS

Graziane C. Forti

2.19 31 Aug 2006 Fixed problem with the ST header Eric Vigiani

2.20 28 Nov 2006 • Implemented STS Header

• Fixed problem BCDDW, BCDDWS, BCDDW3, BCDW3S and STusing Block Size=1

Graziane C. Forti

Page 25: Indusoft_Modbus.pdf

MODBU Driver

Page 25

DriverVersion

Revision Date Description of Changes Author

• Fixed problem S/U address configuration (types that this operationis not allowed)

• Implemented Block size 1 using MDS

• Fixed problem ST/STS using write trigger (SDS)

• Fixed problem to calculate LRC - ASCII protocol

• Changed Maximum Range (exception problem)

• Fixed the String writing

2.21 19 Jan 2007 Implemented Unsigned/Signed to work like version 2.16 as well, usingComboBox

Graziane C. Forti

2.22 21 Feb 2008 Removed the error Invalid Word Swap for ST and STS header. Eric Vigiani

10.1 07 Jan 2009 Updated driver version, no changes in the functionality Marcelo Carvalho

10.3 01 Jul 2009 • Modified driver to properly handle error codes sent by the PLC

• Modified driver to support communication with multiple Stationswhen using Serial Encapsulation over TCP/IP or UDP/IP

Fellipe Peternella

10.4 16 Sep 2010 Improved driver reliability André Körbes