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 2 Last month we started a discussion about modems and we thought it best to approach the topic from a philosophical standpoint with a "beginner's mind". We discussed how a modem works, why we need modems, what are Uarts and why do we need them , and what are Comm ports. We called this our "Freshman" level in our series. Tonight we move onto some sophomore (not sophomoric!) topics, starting with "What is a Hayes?" Modem 201 - What is "Hayes"? ---------------------------- Actually, it should be "who is Hayes"? Dennis Hayes founded Hayes Micromodems a few years ago. Some people actually believe that he invented modems. Well he did and he didn't. The actual physical modem has been around for quite a long time now. What Dennis Hayes did was invent one of the earliest modems designed specifically for microcomputers. Hayes modems are very well built, but this day and age, the same can be said for almost any modem. The circuitry for most modulation and demodulation sections of modems are contained on standard chip sets made by Rockwell, XR, and a few other manufacturers. What made Hayes modems the "standard" was the programming interface that Dennis Hayes created. As I sit here and type, it occurs to me that one of the most frequently used words around computers is "Interface". It is spilling over into all of our modern "lingo" where people who sell cars talk about interfacing to clients. An interface in electronic terms is simply another word for a connecting method. Connectors can be physical or virtual. Virtual means that it acts like a real connection, but it is not physically real. An example of a virtual connection is a software switch. It acts like a switch that might be attached to a light, and it does turn something on or off, but it's just a character on a screen, it's not a real, touchable switch. A programming interface is a virtual connection between devices or modules in a program. Hayes modems came with a programming interface that allowed people to write programs that used modems, but to be able to do it in a manner where the programmer did not have to actually write commands to dial, connect, change baud rates, or disconnect. The Hayes modems contained a microprocessor. This in function was no different than your computer you use everyday, however it's only purpose was to look at the characters being sent to it. If a line started with the letters "AT", the Hayes modem knew that the next group of characters it would see would contain a command for it. This command could tell it to answer the phone (ATA), dial a phone number (ATDT832-1398), turn off it's speaker (ATM0), turn on it's speaker (ATM1) and a host of other commands. Likewise, it interfaced back to the computer program using it by sending real English messages like "OK", or "CONNECT 2400", "RINGING", "BUSY" and the like. Programmers loved working with it because it offered two advantages to them; First, all they needed to do was send characters to the modem to do all kinds of complex telecommunication activities, and secondly as long as a modem used this "AT" command structure, it didn't matter if the end user went out and bought a new and improved modem, for as long as it used the "AT" instruction set, it would continue to work with the software the programmer had written. Hayes had succeeded at something IBM failed to do, for IBM originally had thought of the ROM-BIOS in it's machines as a virtual connection between a program and the computer. IBM could have then changed the way the computer worked in a manner transparent to the software, as long as the software used ROM-BIOS calls. Well as anyone who has been around computers knows, the ROM-BIOS in the original PC's worked so slowly that programmers took short-cuts around it. This doomed the PC and future PC makers to forever stay hardware compatible with the original machine. Dennis Hayes's "AT" set however became the standard for personal computer communications in the PC, Macintosh, Atari, and nearly all other digital communication devices. Many people make modems that are compatible with the Hayes 300/1200 and Hayes 2400B modem command sets, with some expanding or creating what computer people call "supersets" of the original Hayes "AT" instruction set. When you are shopping for a modem, you will see them touted as "Hayes Compatible". What that means is that they use the "AT" instruction set and follow the same command structure as did the original Hayes 300/1200 or Hayes 2400 series modems (there is a slight difference between the 300/1200's and the 2400 commands). This does not mean they are as good as a Hayes, in fact they might be better. All it means is that you can use 99% of all the communication software developed for your PC with this modem. Ok, so if 99% work, where is that 1% incompatibility? Well, there are storage registers on a Hayes modem and most compatibles. These storage registers (or S-registers) hold vital communications information. They store all the parameters the modem uses to communicate. These registers can be accessed, just like a programmer can write directly to your screen and bypass the ROM-BIOS. If a program does this, then it obviously expects the display adapter to use a standard address. If a programmer writes or reads an S-register, it expects the modem to use that S-register for the same thing that the modem it was written for originally had used. Although a modem claims to be "Hayes Compatible", it is doubtful that it is 100% Hayes "hardware" compatible, for the only way to do that is to own a Hayes. If your software was written in such a way that it expects Hayes "hardware" compatibility, then that program may need to be modified when used with a different brand of modem. Many of the early BBS programs were written for this hardware compatibility and would not operate properly without it. What modem should you buy then? It depends on the application. Quite frankly, most communication programs written during the last 2 years will work well with any modem that uses the "AT" instruction set. There are other considerations in buying a modem that we will discuss when we get to the end of our series, for we have a lot more ground to cover. For now though, remember the buzz word "Hayes Compatible" and that it truly means "AT instruction-set compatible" (interfaces like a Hayes to your software). Modem 202- Learning to speak mnemonics -------------------------------------- Like any good college program, a foreign language needs to be included so that the student's eyes can be opened to a wider world. Language is one of the interfaces between human beings, but there are others: music, video, still pictures, and smells also serve as languages. Some of these, especially still pictures and smells can be a more powerful messenger than written correspondence. Languages can also pose problems in the areas of translation, and when translations are made between languages (like for example in phrase books) the true meaning of the original language can be lost or misinterpreted. Lately we have been noticing a rise of what have been termed "international symbols". A picture of a dog with a line through it means "no dogs allowed". I guess that someone could still misinterpret this sign on a restaurant to mean that "dogs are not served on the menu", but these symbols for the most part can be fairly straight-forward message bearers between languages and people. In the computer world, such messages are called mnemonics. A popular example of a mnemonic is an icon that you access with a mouse. Another example would be the command names used in assembly language programming for op-codes, still another the name you assign to a range of cells in a spreadsheet program. Mnemonics are kind of a pseudo-language that can be easier to understand than a full-blown language. Now there are many different ways of looking at the AT instruction set, but I think the best one is to think of it as a series of mnemonics that help you control your modem. As I explained earlier, the AT of the AT instruction set means "attention". It is a way for the microprocessor in the modem to distinguish between normal characters being sent to it and a command. There are also two modes that a AT compatible modem operates in; the command mode and the on-line mode. When you first turn on your computer and load a communications program, you are communicating to the modem in the command mode. When your modem connects to a BBS or other service, the modem switches automatically to the on-line mode. When you are in the command mode, you can talk to your modem using AT commands and change many of the ways that the modem functions. When you are in the on-line mode, you cannot communicate to the modem with AT commands (there is a way to go back to the command mode while on-line, but we'll talk about that later). The beauty of the command mode is not only appreciated by people who write communications programs, but it can be appreciated and used by you too. After you have loaded your communications program (lets say Procomm, Qmodem or Telix for the sake of discussion) you will notice that you can type characters on the keyboard and have them displayed on the screen. How does this happen? No, computers don't echo what you type to the screen like a typewriter, you have to instead have a program that will take a character and send it to the screen. Good proof of that is try typing characters when your computer is hung-up. Nothing happens! MS-DOS does the echoing for command.com and programs can use MS-DOS or their own echoing schemes. When you are communicating with a modem you send characters by typing on your keyboard. These characters are then sent to the modem. The modem then sends these characters back to the computer, where the program you are using places the character on the screen. This is technically referred to as "Full-Duplex" operation and "Local Command Echo". In this mode, you can change many of the operating characteristics of your modem by typing a few letters. All you need to do is follow some simple rules; First, all commands must start at the beginning of a line and the first 2 letters must be AT. Second, you can place multiple commands all on the same line up to about 40 characters. Third, all the characters you type must be legitimate commands for your type of modem, otherwise you will see the word ERROR get echoed. Try sitting at the computer with your communications program loaded and type the command ATH1 and press return. This will take your phone off-hook and you should hear a dial tone. To place the phone back on-hook, type ATH0 and press return. Voila! You are now speaking mnemonics to your modem. More importantly, you've just taken the first steps to letting the modem work for you! Using AT commands, you can set your modem up for special applications. For example, most BBS programs do not like to see local command echo, so there is a command ATE0 that can be used to turn this echo off. If you do this, you will notice that from that point on every character you type to the modem will not be displayed. The modem will still respond and send the word OK or ERROR back to the screen, but it will not echo the character you type back to the computer. To turn the local echo on again, just press return (to make sure you are at the beginning of a new line because you don't know for sure since the echo was off), type ATE1 press return. The modem responds OK and now you can see your characters echoed back again unless you type another ATE0. You could start your program and tell the modem that you want to turn the speaker off all the time by typing ATM0 and pressing return. To turn the speaker back on, type ATM1 and press return. Simple eh? It really is. There are many AT commands that can be used by you to program your modem to work the way you would like it to. Take a look at the book that came with your modem, or if you don't have a modem (or lost your book), there are some reference books you can pick up at your book store that list these commands. Now say that you would like to turn off the speaker each time you start your communications program because you hate hearing dial-tones. You can start your program, then type ATM0 and press return. This works fine. But lets assume you wanted to do some other creative things too. Typing this over and over can be bothersome, and of course you could type an ATM3 when you meant an ATM0 by mistake. It's time to explore a built-in feature of most communication programs call the initialization string. Modem 203 - Using initialization strings ---------------------------------------- What is an initialization string? Well, it's nothing more than some AT commands that are sent automatically to your modem by your communication program each time you start it up. A proper initialization string can be important to some applications. For example, a bulletin board program usually does not operate properly if the incorrect initialization string is being used. Most communications program allow you to custom set your modem each time you start it up. What you put in that initialization string is totally up to you. In our previous example, if you wish to turn off the speaker each time the communication program is loaded, then your initialization string is ATM0. If you wish to return extended result codes that will tell you if the modem sees a busy signal, your initialization string is AT X4. If you wish to both turn the speaker off and see extended codes, your initialization string is AT M0 X4. Any legal command for your modem can be placed in this initialization string. You can also manipulate the contents of something called S-Registers. An S-Register is a memory location in the modem. Each location is marked with a number S0 for example records how many times the phone has rung. S7 sets a timer that counts down a pre-determined number of seconds that the modem will wait until it quit's trying to make a carrier connection. S11 controls the speed that your touch-tone dialing commands get sent out to the phone company. S-Registers are different from AT commands, primarily because how many S-Registers you have and how they are used can vary from manufacturer to manufacturer (or in other words, they may or may not be hardware compatible with Hayes). The first 16 S registers however have been universally implemented to work the same as the original Hayes 1200's. Your modem may have more or less than a Hayes. Some modems have close to 99 of these S-Registers. Fortunately, you do not need to be as familiar with S- Registers as you do with AT commands. Some simple tricks with S-Registers is all you need to know in order to use your modem properly. Put these S- Register commands in your initialization string and you have a powerful, yet easy tool for setting up your modem. To change the contents of an S-Register, you just type (on a new line of course) ATSx= nnn (x = an S-Register number, nnn = a 3 digit parameter). For example, to change the time a modem waits to connect from it's default time of 30 seconds to 255 seconds, type ATS7=255 and press return. To read an S- Register value, you type ATSx? (where x again is the number of an S- Register). to see the value of the S7 register, just type ATS7? and press return. The value currently in the S7 register will be displayed in a 3 digit form (030 is the default, for 30 seconds). All S-Registers have default values, but there can be reasons for changing these defaults. For example, suppose you wished to wait for 1 minute to connect to a BBS instead of 30 seconds. You have to change the value of the S-Register 7 in order for your modem to work properly. So your initialization string (including what we already mentioned above) now becomes AT M0 X4 S7=60. The only limit to the number of commands you can use is usually 40 total characters (for most modems). Recess time ----------- Well that is about all the space we have for this month's look at our series, a Modem Primer. Next month, we'll go to the junior level and talk more about using initialization strings, serial cables, internal vs external modems, and handshaking signals.