Windmill Software Ltd |
![]() May 2006 |
Tips on Extracting Data |
Parsing Messages from RS232 InstrumentsIf you have an instrument or device which you can plug into the PC's COM port, and it communicates using ASCII messages, chances are you can use the free Windmill software to collect its data. This is because Windmill's free LabIML driver was designed to be as flexible as possible and accommodate almost any instrument with an RS232 port. However, this flexibility has meant that the initial set up can be a case of trial and error. These notes should reduce the error and help you decide the best way to interpret, or parse, the messages from your instrument. (Our latest serial driver is more transparent, see http://www.windmillsoft.com/comiml.html for details.) When an instrument sends a message it rarely just contains data. All sorts of extra characters and codes are in there. Here are some examples of messages. A weighing scale might send: + 125.32 g, A GPS receiver might send: $GPGLL,5330.12,N,00215.31,W,134531,A A Parallax BASIC Stamp might send: +66.4 A spectrophotometer might send: DR/4000U S/N: 9807U0000905 2.303-APR-04 10:05:56 MULTI-WAVELENGTHGroup 0000 Sample 0002 -0.000 ABSA=K1A1+K2A2 665.0 nm -0.004 ABS K1: 1.0000 750.0 nm - 0.004 ABS K2: -1.0000 Windmill doesn't just store the entire message, superfluous characters and all. It extracts the relevant data from each message, directing each data item to a channel: latitude readings to one channel, longitude to another and so on. Each data item can be up to 20 characters long. There is often no need to collect the units of the reading. You can use the SeupIML program to specify the units of each channel. It's not only message formats that vary. Some instruments need a command prompt from Windmill before they will send data, others initiate data transfer themselves - often regularly sending data. In this case the message can be considered as a continuous stream of data that has a recurring pattern. LabIML calls an instrument that sends one message after a command a Request/Response instrument. Devices which constantly send data are called Continuous Flow instruments. Setting up Instructions to Extract DataTo set up parsing instructions use the Windmill ConfIML software and select the LabIML driver. Go to the Channels settings. The first thing to do is to locate the data. You can do this by:
At first glance methods 1 and 2 seem to do the same job. However, when you search for characters the next action occurs AFTER the searched for characters. When you ignore characters the next action occurs ON the specified character. So if you searched for a + sign you would not be able to extract it, but if you ignored all characters until the + sign you would. Also, a search will look for the entire string specified (eg "abc"), whilst ignoring characters will stop at any of the characters specified (eg "a" or "b" or "c"). Be aware that with instruments that constantly send data LabIML will not know where the beginning of the message is. So, using the GPS example above, it's no use ignoring 8 characters and expecting the next value to be a latitude reading. Instead search for a unique string such as $GPGLL. Once you've located the data you need to extract it. There are two ways to do this:
Extract until means that LabIML will extract values until it finds any one of the characters specified. The next command in the parse string then acts ON THIS character. Using the GPS receiver as an example again $GPGLL,5330.12,N,00215.31,W,134531,A The data we might want to record from this string is the latitude and the longitude. These are the 5330.12 and 00215.31 figures respectively. We should have already created 2 channels: one to hold the latitude readings and one to hold the longitude. For the latitude channel we might: Search for $GPGLL, and extract until , For the longitude we might: Search for N, and extract until , As another example, the BASIC Stamp might continually
send a reading comprising a leading sign character, a trailing
carriage return to mark the end of data and a maximum length of
six characters. For example -55.27 \I"+-"\E"\C013" Extracting Several Channels of Data Home | Windmill Programs | Monitor | On-Line Shop | Free Literature and Software Demos | Contents | Search
|