Windmill Data Acquisition Software Logo
28 April, 2004

Windmill Software
Data Acquisition Intelligence
Call now: +44 (0)161 834 6688

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

Welcome to April's Monitor.  We hope you find it useful, 
but should you wish to cancel your subscription please 
do so at 
https://www.windmill.co.uk/newsletter.html

CONTENTS
========
* Windmill News: Windmill Detects PLC Communications
* Excel Corner: Scrolling through a Chart
* Monitoring Current Signals
* Windmill Notes: Parsing Data with the Free Windmill
________________________________________________________
________________________________________________________

Windmill News: 
Windmill Detects Siemens PLC Communications
________________________________________________________

The Siemens S5 programmable logic controllers have been 
widely used for automation purposes around the world. 
Although now superseded by the S7, there are many still 
in use. One of our readers was studying the properties 
of the S5's serial connection, with a view to writing 
his own software to communicate with this plc. He 
downloaded Windmill ComDebug and found that..."it was 
the most simple way to detect the right data used for 
communication".  Windmill speeded up his programming 
task and helped him identify and eliminate data transfer 
errors.

You can download Windmill ComDebug from
https://www.windmill.co.uk/serial.html

________________________________________________________
________________________________________________________

Excel Corner: Scrolling through a Chart
________________________________________________________

With a continuous data logging program like Windmill 
Logger, you can very quickly collect a vast amount of 
data.  There are times when you might want to replay the 
data as a moving chart.

With a little ingenuity you can create a chart which you 
can scroll through in Excel. The speed the chart 
moves depends on how fast you drag the scroll bar control. Our 
explanation of how to do this (below) will probably be 
easier to understand if you download our example 
spreadsheet from 
https://www.windmill.co.uk/scrollchart.xls. (This is an 
Excel 2002 spreadsheet. For other versions of Excel 
you can download our example Logger file, 
https://www.windmill.co.uk/scroll.wl, and follow the 
instructions below.)

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.

Say you have imported a Windmill Logger file into Excel 
which has time in the first column (A) and voltage 
readings in the second column (B).  You want to chart 
the voltage signal against time.

Defining Dynamic Ranges with the Offset Function
================================================

First you need to define two dynamic ranges. To do this 
we're going to use the Offset function, which returns a 
cell reference according to your settings.  

To create our ranges:
1. From the Insert menu choose Name then Define.
2. Type Time into the Names box and 
   =OFFSET(Sheet1!$A$6,Sheet1!$E$5,0,Sheet1!$E$6,1) 
   into the Refers to box. 
   Click Add.
3. Type Signal into the Names box and 
   =OFFSET(Sheet1!$A$6,Sheet1!$E$5,1,Sheet1!$E$6,1) 
   into the Refers to box. 
   Click Add.
4. Click OK.

This is the syntax of Offset: 

OFFSET(reference, rows, cols, height, width)

Reference is the location from which you want to base 
the offset.  In our example this is the leftmost cell 
immediately above the data: A6. 

Rows and columns define how far away the offset is from 
the reference cell.  We want the row number to change as 
we scroll the chart, so we don't use an absolute value 
for rows.  Instead, we'll put the rows value into cell 
E5, and link this to the scroll bar.

Columns tells us whether we are referring to time 
(column 0) or voltage (column 1) readings. 

In our example, height is the number of rows of data to 
be displayed at any one time on the chart.  That is, the 
number of data items to be shown.  We could enter a 
number for this, 30 say.  However, if we enter the 
height value into a cell and reference that, we can then 
change this value and zoom in and out of the chart. 
We'll use E6 to store the number of data points to be 
displayed.

Finally the width value. This is the number of columns 
of the returned reference, or, in our example, the 
number of data series in the chart. For our chart this 
is 1.

Entering the Row Number and Data Points to be Displayed
=======================================================

We now need to set our row number (E5) and number of 
data points displayed (E6).  Enter 1 into E5 and 30 into 
E6.  (Remember, dragging the scroll bar will change the 
value in E5 and hence the row of data displayed.)

Creating the Chart
==================

We can now create the chart.
1. From the Insert menu choose Chart. 
2. Select Line as the Chart type and press Next.
3. Click the Series Tab. Press Add. Type into the boxes 
   as follows:
   Name: Chan_1
   Values: =Sheet1!Signal
   Category (X) axis labels: =Sheet1!Time
   
You should see a chart of the first 30 data values. 

You now need to fix the y axis, so it doesn't expand or 
contract when another set of data is shown. 
1. Right-click the y axis.
2. Select Format axis and the Scale tab.
3. Clear all the auto boxes and make sure that the 
   maximum and minimum values span your data. In our 
   example these are +10 and -10 (Volts).

Inserting the Scrollbar
=======================

The next step is to insert a scrollbar control.

1. From the View menu select Toolbars and show the 
   Control Toolbox.
2. Click the scrollbar control. (Click off the chart to 
   do this.)
3. On the worksheet, drag the scrollbar to the size you 
   want.
4. Right-click the scrollbar and select properties.
5. Enter E5 as the Linked Cell.
6. Set the minimum value to be 1 and the maximum value 
   to be the number of rows of data you have.
7. Click the Set-Square and Pencil icon on the Control 
   Toolbox to exit Design mode.

Zooming Into the Chart
======================

To zoom into the chart simply change the figure in E6: 
the number of data points displayed. The less data 
points the greater the magnification and vice versa.

Further Reading:
================

Our method is a modified version of Andy Pope's 
scrolling chart example - 
http://www.andypope.info/charts/Scrolling.htm

Other Excel Charting Tips
https://www.windmill.co.uk/excel/excel-charting.html

Windmill Replay, which also scrolls charts
https://www.windmill.co.uk/replay.html

Comments
========
________________________________________________________ ________________________________________________________ Monitoring Current Signals ________________________________________________________ Current is often used to transmit signals in noisy environments, especially where there is a long distance between the measurement point and the data acquisition system. This is because current is much less affected by environmental noise pick-up. The full scale range of the current signal is normally either 4-20 mA or 0-20 mA. A 4-20 mA signal has the advantage that even at minimum signal value there should be a detectable current flowing. The absence of this indicates a wiring problem. Before the data acquisition equipment can digitise the current signal and transfer it to the computer, a current-sensing resistor is usually used to convert the current to a voltage. The resistor should be of high precision (consider how much resolution the analogue-to-digital converter will give you). It should also match the signal to an input range of the analogue input hardware. For 4-20 mA signals a 50 ohm resistor will give a voltage of 1 V for a 20 mA signal (V=IR). Choose 0.03% or 0.01% resistor accuracy. The accuracy is a measure of the long-term stability of the resistor and its tolerance to temperature changes. ________________________________________________________ ________________________________________________________ Windmill Notes: Parsing Data with the Free Windmill ________________________________________________________ If you have an instrument or device which you can plug into the PC's COM port, and it communicates using ASCII messages, chances are you can use the free Windmill software to collect its data. This is because Windmill's free LabIML driver was designed to be as flexible as possible and accommodate almost any instrument with an RS232 port. However, this flexibility has meant that the initial set up can be a case of trial and error. These notes should reduce the error and help you decide the best way to interpret, or parse, the messages from your instrument. (Our latest serial driver is more transparent, see https://www.windmillsoft.com/daqshop/rs232-modbus.html for details.) When an instrument sends a message it rarely just contains data. All sorts of extra characters and codes are in there. Here are some examples of messages. A weighing scale might send: + 125.32 g A GPS receiver might send: $GPGLL,5330.12,N,00215.31,W,134531,A A Parallax BASIC Stamp might send: +66.4 A spectrophotometer might send: DR/4000U S/N: 9807U0000905 2.303-APR-04 10:05:56 MULTI-WAVELENGTHGroup 0000 Sample 0002 -0.000 ABSA=K1A1+K2A2 665.0 nm -0.004 ABS K1: 1.0000 750.0 nm - 0.004 ABS K2: -1.0000 These examples show why Windmill needs to be flexible in extracting the relevant data from the message. It's not only message formats that vary. Some instruments need a command prompt from Windmill before they will send data, others initiate data transfer themselves - often regularly sending data. In this case the message can be considered as a continuous stream of data that has a recurring pattern. LabIML calls an instrument that sends one message after a command a Request/Response instrument. Devices which constantly send data are called Continuous Flow instruments. To set up parsing instructions use the Windmill ConfIML software and select the LabIML driver. Go to the Channels settings. The first thing to do is to locate the data. You can do this by: 1. Searching for specific characters in the message string. 2. Ignoring characters until one of the ones in which you are interested appears. 3. Ignoring a number of characters in the message string. At first glance methods 1 and 2 seem to do the same job. However, when you search for characters the next action occurs AFTER the searched for characters. When you ignore characters the next action occurs ON the specified character. So if you searched for a + sign you would not be able to extract it, but if you ignored all characters until the + sign you would. Also, a search will look for the entire string specified (eg "abc"), whilst ignoring characters will stop at any of the characters specified (eg "a" or "b" or "c"). Be aware that with instruments that constantly send data LabIML will not know where the beginning of the message is. So, using the GPS example above, it's no use ignoring 8 characters and expecting the next value to be a latitude reading. Instead search for a unique string such as $GPGLL. Once you've located the data you need to extract it. There are two ways to do this: 1. Extract until a specified character. 2. Extract the next so many characters. Using the GPS receiver as an example again $GPGLL,5330.12,N,00215.31,W,134531,A The data we might want to record from this string is the latitude and the longitude. These are the 5330.12 and 00215.31 figures respectively. We should have already created 2 channels: one to hold the latitude readings and one to hold the longitude. For the latitude channel we might: Search for $GPGLL, and extract until , For the longitude we might: Search for N, and extract until , As another example, the BASIC Stamp might continually send a reading comprising a leading sign character, a trailing carriage return to mark the end of data and a maximum length of six characters. For example -55.27 or +66.4 (where is the carriage return. In this case we could ignore all characters until we reach the + or - sign, and then extract all data up to the carriage return. This translates in LabIML's parse string to \I"+-"\E"\C013" When you are extracting several channels of data from a string, note that if you have chosen a continuous flow protocol, the parsing proceeds along the string for each channel. For a request/response protocol though, the parser goes back to the beginning of the string each time for each channel. -- Further Reading: The LabIML Help file. You can download the latest version of this from https://www.windmill.co.uk/help.html Our notes on - software for GPS receivers software for Sartorius balances software for Mettler Toledo balances software for Desoutter torque meters software for Molytek loggers software for Parallax BASIC Stamps ________________________________________________________ ________________________________________________________ * 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

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.

Previous Issue Next Issue