Windmill Data Acquisition Software Logo
26 October 1999

Windmill Software
Data Acquisition Intelligence
Call now: +44 (0)161 833 2782

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


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 low-speed 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 200 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.)


RS-232 Software

To obtain data from your RS-232 instruments and display it on your PC you need some software. Windmill have two drivers designed to communicate with almost any instrument that sends ASCII data over an RS-232 cable. Our newest offering, COMIML, handles not only RS-232 instruments but RS-485 and Modbus devices as well.


Further Reading

On the Windmill Site:
RS-232 Driver Software for up to 10 devices
Free RS-232 Troubleshooting and Data Logging Software
Issue 42 of Monitor: The Ins and Outs of RS-232 COM Ports
RS-232 Wiring and Connections

Serial Port Complete, Jan Axelson, Lakeview Research 1998.

Other RS-232 Web Resources:
Notes on the RS232 Serial Port and Data Acquisition
Lammert Bies, RS232 Specifications


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.

Our other Visual Basic articles are in:

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.

*  Your Email Address:
*  Preferred Format:
    First Name:
    Last Name:
*  Enter the security code shown:

Subscribe Monitor

*  Email:
*  Format:

Subscribe to Monitor
for more articles and tutorials