Windmill Data Acquisition Software Logo
March 2001

Windmill Software
Data Acquisition Intelligence
Call now: +44 (0)161 834 6688

------------------------Monitor-------------------------
The Newsletter for PC-Based Data Acquisition and Control
Issue 32          www.windmill.co.uk          March 2001
--------------------ISSN 1472-0221----------------------

Welcome to the March issue of Monitor. This month we're 
pleased to announce the launch of two new serial 
communications programs, one of them free! Our main 
article continues the serial communication theme and 
covers the differences between RS232, RS485, RS422 and 
Modbus.

We only send this newsletter to people who have 
subscribed - should you wish to cancel your free 
subscription please visit 
https://www.windmill.co.uk/newsletter.html

CONTENTS
========
* Windmill News
  - Windmill launch new driver for RS232, RS422, RS485
    and Modbus devices
  - Also released today, free serial trouble-shooting 
    software
* Serial communications
  - RS422 and RS485
  - Modbus
________________________________________________________

Windmill News: Windmill Launch New Serial Driver and 
Free Trouble-Shooting Software
________________________________________________________

For some time we have been offering you free software, 
LabIML, to read data from instruments connected to the 
PC over RS232. Today we're pleased to launch two new 
serial communications programs: COMIML and ComDebug.

COMIML is our new serial driver. It improves upon our 
free LabIML driver as it:
- can read binary as well as ASCII data
- can accept RS485, RS422, Modbus and RS232 instruments
- lets you send ASCII values, twos complement integers, 
  unsigned integers, single bits, etc, to your instrument

For more details of COMIML visit
https://www.windmillsoft.com/daqshop/rs232-modbus.html

Our second new program, ComDebug, makes it extremely 
easy to interact with your instrument. What's more it's 
free!

ComDebug lets you see exactly what messages your 
instrument is sending and quickly extract the necessary 
data. If you have problems eliciting replies from your 
instrument, ComDebug lets you see what's happening at 
the COM port, and provides several trouble-shooting 
facilities. 

When you've established communication, you can save your 
ComDebug settings in a file. The new COMIML serial 
driver will automatically read this file and control 
your instrument accordingly.

However, you don't have to have bought COMIML to use 
ComDebug: you can use it simply as a terminal emulator. 
If you are having trouble reading data with LabIML, for 
example, you can use ComDebug to investigate the 
problem.

For more about ComDebug see
https://www.windmill.co.uk/serial.html

________________________________________________________

Serial Communications: RS422, RS485 and Modbus
________________________________________________________

In serial communications, the instrument sends one bit 
after another to the computer. Eight of these bits make 
a byte, and the computer translates the bytes into 
characters. The instrument and the computer must agree 
on such things as:
- At what rate will the data be arriving (baud rate)?
- What, if any, error checking is used (parity)?
- What signifies the start and end of a byte of data 
  (start and stop bits)?

In the Windmill news section we talked about COMIML, the 
new serial device driver. This can read data from 
instruments connected to the PC's COM port communicating 
over RS232, RS422, RS485,  Modbus or TCP/IP. The COM port was 
designed to accept RS232 signals. The RS232 standard, 
initially conceived in the 60's, specifies electrical 
and mechanical characteristics of the connection, 
including the function of the pin connections, the 
voltage levels and maximum bit rate. RS422, RS485 and 
Modbus were designed later. So, how is it that RS422, 
RS485 and Modbus devices can also be attached to the 
RS232 COM port?

RS422 and RS485
===============
The short answer for RS422 and RS485 is with an adaptor 
plugged into the COM port. This takes the RS485 or RS422 
voltage signals and converts them to RS232 signals. 
RS422 and RS485 use differential data transmission, 
giving them two major advantages over RS232.
1. Cables can be much longer and instruments thus much 
   further away from the PC.
2. Several instruments can be connected to one RS422 or 
   RS485 cable. 

Length of Cable and Voltage Levels

Instruments connected to an RS485 cable can be around 
1200 m away from the computer, as opposed to around 50 m 
for those connected to an RS232 cable. The reason for 
this increase in distance is due to the reduction of 
noise errors brought by the differential connections and 
shielded wires.

In a differential system each signal is transmitted over 
two wires. On wire carries a negative voltage signal and 
one a positive. As the wires are twisted together, any 
external noise interference should apply equally to each 
wire. Subtracting the reading of one wire from the other 
eliminates any common noise.

But in the introduction we talked about sending a series 
of bits, not voltage signals. Well, a bit is set to 1 or 
0 depending on the voltage level on the cable. The baud 
rate sets the time span before the next bit arrives.

Number of Instruments

RS232 uses one-to-one communications. A PC is at one end 
of the cable and one data acquisition instrument at the 
other. To connect more instruments over RS232 you need 
to install more COM ports. RS485, on the other hand, is 
multidrop. It allows 32 devices or stations to be 
attached to one cable. The earlier RS422 standard allows 
10 devices to be attached to a cable. For a channel on 
RS485 or RS422 device, you need to include an address in 
your request for data.

What about Modbus?
================== 
Unlike the Recommended Standards (RS232, RS422 and 
RS485), Modbus is a protocol that doesn't insist on 
voltage levels, connection pins, etc. Modbus devices can 
use a variety of cables or networks, including RS485 or 
RS232. The Modbus protocol defines a message structure - 
how the PC addresses and requests information from a 
Modbus device, how the device will respond and how 
errors are detected and reported.

Modbus has two modes: ASCII and RTU (remote terminal 
unit). In ASCII mode each 8-bit byte in a message is 
sent as two ASCII characters. It allows intervals of up 
to 1 second between characters, without causing an 
error. Messages start with a colon and end with a 
Carriage Return followed by a Linefeed.

In RTU mode each 8-bit byte in a message contains two 4-
bit hexadecimal characters. Greater character density 
allows better data throughput than ASCII for the same 
baud rate. Each message is transmitted in a continuous 
stream. The final part of a RTU message is a cyclic 
redundancy check, CRC. This calculates its value based 
on all earlier bytes in the message, it then adds 
its 2 bytes into the message. The computer therefore 
knows when it has received a corrupted message and 
can ask the instrument to resend its data.

                         *

Further Reading:

We covered RS232 in more detail in Issues 42 and 15
https://www.windmill.co.uk/monitor42.html
https://www.windmill.co.uk/rs-232.html

Help on using the free Windmill ComDebug trouble-shooting
software with Modbus devices is at 
https://www.windmill.co.uk/modbussettings.html

For more information on the Modbus protocol see
http://www.modicon.com/TECHPUBS/intr7.html

We've ignored any discussion of the newer Universal 
Serial Bus, as you cannot plug USB instruments into the 
COM port. For a discussion of the USB see Issue 24 of 
Monitor
https://www.windmill.co.uk/monitor24.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.

You will receive an e-mail asking you to confirm your subscription. On doing so you will be sent details of how to download the free software. If you don't receive this e-mail please contact monitor@windmillsoft.com.

You can read an archive of previous issues on our Data Acquisition Intelligence site.

Cancel Subscription

You can cancel your free subscription at any time - just return to this page or follow the instructions in the newsletter.

Previous Issue Next Issue