Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Contents
Contents
MODBU DRIVER....................................................................................................... 3
Driver specifications.......................................................................................................................................................................4
Configuring the device's communication settings......................................................................................................................... 6
Adding a communication driver to your project............................................................................................................................ 7
Configuring the driver's communication settings.......................................................................................................................... 8
Serial encapsulation for a modem connection.................................................................................................................... 10
Serial encapsulation for a TCP/IP or UDP/IP connection................................................................................................... 11
About driver worksheets..............................................................................................................................................................13
Adding and configuring a Standard Driver Sheet................................................................................................................13
Configuring the Main Driver Sheet...................................................................................................................................... 18
Checking the Driver Runtime task.............................................................................................................................................. 21
Troubleshooting............................................................................................................................................................................22
Revision history........................................................................................................................................................................... 24
Page 2
MODBU Driver
MODBU Driver
MODBU Driver for Serial Communication with Devices Using the Modbus Protocol (version 10.4, last revised
16 Sep 2010).
The MODBU driver enables communication between the Studio system and remote devices using the Modbus
protocol, according to the specifications discussed in this document.
This document assumes that you have read the "Development Environment" section in the main Studio
documentation.
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 the
Windows Start menu) as you work through this document.
Page 3
MODBU Driver
Driver specifications
This section identifies all of the software and hardware components required to implement communication
between the MODBU driver in Studio and remote devices using the Modbus protocol.
Driver files
The MODBU driver package comprises the following files, which are automatically installed in the Drv folder
of the Studio application directory:
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 are
described 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 Acrobat
Reader 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
Device specifications
To 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
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 specifications
To establish communication, your device network must meet the following specifications:
Page 4
MODBU Driver
Conformance testing
The following hardware/software was used for conformance testing:
Communication Settings:
Modbus Port: 1
Protocol: RTU
Data Bits: 8
Stop Bits: 1
Parity: Odd
Page 5
MODBU Driver
Page 6
Protocol: RTU
Data Bits: 8
Stop Bits: 1
Parity: None
MODBU Driver
Page 7
MODBU Driver
Description
None
Modem
TCP/IP or UDP/IP
Note: Most of the serial communication drivers should work with every serial encapsulation
mode. However, most of the drivers were developed before the serial encapsulation feature was
added to the software, so they may not have been thoroughly tested. If you have problems with
serial encapsulation on a specific driver, please contact Technical Support.
4. Configure the remaining, driver-specific settings as needed.
Page 8
MODBU Driver
Default Value
Possible Values
Description
Signed/Unsigned
Unsigned
Unsigned (legacy)
Signed (legacy)
Unsigned
Signed
RTU
No Swap / Write
Item
Integer: 0 to 65535
DWord: 0 to 4294967295
2147483647
ASCII
Each 8-bit Word is sent as two 4-bit ASCII characters, allowing for a time
interval between characters without causing errors.
RTU
Each 8-bit Word is sent as two 4-bit hexadecimals, allowing for greater
density and faster throughput. In most cases, we recommend using this
protocol.
No Swap or Swap
This setting enables or disables the Swap Word order in the Read and Write
commands. Note that it only works with the FP, FPS, FP3, FP3S, DW, DWS,
DW3, and DW3S register types.
This setting chooses the function 0x06 (Preset Single Register) or 0x10
(Preset Multiple Registers) to write:
Write Item:
Write Group: Any writing in the driver uses the Modbus function 0x10.
For more information about the functions, please consult the Modbus protocol
documentation.
Block Size / (EROxxx):MaxGap
64
0 to 512
ERO-xxx
0 to 512
This setting is used with Main Driver Sheet and configures the gap size
between two addresses that could belong to the same group or block
according to the Block Size but, if there are no other I/O addresses between
them and their addresses difference is bigger than the gap, then they will end
up in separated virtual read groups. This setting can never be higher than the
Block Size.
(Max Gap)
5. Click OK.
The settings are saved and the Communication Settings dialog is closed.
Page 9
MODBU Driver
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 not
know the modem name, use the Auto Detect option. The Auto Detect 1 will use the first modem available, Auto
Detect 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 field
accepts tags between curly brackets.
Settings button: Click on this button to configure the modem settings. The window that displays when you
click 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. The
information is saved on the operating system registry, and they are valid only in the computer
that you are interacting with. If you install your project on another computer, you will have to
reconfigure these settings.
Page 10
MODBU Driver
Connection button: Click to open the Connection Control window. The default connection settings should
suffice for most of the projects. However, you can take full control over the connection, and also enable
incoming calls, by clicking on this button.
Dial out trigger field: When the value of the tag configured in this field changes, the driver will try to
connect 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 disconnect
from the remote device. If the device is disconnected the command is ignored. You do not have to use
this 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 before
sending any information. If the connection fails, the next attempt will be made after the Retry Interval
has expired.
Disconnect call if idle for more than field: When this option is checked, the driver will automatically disconnect
from 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 the
remote device. You can use the Hang up trigger to drop the call once it has been established. Notice
that 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. The
description is associated with the Code field; however, it brings some additional information about the
current status.
Page 11
MODBU Driver
serial form, you can connect standard devices that support serial communications to the terminal server. The
following diagram provides one example of applying this solution:
Page 12
IP Address field: Specify the IP Address for the Terminal Server. This field accepts tags in curly brackets.
Status Tag field: This field is available only when using TCP/IP. The tag on this field receives the value 1
when 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 responsible
for establishing the connection to enable the communication.
MODBU Driver
On the Insert tab of the ribbon, in the Communication group, click Driver Sheet and then select MODBU from
the list.
In the Comm tab of the Project Explorer, right-click the MODBU folder and click Insert on the shortcut
menu.
Page 13
MODBU Driver
A new MODBU driver worksheet is inserted into the MODBU folder, and then it is automatically opened for
configuring.
Page 14
0X
MODBU Driver
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 is
valid. If the syntax is invalid, then the development application automatically inserts a default
value of 0X:0.
You can also specify an indirect tag (e.g. {MyHeader}), but the tag that is referenced must follow
the same syntax and contain a valid value.
The following table lists all of the register types and address ranges that are valid for the Header
field:
Valid addresses for Header field
Register Type
Sample
Header
Comments
0X
0X:0
Coil status: Reads and writes events using Modbus instructions 01,
05, and 15.
1X
1X:0
STA
STA:0
3X
3X:0
4X
4X:0
FP
FP:0
Floating-point value (Holding Register): Reads and writes floatingpoint values using two consecutive Holding Registers.
Page 15
MODBU Driver
Register Type
Sample
Header
Comments
FPS
FPS:0
Floating-point value (Holding Register): Reads and writes floatingpoint values using two consecutive Holding Registers with Byte
Swap.
FP3
FP3:0
FP3S
FP3S:0
DW
DW:0
DWS
DWS:0
DW3
DW3:0
DW3S
DW3S:0
BCD3
BCD3:0
BCD
BCD:0
BCDDW
BCDDW:0
BCD 32-bit integer value (Holding Register): Reads and writes 32-bit
integer values using two consecutive Holding Registers.
BCDDWS
BCDDWS:0
BCD 32-bit integer value (Holding Register): Reads and writes 32bit integer values using two consecutive Holding Registers with Byte
Swap.
BCDDW3
BCDDW3:0
BCD 32-bit integer value (Input Register): Reads 32-bit integer values
using two consecutive Input Registers.
BCDDW3S
BCD 32-bit integer value (Input Register): Reads 32-bit integer values
using two consecutive Input Registers with Byte Swap.
ID
ID:0
ST
ST:0
String value (Holding Register): Reads and writes String values using
consecutive Holding Registers.
STS
STS:0
String value (Holding Register): Reads and writes String values using
consecutive Holding Registers with Byte Swap.
3. 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.
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/Unsigned
Optional 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's
communication settings.
AddressOffset
Page 16
MODBU Driver
Parameter that is added to the AddressReference parameter of the Header, to compose the
specific 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.
Bit
Use this optional parameter only for 3X (Input Register) and 4X (Holding Register) types, to
indicate which bit on the register will be read from and/or written to.
Length
Length 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 must
follow the same syntax and contain a valid value.
Note:
You must not configure a range of addresses greater than the maximum block
size (data buffer length) supported by the target device. The default block size
is 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 in
the 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, Enable
Read When Idle, and Write Trigger commands attempt to communicate the entire block of addresses
that is configured in the sheet, so if the block of addresses is larger than the maximum block
size 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 limit
on 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
00010
0X:0
10
01020
0X:1000
20
10001
1X:1
10010
1X:0
10
11020
1X:1000
20
30001
3X:1
30010
3X:0
10
31020
3X:1000
20
FP3:0
FP3S:0
1000
40001
4X:1
40010
4X:0
10
41020
4X:1000
20
Page 17
MODBU Driver
Device Register
Header
Address
40010 (bit 0)
4X:0
10.0
41010 (bit 7)
4X:1000
10.7
FP:1
FP:0
13
FP:1000
21
DW:1
DW:0
13
For more information about the device registers and addressing, please consult the manufacturer's
documentation.
4. Save and close the worksheet.
On the Insert tab of the ribbon, in the Communication group, click Main Driver Sheet and then select MODBU
from the list.
In the Comm tab of the Project Explorer, expand the MODBU folder and then double-click MAIN DRIVER
SHEET.
Page 18
MODBU Driver
Tag Name
Type the name of the project tag.
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 must
follow the same syntax and contain a valid value.
Note: You cannot leave the Station field blank.
I/O Address
Specify 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:
Type
Register 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 19
MODBU Driver
STS
Signed/Unsigned
Optional 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's
communication settings.
Address
Address of the device register.
Bit
Use this optional parameter only for 3X (Input Register) and 4X (Holding Register) types, to
indicate which bit on the register will be read from and/or written to.
Length
Length 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 must
follow the same syntax and contain a valid value.
Note:
For DWord registers (DW, DWS, DW3 and DW3S) using the unsigned option in
the I/O Address field, the associated project tag must be Real type.
Note: The Main Driver Sheet can have up to 32767 rows. If you need to configure more than
32767 communication addresses, then either configure additional Standard Driver Sheets or
create additional instances of the driver.
3. Save and close the worksheet.
Page 20
MODBU Driver
If the Driver Runtime task is set to Manual, select the task and then click Startup to change the task to
Automatic.
Page 21
MODBU Driver
Troubleshooting
This section lists the most common errors for this driver, their probable causes, and basic procedures to
resolve them.
Description
Possible Causes
Procedure To Solve
OK
None required
Equipment failed
Ack
Equipment in use
Negative Ack
10
11
12
13
Invalid CRC
18
19
100
Illegal operation
-15
Disconnected cables
-17
Timeout between Rx
characters
Wrong parity
Page 22
Description
Possible Causes
Procedure To Solve
OK
None required.
MODBU Driver
Status Code
-15
Description
Possible Causes
Procedure To Solve
Disconnected cables.
Operating System and Project Information: To find this information, click Support in the Help tab of the
ribbon.
Driver Version and Communication Log: Displays in the Output window (LogWin module) when the
driver is enabled and the project is running is running.
Device Model and Boards: Consult the hardware manufacturer's documentation for this information.
Page 23
MODBU Driver
Revision history
This section provides a log of all changes made to the driver.
Revision history
Driver
Version
Revision Date
Description of Changes
Author
2.02
30 Jul 1999
Roberto V. Junior
2.03
13 Dec 1999
Roberto V. Junior
2.04
05 Jun 2000
Roberto V. Junior
2.05
30 Oct 2000
Loureno Teodoro
2.06
14 Nov 2001
Loureno Teodoro
Fixed bug that caused 100% CPU usage when a message was
waiting in a timeout situation
2.07
Page 24
21 Feb 2002
Roberto V. Junior
2.08
22 Aug 2003
Eric Vigiani
2.09
11 Dec 2003
Eric Vigiani
2.10
25 May 2004
Eric Vigiani
2.11
14 Jun 2004
Implemented SwapWord for FP, FPS, FP3, FP3S, DW, DWS, DW3
and DW3S
Changed FP, FPS, FP3, FP3S, DW, DWS, DW3 and DW3S with
and without SwapWord to conformance to standards (FPS, FP3S,
DWS and DW3S are data types with Byte Swap)
2.12
03 Sep 2004
2.13
24 Sep 2004
2.14
19 Jan 2005
Leandro Coeli
2.15
19 Feb 2005
Leandro Coeli
2.16
26 Apr 2005
Leandro Coeli
2.18
12 Jun 2006
Graziane C. Forti
2.19
31 Aug 2006
Eric Vigiani
2.20
28 Nov 2006
Graziane C. Forti
MODBU Driver
Driver
Version
Revision Date
Description of Changes
Author
2.21
19 Jan 2007
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
Marcelo Carvalho
10.3
01 Jul 2009
Fellipe Peternella
10.4
16 Sep 2010
Andr Krbes
Page 25