Monitor - ISSN 1472-0221
The Newsletter for PC-Based Data Acquisition and Control
Issue 187, February 2014
Thanks very much for subscribing. Today we have tips on reading Modus devices over TCP/IP. We also cover how to scroll Excel charts.
You can download Monitor as a pdf file from http://www.windmill.co.uk/monitor/monitor187.pdf
We hope you find Monitor useful, but should you wish to remove yourself from our mailing list you can do so at Monitor Newsletter
Here we explain how to communicate with a Modbus device over TCP/IP using the free ComDebug program. However, the settings apply to other software as well.
In ComDebug, edit an existing instrument file (or create a new one) and choose TCPIP Communications.
The master and slave must use the same port, usually port 502.
Using ComDebug to send a message via TCP/IP
Use the prompt grid in ComDebug's Message screen to send commands and data to your Modbus device. Either type directly into the Hex column or use the NumLock key on the keyboard to enter decimal addresses, codes, etc. Address 1, for example, would be shown as Char 001 and Hex 01.
Each message comprises three parts: modbus application header, function code and data. When more than one byte specifies an item, the most significant byte is sent first.
The Modbus Application Header (MBAP) is a 7-byte header at the start of the message.
The Function Code specifies the type of message. It contains one byte of information (Byte 8).
|Bytes 1 & 2||are a transaction identifier, usually 0 0, but may be different depending on how the system has been set up.|
|Bytes 3 & 4||are a protocol identifier, always 0 0.|
|Bytes 5 & 6||identify the number of bytes to follow. Byte 5 is always 0 as messages are shorter than 256 bytes|
|Byte 7||identifies a unit. It is used when the Modbus device is actually several devices behind a gateway or bridge, and specifies the Slave address of one of those devices.|
|Byte 8|| is the Modbus function code, eg: |
03 (read holding register) or
04 (read input registers)
|Byte 9||is the msb of register: starting address|
|Byte 10||is the lsb of register: starting address|
|Byte 11||is the msb of number of bytes to read: normally 0|
|Byte 12||is the lsb of number of bytes to read: for example 2|
Entering Modbus TCP/IP settings
The function code specifies whether to read, write or perform some other function. Function 03, for example, reads the holding register. This comprises two bytes. You can read or write to a holding register. The function code 04 reads an input register; this can only be read. It may be used to return measured analogue input values such as temperature.
Modbus input registers commonly start counting at 40001. They are addressed with addresses starting at 0. You need to subtract 40001 from the register number to find the starting address. If your register address starts with a 6, for example 62592, convert this number to hex. You can use the converter at the bottom of this page. 62592, for example, converts to F480 and so you would enter F4 into the Hex column of Byte 3 and 80 into the Hex column of Byte 4. Similarly holding register numbers start at 30001. This is really register 0001 (address 0) and is accessed using Modbus function code 03.
The Reply to a Read Input Register Request (TCP/IP) Comprises
Byte 1 = function code (04) Byte 2 = number of bytes read Byte 3 = 1st word, msb Byte 4 = 1st word, lsb Byte 5 = 2nd word, msb Byte 6 = 2nd word, lsb etc
Any questions e-mail [email protected]
In Excel, I can successfully paste the link "Windmill|Data!AllChannels" and obtain all data in a horizontal row but cannot produce data in a vertical column. Is this possible?
Long-term subscribers might recognise this story: we first discussed how to scroll through Excel charts ten years ago in issue 69. It has proved the most popular of our Excel articles, so we thought it worth repeating for our newer readers.
You can download an example spreadsheet showing the scrolling chart in action, and the code behind it, from http://www.windmill.co.uk/scrollchart.xls
Our solution makes use of dynamic named ranges and the fact that you can link a scroll bar to a cell, where scrolling causes the cell's value to change. The speed the chart moves depends on how fast you drag the scroll bar control.
In our example, the scroll bar is linked to cell E5 which holds a row number. We start with 1, but moving the scroll bar to the right increases the row number.
The number of points set in cell E6 acts as a zoom function. The fewer the points more higher the zoom.
We then create two dynamic ranges using the offset function. The number in cell E5 changes as you drag the scroll bar thumb along. This specifies the first row of data to show in the chart. Using offset to create a range, and E5 to specify the row number, means that the range charted changes depending on the value in E5.
If you need any more information please get in touch.
Welcome to our round-up of the data acquisition and control news. If you would like to receive more timely DAQ news updates then follow us on Twitter - @DataAcquisition or Google+ - https://plus.google.com/107072683025496630222/
First graphene radio broadcast
Three letters beamed across a lab bench may spark a revolution in wireless communication. The seemingly simple transmission of "IBM" was received by the first working radio chip to be made from the modern wonder material, graphene - sheets of carbon, each just one atom thick.
Source: The New Scientist
Whale Watching from Space
But not by astronauts or space tourists. Scientists from the British Antarctic Survey are using satellite images to detect and automatically count southern right whales
Source: SCUBA News
Engineers look to low-cost sensors as GPS backup
Researchers are developing a navigation system that can locate itself by scanning the surrounding environment.
Source: The Engineer
Cuttlefish shows the way for ingenious materials composition and structure
Their skin can change colour and pattern in just a second to match their environment. Researchers suggest that the military can learn from the cuttlefish and create "invisible suits". Cuttlefish could also help scientists create paper-thin flexible or wearable displays.
Piezoelectric Sensors Work in Extreme Conditions
New piezoelectric sensors, using novel ingredients such as bismuth and iron, can work at temperatures up to 500 degrees Celcius, providing capabilities not offered by conventional devices.
Source: University of Leeds
* Copyright Windmill Software Ltd
* Reprinting permitted with this notice included
* For more articles see http://www.windmill.co.uk/
We are happy for you to copy and distribute this
newsletter, and use extracts from it on your own web
site or other publication, providing the above notice
is included and a link back to our website is in place.
For previous issues by subject see http://www.windmill.co.uk/monitorindex.html
FREE DATA ACQUISITION SOFTWARE
As a thank you for subscribing we offer you the ComDebug data logging and Com port trouble-shooting software for free. Log data over RS232, RS422, RS485 or Modbus. Also included is a free month's trial of the Windmill 7 logging, charting and control programs.
SUBSCRIBING OR CANCELLING SUBSCRIPTION Visit http://www.windmill.co.uk/newsletter.html and add or remove your e-mail address.
Windmill Software Ltd, PO Box 58, North District Office,
Manchester, M8 8QR, UK
Telephone: +44 (0)161 833 2782
Facsimile: +44 (0)161 833 2190
E-mail: [email protected]
Subscribe to Monitor
Tip: For a speedy response, when using Google+ comments alert us by adding +Windmill Software