01.03.2013 Views

TWinSoft FAQ - Communication

TWinSoft FAQ - Communication

TWinSoft FAQ - Communication

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Eng: 1.03<br />

TBox, TWinsoft<br />

<strong>FAQ</strong>,<br />

tips & tricks<br />

1. COMMUNICATION<br />

COMMUNICATION,<br />

, PROTOCOLS PROTOCOLS,<br />

, ...


Disclaimer<br />

Every effort has been made to ensure the accuracy of the information in this guide. However, Semaphore. assumes<br />

no responsibility for the accuracy of the information. Product information is subject to change without notice.<br />

<strong>TWinSoft</strong> and A are registered trademark of Semaphore.<br />

Windows is a trademark of Microsoft Corp.<br />

Copyright<br />

© 2007-2008 by<br />

Chaussée de Bruxelles, 732a<br />

B-1410 Waterloo<br />

Edition: September 18, 2007<br />

Author: Jean Burton<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 2


TABLE OF CONTENTS<br />

INTRODUCTION.....................................................................................................................................5<br />

1. RESTORE COMMUNICATION WITH TBOX-MS / TBOX-LITE................................................6<br />

1.1.INTRODUCTION..............................................................................................................................6<br />

1.2.GLOBAL RESET.............................................................................................................................7<br />

1.3.TOTAL RESET...............................................................................................................................8<br />

1.4. GLOBAL RESET WITH TBOX-CPU3.................................................................................................9<br />

2. MODBUS VS. J-BUS ADDRESSING ISSUE...................................................................................10<br />

2.1. INTRODUCTION...........................................................................................................................10<br />

2.2. ADDRESS PREFIX (MODICON STANDARD).........................................................................................10<br />

2.3. ADDRESS OFFSET (MODICON STANDARD)........................................................................................10<br />

2.4.MODBUS ADDRESSING OF TAGS IN TBOX.........................................................................................11<br />

2.5. ACCESSING REMOTE DEVICE FROM TBOX.......................................................................................11<br />

2.6.ACCESSING TBOX FROM AN EXTERNAL DEVICE (HMI, SCADA, PLC, ...).............................................12<br />

2.7. ABOUT HARDWARE.....................................................................................................................12<br />

3. CREATING A REMOTE TAG 'SERIAL': STEP BY STEP...........................................................13<br />

3.1.SET THE COMMUNICATION CHANNEL..................................................................................................13<br />

3.2.CREATE THE REMOTE DEVICE........................................................................................................13<br />

3.3.CREATE THE TAG........................................................................................................................14<br />

3.4.CREATE THE REMOTE TAG............................................................................................................14<br />

3.5.TESTING....................................................................................................................................15<br />

3.6. BLOCK COMMUNICATION..............................................................................................................15<br />

4. REMOTE TAG: TBOX TAG VS. QUANTITY OF VARIABLES.................................................16<br />

4.1. WITH ANALOG TAGS...................................................................................................................16<br />

4.2. WITH DIGITAL TAGS...................................................................................................................17<br />

5. MODBUS: HANDLING 32 BITS VARIABLES...............................................................................18<br />

6. MODBUS ADDR. ISSUE WHEN CONNECTING TO MODBUS DEVICES (EXOR, HMI, ...).19<br />

6.1. EXOR WORKS AUTOMATICALLY WITH ‘BLOCK COMMUNICATION’.............................................................19<br />

6.2. WORKING WITH ANALOG VARIABLES.................................................................................................20<br />

6.3. WORKING WITH 32 BITS VARIABLES................................................................................................20<br />

6.4. DIFFERENCE BETWEEN TBOX-MS -LITE AND TBOX CPU3..............................................................20<br />

7.COMMUNICATION ERROR – MODBUS EXCEPTIONS.............................................................21<br />

8. TWINSOFT IS UNABLE TO OPEN A SERIAL PORT..................................................................22<br />

9. TESTING COMMUNICATION WITH TBOX................................................................................23<br />

9.1.LEDS OF COMMUNICATION PORT.....................................................................................................23<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 3


10. IP SETTING ISSUES OF THE TBOX............................................................................................24<br />

1. IP address..........................................................................................................................................24<br />

2. IP subnet............................................................................................................................................24<br />

3. Gateway address................................................................................................................................25<br />

4. IP addresses handling in TBox MS and TBox LITE...........................................................................25<br />

11. INTERFACING TO SCADA. CLARIFICATION ABOUT OPC.................................................26<br />

12. TRANSMISSION TIME IN MODBUS PROTOCOL....................................................................28<br />

12.1. BLOCK COMMUNICATION............................................................................................................28<br />

12.2.TRANSMISSION TIME...................................................................................................................28<br />

13.TCP/IP HIGH END DEBUG USING “WIRESHARK”..................................................................29<br />

14. IP ADDRESS AND MAC ADDRESS ARP TABLE.......................................................................31<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 4


Introduction<br />

The goal of the <strong>FAQ</strong> document is to provide detailed explanations on specific topics, to insist on<br />

certain points and to answer regular questions.<br />

It does not provide general information on how using TBox, but it can help you to solve<br />

selective problems while developing a project.<br />

In order to help you finding the information, the <strong>FAQ</strong> are divided into different manuals:<br />

TBox/<strong>TWinSoft</strong> <strong>FAQ</strong> documents:<br />

1. <strong>Communication</strong>: general information about ModBus, local communication (this<br />

document)<br />

2. Modem: all you want to know about dial-up connection<br />

3. Miscellaneous: all the rest (coming soon)<br />

You will also find <strong>FAQ</strong> document about WebForm Studio and TView.<br />

All those documents available at: http://tbox.biz/uk/telecharg.php --> <strong>FAQ</strong>/Technical Notes<br />

There is no hierarchy between the different topics. Unless specified, each topic can be read<br />

independently from the others.<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 5


1. Restore <strong>Communication</strong> with TBox-MS / TBox-LITE<br />

This topic describes how to restore a communication with a TBox and how the firmware and<br />

application levels are organized in the RTU.<br />

1.1. Introduction<br />

In some cases, it may happen you cannot communicate anymore with your RTU, because you<br />

don't know the settings of the com. port of TBox you are connected to (Baudrate or IP settings<br />

and/or protocol).<br />

To test the communication, you use the menu “<strong>Communication</strong>” “RTU identification”. If it<br />

does not show you anything, it means you are not communicating with your TBox.<br />

To restore communication, you can set the RTU to a known, default configuration.<br />

This is called the global reset of the RTU: you stop the application running in the RTU.<br />

This operation does not erase the application, but stops it.<br />

A single push on the 'Reset' button will restart the application.<br />

The procedure for TBox CPU-3 is explained at chapter 1.4.<br />

Previous to act on the application, let's see how the different software levels are organized in<br />

TBox.<br />

The software is organized in three levels, with:<br />

Application<br />

O.S.<br />

Loader<br />

1. the application<br />

it corresponds to the development done with <strong>TWinSoft</strong><br />

2. the O.S. (Operating System)<br />

it contains all features on TBox (alarms, datalogging, process, TCP/IP, ...)<br />

3. the loader<br />

it handles local communication in ModBus protocol<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 6


1.2. Global reset<br />

With TBox MS and TBox LITE you maintain the reset button to ‘Reset’ position and let the<br />

LED 'Run' flashes 3 times. You release then the button. The application stops and the RTU<br />

runs with the Operating System (O.S.).<br />

The LED 'Run' flashing at ½ Hz indicates the application is stopped.<br />

Application<br />

O.S.<br />

Loader<br />

Factory OS settings:<br />

- Station address (ModBus)= 1<br />

- Serial ports = 9600, N, 8, 1 - protocol: ModBus-RTU<br />

- IP address = 192.168.1.99 - protocol: ModBus/TCP<br />

Once the global reset has been carried out, you adapt <strong>TWinSoft</strong> “PC Setup” (from the main<br />

menu “<strong>Communication</strong>”) to the current TBox configuration (see O.S. settings above).<br />

Then you test communication doing<br />

from the main menu,<br />

<strong>Communication</strong> RTU<br />

identification.<br />

The following information (adapted<br />

to the model of TBox you are using)<br />

must be display:<br />

Then you can send your own program, with new communication settings.<br />

If you had sent the sources of the application to the RTU, you can then also retrieve it from<br />

the menu “<strong>Communication</strong> “Download” Program sources”.<br />

If you wish to re-start you the RTU, without modification, press the button once to the<br />

'Reset' position. The application restarts.<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 7


1.3. Total reset<br />

The total reset may be needed in very rare situation, but at least you will understand what<br />

happens if you press longer the button 'Reset'.<br />

To carry our a total reset, you maintain the reset button to ‘Reset’ position and let the LED<br />

'Run' flashes 5 times.<br />

The RTU is back to the loader level (below the O.S. level). In this mode, you can only send<br />

an OS to the RTU (“<strong>Communication</strong>” “Upload” “Operating System”.<br />

Application<br />

O.S.<br />

Loader<br />

Factory Loader settings:<br />

- Station address (ModBus)= 1<br />

- Serial ports = 9600, N, 8, 1 - protocol: ModBus-RTU<br />

- IP address = NO Ethernet available<br />

As you can see, you can only communicate through serial port.<br />

Then you test communication<br />

doing from the main menu,<br />

communication RTU<br />

identification.<br />

The following information<br />

(adapted to the model of TBox you<br />

are using) must be displayed:<br />

If you change your mind just after the reset, press the button once to the 'Reset'<br />

position. The O.S. and application will restart.<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 8


1.4. Global Reset with TBox-CPU3<br />

With previous generation of CPU, the philosophy of Global Reset and Total Reset are similar,<br />

but the way to achieve them is slightly different.<br />

You will use the two small push buttons on the front “PGM” and “RST”:<br />

– Press and Hold “PGM”<br />

– Press and Release “RST”<br />

– Let the LEDs flash 2 times (4 times for the Total Reset)<br />

– Release “PGM”<br />

The LED “USR”, after a Global Reset, must be flashing at ½ Hz.<br />

Features “O.S.” settings “Loader” settings<br />

Station address<br />

COM1, COM2, COM3<br />

COM4 - PSTN<br />

COM5 - PCMCIA<br />

COM5 - PSTN<br />

Protocol<br />

Ethernet<br />

9600, E, 8, 1<br />

V22<br />

V34<br />

V34<br />

ModBus-RTU<br />

NO Ethernet<br />

1<br />

9600, E, 8, 1<br />

V22<br />

Not available (*)<br />

Not available<br />

ModBus-RTU<br />

NO Ethernet<br />

(*): the modem will pick-up the line and synchronize, but there is NO communication.<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 9


2. ModBus vs. J-Bus Addressing issue<br />

This topic describes basics in ModBus protocol addressing.<br />

2.1. Introduction<br />

ModBus is a very simple protocol and very easy to communicate with. It is based on:<br />

- Station number (0 .. 255)<br />

- Function index (standard functions: 1, 2, 3, 4, 5, 15, 16) (read, write, digital, analog,<br />

simple, ....)<br />

- Address (0.. 65535)<br />

Historically, Modicon created ModBus-RTU protocol and was the only one that could use it.<br />

Other companies should use J-Bus (differences explained below)<br />

To make things clearer for their users (!), Modicon fixed some rules.<br />

2.2. Address prefix (Modicon Standard)<br />

As a PREFIX of the address, they indicate an index, telling which kind of variable is concerned:<br />

Examples: Prefix '0' Coil<br />

Prefix '1' Digital Input<br />

Prefix '4' Holding register<br />

Then following this prefix, they decided that the ModBus address would have maximum 4<br />

characters: 0000 9999.<br />

Examples:<br />

1xxxx = addressing a digital input<br />

4xxxx = addressing an analog register<br />

2.3. Address offset (Modicon Standard)<br />

They decided that the first address '0' would become '1'.<br />

This has given the distinction between ModBus (start at '1') and J-Bus (start at '0').<br />

ModBus (Modicon) and J-BUS are identical, and every one speaks commonly of ModBus.<br />

But to be exact, TBox supports J-Bus.<br />

Example:<br />

If you have a SCADA using the 2 rules presented above, if you want for instance to read the<br />

TBox analog register at address 123, you will indicate in the SCADA with the Modicon syntax:<br />

40124.<br />

But the real address (used in the transaction) is 123. The prefix “4” is not part of the<br />

address.<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 10


2.4. ModBus addressing of Tags in TBox<br />

The ModBus address of variables in TBox is always a REAL address (NO prefix, NO offset).<br />

ModBus addressing of Tags depends on the family of TBox.<br />

With CPU-3:<br />

All variables have predefined address you cannot change.<br />

Examples:<br />

second=22016<br />

AIR0=20480<br />

Ana0 of the CPU=64<br />

Float0=23040<br />

With TBox-MS, -LITE, -LP:<br />

All variables can be assigned any free ModBus address:<br />

2.5. Accessing Remote Device from TBox<br />

To read/write data in external devices with TBox, you use Remote Tags (see details chapter 3.)<br />

The external variable you want to read/write is indicated into the Remote Tags with its real<br />

ModBus address.<br />

Depending on the documentation you receive from the manufacturer, you may have to adapt<br />

the addressing indicated into the manual.<br />

The trick is to try different addresses, one by one: adding 1 unit, removing 1 unit, removing<br />

possible prefix, ...<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 11


2.6. Accessing TBox from an external device (HMI, SCADA,<br />

PLC, ...)<br />

When an external device using Modicon standard has to access TBox, the format of the address<br />

(max. 4 or 5 digits) might be an issue.<br />

Working with CPU-3<br />

If the format of addresses supported by the SCADA allows only 4 digits, you have to use the<br />

driver “NewMap” to remap the addresses to 0000 9999, as the addresses in CPU-3 are<br />

fixed.<br />

Working with TBox MS and TBox LITE<br />

There is no problem as you can adapt ModBus address for each Tag (see above).<br />

Think also about the prefix and the offset. If your SCADA uses the genuine Modicon syntax, the<br />

address might be like: 4xxxx (to access an analog variable), or 1xxxx to access a digital<br />

input, ... If the SCADA uses an offset: xxxx=TBox Tag address + 1<br />

2.7. About Hardware<br />

Sometimes there are also hardware problems, linked to the fact that one device answers too<br />

fast, or that a Remote Device reacts too slow, because communication is not its main task.<br />

- TBox working as a 'slave',<br />

if TBox answers too fast for the Master, this can be adjusted by<br />

increasing its 'end of frame detection' of the COM port, in COM port 'Advanced'<br />

parameters.<br />

For instance 50 msec. or more.<br />

As of <strong>TWinSoft</strong> 10.xx and OS 3.14.xxx, the 'end of Frame' detection is replaced by<br />

'Incoming Frame Detection' and works in automatic.<br />

- TBox working as a 'master',<br />

to avoid TBox starting transactions one after each others to<br />

quickly, when for instance one 'slave' is still in the answering phase, you can add an<br />

'IFG' (Inter Frame Gap).<br />

We suggest IFG should be of minimum 10 ms. (8 ms. With CPU3)<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 12


3. Creating a Remote Tag 'Serial': Step by Step<br />

This topic describes how to establish a communication between TBox and another ModBus<br />

device; typically another TBox.<br />

Do a new clean project!<br />

3.1. Set the communication channel<br />

- From the 'Resources', go to<br />

the tab 'Parameters' of the<br />

com. port you will use.<br />

- Select the same Baudrate as<br />

the one of the device you are<br />

connected to. You must<br />

KNOW it, don’t guess it!<br />

- Select the same data, parity<br />

and stop bits as the device.<br />

You must KNOW them.<br />

- Select the protocol : ModBus-<br />

RTU<br />

- In the tab 'Advanced', declare<br />

an inter-frame gap of 10 ms.<br />

- Tag the communication<br />

variable from the COM port,<br />

tab 'DCV', 'ComX.Noreply'<br />

3.2. Create the Remote Device<br />

From the “Resources” “List of I/O”,<br />

create a “block of I/O”<br />

- Select “ModBus Device”<br />

- Type the Station ModBus address of the<br />

slave<br />

- Select the COM port of the TBox<br />

connected to the device<br />

example: COM2 - RS485 of CPU<br />

- Select a digital Tag (internal variable)<br />

used as Trigger, to activate the<br />

communication. Select the condition<br />

“High State”.<br />

The Tag must be initialized to 1.<br />

Example using COM2 – RS485 of MS-CPU16<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 13


3.3. Create the Tag<br />

In the below example, the Tag will receive ONE analog value read from the device (let's start<br />

with one!).<br />

You have to know the format of the Tag you want to read in the device (8bits, 16bits,<br />

32bits, float?) and create a Tag with the same format in your <strong>TWinSoft</strong> project.<br />

Don’t guess the type, you must know it!<br />

Concerning Analog Tags, as ModBus only defines addresses of 16bits variable, if the Tag<br />

you select is of format 32bits, TBox will automatically build a request for 2 addresses.<br />

3.4. Create the Remote Tag<br />

A Remote Tag corresponds to a transaction with a Remote Device. It associates a TBox Tag to<br />

an address in a Remote device.<br />

In the Remote Tags folder of the <strong>TWinSoft</strong> project, create ONE Remote Tag.<br />

- select the Tag you have created (see above).<br />

- select READ.<br />

- Quantity=1.<br />

- Select the remote device you want to read.<br />

- Chose the type of register you read: Don’t guess it!<br />

Click “Help” to choose the type. A table associates the types with ModBus Functions. If you<br />

chose the wrong one, you may have communication errors!<br />

Check in the documentation of the device to verify which ModBus functions are supported.<br />

Don’t guess it!<br />

- Select the address of the remote device you want to read: if the device uses Modicon<br />

standard, remove the prefix of the address and subtract 1 from the address number: eg.<br />

3041 -> 40 (see also chapter 2. above).<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 14


3.5. Testing<br />

Cable the TBox to the remote device.<br />

Check if the remote device has the same port settings and is in Slave mode, it means it has no<br />

'Master' configuration.<br />

Check also the pin out correspondence for the RS485 between the slave and the TBox.<br />

Upload the project in the TBox and look at the LED<br />

if the cabling is good, TxD of the TBox must blink to indicate the sending of request.<br />

If RxD is blinking, it means that Modbus frames are returned by the device<br />

Results<br />

To check if TBox receives a value, try to change its value using the key in the list of Tags.<br />

If the value you type is maintained, there is no communication.<br />

If you have 'ComX.Noreply' = 1, it means you do not have right communication (time out,<br />

wrong cabling, wrong CRC for the frame)<br />

This variable is SET by the OS. Reset it ( in the list of Tags) and check it again.<br />

3.6. Block <strong>Communication</strong><br />

You can also try a block communication as some devices only answer by block of 8<br />

addresses especially when transferring digital data:<br />

- Create 8 Tags of the SAME TYPE with SUCCESSIVE ModBus addresses in TBox<br />

- In the Remote Tag you declare as Tag the FIRST one and quantity to 8<br />

- In the Address field, type the ModBus address of the FIRST variable in the slave<br />

(corresponding to the first of a block of 8 SUCCESSIVE addresses), having the SAME TYPE<br />

as the one of the Tags in TBox.<br />

Upload the project in TBox and check that the LED RxD and TxD of the RS485 port blink. Then<br />

check with <strong>TWinSoft</strong> the value of the Tags.<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 15


4. Remote Tag: TBox Tag vs. Quantity of Variables<br />

Chapter 3. above describes the principle of Remote Tags. This topic describes the relation<br />

between the formats of Tag (8bits, 16bits, 32bits, Float) and the quantity.<br />

4.1. With Analog Tags<br />

ModBus protocol is built on 'Bytes', and as far as analog is concerned, it defines the way of<br />

transferring 16 bits variables.<br />

Each 16 bits variable corresponds to ONE ModBus address.<br />

But with ModBus it is possible to exchange 32 bits variables like DWORD or FLOAT<br />

If you want to exchange DWORD or FLOAT, see also chapter 5. about Handling 32 bits<br />

variables).<br />

In Remote Tag configuration of a Analog Tags, the quantity relates to number of variables (not<br />

to ModBus addresses).<br />

Examples:<br />

Operation / Qty / Format ModBus addresses<br />

of the TBox Tags<br />

Read / 8 / 16 bits 20480<br />

20481<br />

20482<br />

20483<br />

20484<br />

20485<br />

20486<br />

20487<br />

Read / 4 / Floats 22400<br />

22402<br />

22404<br />

22406<br />

Write / 2 / 32 bits 1000<br />

1002<br />

ModBus addresses<br />

in Remote Device<br />

1200<br />

1201<br />

1202<br />

1203<br />

1204<br />

1205<br />

1206<br />

1207<br />

600<br />

602<br />

604<br />

606<br />

20000<br />

20002<br />

ModBus addresses are chosen as example<br />

Remarks<br />

Successive ModBus<br />

addresses, one by one.<br />

Successive even<br />

addresses, as 32bits<br />

variables need TWO<br />

addresses.<br />

Successive even<br />

addresses, as 32bits<br />

variables need TWO<br />

addresses.<br />

You see how important it is that the format of the Tags of TBox must be the same as the<br />

format of the variables you want to retrieve!<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 16


4.2. With Digital Tags<br />

ModBus protocol is based on 'Bytes', and as far as digital is concerned, it transfers digital<br />

information through Byte(s) (= 8 bits).<br />

Each Bit corresponds to ONE ModBus address.<br />

ModBus protocol supports transfer of less than 8 bits. In this case, some bits are not<br />

interpreted.<br />

In Remote Tag configuration of Digital Tags, the quantity relates to number of bits (= ModBus<br />

addresses).<br />

Working with quantity higher than 8, be sure that everything is multiple of 8:<br />

– ModBus address of the First Tag<br />

– Quantity<br />

– ModBus address of the first variable to access in the remote device.<br />

With Digital or Analog, check there is no gap in ModBus addresses when working with<br />

blocks (Quantity > 1).<br />

Reading block data to TBox MS and TBox LITE (as Slave), if all Tags have not been<br />

created it will lead to communication errors.<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 17


5. ModBus: handling 32 bits variables<br />

This topic describes how TBox uses ModBus protocol to handle 32 bits variables.<br />

The ModBus protocol description does not specify anything regarding 32 bits registers.<br />

The protocol based on transfer of , describes only 'Boolean' and '16 bits' data<br />

transmission.<br />

Therefore, transmission of 32 bits is declared as 2 x 16 bits transmission, corresponding<br />

internally to 2 x ModBus addresses. Then each manufacturer has to determine a way of<br />

organizing the bytes with 2 possibilities: Little Endian or Big Endian.<br />

With TBox families and associated software's (<strong>TWinSoft</strong>, TView, TComm, ...), bytes are<br />

transferred in order HI to LO, the same as when transferring a 16 bits (corresponding to Big<br />

Endian):<br />

- 16 bits: , , <br />

- 32 bits: , , <br />

Example with a Floating point register: ModBus addresses are chosen as example<br />

Float value : 0.02<br />

Value in hex.: 3CA3D70A<br />

Hi Word: 3CA3 (ModBus address 100)<br />

Lo Word: D70A (ModBus address 101)<br />

In the frame: ......<br />

From HMI, this way of addressing 32 bits is sometime indicated:<br />

INV FLOAT and INV DWORD<br />

In case an external device connected to TBox works “from the other side” (little endian), you<br />

have to invert data of both addresses using BASIC functions ‘Split32’ and ‘Pack32’:<br />

' Splitting the 32 variables to two 16 bits registers<br />

Split32(Input,High_W,Low_W)<br />

' Packing the two 16 bits registers in the other side.<br />

Pack32(Output,Low_W,High_W)<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 18


6. ModBus Addr. Issue when Connecting to ModBus<br />

Devices (EXOR, HMI, ...)<br />

This topic answers questions on how addressing TBox variables in HMI, with EXOR UniOp as<br />

example.<br />

This is a general discussion regarding block read and write from any ModBus device to TBox.<br />

Here is the situation when working with EXOR UniOp, an operator panel that can be supplied<br />

with TBox.<br />

The same rules can be applied to any ModBus HMI.<br />

The issues relate to the connection between Tags in the HMI and Tags in the TBox.<br />

Some basic rules have to be respected.<br />

➢ Working with TBox MS and TBox LITE, ModBus addresses of their Tags are not fixed.<br />

For each Tag, you can change its ModBus address.<br />

➢ Creating Analog Variables you can also define their format (8 bits, 16 bits, 32 bits or<br />

Float).<br />

In order to have the best performance with EXOR, you should be careful about the following<br />

points.<br />

6.1. EXOR works automatically with ‘block communication’<br />

Working with digital Tags: always be sure that you have defined in <strong>TWinSoft</strong> blocks of 8<br />

consecutive ModBus addresses, starting at a multiple of 8.<br />

Example: you have 9 digital inputs you want to display in EXOR.<br />

EXOR will ask TBox values for 16 addresses, starting at the first one which must be<br />

multiple of 8.<br />

Check in the TBox application the first one has an address multiple of 8 and that<br />

you have created Tags to have a total of 16 successive ModBus addresses.<br />

Working with Analog Tags: always be sure that you have defined in the TBox application Tags<br />

with consecutive ModBus addresses. When it is possible, EXOR builds automatically a block<br />

from the first ModBus address until the last ModBus address. You can’t leave a gap in the TBox<br />

addresses.<br />

Be careful of the Floats/32 bits limitation in a communication block of TBox CPU3. Indeed,<br />

the maximum quantity of floats/32 bits that the TBoxCPU3 can manage in a communication<br />

block is 8. For example, if you read the floats 4, 8 and 13, EXOR makes a block of 9 too big<br />

for the CPU3. The solution is working without communication block using the option “No data<br />

blocks” in “Project configure controllers select protocol controller setup”.<br />

If one of those rules is not respected, EXOR will return communication errors.<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 19


6.2. Working with analog variables<br />

Check you have a block of variables of similar type (16 bits, float,…) with consecutive<br />

ModBus addresses.<br />

6.3. Working with 32 bits variables<br />

For such data, there are two ways of interpreting the data: from left to right and from right to<br />

left. TBox interprets the 4 bytes of 32 bits from left to right (also known as Big endian).<br />

In case the HMI interprets them in another order, you should use BASIC functions ‘Split32’ and<br />

‘Pack32’ to reorder the bytes (see chapter 5. above).<br />

Concerning EXOR:<br />

– to display ‘Float variables’ you should select the Data field format: INV FLOAT<br />

– to display ‘Long-32 bits’ select the Data field format: INV DBL WORD<br />

It is always possible to change EXOR communication settings to work without block<br />

communication (see EXOR manual, chapter 4.: PLC Setting PLC Comm…), but for<br />

performance reason, we advise to keep block communication and adapt Tag settings<br />

in <strong>TWinSoft</strong>.<br />

6.4. Difference between TBox-MS -LITE and TBox CPU3<br />

In TBox CPU-3, all ModBus addresses exist by default. Then, even if you have not tagged<br />

variables (I/O, AIR, DIR, STO, ...), the ModBus addresses exist.<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 20


7. <strong>Communication</strong> Error – Modbus Exceptions<br />

This topic explains the principle of communication error codes called “Exception Codes”<br />

When a bad request is sent to a TBox MS and TBox LITE (TBox = Slave), it responds with<br />

error codes (called exception codes). This helps you to find which parameter is wrong.<br />

Byte 0 : The Station address of the RTU<br />

Byte 1 : Modbus function in error + 80h<br />

Byte 2 : Code which specifies the error<br />

Byte 4 : CRC16 High<br />

Byte 5 : CRC16 Low<br />

Example :<br />

01 Illegal function<br />

02 Illegal data address (Modbus address)<br />

03 Illegal data value<br />

04 Slave device failure<br />

05 Acknowledge<br />

06 Slave device busy<br />

07 Negative acknowledge<br />

08 Memory parity error<br />

The master sends 01 04 50 00 00 01 20 CA<br />

In details: 01 = Slave device Modbus address<br />

04 = Modbus function (Read analog variables)<br />

50 00 = Tag Modbus address (50 00 h = 20480 d)<br />

00 01 = Quantity<br />

20 CA = CRC16<br />

The slave responds the following exception code 01 84 02 C2 C1<br />

In details: 01 = Slave device Modbus address<br />

84 = Modbus function (04) + 80 h<br />

02 = Illegal data address<br />

C2 C1 = CRC16<br />

Conclusion : The master tries to read a Tag with unknown ModBus address. Typically, when<br />

using TBox MS and TBox LITE, it correspond to a missing Tag in your TWinsoft program.<br />

To understand how the Modbus protocol work, you can use the free software<br />

“ModBus tester” available on our website :<br />

“http://www.tboxsupport.biz/free_downloads/ModBusRTUTester.exe”<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 21


8. <strong>TWinSoft</strong> is Unable to Open a serial Port<br />

This topic relates to <strong>TWinSoft</strong> PC Setup and relation between <strong>TWinSoft</strong> and Windows.<br />

Setting <strong>TWinSoft</strong> to communicate with a serial port (from the menu “PC Setup”), it may happen<br />

that you receive the message: ”<strong>TWinSoft</strong> is Unable to Open the <strong>Communication</strong> Port’’.<br />

It usually means the <strong>Communication</strong> port has already been captured by another Windows<br />

application.<br />

You must verify if you do not run another application using the same serial port. If you do not<br />

find anyone, you must open the ‘Windows Task Manager’ (press Ctrl+Alt+Del) and verify in the<br />

‘Applications’ tab, then in the ‘Processes’ tab, that that there is no <strong>TWinSoft</strong>, TView,<br />

Hyperterminal, ... process already running (former processes that have not been closed<br />

properly by Windows).<br />

If it is the case, close the process(es).<br />

Some programs, like PLC programs may have installed a driver that takes over the serial<br />

port. In such case, the driver should be disabled.<br />

If you removed all the applications using the communication port which were running, you<br />

should be able to use the port in <strong>TWinSoft</strong> again.<br />

If this still does not work, reboot the PC and start <strong>TWinSoft</strong> before any other task.<br />

Working with USB Serial interface, be sure of the ID of the COM corresponds to<br />

the one you are using.<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 22


9. Testing communication with TBox<br />

This topic illustrates how you can use '<strong>Communication</strong> Variables'.<br />

TBox provides diagnostic variables to monitor communications. For each communication port,<br />

TBox provides internal variables indicating different status of the port.<br />

Working with TBox MS and TBox LITE those variables are accessible from the tabs 'DCV' and<br />

'ACV' of each communication port.<br />

Working with CPU-3, those informations are available from the “Resources” “Digital and<br />

Analog Special Registers”.<br />

Example with TBox MS16 of testing on COM2 (RS485) the quantity of communication errors<br />

and the time the communication error lasts. The variable used is the DCV [Com2.NoReply]<br />

Alarms and Datalogging<br />

You can combine those tests with alarms and datalogging features.<br />

For instance with the above example, the Tag 'Timer1_Status' could be declared as digital<br />

chronology and/or Alarm condition.<br />

9.1. LEDs of communication port<br />

LEDs are very useful as first verification of communication validity:<br />

➢ With TBox MS each serial port and modem are equipped with individual Tx and Rx<br />

LED.<br />

➢ With TBox CPU-3, there are common LED Tx and Rx for all communication ports,<br />

except Ethernet port.<br />

To test ONE port, you should remove connector of the other ports.<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 23


10. IP Setting issues of the TBox<br />

This topic answers basic questions related to IP addresses in TBox.<br />

1. IP address<br />

Each port (all interfaces included) must have a unique IP address<br />

In case you don't follow this rule, result might be unpredictable and might cause lots of<br />

communication trouble.<br />

TBox does not support DHCP (dynamic IP addressing). TBox requires for any of its Ethernet<br />

port, a fix IP address.<br />

2. IP subnet<br />

Be sure the different interfaces are defined into different subnets.<br />

The possible interfaces are: Ethernet of the MS-CPU16, each Ethernet of MS-CPU32, MS-<br />

ETHER, MS-ETHER4, modem.<br />

The subnet is built from the IP address and the subnet mask.<br />

Example:<br />

IP: 192.168.1.99<br />

Mask: 255.255.255.0<br />

The subnet: 192.168.1.xxx (any address in the range 192.168.1.xxx).<br />

About the modem subnet, it<br />

concerns the RTU acting in<br />

'Server' mode (receiving call).<br />

You access its configuration<br />

from the Advanced RTU<br />

properties TCP/IP.<br />

Define a range which is in a<br />

different subnet than any<br />

Ethernet Port of the CPU.<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 24


3. Gateway address<br />

You need the Gateway address for outgoing 'Client' connection, to access an IP address which<br />

is not in the current subnet. For instance when sending e-mail or FTP using an external<br />

Server.<br />

The gateway address is always<br />

in the same subnet as the IP<br />

address<br />

4. IP addresses handling in TBox MS and TBox LITE<br />

IP Forwarding is one of the features of TBox MS and TBox LITE . IP forwarding uses the<br />

following rules:<br />

➢ If you send a request to an existing IP address of the subnet, the device will answer.<br />

➢ If you send a request to an unknown IP address, AND IP Forwarding is not activated,<br />

the request is lost.<br />

➢ If you send a request to an unknown IP address, AND IP Forwarding is activated, the IP<br />

address is tested with all interfaces, starting with the CPU.<br />

If IP address fits with an interface, the interface will answer (like point 1. here above).<br />

Otherwise, the request is lost.<br />

The same in a “computing” format:<br />

1. If (Dest.IP == Netif.IP) then OK --> TCP/UDP, ... else 2.<br />

2. If (IP Forward?) then 3. else Discard.<br />

3. For (all NetIf's)<br />

if (Dest.IP & NetIf.Subnet?)<br />

if (Dest.IP==NetIf.IP) then OK --> TCP/UDP, ...<br />

else IP Output --> Forward<br />

next for<br />

Discard<br />

Dest= Destination<br />

NetIf= Network Interface<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 25


11. Interfacing to SCADA. Clarification about OPC<br />

This topic presents different ways a SCADA software can communicate with TBox.<br />

TBox's native language is ModBus (RTU, ASCII, TCP).<br />

For Tag sampling, TBox uses standard ModBus functions, but as TBox supports<br />

datalogging and alarming, some extra ModBus functions that support time-stamping have<br />

been implemented.<br />

Then, the protocol TBox uses could actually be renamed "time-stamped ModBus".<br />

If a SCADA software wants to communicate with a T TBox and only read locally on-line values,<br />

then you can use standard ModBus protocol (to be more accurate: "J-Bus" protocol. See<br />

chapter 2. above).<br />

Note also that besides embedded ModBus protocols, TBox supports other standard SCADA<br />

protocols: IEC-60870-5-101, -104, DNP3.0, TG800, DF1 serial.<br />

If any customer or SCADA software editor wants to interface their software to TBox and be able<br />

to retrieve historical database or alarms, they have several options.<br />

1. First solution is to write a new driver from scratch knowing the custom functions and<br />

memory organization. This is hard work and the customer should sign a non disclosure<br />

agreement. The disadvantage of this method is also that if we make any change in the<br />

TBox features, or memory organization in the future or if we add new hardware, the<br />

developer will have to develop new code and will have to recompile the whole thing.<br />

For those reasons, we don’t allow users to do this. See next solution.<br />

2. Second solution is to use the "TCOMM.dll" library. The TCOMM handles all difficult<br />

part of the download mechanisms for the programmer so the development of a TBox<br />

interface becomes much easier. One limitation: TCOMM supports only Windows<br />

environment, so no Linux, no Unix...<br />

TCOMM is free of charge and can be downloaded from our WEB site at:<br />

http://tbox.biz/TComm/TComm_dll.php. On this WEB page, you'll find an executable file<br />

that will unzip the library files and gives you the appropriate technical documentation<br />

(PDF format), examples on how to implement the API's in your SCADA.<br />

NOTE: TCOMM does not handle the dial up features to the outstations. Those features<br />

must still be implemented on the SCADA side.<br />

The following SCADA manufacturers have already implemented the complete TBox driver<br />

using TCOMM: Wizcon (Axeda – USA), Factorylink (USData - USA), Citect (Citect -<br />

Australia: driver developed by the french distributor of Citect), Cimview (Aspentech - USA),<br />

Winlab (Germany), Topkapi (Areal - France), Tablegrabber (Projex - The Netherlands),<br />

Acron Connect (Dataforum - Germany), ViewStar (Cegelec - Germany), Cube (Orsi-Siemens<br />

- Italy), PView (Endress+Hauser - Italy), Comsat (Onyx-T+ - France), LabView (National<br />

Instruments - USA), PANORAMA (France). Most of those drivers have a license fee.<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 26


3. Third solution is to use OPC.<br />

OPC topology is:<br />

TBox OPC “Server” OPC “Client” SCADA<br />

OPC concept:<br />

OPC “Server”: ModBus/OPC interface to TBox<br />

OPC “Client”: SCADA driver that connects to the “Server”<br />

OPC-DA: version “Data Access” of the driver. Standard for local sampling only.<br />

OPC-HAD: version “Historical Data Access”. This version should be the best solution<br />

to collect time-stamped data in TBox but is not supported by any SCADA!<br />

Our Slovenian distributor has recently developed an OPC server dedicated to download<br />

data through modem. This OPC Server supports all TBox models (standard TBox, Low<br />

Power devices LP100, LP200 and LP300, TBox MS and TBox LITE).<br />

For all technical and commercial information about this OPC Server, please contact Mr.<br />

Tomaz Remih at ELLAB: tomaz.remih@ellab-tr.si<br />

Another solution, based on OPC-DA, adapted to “time-stamped data” has been<br />

developed by the French company TECHNILOG.<br />

Contact person: Eric Decke at eric.decke@technilog.com. Tel: +33 (0)1 69 18 73 00<br />

4. The newest solution is to use our TVIEW software. TVIEW should be seen as an<br />

intelligent front-end collecting data from any TBox outstations.<br />

TVIEW can collect data by two ways:<br />

Push technology: TBox send data through e-mail or FTP and TVIEW collects it.<br />

Pull technology: TVIEW dials TBox and retrieve data.<br />

TVIEW allows on-the-fly export of data to all RDBMS, incl. SQL, Oracle, Access, etc...<br />

A presentation of TVIEW can be found on http://www.cse-semaphore.com/products/tbox/t-view.php<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 27


12. Transmission time in ModBus protocol<br />

This topic deals with ModBus protocol and the transmission time. It also illustrates the<br />

advantage of using 'Block communication'.<br />

12.1. Block <strong>Communication</strong><br />

TBox can communicate in 'Block' in both 'Slave' and 'Master' mode (see also chapter 3.6).<br />

It means it transfers data of several Tags in one transaction. This reduces data overhead and<br />

therefore communication time.<br />

The rules to use Block communication are:<br />

– Format of Tags<br />

Identical format of Tags in one block (Bool, Word, Float, ...)<br />

– ModBus addresses<br />

Tags with successive ModBus addresses<br />

– Digital Tags<br />

Working with quantity bigger than 8, you have to work with multiples of '8'<br />

12.2.Transmission Time<br />

The transmission time depends on Baudrate and quantity of data transmitted.<br />

In <strong>TWinSoft</strong> on-line Help, you can find general info about 'ModBus protocol'.<br />

REMINDER:<br />

Working at 9600,N, 1 byte transmitted correspond to 10 bits (1 start bit - 8 data bits - 1 stop<br />

bits)<br />

Example: Reading 8 x analog 16 bits variables<br />

Question: 8 bytes:<br />

[Station - Function - Ad(1) - Ad(2) - Qty(1) - Qty(2) - Crc(1) – Crc(2)]<br />

Answer: 21 bytes:<br />

[Station - Function - Qty - Data1(1) - Data1(2) - Data2(1) - Data2(2) - Data3(1) -<br />

Data3(2) - Data4(1) - Data4(2) - Data5(1) - Data5(2) - Data6(1) - Data6(2) -<br />

Data7(1) - Data7(2) - Data8(1) - Data8(2)- Crc(1) - Crc(2)]<br />

Time:<br />

Question: 8 * 10 = 80 bits. At 9600 bps= 1/9600 * 80 = 8.3 ms.<br />

Answer: 21 * 10 = 210 bits. At 9600 bps= 1/9600 * 210 = 21.8 ms.<br />

To this time, you have to add ModBus timeouts:<br />

End of frame detection: which is 3.5 the time of transmitting one character<br />

IFG (time before sending the next question): default = 10 ms.<br />

Then the total time between two questions is: 8.3 + 3.5 + 21.8 + 3.5 + 10 = 47.1 ms.<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 28


13.TCP/IP High End Debug using “WireShark”<br />

This topic explains how to trace a TCP/IP connection using the free ware “WireShark” in case<br />

of communication problem.<br />

Here is the reference to a Window software (Wireshark) to spy TCP/IP communication from a<br />

PC.<br />

You have to install the following software: http://www.wireshark.org<br />

You cable TBox and PC to the same HUB. It is important to use a HUB because we are sure we<br />

see exactly everything going to the TBox.<br />

Start the program ‘Wireshark’. Do not be impressed by the complexity of the interface!<br />

From the main menu, go to Go to the “Capture” → “Options...”:<br />

Set the above configuration (note the ‘Ethernet driver’ interface type. Depending on Ethernet<br />

interface available on your PC, you should find something similar).<br />

Click “Start”<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 29


Further on, to capture new trace, you can click directly from the main menu: 'Capture' <br />

'Start'. Do capture without filter (like example here above), then we are sure we get everything.<br />

To stop capture, press button Stop in the Capture window.<br />

A display filter could be use to filter data and make analyze easier. Typically, you will declare<br />

the IP address of the PC or the TBox.<br />

From the button 'Filters', create a filter with the IP address of the PC. The syntax is (example)<br />

‘ip.addr == 192.168.1.50’<br />

Example of Modbus TCP communication with TwinSoft :<br />

A trace can also be saved with the extension ‘.ACP’<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 30


14. IP address and MAC address ARP Table<br />

This topic explains how to erase the APR table in case of Ethernet communication problem.<br />

The MAC address stays for Media Access Control Address. Each Ethernet interface has a hard<br />

coded unique MAC address which identifies it in the network.<br />

A PC has a table called ARP table which associates each IP address to MAC address. If you<br />

connect several TBox having identical IP address (typically 192.168.1.99), it will be possible to<br />

communicate only with the first one.<br />

When you do not succeed to connect a TBox through Ethernet using <strong>TWinSoft</strong> and you are sure<br />

of the IP address of your TBox, erase the ARP table may solve the problem.<br />

Open a prompt window:<br />

To know the Mac address corresponding to an IP address:<br />

- Connect first to the equipment with your PC, to refresh the ARP table in the PC.<br />

- Type he command “arp -a ”:<br />

To erase completely the ARP table of your PC, type the command “arp -d”<br />

Under VISTA: Open the Command Prompt window by right-clicking the link and selecting<br />

“Run as Administrator.<br />

Version: 1.03 <strong>FAQ</strong>, tips & tricks – COMMUNICATION 31

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!