Windmill Software Ltd
Data Acquisition Intelligence

RS-232 Interface
October 1999

Issue 15: Remote Sensing and RS-232 Interface


Windmill News - Remote Sensing | What is RS-232? | VB Corner


Coral reefs provide a home for thousands of species of marine life. However, the reefs are threatened. They are being destroyed by, amongst other things, fishing by dynamite, erosion on land and pollution by industrial waste.

There is therefore a growing need for mapping and monitoring marine environments - not only for coral reef preservation but also for deep-sea research, marine archaeology, salvage and so on. Previously such systems were costly and complex, but with Windmill software automated sea-floor mapping is available to anyone with a GPS, sonar and laptop PC.

The Windmill monitoring system uses the GPS for global positioning and the sonar for depth measurement. These plug into the COM (RS-232) ports of a laptop PC. The three-dimensional position data from these instruments is integrated and logged by Windmill, and exported in a spreadsheet format. From there it can be imported into any major mapping software on the market.

The Marine Biology Department using the system has completed mapping sessions in less than 20 minutes. This is because mapping can be done at high speeds (20-30 knots, limited only by the output rates of the sonar and GPS) and maps can be plotted instantly on the laptop.

For more details of the marine mapping project, and other remote sensing applications, see To download the set-up files for the GPS and sonar visit our file library.


In the Windmill News section we talked about plugging a GPS and a sonar into the COM (RS-232) ports of a computer. RS-232 is a popular communications protocol for connecting computers to modems and peripherals like balances, PH meters, gas analysers and other laboratory instruments.


How Standard is the RS-232 Standard?

RS stands for recommended standard. In the 60's a standards committee now known as the Electronic Industries Association developed an interface to connect computer terminals to modems. Over the years this has been updated: the most commonly used version of the standard is RS-232C (sometimes known as EIA232); the most recent is RS-232E. The standard defines the electrical and mechanical characteristics of the connection - including the function of the signals and handshake pins, the voltage levels and maximum bit rate.

The modems and instruments sending and receiving serial data are referred to as data communication equipment, or DCE, in the standard. The computer at the other end of the cable is referred to as data terminal equipment or DTE. A DTE has a plug and a DCE a socket.

However, after all this talk of standards, I'm afraid that in data acquisition at least, a multitude of interpretations exist. Different manufacturers implement RS-232 communications in different ways - often with very good reasons. For instance, instead of being a DCE device, a measuring instrument might be configured as DTE. In this case you need an adaptor or the RS-232 cable wired differently to normal.

Another deviation from the standard is in the number of wires used. The standard specifies a 25-pin connector shaped like an elongated D, with the connections in two rows. However, most PCs have 9-pin COM ports. At their simplest data acquisition devices need only 3 wires: one to receive data from the computer, one to transmit data to the computer and a signal ground. (Many of the other wires are specific to modems.)


How Fast Can Instruments send data over RS-232?

The speed of RS-232 communications is expressed in Baud. In data acquisition, a Baud is equivalent to bits per second. The unit is named after Jean Maurice-Emile Baudot (1845-1903), a French telegraph engineer and the inventor of the first teleprinter. It was proposed at the International Telegraph Conference of 1927.

The maximum speed, according to the standard, is 20000 Baud. However, modern equipment can operate much faster than this. No matter how fast (or slow) your connection - the maximum number of readings per second you can take from your instrument depends on the software. With Windmill software, speeds of up to 35 readings per second are achievable whilst with Streamer software this rises to 700 readings per second.

The length of the cable also plays a part in maximum speed. The longer the cable, the greater the cable's capacitance and the slower the speed you can run at and still obtain accurate results. The capacitance links voltage changes on one signal wire to an adjacent signal wire. Both resistance and capacitance increase with cable length. Fifty feet is commonly quoted as the maximum distance, but this is not specified in the standard. We generally recommend a maximum distance of 50 metres, but this depends on the type of hardware you are connecting and characteristics of the cable.


Logging from Several RS-232 Devices

The two main problems when logging from several RS-232 devices are:

  1. The number of COM ports available on the computer
  2. Ensuring data is not lost even if all the instruments decide to send their data at the same time.

The first problem is overcome by buying an adaptor card for your PC. Some of these provide 8 COM ports, and you simply install the card inside your computer.

The second problem is also solved by hardware. You can buy an interface which provides an input and output buffer for each RS-232 instrument. This interface communicates with the PC over GPIB - a much faster communications link than RS-232 which can keep up with the multiple serial communications. (You can use Windmill software with this method but will have to buy a Windmill GPIB driver. Contact Windmill Software for details.)


RS-232 Software

To obtain data from your RS-232 instruments and display it on your PC you need some software. Windmill have developed a driver called COMIML, designed to communicate with almost any instrument that sends ASCII data over an RS-232 cable.


Further Reading

Serial Port Complete, Jan Axelson, Lakeview Research 1998. More details at and
Microprocessors and Interfacing, Douglas V Hall, McGraw-Hill Publishing Company, 1992. Available from the Microlink Bookshop.

RS-232 Web Resources:
Lammert Bies, RS232 Specifications
Serial Port Complete Web Resources
CAMI Research RS232 Basics


This month we discuss how to send control instructions from your Visual Basic program to start, stop and modify Windmill programs. For example, you may wish to load and run the Windmill Logger at specified times, or change the logging rate when an alarm occurs.

You can download the code for this month's VB corner.
It covers:


Starting a Windmill Application

This routine will load an application from a specified folder. Should the application not load successfully the appropriate error message is displayed.

  Sub AppLoad(DirName$, AppSpec$)
  On Error GoTo Erro_AppLoad
  myDir$ = CurDir
  ChDir DirName$
  x = Shell(AppSpec$, 7)
  ChDir myDir$
  Exit Sub
    Select Case Err
    Case 76
      a$ = "Failed in Appload - Directory not found"
    Case Else
      a$="Failed in AppLoad - Err =" + Str$(Err)
    End Select
    Call ShowError(a$)
    Resume Exit_AppLoad
End Sub

Sample call for loading Windmill logger with a specified setup, and starting data collection:

myCommandLine$="logger.exe c:\windmill\mySetup.wlg /A"
Call AppLoad(myDir$, myCommandLine$)


Sending Commands via DDE to Stop and Modify Windmill Programs

Dynamic data exchange allows co-operating Windows applications to transfer data in real-time. Your Visual Basic application may send or request data from Windmill as and when required. Additional information, such as channel names, units, alarm states and error codes, can also be obtained using Visual Basic. For details of the DDE commands that Windmill accepts, see the Windmill Help files.

To send commands from your Visual Basic program, first create a label on your VB form with these details: = myForm = DDEmessage

Here is the code which will work with any Windmill application. See the later comments for details of using this in practice.

Private Sub LinkExecuteMessage(Topicstr$, itemstr$, textstr$)
myForm.DDEmessage.LinkTopic = Topicstr$
myForm.DDEmessage.LinkItem = itemstr$
  On Error GoTo LinkExecuteErr
my.Form.DDEmessage.LinkMode = 2

myForm.DDEmessage.LinkExecute textstr$
myForm.DDEmessage.LinkMode = 0
Exit Sub
  ThisError = Err
  If ThisErr = 285 Or ThisErr = 286 Then Resume Next
  ErrMess$ = "DDE LinkExecute error (" + 
           Str$(ThisErr) + ") - No response 
           from "   + Topicstr$
  Exit Sub

End Sub

Sample Use in Practice
To send a "start logging" message to a Windmill Logger which has been previously loaded.

Note: in the TopicStr$ the "Logger" is the DDE name of the Logger application, which is set using the File.DDE menu item in the Logger application.

Call LinkExecuteMessage(TopicStr$, ItemStr$, TextStr$)

Sending Keystrokes

If all else fails we can send key-strokes to our application to replicate the keys a user would press if they were controlling the application from the keyboard.

Sub SendKeyString(AppName$, KeyString$)
On Error GoTo Error_SendKeyString
AppActivate AppName$
SendKeys KeyString$
Exit Sub
  a$ = "Error in SendKeyString - Err =" +Str$(Err)
  Call ShowError(a$)
  Resume Exit_SendKeyString
  Exit Sub
End Sub

Sample Use in Practice

'% for the ALT key, {F4} for function key F$
Call SendKeyString(AppName$, KeyString$)

The full list of codes for control characters can be found in the VB documentation - see, for example, SendKeys.


Future VB Corners

Next month VB corner give hints on using web pages as your user interface.

Do you have a comment or suggestion for this newsletter? E-mail the editor - Jill - at [email protected]

Copyright 1999 Windmill Software Ltd. All rights reserved. This newsletter may be distributed in its entirety. However, individual sections may not be reproduced without the prior written agreement of Windmill Software Ltd.


To receive Monitor every month please fill in your email address below. We will not pass your address to any third parties.

*  Email:
*  Format: