data logger for igor pro help file - university of minnesota · • data logger for igor pro ......

16
8/16/2005 Data Logger Help.ihf 1 Data Logger for Igor Pro Written by Tony Withers (http://www.umn.edu/~withe012). For Igor Pro 5.03. Overview Data Logger for Igor Pro is designed to display and record data collected through serial communication with equipment using the RS232 or RS485 protocols. The Data Logger is written as an Igor Pro macro to take advantage of Igor's flexible graphing and analysis environment. Many data logging programs save data at some fixed frequency. In choosing the frequency of acquisition, one must make a compromise between size of the data file and chances of recording a transient event. The algorithm used in Data Logger for Igor Pro dispenses with the fixed frequency idea, instead using a few simple parameters to decide whether data should be recorded. In this way, interesting events are recorded at the highest frequency possible, while uneventful periods result in a smaller number of recorded data. The user interface for the data logger provides an easy way to define the interface parameters required to interface with most laboratory equipment. In addition, I use Data Logger for Igor Pro to publish data logs on the web as they're recorded, and to send automated email alerts when pre-defined alarm conditions are encountered. Requirements Igor Pro version 5.03. RS232 capable device connected to the computer's serial port (RS485 devices may be connected through a suitable converter). Some features of the data logger rely on external programs. The data logger is functional without these programs; they are only required for real time web publishing and automated email capabilities. These programs only work with Windows. For web publishing using the secure shell 2 protocol with private key, you need to install the Windows version of the secure copy 2 tool (scp2.exe). This is included in the SSH Secure Shell for Workstations Windows client, which may be downloaded from ssh.com: ftp://metalab.unc.edu/pub/packages/security/ssh/SSHSecureShellClient-3.2.5.exe This software may be free for non-commercial and university use (check www.ssh.com for details). For real time publishing of compressed data files on the web, I use the command line pkzipc.exe utility. A self-extracting installation file containing the shareware version of pkzipc (pkzc400s.exe) may be downloaded from many shareware distributors (see www.pkware.com for details). For automated email capability, a Windows command line equivalent of the UNIX sendmail, postie.exe, is required. Postie (Personal Edition WIN32) may be downloaded from http://ftp.infradig.com/download.shtml, and may be free for personal use/evaluation (check www.infradig.com for details). Disclaimer Copyright © 2003 Anthony C Withers All rights reserved.

Upload: vungoc

Post on 07-Jun-2018

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 1

• Data Logger for Igor Pro

Written by Tony Withers (http://www.umn.edu/~withe012).For Igor Pro 5.03.

• Overview

Data Logger for Igor Pro is designed to display and record data collected through serial communication with equipment using the RS232 or RS485 protocols. The Data Logger is written as an Igor Pro macro to take advantage of Igor's flexible graphing and analysis environment. Many data logging programs save data at some fixed frequency. In choosing the frequency of acquisition, one must make a compromise between size of the data file and chances of recording a transient event. The algorithm used in Data Logger for Igor Pro dispenses with the fixed frequency idea, instead using a few simple parameters to decide whether data should be recorded. In this way, interesting events are recorded at the highest frequency possible, while uneventful periods result in a smaller number of recorded data. The user interface for the data logger provides an easy way to define the interface parameters required to interface with most laboratory equipment. In addition, I use Data Logger for Igor Pro to publish data logs on the web as they're recorded, and to send automated email alerts when pre-defined alarm conditions are encountered.

• Requirements

• Igor Pro version 5.03.

• RS232 capable device connected to the computer's serial port (RS485 devices may be connected through a suitable converter).

• Some features of the data logger rely on external programs. The data logger is functional without these programs; they are only required for real time web publishing and automated email capabilities. These programs only work with Windows.

For web publishing using the secure shell 2 protocol with private key, you need to install the Windows version of the secure copy 2 tool (scp2.exe). This is included in the SSH Secure Shell for Workstations Windows client, which may be downloaded from ssh.com:ftp://metalab.unc.edu/pub/packages/security/ssh/SSHSecureShellClient-3.2.5.exeThis software may be free for non-commercial and university use (check www.ssh.com for details).

For real time publishing of compressed data files on the web, I use the command line pkzipc.exe utility. A self-extracting installation file containing the shareware version of pkzipc (pkzc400s.exe) may be downloaded from many shareware distributors (see www.pkware.com for details).

For automated email capability, a Windows command line equivalent of the UNIX sendmail, postie.exe, is required. Postie (Personal Edition WIN32) may be downloaded from http://ftp.infradig.com/download.shtml, and may be free for personal use/evaluation (check www.infradig.com for details).

• Disclaimer

Copyright © 2003 Anthony C Withers

All rights reserved.

Page 2: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 2

Redistribution and use in source form, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Neither the name of the Author nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

• Limitations

Up to ten channels of data can be monitored and recorded. The acquisition frequency will depend primarily on the communications speed of the external device(s). The data logger routine allows a maximum cycle speed (without any communications overhead) of around 40 Hz when recording simulated data from ten channels on my 800 MHz PIII computer. The data logger is designed to send and receive ASCII characters, the received characters being interpreted as a numerical value. Up to eight serial ports are supported. I have not tested the procedures with many screen resolutions: 1280x1024 and 1024x768 seem to work. Some windows may be drawn off-screen if the resolution is too low. At the time of writing I have started to test the data logger with Igor 5 and Windows 2000/XP.

• Setting up Data Logger for Igor Pro

Method 1: Automated installation using the InstallDataLoggerForIgorPro.pxp file. Simply open the file and Igor should automatically install all the necessary files. I haven't used any overwrite options, but if you are not comfortable running a procedure which will write files to your hard drive you may perform a manual installation as described below.

Method 2: Download the required files (DataLogger.zip). All the files included in the package should be extracted to a folder within the User Procedures folder (ideally :Igor Pro Folder:User Procedures:Data Logger:). A shortcut to the VDT2 XOP should be placed in the Igor Extensions folder (VDT lives in the More Extensions:Data Acquisition: folder. You may want to put a shortcut to Data Logger.ipf in the Igor Procedures folder.

Start (or restart) Igor Pro and open the procedure file DataLogger.ipf, compile and hide the file (you can skip this step if you've put a shortcut in the Igor Procedures folder). If you have compilation errors, it's possible that there are conflicts with functions in other procedures that you use (see Advanced Details for Igor Pros). Open the help file (Data Logger Help.ihf)

From the Logger menu, choose Initialise Data Logger. Two windows should open - the main Data Logger Control panel and the Log Graph window. The default settings for the data logger when it is first run is to create two "channels" for monitoring and recording two streams of data. Since we do not have any external devices set up yet, these two channels are initially set to simulate data acquisition. It's a good idea to play with the simulation to familiarise yourself with the basic workings of the data logger.

Page 3: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 3

• Data Logger Windows

Data Logger Control

At the top of the Data Logger Control panel are three buttons:

• START/STOP: Starts and stops the Data Logger. Think of this as the Power On switch: you can turn individual channels on and off, but nothing will happen unless the logger is turned on.

• Reset: Clears the current log allowing you to start over.

• Exit: Closes the data logger. When the logger is active, the reset and exit buttons are disabled. You must use the Start/Stop button to stop the logger before you can exit.

At the top right is a Time Counter. When the logger is active the current time should be displayed here. If the time counter freezes, something bad has happened (e.g. a compilation error), and you will have to stop and start the logger to reactivate it. When the logger is stopped the time counter should display 00:00:00.

Beneath the time counter the Experiment ID can be set. This text will form the basis of names for files which will be saved as the log progresses. Note that choosing the same name as an earlier log could cause a file to be overwritten.

The Acquisition Rate readout gives a rough indication of the current frequency of data reading. Note that this is not normally equal to the recording rate. Starting and stopping the log will result in an inaccurate estimation of acquisition rate. Because the acquisition rate refers to the frequency of data collection for each channel, the total number of readings per second is calculated by multiplying the acquisition rate by the number of channels being monitored.

Each signal (e.g. voltage, current etc.) is stored as a "channel" of data. Multiple channels may be recorded from a single device, using the same serial port and communication settings. If multiple devices on an RS485 network are connected by means of an RS232-485 converter to a single serial port, we would want to have multiple channels and a single set of

Page 4: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 4

communication parameters. Up to ten channels can be recorded from up to eight com ports using the VDT2 XOP.

Within the Channels groupbox are radio buttons to turn individual channels On and Off. When a channel is turned on, its current value is displayed in the box to the right of the channel label. When the channel is turned off, or when the data logger cannot read the value of that channel, the display will read NaN ("not a number"). The Rec checkboxes toggle recording of a channel. When a channel is being recorded, a trace will appear in the Log Graph window.

Tip: Holding down the shift key while clicking Off, On or Rec buttons will change the status of all channels simultaneously.

The four buttons in the Settings area at the bottom of the Data Logger Control panel open more control panels in which many settings can be adjusted:

• Log settings: Opens the Set Log Options panel to set acquisition parameters and instrument settings.

• Display Settings: Opens the Display Controls panel to scale axes of log graph and choose channels to be displayed.

• File Settings: Opens the File Control panel, to load and save logs and edit server settings.

• Alarm Settings: Opens the Set Alarm Conditions panel to define and activate alarms

Log Graph Window

When a channel is being recorded a trace will appear in the Log Graph window. As values are read from a device, the readings are plotted as a faint-coloured trace. Data that are saved are

Page 5: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 5

plotted over the top of the monitored data in a darker colour. When most of the data are being saved, you may not be able to see the faint trace. As data scrolls out of the display window, the readings which make up the faint traces are not saved. The appearance of the Log Graph window can be adjusted through the Display Controls and Set Log Options panels. If you have some experience in using Igor, you can further tweak the Log Graph appearance by editing the DataLoggerGraphStyle function in the Data Logger User Functions procedure window (choose Edit User Funcs in the Logger submenu of the Macros menu). When multiple channels are plotted on the same vertical axis, the axis is labeled for the first channel, and a "+" is appended to the axis label to indicate that other channels are plotted on the axis.

If web publishing is active (see Set Log Options panel) and a remote summary file name is set (see Server Settings panel), from time to time the Log Graph will automatically rescale to show the full range of data, and an image file of this graph is copied to the server before the graph returns to its previous view.

Set Log Options

• Update Interval for Tracking: Sets the time interval for rescaling the x-axis of the Log Graph so that newly acquired data are plotted in the window and older data scroll out of the window.

• Display Range for Tracking: The maximum range of the x-axis for normal "tracking" view. If a summary plot is published on the web, this will also set the time interval between making and saving summary plots. See Web Server Settings.

• Maximum Interval Between Recordings: When there is no other activity to trigger recording, new data will be recorded after this interval.

• Save Interval: Time between successive saves. The Igor experiment is saved and, if a Save Path has been set, an external log file is updated after this interval. The location of the external file can be set in the Server Settings panel.

Page 6: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 6

• Channel Threshold: If the current value for a channel deviates by more than this threshold from the last saved value, the current value (of all channels) will be saved. Be careful not to set this value so small that insignificant fluctuations in the reading trigger many recordings. if the current value of a channel is significantly far from the last recorded value (currently defined as more than 1.5 times the threshold value), in addition to recording the current value, the previous unrecorded value will be inserted in the recording. This means that if a sudden event occurs after a period of inactivity, the data will not be smeared out because the value immediately prior to the event will also be saved.

Consider the example below:

3.5

3.0

2.5

2.0

1.5

1.0

14121086420Time from start

3

4

5

7

8

In this figure, the data as read are shown as a faint trace. Recorded data are shown as markers connected by a bold trace. The threshold value for this channel was set to 0.4 (the noise in the signal has a Gaussian distribution with standard deviation of 0.1). Following the heavy trace from the left side of the plot, the first three recorded points were triggered by a deviation of >0.4 from the previous recorded value. The next recording was triggered by a deviation of 1.1 from the previous recorded value (the difference between the third and fifth markers). Because this was interpreted as a sudden jump (deviation of >1.5 times the threshold value), the fourth point was inserted so that the recording reflects this sudden jump. The seventh point was inserted before the eighth in the same way.

Note: If threshold values are sufficiently large, data will be logged at a (more-or-less) fixed frequency, as defined by the Save Interval. If web publishing or auto-save features are enabled, there may be some irregular intervals in the saved data. The maximum frequency of acquisition will be limited by the time required for communications.

• Publish Log On The Web: Enable web publishing functions. External software is required for saving images of the Log Graph on a server. See Web Server Settings.

• Update Web Now: Forces an update of the Log Graph image saved on a remote server. See Web Publishing.

• Verbose Mode: Allows useful information to be saved in the experiment history. Alarm conditions will override this setting and will always be recorded in the history.

• Channel Setup: Opens the Set Up Channels panel to set the communication parameters for external devices.

Page 7: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 7

Set Up Channels

Use this interface to set the communications settings for external devices (com port, baud rate, data bits, stop bits and parity). The channel name and label can be set (the label will identify the channel in the Log Graph window and Data Logger Control panel). The query string consists of the ASCII characters that should be sent to the external device to trigger a response. If the query string is empty, the port will not be set and the buffer will not be cleared (this is useful if you want to write your own function to handle communications; to clear the buffer without writing anything to the com port, set the query string to the character represented by ASCII code 255). The response is read as a variable by Igor's VDT XOP, which for most instruments will extract the required value from the response. If the device replies with an ambiguous response, entering a format string will force the response to be read as a string from which a single value is extracted using Igor's sscanf function - see sscanf for further information on how to construct the format string. By default a comma, tab, or carriage return are treated as terminator characters, the string being read up to, but excluding, the terminator. Setting the start/stop characters enables specification of custom start and terminator characters (nb. the stop character has nothing to do with stop bits!). The start character will have no effect unless a format string is set, but the stop character will set the terminator whether data is read as a string or a variable. If a start character is set, characters up to and including the start character will be ignored. By setting the start/stop characters, it's possible to log data from an instrument that transmits a constant stream of readings.

Note: The start and stop characters are entered as text, not ASCII code. To convert from ASCII code to characters and vice versa, use the ASCII String Builder utility.

Example 1: A voltmeter responds to a query of "<STX>meas<ETX><CR>" with the reply "1.234V<CR>" (<STX>, or start of text, and <ETX>, or end of text, correspond to ASCII codes 2 and 3, and <CR> represents a carriage return, ASCII code 13). To trigger a response from the voltmeter, construct the query string using the ASCII String Builder:

Page 8: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 8

Simply type "2" in the first ASCII Code position, then "m" in the second character position, "e" in the third, and so on until the entire string has been constructed. Note that you don't need to add the carriage return. Select Copy String to copy the string to the clipboard, and paste into the query string box in the Set Up Channels panel. Leave the format string and start/stop characters blank, and the response will be read as a variable (1.234).

Example 2: Let's say that we want to read a value from a voltmeter that continuously transmits a stream of voltages in the format "V= 1.234<CR>", where each reading is separated by a carriage return (<CR>). In this case, we would set the query string to ASCII character 255, which will set the com port and clear the buffer for that port. If we set the start character to a carriage return (ASCII 13), characters will be read and ignored until a carriage return is received. Once a carriage return is received, characters up to, but excluding, the next carriage return are read into a string. Setting the format string to "V= %f" will extract the value (1.234) from the string.

If the device returns a particularly cryptic response, it may be necessary to write an Igor function to deal with this. See Data Logger User Functions for details.

• Add Channel: Adds a new channel (maximum of 10 channels).

• Delete: Deletes the channel from the current setup

• Load Channel Setup: Loads a setup which has been previously saved as an external file.

• Save Channel Setup: Saves current channel setup as an external file.

• ASCII String Builder: Provides an interface for easily creating strings containing control characters (low value ASCII codes such as ENQ, ACK etc.).

Display Controls

Page 9: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 9

By default the vertical axes of the Log Graph window will automatically scale to the whole range of data values. Select auto scaling to scale to the entire range of data collected, win scaling to scale the axes to the on-screen data, or man scaling to fix the diplay range (the vertical axis scale will not update, even if data plots off-screen).

Tip: Holding down the shift key while clicking Auto, Win or Man buttons will change the scale of all axes simultaneously.

Horizontal scale controls:

<< Pan left

>> Pan right

<-> Expand view (zoom out)

-><- Shrink view (zoom in)

<A> Autoscale to entire data range

>T> Turn tracking view on (see Set Log Options)

• Setup: Interface for adding or removing channels from graph (Change Display panel). Using this interface you can plot multiple channels on a single axis. When more than one channel is plotted on a single axis, the Display Controls panel will show the name of the first channel on that axis with a "+" appended to indicate that further channels are present on that axis. There can be only one instance of a channel in the Log Graph window.

Page 10: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 10

File Control

Logged data can be saved both in external files (to/from file buttons), and internally in an Igor experiment (to/from memory buttons). If many logs are saved within one experiment the experiment size could become unmanageable. When a log is saved "to memory," a data folder is created in the root folder of the experiment and sensibly named waves will be added to this folder. This is useful if you want to use Igor for further analysis and presentation of the data. Also, if you want to compare several logs it can be useful to load and save them in separate data folders in one experiment. The Export Text button saves data in a text file which can be easily read by most other software. The time stamp in an exported text file will be seconds from start of recording, rather than the absolute times used within the data logger environment.

• Save Log To Memory: Save recorded data to a data folder in the root directory

• Save Log To File: Save recorded data in an external file

• Export Text: Save recorded data in a text file which can be easily read by most other software. Data is arranged in the text file is arranged in tab-delimited columns. A single

Page 11: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 11

header line contains channel labels. Time is saved as time from start of recording (seconds).

• Load Log From Memory: Restore a log from a data folder saved in Igor's root directory. Note that the current channel settings will be overwritten by those saved with the log. If you want to preserve the current settings, you should save them to a unique file before reloading the saved log. See Set Up Channels panel for details.

• Load Log From File: Restore a log saved in an external file (.ilf filetype). Note that the current channel settings will be overwritten by those saved with the log.

• Server Settings: Opens the Server Settings panel, to set email, web server, default save path and external program options.

To delete a log from memory, use Igor's data browser to delete the whole folder containing the log. Log folders are always saved in the root directory.

Server Settings

Email Settings

Note: To use the automated email feature requires the postie.exe command line mailer. Before using this feature check with your Systems Administrator that using your SMTP server in this way is permissible.

• Send Email To: Address to which you wish automated email to be sent

Page 12: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 12

• From Address: The from field for automated email

• SMTP server: Probably has to be a server that doesn't worry too much about authentication

• Subject Line: Subject field for automated emails

Web Server Settings

Note: To use the file upload features you must have installed scp2.exe (part of the SSH secure shell client distribution). Authentication by private key should be enabled - contact your Systems Administrator for assistance in setting up encryption keys.

• Server Address: Used by scp2.exe for secure file transfer. Usually has a format like: [email protected]:www

• Remote Log Name: The name of the file on the web server containing a recent screenshot of the Log Graph window. If the value is not set, no file will be copied to the server. Turn web publishing on in the Set Log Options panel (Publish Log On The Web checkbox).

• Remote Summary Name: The name of the file on the web server containing an image of the entire log. Update interval is set in the Set Log Options panel. If the value is not set, no file will be copied to the server. Turn web publishing on in the Set Log Options panel (Publish Log On The Web checkbox).

• Remote Data Name: The name of the file on the web server containing a compressed Igor text wave containing all the necessary information to recreate the entire log in another Igor experiment. If the value is not set, no file will be copied to the server. Turn web publishing on in the Set Log Options panel (Publish Log On The Web checkbox). The external command line compression program pkzipc.exe is required for this option.

Choosing the Create Web Page Template from the Logger submenu of the Macros menu will automatically generate an HTML file which contains links to the files named in the web server settings. This file should be copied to the same directory as the remote log files, as set in the Server Address.

Name and Path Settings

• Default Log Name: the Experiment ID is initialised based on this value when the data logger is reset.

• Save Path: The location in which log files will be automatically saved by Igor. When this path is not set, log files will not be automatically saved and updated. Choosing the cancel button in the dialog will remove the path.

• Postie Path: If you want to use postie.exe as a 344 kb standalone executable (not registered with windows, and not in the Igor Pro folder), you can set the path to the executable here. Pressing the cancel button in the dialog will remove the path.

• Pkzipc Path: If you want to use pkzipc.exe as a 253 kb standalone executable (not registered with windows, and not in the Igor Pro folder), you can set the path to the executable here. Pressing the cancel button in the dialog will remove the path.

Set Alarm Conditions

Page 13: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 13

Alarm conditions can be defined so that you can be alerted if an alarm is tripped. This is a useful feature if you're using the data logger to monitor an experiment which should have more-or-less constant values for some channels. Two types of alarm - "full scale high" and "deviation" are used. When a full scale high alarm is set, if a channel reading exceeds the alarm value the event is recorded in the history and the channel label in the Data Logger Control panel is illuminated in red. If the Send Email Alerts checkbox is checked an email alert will be sent when a full scale high alarm is tripped. See Server Settings panel for further email settings. Once a full scale high alarm is tripped the background of the channel label will remain illuminated until the alarm is reset.

Deviation alarms are tripped when a channel reading deviates from the setpoint by more than the value of the alarm. Deviation alarms do not initiate an automated email. The first time a deviation alarm is tripped the event will be recorded in the history. While the channel remains in the alarm condition the channel label in the Data Logger Control panel will have a red background.

In addition to setting the values for the alarms, you can define conditions under which the alarms should be activated (the same effect as checking ALL the alarm checkboxes), and when they should ALL be deactivated. If both Activate and Deactivate conditions are set, the Deactivate condition will be ignored until the alarms are activated.

Editing a Log

To open the Edit Log panel choose Edit Log from the Logger submenu of the Macros menu (cannot be opened while a log is active). Move the cursors in the Log Graph window to select a data range.

• Cursors: Move the cursors to the selected channel

• Clear Data: Set the data between the cursors to NaN. Only the channel on which the cursors lie will be affected.

• Truncate Channels: Data for ALL channels outside of the cursors will be deleted

• Time Average: A time average for the data between the cursors is calculated. The selected range must not include any NaNs.

Page 14: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 14

Note that if you load a log from an external file or from memory for editing, the saved log will not be overwritten unless you resave the log using the File Control.

• Advanced Details for Igor Pros

Data Logger Algorithm & File Structures

The data logger is essentially a background task that uses VDT functions to communicate with external devices. A typical sequence of VDT commands executed to read data from an instrument would be something like:

VDTOperationsPort2 COM1VDT2 killioVDTwrite2 /O=0.5/Q "query string"VDTread2 /O=0.5/Q VDTReadValue

The function which forms the main loop of the background task is LogData(). Data are saved in the folder root:Packages:RS232Logger:. Values read from devices are stored in waves called W_display# and recorded values are stored in channel#, where # is the channel number, numbered from 0. Timestamps are saved in the double-precision W_display_time and W_Time waves. As the "display" waves are filled with values, data are occasionally stripped from the start of the waves (in a similar way to a FIFO structure), so that readings older than the tracking display are not preserved. As data are recorded, points are appended to the channel waves, so that they increase in size ad infinitum. Five waves are used as storage space for global values: Config and ConfigTxt contain numeric and string configuration information (user-configurable options), and Chan and ChanTxt are two dimensional waves where channel-specific information is stored, with each column representing a channel. W_Log is a double precision wave which provides an internal scratch space for the logger. Dimension labels have been used extensively in the code to help with identification of the global values. When certain configuration settings are reset, config.txt is saved to the data logger folder as an Igor text wave (ServerSettings.itx), and the Chan and ChanTxt waves are saved as ChannelSetup.itx. When the data logger is initialised, these waves are read to set the file and channel settings. In this way, most of the current settings are not lost when we exit the data logger.

When a log is saved to memory, a data folder is created at the root level and named after the experiment ID. Copies of the "channel" waves are stored in this data folder and are renamed to reflect the channel names. Copies of Chan, ChanTxt and W_Log are stored in a subfolder named LogSetup. For the log to be reloaded correctly, all of these waves must be preserved in

Page 15: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 15

their saved locations. The channel numbers are saved in the wavenote of each wave so that they can be restored when the log is reloaded. The experiment ID is saved as the wavenote for Chan.

When a log is saved to file, the channel waves together with Chan, ChanTxt and W_Log are saved as an Igor text wave. The file is saved with the extension .ilf (not listed at http://filext.com/) to identify and assist with reloading logs.

Data Logger Compilation Errors

Check that you don't use any procedures with the same name as those in the DataLogger procedure file (most of the Data Logger function names are preceded with DL_ to avoid clashes), and that you have the VDT2 XOP loaded.

Hiding of Procedure Files

A compilation error will stop a background function. To try and ensure stability of the logger (or to protect the background process from inquisitive users), when the logger is started all procedure windows are hidden and the Other Windows submenu of the Windows menu is disabled to prevent the user accessing the procedure windows and recompiling. To allow access to procedures while the logger is active, edit the line at the beginning of the Data Logger.ipf procedure file to change the value of static variable ktesting to 1.

How Time is Calculated

In order to calculate time with sufficient precision, I was forced to use the ticks function, which returns the number of ticks elapsed since the operating system was initialised. A reference time and number of ticks are saved, from which the current time can be calculated, provided you know the tick rate (~60 per second for a PC). Unfortunately, the tick rate seems to vary somewhat between machines. You can use the function DL_TicksTest(num) to determine the approximate tick rate - Igor will not respond until num seconds have elapsed. The tick rate is stored in W_Log[%TicksPerSec] and is reset when the data logger is initialised - edit the function DL_InitialiseDataLogVariables() if the value 58.8245 doesn't work for you! When the logger is active the calculated time is occasionally checked against datetime, and if the two are out of sync the reference time and tick values are reset.

How Acquisition Rate is Calculated

An estimate of acquisition rate is provided by dividing the number of points in the "display waves" by the time period represented by the waves (the difference between the first and last timestamps for these data, which is approximately the x-axis range of the Log Graph when viewed in tracking mode).

Data Logger User Functions

If you are familiar with writing procedures for Igor Pro you can extend the functionality of the Data Logger by editing or adding functions to the Data Logger User Functions procedure file. You can write functions to read data from instruments that return cryptic strings that need parsing, or convert readings to different units. You could even use another XOP for communications. The appearance of the Log Graph can be tweaked by editing the DataLoggerGraphStyle() function. For example, if you want to display a channel named foo in the Log Graph in cityscape mode, with the axis autoscaled from zero, add the following case to the switch statement:

case "foo": // channel name stringModifyGraph mode($StrTraceName)=6 SetAxis /A/E=1 $StrAxisName

break

Page 16: Data Logger for Igor Pro Help File - University of Minnesota · • Data Logger for Igor Pro ... Tip: Holding down the shift key while clicking Off, On or Rec buttons will change

8/16/2005 Data Logger Help.ihf 16

Note that the channel name, rather than label, is foo. Channel names and labels are set in the Set Up Channels panel. Use $StrTraceName to reference the channel trace, and $StrAxisName to reference the appropriate axis.

Additional Email Flags

If you wish to use additional flags for postie, they can be stored as text in ConfigTxt[%emailFlags].

Communication Errors

If a device fails to respond to a request for data, the VDTread operation will time out after 0.5 seconds and NaN will be taken as a reading. When a device continues to time out with every attempt to read data, it may appear as if Igor is locked up, because most of the time VDT will be waiting for a response and not allow any other activity to occur. This means that there is no easy way to abort the background task or turn the recalcitrant channel off. In an attempt to deal with this situation, when NaN is returned, indicating a failure to read, a panel is created on the screen with some text informing the user that there's a problem, and suggesting that the user hold down the escape key to turn off that channel. The panel is left on the screen for a couple of seconds (to allow the user to read the message) and the keyboard is monitored for the escape key. When the escape key is detected, the bad channel is turned off, allowing the user to interact with the GUI. If anyone can suggest a more elegant way of dealing with communication errors, I'd like to hear your ideas!

I think the data logger should work on the Mac OS9, without email and web publishing capabilities. It should be easy to adapt for Mac OSX, using command line scp and sendmail.