Windmill Software Ltd
Data Acquisition Intelligence

Monitor
March 2011

-------------------------Monitor------------------------
The Newsletter for PC-Based Data Acquisition and Control
Issue 151         www.windmill.co.uk       February 2011
--------------------ISSN 1472-0221----------------------

Hello and welcome to Monitor, published by Windmill 
Software.  This year is our 20th anniversary.  To mark 
our birthday we are planning a series of special offers 
throughout the year. We also thought that after 20 years 
our web sites could do with an overhall, so we've started 
with our data acquisition shop site.

In January's Monitor we launched the new Windmill 
data acquisition software for Windows 10, 8, 7, at the special 
price of £50.  This has proved very popular and so we are 
keeping it at this price for the next two months. It is 
available from 
http://www.windmillsoft.com/daqshop/rs232-modbus.html

For several years we have offered you free software to 
collect readings from instruments connected to the 
PC's COM port. This software - Windmill 4.3 with LabIML - 
is now very old and so we would like to offer you some 
new software to replace it. Still free of charge. Read 
the Windmill News below for details or go to 
http://www.windmill.co.uk/windmill7.html

We hope you find the newsletter useful, but should you 
wish to remove yourself from our mailing list please 
go to 
Monitor Newsletter

CONTENTS
========
* Windmill News: Windmill 7 Trial and Free Logging Software
* Interfacing Modbus Devices
* Excel Corner: Logging data, timestamping and showing 
  interval sub-totals
* Data Acquisition and Control News Roundup
________________________________________________________
________________________________________________________

Windmill News: Windmill 7 Trial and Free Logging Software
________________________________________________________

We are delighted to offer you some new free logging software 
for instruments plugged into the PC's COM port. We have 
modified our existing ComDebug application to allow it 
to save data from instruments connected over RS232, 
RS422, RS485 and Modbus.  Previously ComDebug would 
let you see data from these instruments, but would not 
save readings for you.

With the ComDebug download we have also packaged a 
trial of the other major Windmill programs: Logger, 
Chart, DDE and Control Panels.  You can use these, with 
full functionality, for a month. At the end of the 
month's trial you can, if you wish, licence your 
programs and keep using them.  Even if you choose not to 
do this, you can still keep using ComDebug to log data 
from your instrument. 

ComDebug also lets you trouble-shoot data communications 
at the COM port. You can control the state of the PC's 
COM port output lines, setting them high or low. ComDebug 
works with instruments communicating in ASCII or binary.
 
It lets you send ASCII values, twos complement integers, 
unsigned integers, single bits, floating point, CRCs etc, 
to your instrument. You can see all bytes sent and 
received, even non-printing characters like carriage 
returns.  This is crucial when dealing with binary data. 
 
With a flexible approach to building command strings, 
and parsing the received data strings to extract 
data values, the majority of serial analytical 
instruments are supported. These include GPS, sonar, 
digital indicators, gas analysers, pH transmitters, 
data loggers, PIC microcontrollers, titrators, particle 
analysers, pressure transmitters, water baths, hygrometers, 
oxygen electrodes, I2C devices, DMR, plcs and 
laboratory scales.

You can use Windmill to interface up to 10 instruments, 
from different manufacturers.  For example, serial 
devices from A&D, Anton Paar, Advantec, Ashtec, Dataq Instruments, 
Datel, Datataker, Denver, Desoutter, Ecom, Edge Tech, 
Electro Industries, Fisher, Furuno, Garmin, Horiba, 
Mettler Toledo, Microchip Technology, Motorola, 
Molyteck, Newmar, Nu-Metrics, Ohaus, Omnistar, Omron, Orion, 
Parallax, Paroscientific, Patton, Phytron, Quantum Logic, 
Quest Scientific, Sartorius, Siemens, Telegan, 
Telemecanique, Texas Instruments, Transcell and TTi. 
Many channels of data can be accepted from each instrument.

I hope you find the new software useful. Please let us 
know what you think - any suggestions for improvement, 
difficulties you encountered or indeed comments on 
the features you most liked would be appreciated. 

The trial comes with demo setups to get you started, 
with full hypertexed Help files. 
________________________________________________________
________________________________________________________

Interfacing Modbus Devices
________________________________________________________

The free ComDebug can communicate with Modbus devices 
connected to the PC over RS232 or RS485.

The Modbus serial protocol defines two modes of 
transmission: ASCII and RTU (Remote Terminal Unit). 
Windmill supports both modes. 

In ASCII mode each 8-bit byte in a message is sent as 
two ASCII characters. Messages start with a colon and 
end with a Carriage Return followed by a Linefeed.  The 
advantages of ASCII mode is that it allows intervals of 
up to a second to occur between characters without 
causing an error.

RTU mode uses binary coding. Each 8-bit byte in a message 
contains two 4-bit hexadecimal characters. Greater 
character density allows better data throughput than 
ASCII for the same baud rate. Each message is transmitted 
in a continuous stream. The final part of a RTU message 
is a cyclic redundancy check, CRC. This calculates its 
value based on all earlier bytes in the message, it then 
adds its 2 bytes into the message. The computer therefore 
knows when it has received a corrupted message and can 
ask the instrument to resend its data. 

Each message comprises four parts: device address, 
function code, data, error check. 

The Device Address identifies your instrument. It contains 
one byte of information. In ASCII it is coded with 
two hexadecimal characters, in RTU with one byte.  Valid 
addresses are between 0 and 247. 

The Function Code specifies the type of message.  It 
contains one byte of information. In ASCII it is coded 
with two hexadecimal characters, in RTU with one byte.

Windmill supports any mix of digital and analogue inputs 
and outputs. These can be distributed across any set of 
Modbus slave devices.  With ComDebug you can configure 
the slave device address and the parameter number 
(register number) for each channel individually.


Modbus COM Port Settings
========================
This data is the same for all devices on a network. 

ASCII
Start Bit = 1
Data Bits=7
If Parity is even or off then Stop Bits = 1
If Parity is none then Stop Bits = 2

RTU
Start Bit = 1
Data Bits=8
If Parity is even or off then Stop Bits = 1
If Parity is none then Stop Bits = 2

Modbus Settings in ComDebug
===========================

You can enter all your Modbus communication settings 
with our ComDebug program, available free to our 
newsletter subscribers.

Modbus Messages
===============
Use the prompt grid in the ComDebug Terminal screen to 
send commands and data to your Modbus device as a series 
of bytes.  Use the NonPrint menu to enter addresses, 
codes, etc. For example, to enter a device address as 
Byte 1, select NonPrint Decimal from the NonPrint menu. 
Type the device address into the blue box. Address 1, 
for example, would be shown as Char 001 (and Hex 01). 

To Read a Single Modbus Register (RTU)
=====================================
Byte 1 = device address
Byte 2 = Modbus function code: 03 or 04
Byte 3 = msb of register
Byte 4 = lsb of register
Byte 5 = msb of number of bytes to read: normally 0
Byte 6 = lsb of number of bytes to read: for example 2
Byte 7 = CRC: use the CRC menu

The Reply Comprises 
Byte 1 = device address
Byte 2 = function code
Byte 3 = number of bytes read
Byte 4 = 1st word, msb
Byte 5 = 1st word, lsb
Byte 6 = 2nd word, msb
Byte 7 = 2nd word, lsb
etc
Byte n = CRC

To Write to a Register
========================
Byte 1 = device address
Byte 2 = Modbus function code: 06
Byte 3 = address of word, msb
Byte 4 = address of word, lsb
Byte 5 = value of word, msb
Byte 6 = value of word, lsb
Byte 7 = CRC

The Reply Comprises
Byte 1 = device address
Byte 2 = function code: 06
Byte 3 = address of word, msb
Byte 4 = address of word, lsb
Byte 5 = value of word, msb
Byte 6 = value of word, lsb
Byte 7 = CRC

Notes
=====
The function code 03 reads the holding register. 
This comprises 2 bytes and may be used to return 
measured values like temperature.  A holding register 
can be read or written to. The code 04 reads an 
input register; this can only be read. 

The register number is not the same as the address. 
For example, Register 1 is Address 0.

More Information:
=================
Connecting ASCII and RTU Modbus Devices, via RS232 or RS485
________________________________________________________
________________________________________________________

Excel Corner: Logging data, timestamping and showing 
interval sub-totals
________________________________________________________

One of our readers is collecting readings every 
five minutes.  These steadily increase over time. Rather 
than show just the increasing total, in Excel he wanted 
also to see the totals for each five minute interval

To do this you need first to open Windmill DDE Panel 
and show the data there. Once DDE Panel is running you 
can use an Excel macro to grab the data from DDE Panel. 
It will write the data into the spreadsheet, together 
with the time of the reading.  It will also subtract 
the current reading from the last reading to give the 
five minute interval sub-totals.

Copy the macro given below.  Open Excel, create a 
new macro and paste the example into it.

On running the macro you will be asked how many readings 
you want to collect, and the interval between taking the 
readings. Make sure DDE Panel is running before 
starting the macro. 

-

Sub SampleData()

'If NoOfRows = 1, the first data value
'will be placed in row 1.
NoOfRows = 1

'Ask for number of sets of samples and sample interval.
NoOfSamples = Val(InputBox("Please enter no of samples to collect", "No of Samples"))
SamplePeriod = InputBox("Please enter sample interval in seconds", "Sample Interval")

'Coverts interval to fraction of 24 hours
'(Excel expects times in this format).
SamplePeriod = (Val(SamplePeriod)) / 86400

'Initiates conversation with DDE_Panel
ddeChan = DDEInitiate("Windmill", "Data")

'Keeps conversation open until the required
'number of samples have been collected.
While NoOfRows < NoOfSamples + 1

'Requests data from all channels and stores it in
'memory in an array called mydata.
mydata = DDERequest(ddeChan, "AllChannels")

'Selects first sheet in default workbook.
Sheets("Sheet1").Select

'Finds the lower & upper boundaries of array,
'to determine the number of columns needed to
'store the data.
Lower = LBound(mydata, 1)
Upper = UBound(mydata, 1)

'Inserts data from the array into a row of cells.
For Column = Lower To Upper
Cells(NoOfRows, Column).Value = mydata(Column)
Next Column

'Inserts the time into the next column
Column = Upper + 1
Cells(NoOfRows, Column).Value = Now

'Subtracts current reading from previous reading
'and inserts it into the next column
Column = Upper + 2
Cells(NoOfRows, Column).Value = "=RC[-2]-R[-2]C[-2]"

'Waits for the specified sample interval
Application.Wait (Now + SamplePeriod)

'Increments number of rows, so next set of samples
'is inserted in the next row down.
NoOfRows = NoOfRows + 1

'Stops loop when required sets of samples collected.
Wend

'Closes DDE Connection
DDETerminate (ddeChan)
End Sub
-

Further Reading:
Using Excel for data acquisition
________________________________________________________
________________________________________________________

DAQ News Roundup
________________________________________________________

Welcome to our roundup of the data acquisition and 
control news.  If you would like to receive more 
timely DAQ news updates then grab our RSS newsfeed 
at http://www.windmillsoft.com/monitor.xml.  Read 
http://www.windmill.co.uk/newsfeed.php for notes
on how to display the live news on your own web site.

Bee sensor picks up queen bee's farewell vibes
   Accelerometers embedded into the walls of a 
   beehive can help beekeepers prepare for the moment 
   when the queen bee deserts the hive. The 
   accelerometers detect the motion caused by the 
   buzzing insects. The sensors are hooked up to a 
   computer to monitor changes in the hives' 
   vibrations over five months.
   Source: New Scientist
   http://www.newscientist.com/

Researchers double the speed of wireless networks
   A new technology that allows wireless signals 
   to be sent and received simultaneously on a 
   single channel has been developed by Stanford 
   researchers.  Up until now, when a radio is 
   transmitting, its own transmission is billions 
   of times stronger than anything else it might 
   hear from another radio. "It's trying to hear 
   a whisper while you yourself are shouting." If 
   a radio receiver could filter out the signal from 
   its own transmitter, weak incoming signals could 
   be heard, doubling the communication speed.
   Source: Stanford University
   http://news.stanford.edu/news/

UV-Spectroscopic Methods Transformed
   Image sensors as used in cell phones are 
   partially colour-blind. This is because of their 
   coating, which prevents UV light from passing 
   through. CMOS chips have as a result not been 
   suitable for spectroscopy up to now. A new 
   production process makes the coating transparent. 
   This could revolutionize UV spectroscopic methods, 
   which are used in laboratories around the world, 
   significantly improving their accuracy. 
   Source: Eureka
   http://www.eurekalert.org/

New Sensor Designed to Accurately Measure Strain
on Curved Mounting Surfaces
   Columbia Research Laboratories has introduced a 
   new sensor to measure circumferential strain around 
   the diameter of the surface to which it is mounted. 
   Source: Columbia Research Laboratories
   http://tinyurl.com/68x8pot

Global Investment in Smart Water Meters to Rise
   During the past century, demand for water has 
   increased by more than twice the rate of population 
   growth. Water utilities are increasingly turning to 
   advanced sensor networks and automation systems to 
   enable more accurate leak detection.  One of the 
   most important strategies for utilities will be 
   the installation of smart water meters on 
   customer's premises. According to a recent report 
   from Pike Research, cumulative global investment in 
   smart water meters will total $4.2 billion during the 
   years from 2010 to 2016
   Source: Pike Research
   http://www.pikeresearch.com/

________________________________________________________ ________________________________________________________ * 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 publication, providing the above notice is included and a link back to our website is in place. An archive of previous issues is at http://www.windmill.co.uk/newsletter.html and an index of articles at http://www.windmill.co.uk/newsletter.html 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] http://www.windmill.co.uk/ http://www.windmillsoft.com/

Subscribing

To receive Monitor every month please fill in your e-mail address below. We will not pass your address to any third parties, nor send you any unsolicited e-mail.

Subscribe Monitor

You will receive an e-mail confirming your subscription, with details of how to download the free software. If you don't receive this then your spam filter may be blocking our message. Make sure it is set to accept messages from [email protected] If you have problems contact the Editor.

Previous Issue Next Issue