Windmill Software Ltd
Windows Engineering Software

Monitor
December 2004

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

Welcome to December's Monitor. We wish you a peaceful 
New Year.

Should you wish to cancel your subscription to Monitor 
you can do so at 
http://www.windmill.co.uk/newsletter.html

CONTENTS
========
* Windmill News: Data Acquisition News Available via PHP
* Windmill Notes: Manually Entering Data into a Log File 
* Excel Corner: Time Stamping in Tenths of Seconds
________________________________________________________
________________________________________________________

Windmill News: Data Acquisition News Available via PHP
________________________________________________________

You can now display live news headlines in your web site 
using PHP.  The news is selected by human editors and so 
is guaranteed relevant to the data acquisition, control, 
measurement and instrumentation fields. For how to do 
this see
http://www.windmill.co.uk/newsfeed.php

You can also keep up-to-date by having the news 
delivered by e-mail, view it in news aggregator 
software or show it in a "ticker" on your PC's 
desktop.  Again, details are at 
http://www.windmill.co.uk/newsfeed.php 

If you already receive other RSS news feeds you can grab 
ours at https://www.windmillsoft.com/monitor.xml
________________________________________________________
________________________________________________________

Windmill Notes: Manually Entering Data into a Log File
________________________________________________________

The Windmill Logger program saves data from sensors and 
instruments in an ASCII file.  It also records the time 
of each reading.  There may be occasions, though, when 
you want to include other data in the file.  For example, 
you might want to make a note of a batch number or 
include somebody's name.  You can do this in Windmill 
using the Blackboard and AnalogOut programs.

AnalogOut is included with every copy of the Windmill 
suite.  Amongst other things, it lets you use the 
computer's keyboard to enter data into the sytem.  You 
also need the Blackboard program to store the data until 
it is picked up by Windmill Logger.  You can think of 
AnalogOut as chalking words and numbers onto the 
Blackboard, where they remain for a pre-specified time.  
During this time Logger can read the information and 
save it alongside the other data it is collecting.

Further Reading
===============
For more on Blackboard and AnalogOut, either see their 
Help files or contact [email protected]  The latest 
versions of the Help files are available from
http://www.windmill.co.uk/help.html
________________________________________________________
________________________________________________________

Excel Corner: Time Stamping in Tenths of Seconds
________________________________________________________

In Issue 74 of Monitor I explained how to use Excel to 
log data from instruments, and also display the time of 
each data reading.  That method displayed the time to 
the nearest second.  But what if you are logging data 
quicker than once a second?  This month I explain how 
to display the time in fractions of a second.

First of all decide how many columns of logged data 
you are going to need.  In this example I'll assume you 
are logging from one data channel and placing the 
readings in column A.  The time stamp will be placed 
in the next column - column B in my example - and you 
need to format this column to show fractions of a
second.

Formatting the Time Stamp Column
================================
1. Select the entire column by clicking on its letter.
2. From the Format menu choose Cells.
3. Select the Custom Number category.
4. Into the Type: box, enter hh:mm:ss.0 for tenths of 
   seconds or hh:mm:ss.00 for hundredths of seconds. 
   If you would also like the date inserted, type 
   instead dd/mm/yy hh:mm:ss.0

Getting the Time
================
You now need to insert this formula into an unused cell:
=NOW()

For example, into cell C1.

You are now ready to create the macro to collect data. 
Copy the code below, but edit this line so it references 
the cell containing the NOW formula.
Cells(NoOfRows, Column).Value = Range("C1")

--

'Start of 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 to be collected.
NoOfSamples = Val(InputBox("Please enter no of samples to collect", "No of Samples"))

'Ask for the time to wait between taking each set 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 Windmill 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.
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 = Range("C1")

'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

'End of Macro

--

Further Reading
===============
For more on using Excel with Windmill see
http://www.windmill.co.uk/excel/
________________________________________________________
________________________________________________________

* 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/

https://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.

Email:
Format:

Previous Issue Next Issue