Windmill Software Ltd
Windows Engineering Software

Monitor
September 2004

-------------------------Monitor------------------------
The Newsletter for PC-Based Data Acquisition and Control
Issue 74          www.windmill.co.uk      September 2004
--------------------ISSN 1472-0221----------------------

Welcome to September's edition of Monitor.  We hope you 
enjoy this issue, but should you wish to cancel your 
subscription you can do so at 
https://www.windmill.co.uk/newsletter.html

CONTENTS
========
* Windmill News: Live Instrumentation News Summaries
* Interfacing Instruments with RS232 Ports: 
  Handshaking Explained
* Excel Corner: Adding a Time Stamp to Logged Data
________________________________________________________
________________________________________________________

Windmill News: Live Instrumentation News Summaries
________________________________________________________

If you have put our live news headlines on data 
acquisition and control onto your web site, then 
thank you. We hope you are pleased with the results. We 
welcome any suggestions on the news feed: e-mail 
monitor@windmillsoft.com.

You can now also add short summaries of the news to your 
web pages. To do this edit the javascript code given at 
https://www.windmill.co.uk/newsfeed.php, 
and change feed_compact=1 to feed_compact=0

The news feed regularly updates on your page - giving 
your visitors the latest news in one place.  The news 
changes daily and is completely free.  It is selected 
by human editors, not by a computer program, and so is 
guaranteed relevant to the data acquisition, control, 
measurement and instrumentation fields.

For full details of incorporating live news into your 
web site see
https://www.windmill.co.uk/newsfeed.php
________________________________________________________
________________________________________________________

Interfacing Instruments with RS232 Ports: 
Handshaking Explained
________________________________________________________

Windmill software lets you connect RS232 instruments to 
your computer.  As a subscriber to this newsletter you 
can download Version 4.3 of the software for free.  
Alternatively, if you would prefer the up-to-date 
release (called COMIML 6), you can buy this from 
https://www.windmillsoft.com/daqshop/rs232-modbus.html

The RS232 protocol includes handshaking.  Although this 
is often not necessary, it has two functions.
1. It allows the computer to stop your instrument from 
   sending data when the PC is not ready for it. 
2. It allows your instrument to prevent the PC from 
   sending data when the instrument not ready for it. 

The fact that your instrument comes equipped with inputs 
and outputs that can be used for handshaking is no 
guarantee that handshaking is needed.  Unless you know 
differently, when connecting the instrument to the PC it 
is best to start with the assumption that handshaking is 
not required.

If you start with no handshaking what symptoms might 
indicate that it really is needed?.  Well one possibility 
is that the computer misses part of a message because its 
input buffer overflows.  With Windmill's COMIML software 
the buffers are 3000 bytes long so you are unlikely to be 
bothered by this problem. The other possibility is that 
the instrument misses part of a message sent by the 
computer. This will probably cause the instrument not to 
work properly.

There are two types of handshaking: hardware and 
software.

Software Handshaking
====================
Xon \ Xoff Handshaking is a software protocol that is 
often used to control data flow.  Suppose that the 
computer were sending data to an instrument which could 
accept no more data for the time being - the instrument 
would send the single Xoff character to the computer 
which would stop sending data until it received an Xon 
character to restart transmission. The same arrangements 
would apply for the reverse direction of data flow. 

Xon is ASCII character 17 and Xoff ASCII character 19.

Hardware Handshaking
====================
Handware handshaking is not often used, so you can tie
any potential handshake lines to fixed voltages so that 
they do not affect operation. In fact many manufacturers 
add tying resistors to handshake lines so that if you do 
not want to use them you simply make no connection.

If you do decide that handshaking must be used then you 
need to know which lines your communications software 
(such as COMIML) and your instrument use. COMIML, for 
example, uses the DTR (Data Terminal Ready) line to 
indicate when it is able to receive data.  Other 
programs may use the RTS (request to Send) line.  The 
instrument will probably use the CTS (Clear To Send) 
line to indicate when it is ready to receive data.  Once 
you select hardware handshaking in COMIML, the state of 
the CTS input to the computer becomes important. When 
hardware handshake is not selected the CTS line state is 
ignored.  COMIML keeps the DTR output permanently high. 

Further Reading
===============
The COMIML serial driver
https://www.windmillsoft.com/
Serial Ports and RS232 Communications
https://www.windmill.co.uk/rs232-communication.html	
________________________________________________________

Excel Corner: Adding a Time Stamp to Logged Data
________________________________________________________

When the Windmill Logger program saves data, it "stamps" 
each reading with the time and date that it was 
collected.  You can also do this in Excel, by means of a 
macro and the Windmill DDE Panel.

The macro below repeatedly samples data from all the 
instruments' channels and stores the data in Sheet1. It 
then inserts the timestamp at the end of the row.  When 
the macro runs you are asked how many times to sample 
all the channels, and the interval between taking sets 
of samples.  Make sure that Windmill DDE Panel is 
running and displaying data before running the macro.

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

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")

' Convert to milliseconds - needed for sleep statement below.
SamplePeriod = SamplePeriod * 1000

'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")

'Ignores any warning messages which would halt the macro
On Error Resume Next

'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 in Sheet 1.
For Column = Lower To Upper
Sheets("Sheet1").Cells(NoOfRows, Column).Value = mydata(Column)
Next Column

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

'Waits for the specified sample interval
Sleep 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
DDETerminate (ddeChan)
End Sub

--

Notes: This macro is a modified version of one given at 
https://www.windmill.co.uk/excel/.  If you are already 
using this then just insert these lines of code at the 
relevant place.

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

Further Reading
===============
More on using Excel for data acquisition...
For more on data logging with Windmill Logger...
________________________________________________________
________________________________________________________

* Copyright Windmill Software Ltd
* Reprinting permitted with this notice included
* For more articles see https://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 
https://www.windmill.co.uk/newsletter.html
and an index of articles at 
https://www.windmill.co.uk/newsletter.html

Windmill Software Ltd, PO Box 58, North District Office,
Manchester, M8 8QR, UK
Telephone: +44 (0)161 834 6688
Facsimile: +44 (0)161 833 2190
E-mail: monitor@windmillsoft.com
https://www.windmill.co.uk/
https://www.windmillsoft.com/


Subscribing

Previous Issue Next Issue