Digital Communications
                                by Hank Volpe


Note: This material is copyrighted 1990 by Hank Volpe. Reprints of this
      article have appeared in more than 50 newsletters around the country.
      For more information or comments, please write to;
                               Hank Volpe
                               P.O. Box 43214
                               Baltimore MD 21236

                         A Modem Primer - Part 4 of 4

Hopefully you've been part of the last 3 articles here dealing with modems, 
cables, UARTS and computers. If not, take a look through the back issues of 
your newsletter and find these articles. In summary, we've spent time looking 
at some of the technical, physical, and programming facets of using a modem 
with your computer. We have been following a "college" analogy all along and 
will conclude with our senior level talks about modems this month. You should 
realize too that like college, all the information presented here is 
incomplete. This is a starting place. Before we start I'd like to answer a 
few questions about how I learned about modems.
  About 7 years ago I brought a modem home from work. The unit was what we 
call these days a "dumb" modem. It had lots of switches on the front with 
labels like SAL, DL, HS, MR and of course no idea of what these things meant. 
Also, the reason I brought the modem home was because it did not work. It was 
busted and was being thrown out. Being an engineer by trade, I spent a few 
hours fixing the modem. Again, you must remember that 7 years ago, even a 
dumb modem that worked at 1200 bps was at least a $500 item. I managed to get 
it working in a self-test mode that I had stumbled on by accident, however I 
had no idea now what to do with it. A friend of mine explained to me that I 
needed a program to make my PC work with the modem, and he gave me a copy of 
something called PC-TALK. PC-TALK was one of the first shareware programs
distributed via modem on BBS's. I had no idea at all about BBS's's, modems, 
or shareware. I also figured out that PC-TALK was not designed to work with 
my modem. It was meant to work with something called a Hayes. Well, after 
some playing around, I figured out how to make the calls myself, press a 
button to place the modem on-line, and get connected to a BBS. The first 
questions I got were about Xmodem. What the heck was an Xmodem? How did I 
change from 300 to 1200 bps? It was a very exciting time, because I was 
totally confused yet fascinated by this modem and how it could extend my 
computer to other machines. Back in 1974, I had built my first computer by 
making my own microprocessor and memory boards, building a disk drive kit and 
a terminal kit, and placing it all together in a S-100 motherboard kit. It 
was wonderfully incompatible with the universe, and as such, was very 
frustrating to work with. Now I had this compatible PC, and I could tap into 
other computers over the phone. However, my knowledge of the subject was 
extremely limited. I may have been a good engineer, but I knew nothing about 
computers from a system integration side. The modem turned out to be a 
catalyst for me with computers. 
  Sources of information about modems and computers are not hard to come by, 
but you do have to do some digging. Most of my information came from 
Technical reference manuals on the computer, modem, and UARTS. These books 
are very technical in nature (I guess that's why they are technical reference
manuals) and as such assume you know a great deal about the subject you are 
trying to find information about (its like a dictionary..you have to know how 
to spell a word in order to look it up to find the right spelling!). Now 
days, there are plenty of well written information books on the subject. If 
you are interested, go to your main branch library and browse through the 
computer section. I think you will be amazed at the volume and scope of on-
hand information your library has on computers and modems. The final thing 
you need to learn how a modem works is the desire to experiment. Try setting 

things up a certain way, and see the results. If it doesn't work, try a 
different way. You have to maintain that "beginner's" mind we talked about in 
the first article on modems or you cannot learn anything of value. That's a 
brief summary of how I learned about modems and how much time I've spent with 
them. Most of you reading this probably know more about modems now than I did 
when I brought the broken one home to repair. Just remember that persistence 
does pay off!

Modem 401 - A handshake is better than a kiss

You and a friend meet. What do you usually do? If you are like most people, 
you make some physical contact, usually a handshake, to exchange greetings.
With your employer, you might shake hands on an agreement. In our society, a 
handshake can mean many things, but at its basic level, it is a physical 
"touching" of another person. Computer devices need to handshake too. 
Handshaking is part of a protocol, just like it is in human society. There 
are different kinds of handshakes for different occasions. Meeting a business 
client invokes one kind of handshake, a close friend you haven't seen for a 
long time invokes another kind of handshake, and meeting a lover invokes a 
third type. Computers also have levels of handshakes depending on the level 
of intimacy expected or desired between devices. The reason for these 
handshakes is to put the two devices (or people) at ease with each other and 
set the basis for a mutually satisfactory exchange of information. A 
communications "business" contact usually involves the least amount of 
handshaking, while "making love" (transferring a file in an error-free 
manner) involves the most intimate intertwining between systems. A computer 
meeting a modem via a Uart at a basic level needs a bare minimum of wiring. 
You need a wire to transmit data (the TX line), a wire to receive data (the 
RX line) and that is about it. So why are there so many other connections 
available on your 25 pin external connector? These other wires are used to 
implement different levels of hardware-level handshaking. The level you use 
directly limits the speed and method of moving data between machines that you 
can use.

The most basic handshake (the business client) uses two signals. Each device 
places a signal on a line that can be read by the other. The computer in data 
communications is thought of as a "Data Terminal", while the modem is 
considered a "Data Set". When you enable a serial port via your 
communications program or by using Dos's Mode.com, a signal called the "Data 
Terminal Ready" or DTR is activated by the Uart under direction of the 
computer you are using. At the other end of the cable (or on the other side 
of the Uart in internal modems), the modem senses ("feels?") this signal, and 
raises its hand in friendship by activating its "Data Set Ready" signal or 
DSR. The computer extends its hand, and the modem extends its hand, and the 
two now know that each other has shown up for their meeting. Most business 
meetings usually have a "social-time" before the actual negotiation starts. 
During this time, information is exchanged, but usually the information is 
more or less setting up the ground rules or just getting to know each other. 
However, when the formal part of the meeting starts, each side makes their 
presentations along those agreed guidelines. Between computer and modem, the 
preliminary work is done before the modem connects to a BBS or a data 
service. The modem makes its connection, and signals the computer that its 
time to get to work by raising another signal line called the "Carrier 
Detect" or CD line. Hayes-compatible modems also can return an English 

message to the communications program saying "CONNECT", however it is up to 
your program to read that message. Just to be safe, and to prevent 
"misunderstanding", the CD line is raised. 

Body language plays a big part in effective human communications. You walk 
into your boss's office and want to ask for a raise. He greets you with a 
hurried look on his face, grumbles about how high heating bills are these 
days and puts his arm around you and walks you to the door. Unless you are 
really an odd person, you would have figured out that his arm around you does 
not mean he is happy to see you, but rather that he is too busy to talk right 
now and that you can come back some other time. Well modems and computers 
have this same type of handshaking too. Each system can tell the other it is 
ready to send information by raising the RTS (Ready to Send) line. If the 
corresponding receiver raises its CTS line (Clear to Send), the data is 
transferred. If not, the computer or modem can wait until it sees a CTS 
signal, or it can forget about the whole thing. 

Modem 402 - Platonic Connections

There are other ways of handling handshaking between a modem and a computer. 
The methods we talked about above were all based on physical connections 
between the computer and the modem, or in other words, hardware handshakes. 
There are software handshakes that can be used too. Software handshakes are 
pre-defined characters that appear in a data stream. These handshakes can be 
used to relay many different types of instructions between computers or 
between modems. One of the most popular forms of software handshaking is the 
Xon/Xoff system. Xoff (or Control-S) is nothing more than an ASCII character. 
If a modem or a computer recognizes an Xoff command, then it stops 
transmitting data until it sees an Xon command (or Control-Q). Xon/Xoff can 
work between modem and computer, between computer and computer, between modem 
and modem, or even inside of a disk operating system. If you want to see a 
software handshake, tell Dos to type a document to your screen, and then 
press the Pause key on your computer (or Control-S). The screen pauses until 
you press another key to restart it. Control-C is another software handshake 
that tells a program to abort and return to Dos. There are many different 
software handshakes that can be used, but each one has a clear purpose; to 
control the flow of data between devices. 

Software handshaking can also do more than control the flow, it can also be 
used to detect and correct errors that occasionally happen between devices. 
When you call a BBS with your modem you are simply connecting one modem to 
another. Occasionally you will see funny characters on the screen, mostly due 
to a poor connection or to weather conditions. These funny characters are 
caused by the fact that the numerical code for a character got "damaged" and 
altered by transmission. Changing an A to an E is nothing more than changing 
the number 40 hex to  45 hex. In a text transmission, this is more of a 
nuisance than anything else, however if you were downloading a program, this 
could introduce a serious flaw in the program you are receiving! To make 
matters worse, how would you know you have received that error? After all, 
you are getting a file of commands, not text. The only way to do so is to let 
the computers detect an error between them and correct it without you getting 
involved. Such a software handshake method places data into packets of 
information. The size of this packet can vary with the method, however the 
purpose is the same. Each packet contains a packet number (or block number), 

the data to send, and a check value at the end. A computer transmits this 
over the modem. The receiving computer calculates a check value and compares 
it to the value sent to it. If they agree, it moves on to get the next block. 
If not, it asks for the same block to be transmitted again. There are many 
different methods of packeting data. PC-based communications programs call 
this a file-transfer protocol. Whether you use Xmodem, Ymodem, Zmodem, Kermit 
or one of a dozen more protocols, you are using a software 
handshake/correction system to control the flow of data and to correct 
errors. The software method can also be placed inside of a modem instead of 
inside of a communications program. These types of modems are called "error-
correcting" modems and they use a system of sending data between them. One of 
the most popular methods is based on a network-packeting system developed by 
Microcom. Modems that use this method are called MNP (Microcom Network 
Protocol) modems. Another method is called V.42 bis. The latter is from the 
CCITT (an international group that makes recommendations for manufacturers to 
follow). The important thing here to realize is that software handshaking can 
be implemented in many ways, like hardware handshaking. A "business" contact 
uses the fewest controls. In order to operate most modems with your PC, you 
need only to use a TX wire, an RX wire, a DTR wire and a DSR wire. 
Communications that require more "contact" (like 9600 bps communications 
while multi-tasking) require that each device know when the other is ready to 
send and ready to receive. For those, you have to add the RTS and CTS signals 
to your cable. Finally, if a system is to "make love", it needs the most 
intimate details (and also to know if it is performing up to desired 
expectations). At this point you need to have real communications between 
systems. It can be Xon/Xoff, MNP, V.42 or a file transfer protocol, but 
whatever the method, the purpose is to link two systems together as closely 
and intimately as they can.

If you have an internal modem, pay close attention to how you have the 
handshaking set. By default, most modems do not properly use the DTR/DSR 
handshaking. If your software requires this type of communication, it might 
not run properly. If you have an external modem, you should make sure you 
have the right data cable for the job. A data cable can work with as few as 2 
wires, but it will not have all of the handshaking signals in it. You might 
find out that the modem works with some programs but not with others. Usually 
when you buy a data cable, it lasts for the life of the system, so don't go 
cheap. Purchase one that has all the proper handshaking signals (DTR/DSR, 
RTS/CTS, CD, RING, TX, RX). Finally, if you have a high-speed modem, check 
that you are using the proper handshaking between computer and modem. Most 
communications programs use RTS/CTS signalling for high-speed modems. This 
handshaking is important, because when the computer is storing data to your 
disks, it cannot properly get data from your modem. The modem must be told to 
stop transmitting during this time. The communications program will drop its 
RTS signal to the modem, and the modem will hold data in its internal buffer 
until the communications program signals it to start again. This type of 
handshaking is usually important at speeds over 2400 bps.

Modem 403 - Why doesn't my modem work ?

Modem's are fairly easy devices to attach to a computer, and this appears to 
be the biggest reason why things can sometimes go wrong. Compared to fixed-
disks, or memory expansion, a Modem requires nearly no changes to your PC. If 
you are using an external modem, all you need is a cable and a serial port. 

Internal's plug right into a free expansion slot. No muss, no fuss..no work? 
Oh boy, now what is wrong? The best place to solve this problem is to use the 
tools siting right in front of you; the computer and the modem. 

External Modems have LED (Light Emitting Diode) displays that tell you the 
state of certain communication control and status lines. Internal Modems do 
not have these lights, but you can get the equivalent of these lights in 
several programs. Diagnostics such as Checkit or QAplus, or shareware 
programs such as  Breakbox, lights, and the Modem Doctor  all have a feature 
that will show you the status lines of the Modem. These lights are critical 
to finding out if you have a hardware problem. Normally, when a Comm port has 
been properly opened (either by Dos's Mode.com or by a communications 
program), the Serial Port raises several control lines. As we discussed 
above, the two most important are DTR (Data Terminal Ready) and its 
complimentary status signal sent from the modem DSR, or Data Set Ready. Your 
external Modem should show the state of these signals, but it will not 
necessarily use these names. If you have a modem that follows Hayes Modems 
nomenclature, the TR and MR lights will reflect the status of these two 
lines. For your modem to work properly, the TR light (Terminal or Transmit 
Ready which actually is the DTR line) has to be lit. The MR (Modem Ready, 
usually the DSR line) also should be lit. If they are not, and the Serial 
port has been opened properly, you may have a bad cable between your computer 
and your modem. If you use Brkbox or Lights for your internal, you also 
should see these lines lit. The Modem Doctor  will perform a diagnostic and 
display an error message if these lines are not up.

Another pair of indicators that are important are the TX and RX lights 
(sometimes called SD and RD). These are the transmit and receive indicators 
on your modem. When you are running a communications program in the terminal 
mode and you press a key, the TX light should flash (saying that the modem 
got a character) and the then RX light should flash (saying that the modem 
echoed it back to the computer. If one or the other is missing, you might 
have a bad cable again, or a bad Serial port.  If the MR light is out, then 
there may be some problem with your modem. Also, some modems have another 
light called a MC (or Modem Check) light. If this lights, that could mean 
there is something wrong with your modem. Some modems have an extra set of 
lights for the RTS (Ready to send) and CTS (Clear to send) lines. Again, 
these handshaking lines are important in high-speed modems, but unless your 
communications program is looking for these signals, they can be disregarded 
as a source of a problem. Most communication programs have an option to 
select RTS signaling or not. If you cannot communicate with your modem, check 
to see if you have accidentally activated this feature in your communications 
program or purchase a serial cable that has all of the handshaking pairs 
carried out to the appropriate pins. OK- so all the lights are correct. What 
next? Well one problem might be, if you type a character to the modem it 
comes back on your screen fine, but when you try to call a BBS or while you 
are connected things go kind of strange, what is the next thing to check? 


Modem 404 - Interrupts and you

The PC has limited resources for Serial Ports, in fact the ROM-BIOS only 


supports 2 of them. However, there are industry standards that expand this to 
4 Serial Ports. 4 Serial Ports should be enough for the average user, but the 
problem is that you can only use 2 of them at a time. The reason for this is 
due to the fact that they must share IRQ lines. Each time a character is 
received by a modem, it has to get the attention of the computer by raising 
an Interrupt Request Line (IRQ). PC type computers have 8 of these lines, AT 
type computers have at least 16. The 8259 Interrupt controller chip handles 
these requests for attention. By design, COM1 uses IRQ4 and COM2 uses IRQ3. 
IRQ7 is assigned to a printer, IRQ5 to the Hard Drives. It is possible to use 
COM1 and COM2 or COM3 and COM4 at the same time, but you cannot use COM1 and 
COM3 or COM2 and COM4 at the same time because these share IRQ lines. 

Confused??? Well, to make it easier to understand, if you have a computer 
with built-in Serial Ports and you want to use an internal modem, you just 
might wind up with an IRQ conflict or a Serial Port address conflict. What 
happens is that the computer is actually talking to two ports at the same 
time, and that can cause bad characters, false errors, jam-ups or 
intermittent problems especially at higher speeds. If you have a Serial Port 
conflict, you might be able to work around that. If you have a built-in 
Serial Port assigned to COM1, you might be able to disable it by removing a
jumper. If you are not technically inclined and don't feel like playing with
the inside of the machine and are lucky enough to have an internal modem that
can be assigned from COM1 to COM4, then you can use another Comm Port
assignment for the Modem. You will still have to watch your IRQ conflicts, so
if you are using COM1 lets say for a mouse and you want to use your modem at
the same time, then it has to be COM2 or COM4 so the modem will use an IRQ3
while the mouse will use IRQ4. Another way out would be if your modem uses
IRQ7 or IRQ5. You could assign it to COM3 or COM4 and use one of these
different IRQ lines. Remember though, IRQ5 and IRQ7 are reserved for other
devices, so you still might not be able to get around the conflict without
disabling one of the built-in Serial ports. Also, if you needed to use 3 or
more COMM ports at the same time, you would need to use another IRQ line.
However, if you do not need to use 3 or more COMM ports at one time, then it
is best to stick to the reserved IRQ4 and IRQ3 for all of your activity.

Graduation Day

  Well here we sit at the end of our class. If you save these articles you
will have a good source of reference material. However, this material is far
from complete. Its an introduction. You need to follow through and build on
what you have seen here. Take a trip to the library, or read your modem
manual, or pick up one of the many books written to guide you through PC
communicaitons and that help you peek inside your PC. In any case I hope that
these 4 articles have helped you understand more about your modem, and I
would love to hear your comments. Just send them to the address above.