Windmill Software Ltd |
October 1999 |
Monitor Newsletter Archive |
Issue 15: Remote Sensing and RS-232 InterfaceCONTENTSWindmill News - Remote Sensing | What is RS-232? | VB Corner WINDMILL NEWS: MARINE MAPPING PROJECT USING GPS, SONAR AND A LAPTOP PCCoral 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 http://www.windmill.co.uk/mapping.html. To download the set-up files for the GPS and sonar visit our file library. WHAT IS RS-232?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 DevicesThe two main problems when logging from several RS-232 devices are:
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 SoftwareTo 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. The first, LabIML, is free to our newsletter subscribers. Our newest offering, COMIML, handles not only RS-232 instruments but RS-485 and Modbus devices as well. * Further ReadingOn the Windmill Site: Books: Other RS-232 Web Resources: VB CORNER: CONTROLLING WINDMILL APPLICATIONS FROM YOUR OWN CODEThis 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.
* Starting a Windmill ApplicationThis 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
Error_AppLoad:
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
Exit_AppLoad:
End Sub
Sample call for loading Windmill logger with a specified setup, and starting data collection: myDir$="c:\windmill" myCommandLine$="logger.exe c:\windmill\mySetup.wlg /A" Call AppLoad(myDir$, myCommandLine$) * Sending Commands via DDE to Stop and Modify Windmill ProgramsDynamic 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: Form.name = myForm Label.name = 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
LinkExecuteErr:
ThisError = Err
If ThisErr = 285 Or ThisErr = 286 Then Resume Next
ErrMess$ = "DDE LinkExecute error (" +
Str$(ThisErr) + ") - No response
from " + Topicstr$
MsgBox(ErrMess$)
Exit Sub
End Sub
Sample Use in Practice 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. TopicStr$="Logger|System" ItemStr$="Status" TextStr$="Start" Call LinkExecuteMessage(TopicStr$, ItemStr$, TextStr$) Sending KeystrokesIf 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$ DoEvents SendKeys KeyString$ Exit Sub Error_SendKeyString: a$ = "Error in SendKeyString - Err =" +Str$(Err) Call ShowError(a$) Resume Exit_SendKeyString Exit_SendKeyString: Exit Sub End Sub Sample Use in Practice
AppName$="Streamer"
KeyString$="%{F4}":
'% 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 CornersNext 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 monitor@windmillsoft.com 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. SubscribingTo receive Monitor every month please fill in your email address below. We will not pass your address to any third parties. | |
Home | On-Line Shop | Free Literature and Software Demos | Contents | Search
| Copyright Windmill Software Ltd 2006 PO Box 58, North District Office, Manchester, M8 8QR, UK. E-mail:monitor@windmillsoft.com, Tel:+44 161 833 2782 http://www.windmill.co.uk/ Designed by Studholme.net |