MODBUS device
IMPORTANT: It is recommended to use the BC9050 device for the BC9000 controller for new PLC configurations.
The BC9050 Device is newer and better maintained - and includes support for the BC9000 controller. The ModBusTCPDevice is keept to support existing database setup/use only.
BC9050 Device
Status:
This documentation applies to version 1.26.125.28 (2007-03-23) of the MODBUS device.
This code is tested with:
BC9000, firmware version B9 00:
Original version for our oldest PLC systems, received from Beckhoff support
050710
Remark should not be loaded into new PLC's!
Everything works. Calling Reset ModBus or Set Watchdog Timer is
not needed at initialisation of the device. (050711 - PLC01)
BC9000, firmware version BA 00:
Download from Beckhoff
Can not set control bits when the number of control bits does not match one or
more full bytes - resetting MODBUS does not help. The response from PLC when
trying to write the control bits is 'Illegal data address'. If the code is
modified, so only bits up to the last full byte is included, it works for the
bits that can be addressed - i.e. all controls except the last bits that does
not fill a full byte. (050711 - PLC01)
BC9000, firmware version BB FB:
Beta version received from Beckhoff support 050710
This version does not have any known bug related to us.
BC9000, firmware version BB 00 (release of BB):
The newest BC9000's are delivered with this (PLC08...), and we received a copy
061214 from Beckhoff support.
Contents:
Overview:
This device is used to service the Beckhoff Bus terminal system with either BC9000 Ethernet bus terminal controller or the BK9000 Ethernet bus coupler. The communication with Beckhoff terminals is done with the MODBUS protocol.
Configuration of Beckhoff BC9000
The standard configuration of the Beckhoff BC9000 controller that is used with this device is set with the KS2000 program. Only change from default (apart from eventual TCP/IP settings) is to change terminal modules to 'Field bus terminal'. To do this, connect to the BC9000 with from the KS2000 program. Select pos0:BC9000, Settings, Controller settings in the tree view. In the following setup window, select the 'mapping' tab, and change mappings to 'Field bus terminal' for all modules.
Output values goes to zero: The new high
precision (0.05%) 16-bit input modules (KL3132, KL3162,...), have the
problem that they by default performs a calibration from time to time
(default 180 s). When the calibration is taking place the output (as seen
from the field bus) is going to zero. The solution is to cope with the
calibration in a PLC program by checking the status bit (SB1.6)
(see PLC08 program for an example), or to turn off calibration and set a
long time for forced calibration. (If calibration is turned off, the module
still performs calibration, but a lower rate (given by the forced
calibration interval). The default value for the forced calibration is also
quite low. See the manual for more information (search for calibration).
A forced calibration may stop the values going to zero (at least in a
BK9000).
Note that in order to correctly see the above terminal settings a fairly new
version of KS2000 is needed (will work in ver. 4.3.0.53)
Viewing CHM help files: Store the file on a local disk, unblock the content (properties/general). See http://www.beckhoff.com/english/download/NotesAboutChmFiles.asp#Notes for more information.
Change BC9000 register values: In order to be allowed to change a BC9000 register the Write Protection has be abolished. This is done by selecting the menu Online|Coupler|Services...
Fast ModbusTCP: The BC9000 can communicate
ModbusTCP either with "normal" TCP speed (original implementation) or with
fast TCP (about 15 ms for performing a read of the registers using fast, and
about 30 ms using "normal". The setting can be changed in register 29 in
table 100 (1 is fast, 0 is normal). Note that in order to be able to change
the setting the Write Protection has to be abolished (see above). Another
way to change the setting is using ModBus adress 4387 (=0x1123). For
instance use JSN's LabVIEW program PLC_WriteSingleRegister.
Notice: After some time (using Fast ModbusTCP and a PLC device read
delay of 50 ms) we got a IO error on the PLC, and (adc) data was not updated
anymore (communication with the busterminals stopped). Achieved ~15 S/s with
normal TCP and a read delay of 20 ms. (JSN 070927)
KL3102 (16 bit adc, +-10 V) filter (conversion)
setting: In register 37 the filter (conversion) time be changed.
Standard filter setting is 140 ms (0x35C0). Other values are 50 ms (0x1330).
Note that in order to be allowed to change a terminal setting the
code word (0x1235) has first to be entered in register 31.
Device parameters, Addressing:
Device status and control:
When using 'One Dim addressing', the device status and control parameters can be accessed.
parameter |
Suggested |
Description |
Data Type |
Interpretation |
Mode |
Comment |
0 |
ResetComm |
Reset Communication |
Bit |
Pulse bit dataserver |
Write |
Reinitialize the hardware communication |
1 | ResetCnt | Reset counters | Bit | Pulse bit dataserver | Write | Reset status counters |
2 | ResetModBus | Reset MODBUS | Bit | Pulse bit dataserver | Write | Reinitialize the hardware communication and resets MODBUS Bus coupler. All control parameters goes to zero - set again from the device. Should only be defined if needed. |
10 | Active | Coupler active | Bit | Read | TRUE if the bus coupler is active | |
100 | NCommErr | Word | Read | Counts number of communication failures. | ||
101 | noRespncCnt | Word | Read | Counts number of communication connect retries in case of lost connection. | ||
104 | lastErrorMsg | String | Read | Last error message as text |
PLC parameters:
Standard MODBUS parameters are accessed by one of the 5 MODBUS address types:
MODBUS Conversion (22): Address type used for all floating point parameters defined for the PLC crate.
MODBUS Bit (23): Address type used to access a bit.
MODBUS Word (24): Address type used to access a word.
MODBUS Filtered (25): Address type used to access part of a word (selected by a bit mask filter and a rotation number).
MODBUS Three state word (26): Special address type used to combine two bits into a three state value.
All of these address types use the first general purpose address fields as
follows:
a0: MODBUS address. Remark - calculated by the databaseEditor MODBUS tool from
a6,a7
a1: Address type: 0: Floating point input (reading), 1: Floating point
output, 2: Binary Input, 3: Binary output.
a3: For address type 2,3 when addressing bits: zero based bit number in reading.
Remark - calculated by the databaseEditor MODBUS tool from a6,a7
REMARK: a0,a3 are direct address fields used by the device. However, it is recommended to use the special tool for MODBUS devices in the database editor that calculates a0,a3 from module Position and channel number in the module.
a6: Module position: An integer defining the location of the PLC
terminal I/O module.
a7: channel: Input/Output channel in PLC module.
s1: Connector: Description of which connector the channel is connected
to. See Wiring for syntax:
Using the Update MODBUS tool in the databaseEditor:
The Update MODBUS tool found in the database editor is used to calculate the device addresses a0,a3 from the more user friendly address fields a6, module position and a7, input/out channel in the module. One of the major reasons to configure the addressing using this tool is that it is in a way that makes it easy to insert modules at any position - given that module numbers are chosen carefully. Module position numbers must be in increasing magnitude with gaps allowed. It is recommended to have room for insertion of new modules in the module number sequence. The Ethernet bus coupler and the end terminal must be included in the module position sequence.
From version 1.26.125.28:
When used with PLC programs, some modules may be assigned to the Field bus and
others to the process memory for the PLC program. Modules mapped to the field
bus must have iaMap =0 in the ModBusConfig table - and modules mapped to
process memory must have ioMap=1. Addresses for modules mapped to the field bus
will still be calculated as mentioned above. For modules mapped to process
memory a0=a2 + a5.
Example:
Module Module
position Type
1
BC9000 Ethernet Bus Coupler.
100 KL2408
110 KL2408
200 KL4132
300 KL3064
400 KL3102
999 KL9010
End terminal
Database helper tables used by the database editor:
ModBusType:
The terminal modules used must be known by the database editor. All known types are defined in the database helper table 'ModBusType'. The IO maps of the terminals are hardcoded into the database editor. New module types can be defined in the ModBusType table as long as its I/O map is similar to one of the maps already defined. The I/O map for each ioType are hardcoded into the databaseEditor.
moduleTypeId: Unique id for the module - typical the terminal module number
as integer
moduleTypeStr: Module name as string
moduleDescription: Description of the terminal.
ioType: Identifies the hardcode I/O map, i.e. how many floating point in/out and
bit in/out. The type numbers are defined so that input/out type and number of
channels can be identified - see the values in the table.
ModBusConfig:
Before using the update tool the module positions must be defined in the database helper table 'ModBusConfig'. This is typically done using access. Remark: The fields 'inAdr', 'outAdr','bitInAdr','bitOutAdr',bitInBitNo','bitOutBitNo' are used internally in the database editor and should not be filled manually.
deviceId: Unique device id, as defined in the table DeviceLocation
modulePosition: Integer to define the position of the terminal module. See notes
and example above.
moduleTypeId: The moduleTypeId as defined in the table ModBusType.
Comment: Optional user comment.
ioMap: 0: Mapped to field bus, 1: Mapped to PLC process memory
Modbus, setup:
Unique device id: The unique device id as defined in the database, DeviceLocation table.
IP Address: The ip address of the PLC in the form X.X.X.X
Port number: The TCP port, typical 502
Watchdog Time: The setting of the Watchdog timer. Remark: Only set to device during start if 'Send watchdog settings during start' is checked. Always send to the device, a resetModBus is send to the device (i.e. set from the Console).
Read Delay: The time, in ms, between reading updates. Typical 200 ms, If the PLC is set to fast TCP, can be set down to 30 ms.
Reset MODBUS during start (will reset control value): If checked, a MODBUS reset will be performed during device start. This will set all controls to zero! The settings are restored according to the initialisation mode when the MODBUS has been reset.
Send watchdog settings during start: If checked, the Watchdog timer settings is send to the PLC during start of the device. The recommended setting is to leave this on. Watchdog settings are always send to the device, a resetModBus is send to the device (i.e. set from the Console).
Base persistent file name: If at least one of 'Persistent History' or 'Persistent control data' is checked the base file name must be specified. The filename should be specified without path and extensions. It is used to generate the persistent files used to store current control data and history data. The data files are stored in the ConSys executable directory. The extension on history files is 'hst' and on control files 'permanent'. See also the description of the initialisation method below.
Store interval (hours): The time between update of the persistent data on disc. Under normal conditions, the persistent data is stored when the control system is closed. To ensure loss of data in case of a crash the persistent data is updated regularly at the specified intervals.
Persistent history: Checked, if histories should be stored to disc.
Persistent control data: Checked, if control values should be stored to disc.
Control value initialisation mode:
None: The control values are not transferred to the G64 crate
during initialisation
From database: The control values is obtained from the
database default values and send to all control values in the G64 crate.
From persistent file: During device initialisation the
device first looks for a file with the name '<Base persistent file name>.loadOnce'.
If this file exist the command values are loaded from the file and the file is deleted.
If the file does not exist, the device looks for a file with the name ' <Base
persistent file name>.permanent' and load the command
values from this file. If no file could be found the default values from the
database is used to set the crate control values.
The s1 field in the Parameter table is used for a description of the
wiring (i.e. to which connector the parameter is wired).
The syntax of ordinary parameters is a tuple consisting of
ConnectorType: F(ront)/B(ack)-panelNr[_colunmNr]-ConnectorNr[-pinNr]
Some examples are
Relæ: F-1-1 | A relay output on the Front, first panel, first connector (i.e. top connector) |
BNC: F-6_3-2 | A BNC output on the Front, sixth panel, third column, second connector (from the top) |
Thermo-K: F-3-1 | A K-type thermo connector on the Front, third panel, first connector (i.e. top connector) |
For assisting in the wiring to the PLC-modules (bus terminals) a helper table has been defined which for all the terminal gives the pin numbers for the different channels.
ModBusTypePinNumbering:
moduleTypeId: The moduleTypeId of the
ModBusType table.
channelNr: The channel number of the module (corresponding to a7
in the ParameterTable)
pinNr: The pin number on the terminal corresponding to the given channel
number.
groundPin: The ground pin on the terminal corresponding to the given
channel number. Note that there can be several channels which have to share the
same ground (or in some cases there even is no ground in which case the supply
ground must be used - these have an entry of 0 for the ground pin).
Specials parameters which require more channels in the PLC, must be defined specially, either directly in s1 or separately.
In the standard Access database a Report (ModBusWiring) has been made for printing the wiring for a PLC device. Likewise there is a table (a view from the SQL database) for typing in the wiring data.
Use KS2000 program, Login to PLC, Chose Online|Coupler|Firmware Update
Remark: Do not use Firmware Load from the online menu
Remember to set the PLC configuration again
Last Modified 27 September 2024