Copyright: Copyright Brian Thorne


RS-232 pin description

Serial (PC 9)

9 PIN D-SUB MALE (at the computer).

Pin	Name	Dir	Description

1	CD	<-	Carrier Detect

2	RxD	<-	Receive Data

3	TxD	->	Transmit Data

4	DTR	->	Data Terminal Ready

5	SG	-	Serial Ground

6	DSR	<-	Data Set Ready

7	RTS	->	Request To Send

8	CTS	<-	Clear To Send

9	RI	<-	Ring Indicator

Note: Direction is DTE (computer) relative DCE (modem).

Serial (PC 25)

25 PIN D-SUB MALE (at the computer).

Pin	Name	Dir	Description

1	PGND	-	Protective Ground

2	TxD	->	Transmit Data

3	RxD	<-	Receive Data

4	RTS	->	Request To Send

5	CTS	<-	Clear To Send

6	DSR	<-	Data Set Ready

7	SG	-	Serial Ground

8	CD	<-	Carrier Detect

9	-	-	-

10	-	-	-

11	-	-	-

12	-	-	-

13	-	-	-

14	-	-	-

15	-	-	-

16	-	-	-

17	-	-	-

18	-	-	-

19	-	-	-

20	DTR	->	Data Terminal Ready

21	-	-	-

22	RI	<-	Ring Indicator

23	-	-	-

24	-	-	-

25	-	-	-

Note: Direction is DTE (computer) relative DCE (modem).

Source: Connector at http://ftp.unina.it/pub/electronics/hwb/menu_Connector.html

Also take a look at: http://www.airborn.com.au/airborn/rs232.html


Troubleshooting

I've received many questions from people who can't get their serial devices to work properly with Easy Com. When working with serial communication you need to be very patient and carefully examine every part of the system.

1. Properly working comports in Windows. The first thing you should do is to make sure the comports on your computer works properly with Windows. To verify that a comport works, plug in a (working) modem on COM1. Check the properties to make sure you've selected COM1, then send the default string labeled "Enq modem" ("ATZ" followed by a CR and a LF). You should get the reply "OK" and it should also echo whatever you send. You can check signals by turning the modem power on and off. That should toggle the signals and it should be displayed in the signal chart. If not, look for any hardware conflicts on the ports in the hardware listing of the controlpanel (the irq-settings could be wrong) or proceed to step 2.

2. The cable (almost always the bandit). It's important to use the correct cable designed for your serial device. A typical PC to PC communication (DTE to DTE communication) only works with a "null modem cable"  (the send and receive pins are switched). Other devices, like modems (DTE to DCE communication), only work with a straight cable (no switching of pins). Some devices even need a special cable supplied only by the manufacturer of the device. Read the manual on your serial device.

3. The communication settings. The baudrate, parity, databits and stopbits often need to be in one exact state in order for the device to work. Read the manual on your serial device.

That's it. This is by no means a complete listing on how to get your serial device to work, it's only the most common errors people do (or so i gather from the mail I've received).

Note: If you have trouble with slow communications, try to turn of the signal chart to speed it up. Drawing the lines of the chart takes processor time and could delay communication.

Once you get your serial device to work with Easy Com and want to implement communication in your own program you might want to check out the Programmers troubleshooting section.

I hope this was to some help.


About Easy Com

Easy Com Copyright 1998 Brian Thorne.

The purpose of Easy Com is to, in an easy and reliable way, test communications with various peripheral devices in the 32 bit Windows environments, and to display data and signals in a logical and understandable way.

You, the user of this product, can help form Easy Com by suggesting new features that you would like to be included in upcoming versions. Suggestions and comments should be sent to the author by e-mail: brian.thorne@swipnet.se

The latest version of Easy Com can always be downloaded from the authors homepage at http://home2.swipnet.se/~w-24426/

Disclaimer

The author of this program accepts no responsibility for damages resulting from the use of the program, and because of the various hardware and software environments in which this program may be used, makes NO warranty of any kind. This software is provided "AS IS", and it is used AT YOUR OWN RISK. In no event shall the author be liable for ANY damages. By installing the product you implicitly agree with these conditions of use.


Getting started

This is an introduction to Easy Com in which the functions are described very briefly.

Start off by selecting "Properties" in the File menu or in the toolbar and specifying the devicename (COM1, COM2 and so on), baudrate, parity, databits and stobits that apply to your serial device (DCE). Be sure to set the mode to "Serial testing" if you don't want to use the Line monitor mode.

In the 'Status/Errors' window you'll see if the selected device could be opened or not.

When the device is open, type the string which you want to transmit to the DCE device in the send listbox. You can add special characters (like CR and LF) by selecting "Add character". You can also right-click the "Add character" button and select a character to add, or use the speedbuttons.

Now simply click "Transmit", and the string will be transmitted to the device using the communication parameters that you've set up. If you can't get the serial device to work, take a look at the troubleshooting section.

You'll see the transmitted characters in the DTE line in the in/output, and hopefully you'll get a response from the device which will be displayed as characters in the DCE line. If communication signals like CTS or DSR are received, the signal leds will indicate the state. The signalchart also shows a graphic view of the state of each signal. You can click on  any character in the in/output to see the decimal, hexadecimal and binary values of it.

You can select "Repeat mode" in the "Properties" window to continuously transmit a string with a delay in milliseconds that you can specify.

Often you need to transmit a special character like ACK or NAK to respond to the device. That can easily be done by right-clicking the "Transmit" button and selecting the response character, or by using the speedbuttons. It will automatically be transmitted when selected.

Up to 24 different strings can be predefined so you don't need to type frequently used strings every  time you need to transmit them.

Data  that is transmitted and received with Easy Com can be displayed as text  which can be saved to file or printed to your printer. By selecting "Text mode" you can see the buffer as it will look on file or on printer.

If you need to transmit a large amount of data to a serial device you can transmit a textfile by selecting "Transmit File" in the Communication menu.

Memo notes is an easy way to keep notes of what you want to remember between sessions.

Enjoy!


Registration information

Easy Com is free to evaluate for 30 days. After that period you must either register the software or erase it from your computer. If you decide you have use for Easy Com and want to continue using it, you are obligated to register the product by paying US$40 for a personal license, or US$300 for a company license, to the author.

When you register Easy Com you get:

* Free technical support by e-mail

* Free updates of all new versions of Easy Com

* The latest version of Easy Com, shipped on disk

Easy Com can be registered and used the very same day the payment is received. The registration data needed will be sent to you by e-mail. The disk with the latest version will be shipped within two weeks.

At present only cash, international moneyorders or cheques in US$ are accepted. Add US$10 for shipping and handling. Assign your moneyorder or cheque to the author, Brian Thorne.

Please print out this form and send it together with your payment to the following address:

Brian Thorne

Näsby Allé 3

S-183 55  TÄBY

SWEDEN

Order information:

Easy Com personal license (US$40)	US$________

(Single license. You may use the program on your own computer only)

Easy Com company license (US$300)	US$________

(Each person at your company may use Easy Com on his/her computer)

Shipping and handling	US$_____10_

Total payment included together with this order:	US$________

Name:	________________________________________________________________

Company:	________________________________________________________________

Address:	________________________________________________________________

________________________________________________________________

________________________________________________________________

________________________________________________________________

Country:	________________________________________________________________

E-mail:	________________________________________________________________

Phone/Fax:	________________________________________________________________

Comments:	________________________________________________________________

________________________________________________________________

Please note: The author takes no responsibility for cash sent with this form.


Predefined strings

You can predefine up to 24 strings in Easy Com. It's simple to add a predefined string and you save time not having to type frequently used strings each time you need to transmit them.

The strings that you define are saved in the file "Strings.cfg" in decimal format in the Easy Com directory. This is so you won't need to type all your predefined strings again if you need to move the Easy Com files to another computer. All other Easy Com settings are saved in the file "Easycom.cfg".

To make understanding of the data easy, each predefined string has a labelfield and a datafield. The labelfield is a freetext description of what the command in the datafield will perform. For instance, the label "Enq modem" is easier to understand then the actual data ("ATZ<CR><LF>").

Special characters can be added to the datafield by selecting "Add character".

All predefined strings can be selected in the transmit listbox. The label is shown when selecting a string, but once transmitted, the label is stripped as it's not part of the actual data.

If you type a string in the transmit listbox and want to save it as a predefined string, you can click the "Save string" button. You will be asked for a label for the string, and it will automatically be saved to the first empty position that is found.


Text mode

The data that is transmitted and received by Easy Com is, in addition to the DTE/DCE interface, always logged in a textbox which at any time can be viewed, printed to printer or saved to a textfile by clicking the "Show text mode" button in the toolbar. The button will stay down to indicate that text mode is enabled and you can toggle between the two modes at any time. This function replaces the previous logfile function.

By right-clicking the textwindow you can search for a matching string in the textbuffer.

In the properties window you can set some properties for text mode:

Convert unprintable characters

If checked the unprintable characters are shown as their character names within brackets.

Start each line with DCE/DTE tag

Starts each line transmitted with the tag "DTE:" and each line received with "DCE:" in the text window.

Show input only

Skips logging of all lines that are transmitted by Easy Com and only shows input data.

This is an example of how data is represented in text mode with convertion and DCE/DTE tag:

-----------

DTE:ATZ<CR><LF>

DCE:ATZ<CR><LF>

DCE:<CR><LF>OK<CR><LF>

-----------

The same transmission would look like this without DCE/DTE tag and convertion:

-----------

ATZ

ATZ

OK

-----------

 Input only would look like this:

-----------

ATZ

OK

-----------


Adding special characters

Often, you need to transmit characters that can't be written using the keyboard. In Easy Com you can add such characters, both directly to the text to transmit, and to any predefined string.

Select "Add character" to add a special character to the string. A window will be displayed with a table of all available characters (0-255 decimal).

At the bottom of the window, information about decimal value, hexadecimal value, binary value and the characters name is displayed.

Click the character you wish to add and select "Insert" to add it to the string.

You can also right-click the "Add character" button and select a character to add, or use the speedbuttons, but this only works with the most common characters (0-32 decimal and CR+LF) that are used for serial communications.

The NUL character (0 decimal) can't be added to a string as a single character since it is not printable. Easy Com adds the substring "@NUL@" instead of a character to overcome this problem. The "@NUL@" substring will be stripped and replaced by the NUL character when transmitted.

Note: To be able to transmit characters with the decimal value 128 decimal and above, you must use 8 databits for communication. 7 databits only supports characters 0-127.


Memo notes

The memo notes function is an easy way to keep notes of things you need to remember the next time you run Easy Com. Simply type any text in the field, and it will be saved automatically. Memo notes are saved in the file "Memo.ini".


Transmitting files

You may need to transmit multiple commands to your serial device.

For this purpose you can create an ordinary textfile in a texteditor like Notepad or Wordpad containing all the data to be transmitted.

Each line in the textfile will be sent separately, and in "File transfer delay" you can set up a delay in milliseconds between the transmission of each line in the file.

Note: If you need to use special characters in the textfile, be sure to use a texteditor in which you can insert such characters.


The statusbar

The statusbar shows information about the current settings in Easy Com.

The first row shows information about:

Devicename, baudrate, parity, databits, stopbits, flowcontrol, provider and device open/closed status.

The second row shows information about:

Current date, current time, bytes transmitted, bytes received, mode (flashes while in repeatmode).


Properties

Device settings

The device settings are used to setup Easy Com to be able to communicate in a proper way with the serial device. Select the devicename, baudrate, parity, databits, stopbits and flowcontrol that applies to the device with which you intend to communicate.

Convert

You can choose to convert the string you want to transmit to a string of decimal, hexadecimal or binary values. Some serial devices RF-tag and Smart Card readers for instance, accept data only in such form. You could type the string using decimal, hexadecimal or binary values from the start, but this makes it much easier as you can type the text with normal characters and thus get a better overview.

Example:

String without convertion:	"ABC"

String with decimal convertion:    	"065066067"

String with hexadecimal convertion:	"414243"

String with binary convertion:	"010000010100001000100011"

Flags

You can set a number of boolean communication flags in Easy Com:

Parity check

Specifies whether parity checking is enabled. If this flag is checked, parity checking is performed and errors are reported.

DSR sensitivity

Specifies whether Easy Com is sensitive to the state of the DSR signal. If this flag is checked, Easy Com ignores any bytes received, unless the DSR modem input line is high.

Ignore Xoff

Specifies whether transmission stops when the input buffer is full and Easy Com has transmitted the XoffChar character.  If this flag is checked, transmission continues after the input buffer has come within XoffLim (readbuffersize/4) bytes of being full, and Easy Com has transmitted the XoffChar character to stop receiving bytes. If the flag is not checked, transmission does not continue until the input buffer is within XonLim bytes of being empty and the the XonChar character has been transmitted to resume reception.

Error char

Specifies whether bytes received with parity errors are replaced. If this flag is checked and the parity check flag is checked, replacement occurs.

Nullstrip

Specifies whether null bytes are discarded. If this If this flag is checked, null bytes are discarded when received.

Read/Writebuffer size

Specifies the recommended size, in bytes, of the device's internal input/output buffer.

Xon/Xoff characters

Specifies the value of the XON/XOFF character for both transmission and reception.

Properties available from the communication menu

DTR state

Checked - Sends the DTR (data-terminal-ready) signal.

Not checked - Clears the DTR (data-terminal-ready) signal.

RTS state

Checked - Sends the RTS (request-to-send) signal.

Not checked - Clears the RTS (request-to-send) signal.

XON state

Not checked - Causes transmission to act as if an XOFF character has been received.

Checked - Causes transmission to act as if an XON character has been received.

BREAK state

Checked - Suspends character transmission and places the transmission line in a break state. Note that this extended function does not flush data that has not been transmitted.

Not checked - Restores character transmission and places the transmission line in a nonbreak state.

For information on Text mode settings see the Text mode section.


DCE
DCE (Data Communication Equipment) is a term for the device that is connected to the DTE (computer), such as a modem or a printer.


DTE
DTE (Data Terminal Equipment) is a term for the controller of the serial connection, typically the computer.


Line monitor mode

A new feature in this version of Easy Com is the Line monitor mode. It can be selected in the properties window, and is used to display data transmitted from a host to a device.

Easy Com plugs in on the serial cable and displays the data traffic and signals, thus "spying" on the communication between the host and the device. The hosts messages are displayed in the DTE line and the device's messages in the DCE line.

For this you need a special cable, a Y-cable, and a PC or laptop PC with 2 comports. The cable should have 4 different connectors, one plugs in to the host and one to the device (this is the line you want to monitor). The other two are plugged in to the PC running Easy Com on the two comports.

Here is a description of how to make a Y-cable.

Take a straight (no switched pins) serial cable with 9 pin connectors, both male, and cut it in half. On one of the connectors write COM1 and on the other COM2 with a pen. These are your monitor cables.

Take another straight cable with 9 pin connectors, one female and one male, and cut that one in half. This will be your main cable.

Now you must connect the wires together again using the list below.

Cable design

For the first row in the table below, take the pin 3 wires from the main cables both halfs and connect them together with the pin 2 wire of the COM1 monitor cable. That makes 3 wires connected. Proceed with all 9 connections and your Y-cable is ready to use.

Main cable 	Monitor cables

Pin	Cable	Pin

3	COM1	2

2	COM2	2

7	COM1	8

8	COM2	8

6	COM2	6

5	COM1 and COM2	5

1	COM1	9

4	COM1	6

9	COM2	9

An easier version of the cable is just to connect the RxD and TxD (pins 2 and 3) of the main cable to the RxD (pin 2) on the monitor cables (the 2 first rows above). This will monitor communication but not the signals.

Now connect your main cable between the host and the device you want to monitor and the monitor cables to the comports on the PC running Easy Com.

You can monitor a DTE to DTE communication even though your cable is straight. The 9 pin female on the main cable works exactly like the comport on the computer (it's actually only an extension of the comport on which you've put your monitor cables) and you can plug in a straight or a nullmodem cable on it and connect it to a DCE or DTE device. If you need 25 pin connectors, just use converters.

In the properties window set mode to "Line monitor" and set the DCE and DTE devicenames to the proper comports.


Programmers troubleshooting

I've received a lot of mail from people who get their serial devices to work with Easy Com, but not with their own programs. I'll try to explain the basics for communication through your own program using ready communication-components.

The actual data that is sent on the comport is always one or more characters, a string, built up by a combination of the 256 different characters (only 128 can be used if you are using 7 databits) no matter what your manual says about bytes and hexcodes or binary codes.

Manuals for LCD´s, printers, readers or whatever device you use, can be very confusing when they try to explain how to communicate with the device.

An example:

Command:	$05, $0D, $0A

This does not mean that you should send the string "$05, $0D, $0A" but rather the 3 characters that these hexadecimal numbers represent (decimal 5, 13 and 10).

Another example:

Command:	00000101	00001101	00010101

Again, this is a string of the same 3 characters that should be sent to the device this time represented in binary format.

Serial communication in Visual Basic

In Visual Basic you would use the MSComm32 Active X from Microsoft to communicate with serial devices. Make sure you set the properties to the correct protocol parameters (baudrate, databits and so on).

The "Form_Load" event of the form can be used to open the comport when your program starts:

MSComm1.PortOpen = True

Add a button and type this code to the Click event:

Dim MyString As String

Dim i As Integer

MyString = Chr(5) & Chr(13) & Chr(10) 'or whatever characters you need to send to the device

MSComm1.Output = MyString

If you expect an answer from the device, and want to display it, you can add a textbox and change it's property value for MultiLine to true. Then add the following line of code to the OnComm event of the MSComm32 Active X:

If comEvReceive Then Text1.Text = Text1.Text & MSComm1.Input

This line is activated when a com event occurs with a receive data event. There are other com events that you can use, for instance to check the state of various signals.

In the unload procedure of your program, don't forget to close the comport:

MSComm1.PortOpen = False

That's all there is to it. Easy as that.

The MSComm Active X can be used in almost any developer platform such as Visual Basic, Access, Fox Pro, Visual C++ and so on, as all of these platforms supports Active X components. I think you can even use it in Excel and Word if you would find a need for it.

The Active X is included with the Visual Basic installation and it's filename is Mscomm32.ocx.

If you use Borland Delphi or C++ builder, MSComm can be used as well, but there is a free VCL component called Async32 from Varian in Holland, which I used to develop Easy Com. It's very easy to use and highly recommended. Included with the component is an example of use and some documentation and the source code (if you want to do your own Win API programming for serial communication, this is a good start and shows you what to do). It can be downloaded from any big Delphi site on the internet e.g. the Delphi super page. Thanks Varian.


Speedbuttons

The speeduttons provides an easy and really fast way to either transmit a single character or add one to a string.