-------------------------Monitor------------------------
The Newsletter for PC-Based Data Acquisition and Control
Issue 83          www.windmill.co.uk           June 2005
--------------------ISSN 1472-0221----------------------

Welcome to the Midsummer (or Midwinter) edition of 
Monitor.  This month some tips on troubleshooting an 
RS232 connection using free software and a bent 
paperclip.

We hope you find the newsletter useful, but should you 
wish to cancel your subscription you can do so at 
https://www.windmill.co.uk/newsletter.html

CONTENTS
========
* Troubleshooting RS232 Connections
* Excel Corner: Conditional Formatting
________________________________________________________
________________________________________________________

Troubleshooting RS232 Connections: Steps to take when
you cannot get data from your instrument
________________________________________________________

See also - Troubeshooting notes here

You've plugged your instrument into your computer's COM 
port, installed your data acquisition software, but no 
data appears. You suspect it is a problem with your 
RS232 communications.  What do you do?

1. Obtain RS232 Troubleshooting Software

   You can download ComDebug, our free RS232 
   troubleshooting software, from the web at 
   https://www.windmill.co.uk/serial.html
   This provides many features which let you detect, 
   and correct, communication errors.  If you can't 
   immediately obtain data with ComDebug, read on.

2. Find Communication Details: Baud Rate etc.

   Obtain all the information available about your 
   instrument or device. You will need to know the
   baud rate, number of bits in the data byte and parity. 
   If you have information about the stop bits then use 
   it, otherwise set them to 2. This will at worse slow 
   the message down slightly. 

3. Send a Message

   If you can persuade your device to send a message, 
   perhaps a power on message or a message that can be 
   initiated by a button press, then do so. This will
   verify your signal connections. At this stage you 
   should select the no handshake option when setting 
   up the COM Port. If you still can't receive any 
   data, you may have a COM port or a wiring error. Use
   ComDebug's COM Port Status window to check the state
   of the lines to and from the computer, and see 
   points 4, 5 and 6 below.

4. Check the COM port is Working Correctly

   This tip works if your instrument is a DTE computer 
   type with a 9-pin connector. (See Issue 42 of Monitor,
   https://www.windmill.co.uk/monitor42.html, for more on 
   DTE type instruments).  Disconnect the RS232 cable from
   your instrument.  Check it has a socket on the free 
   end.  Unravel a paperclip, insert one end into the 
   pin 2 hole on the cable socket and the other into the 
   pin 3 hole.  (Pin 1 is to the right of the long edge, 
   pin 2 is next to it.) When you now send a message it 
   should echo back to the computer and you can confirm 
   that messages are arriving at your instrument.

5. Check the Cabling

   If you suspect a wiring error, you could try contacting
   the manufacturer of your instrument to see if they sell
   the correct cable. Sartorius devices, for example, 
   won't work with a standard RS232 cable and you need to 
   either purchase a cable from the company or re-wire the
   connections. If your instrument is a DTE computer type,
   you may need a Null Modem adaptor. (See 
   https://www.windmill.co.uk/monitor42.html, for more on 
   Null Modems, DTE type instruments and pin connection 
   names.) Alternatively, you may want to try rewiring the
   cable connector yourself 

   When wiring the cable yourself, the first signals to 
   connect are the ground, RXD and TXD. Try to establish,
   from your device's documentation, which signal wire 
   carries its output data - connect this to the 
   computer's RXD. The signal which inputs data to your 
   device should be connected to the computer's TXD. Don't
   rely on the signal names, remember the signals can be 
   either inputs or outputs depending on whether your 
   device is a computer or modem type. It's not unusual 
   for Instrument Manuals to neglect this vital 
   information, but you may be able to get a clue from 
   other signals. For instance if the manual says that DTR 
   is an output then the instrument should be a computer
   type. If on the other hand it says that DSR is an 
   output then it should be a modem type. In fact if you 
   know the direction of any one of the signals you should
   be able to deduce the rest. Be careful when doing this: we 
   have encountered manufacturers who change the names of 
   the data signals when dealing with modem types - after 
   all it must be confusing to tell a user that 
   Transmitted Data is an input!  

   If the signals are correctly named then a computer to 
   modem link connects TXD to TXD and RXD to RXD. A 
   computer to computer link (more common when dealing 
   with instruments) connects TXD to RXD and RXD to TXD. 
   This crossed arrangement is sometimes called a Null 
   Modem connection, and buying an adaptor may solve your 
   wiring problems.

   If all else fails you can determine which data signal 
   is the output by measuring the unconnected data lines 
   with a voltmeter or using one of the plugs with built 
   in LED indicators which show the line state. The output
   signal will be at a definite negative voltage, properly
   -12 Volts or more. The input line will be close to 
   0 Volts. The only time this strategy will fail is if 
   your device is of the multidrop variety. These only 
   drive the output line for the duration of the 
   transmitted message. 

6. Set Hardware Handshaking or Flow Control

   If you are confident that the signal wires are properly 
   connected, but you still can't retrieve a message from 
   your instrument, you may need to tie the handshake 
   lines.

   Handshake arrangements can be used for two purposes. 
   Firstly the computer can prevent the device from 
   sending data when it is not able to receive it. Secondly
   the device can prevent the computer from sending data 
   when it is not ready for it. The fact that your device 
   comes equipped with inputs and outputs that can be used
   for handshaking is no guarantee that handshaking is 
   needed. The signals are often provided simply because 
   the processor used in the device provides them, so the 
   manufacturer feels he may as well put them on the plug.
   It is usually best to start with the intention of tying 
   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 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. In COMIML the buffers are 
   3000 bytes long so you are unlikely to be bothered by 
   this problem. The other possibility is that the device 
   misses part of a message sent by the computer. This will 
   presumably cause the device not to operate as desired.  

   If you do decide that handshaking must be used then the 
   ComDebug software uses DTR / CTS handshaking. This means
   that the computer uses its DTR output to indicate when 
   it is able to receive data and its CTS input can be 
   controlled by the device to prevent transmission of data
   from the computer. Once you select the hardware 
   handshake option the state of the CTS input to the 
   computer becomes important. When hardware handshake is 
   not selected the CTS line state is ignored, the DTR 
   output however is maintained permanently high so you can
   use it to tie unused inputs on your device.

7. Set Software Handshaking or Flow Control

   Xon \ Xoff Handshaking is a software protocol that is 
   often used to control data flow. Supposing that the 
   computer were sending data to a device which could 
   accept no more data for the time being - the device 
   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. If 
   your device requires this type of handshaking then 
   simply select it in ComDebug. 

8. Other Ideas

   If you've assured yourself that the cabling is fine the 
   problem may be with the way the software is set up. For 
   Windmill LabIML or COMIML check that you have set the 
   parsing correctly. See the Windmill Help files for more 
   details. You can download the latest versions of the 
   Help files from https://www.windmill.co.uk/help.html

Further Reading
===============
Monitor 42: The Ins and Outs of COM Ports
https://www.windmill.co.uk/monitor42.html

Windmill COMIML Serial Device Driver
https://www.windmillsoft.com/daqshop/rs232-modbus.html

Technical Support FAQ
https://www.windmill.co.uk/techsupp.html

Interfacing your Device to the PC
https://www.windmill.co.uk/software.html#technicalsupport

Windmill Setup File Library
https://www.windmill.co.uk/serial_driver.html
________________________________________________________
________________________________________________________

Excel Corner: Conditional Formatting
________________________________________________________

You can tell Excel 97 (and later versions) to 
automatically format a cell - applying a font colour or 
cell shading for example - when a specified condition is 
true.  To do this

1. Select the cells to monitor.

2. From the Format menu select Conditional Formatting.

3. Choose your conditions. For example, values greater 
   than 30.

4. Choose your formatting options. For example, colour 
   the cell red.

In this way you can set up to 3 format conditions for 
each cell.  For example, if a value is between 20 and 30 
you could show the text in blue and if it is over 30 you 
could show the text in red.  When you set several 
conditions, only the first condition which is true is 
used. So, if you set values over 20 to be blue and 
values over 30 to be red, a value of 31 will be shown in 
blue. Because the first condition has been met the 
others are not evaluated. To cope with this either...

1. Put your conditions in the right order. That is to 
   say, put the values over 30 in red condition first.

2. Define your conditions precisely. Use "between" 
   rather than "greater than".

Customise the Conditions
========================

You are not restricted to the built-in conditions that 
Excel offers.  You can instead use your own formula. In 
the Conditional Formatting dialogue, instead of using 
"Cell Value Is" select "Formula Is".  Your formula 
should return a value of either True (non-zero) or False 
(zero).  If your formula returns True, that format 
condition is applied.  If the formula returns False, the 
format condition is not applied, and the next (if any) 
format condition is tested. 

Using custom formulas means that you can change the format 
of one cell based on the value of another.  For example, if 
you want A3 to appear in red if cell B3 is greater than 
20, you can use =B3>20 as the custom formula. 

Cell references in a custom formula are relative.  So if 
you applied =B3>20 to cells A3 to A10, cell A4 would have 
=B4>20 and so on. If, instead, you wanted to compare all 
the A cells to cell B3 - you would use  =$B$3>20

You cannot access other worksheets directly with your 
custom formula. However, you can access named range of 
cells on another worksheet.

Don't Get Carried Away
======================

Applying a conditional format is the same as adding one or 
more formulas to the cell. Be careful when applying to 
large numbers of cells as it may degrade performance.

Further Reading
===============

For tips on automatically logging data with Excel see
https://www.windmill.co.uk/excel/

For tips on charting with Excel see
https://www.windmill.co.uk/excel/excel-charting.html

For how to use a macro to highlight out-of-range data see
https://www.windmill.co.uk/monitor78.html
________________________________________________________
________________________________________________________

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

Email:
Format:

Previous Issue Next Issue