From: jon_sree@world.std.com (Jon Sreekanth)
Subject: Re: Ring Signal/Software Problem
Organization: The World
Date: Sat, 25 Jul 1992 16:57:53 GMT


In article <1992Jul25.052616.1854@ecst.csuchico.edu> rmintz@ecst.csuchico.edu (Rich Mintz) writes:


   I have an application I've programmed that monitors the phone line.
   I've had a constant problem keeping track of how many time the phone
   has rung, because of all the specific timing problems associated with
   checking for the duration of a ring, how long after ringing stops to
   reset the count, considerations for passing through the ring-check
   procedure in mid-ring, while constantly monitoring if the phone has
   been answered (I'm using a voice mail card that can detect a pickup on
   the connected telephone) and doing miscellaneous other processing.

Ring consists of AC between 17Hz to 68Hz nominal, and the cadence
is 2 seconds on, 4 seconds off. All these numbers should be treated as
approximate. If you see RI going 1 -> 0 once, timestamp it, and 
keep incrementing time as long as there is at least one 1 -> 0 edge
in any consecutive 100ms period. When RI transitions stop, calculate
how much time elapsed. Often, if the ring generator got connected to 
your line in the middle of its duty cycle, you might get a short 
burst of ring, < 2 sec, so you have to decide whether to treat it as 
a true ring or not. If RI transitions don't start up again in about 
4 seconds, the caller hung up. While RI edges are happening, you
don't need to check the voice mail card for connected telephone
pickup, you only need to check it when RI edges stop, or during 
the 4 second silent period in between rings. 

   Through trial and error, I can sometimes get it to work right, but
   when I change to a different type/speed of computer, or change some
   aspect of the program that will affect the timing checks, it messes

Your program has to be robust enough so your timing is independent
of computer clock frequency. Can't blame the phone line for that ... :-)

   reliably determine the presence or absence of a ring. This indicator
   also seems to get falsely triggered sometimes when a pickup or hangup
   is made. I had considered constantly polling the Hayes S1 register on

Look for more than one transition on RI before doing anything. If there
are further RI transitions, suspect ringing. If there is 100ms timeout,
check for offhook, for an outgoing call. If none of the above, it was 
a glitch. 

   when I don't want my phone to ring. If I put a rectifier bridge and a
   big capacitor on the phone line going into the modem/voicemail card,
   will it (A) still ring my phone when I select to pass the line through
   to the connected (electronic ringer) telephone, and (B) register as
   ring detect to the modem and produce a continuous "1" signal on the
   serial RI line (as opposed to the normal 1..0..1..0 ring signal), and
   (C) screen out false '1' "blips" in the signal when I pick up or
   hangup my phone? In other words, will just the positive portion of
   the AC ring smoothed out with the capacitor so that it appears to the
   various ring-detect circuitry as a very elevated DC voltage be

Short answer : Mostly, no. 

The "canonical" ring detect circuitry in modems 
consists of a cap, 2 back-to-back zeners (about 20V or so), and an
optocoupler in series.  Normal phone line DC is removed by the capacitor, 
and AC waveforms which exceed the zener value cause current to flow,
which is sensed by the opto. If you feed full wave rectified DC,
you may have enough ripple to go through the zeners, or you may not. 
But if your original problem was too short a period when RI was 0,
you may just make it worse, because the conduction period through the
opto may get narrower. 

Answer to (A) is : the phone and modem will probably still ring. 
(B) whether you'll get a continuous RI indication : No. (C) 
probably not, you might still get RI on pickup/hangup.

   recognized as a ring? If not, is there an alternate configuration
   someone can suggest that would do this job?

I suggest getting away from hardware modifications. The RI assertion 
period has got to be at least a few mS, so it's hard to see why that's
difficult to check for. Put your filtering in software. Checking
for multiple RI edges, instead of acting on the first one, is a form
of software filtering. 

Here are some phone line related DIY books I've used :

1. Understanding Telephone Electronics, John Fike and George Friend, 3rd ed,
Howard Sams' and Co., ISBN 0-672-27350-0, LOC 91-62208, 1991, $24.95

2. Electronic Telephone Projects, Anthony Caristi, 
Howard Sams' and Co., ISBN 0-672-22485-2, LOC 86-60937, 1986, $10.95

3. The Talking Telephone, Steve Sokolowski, 
Tab Books, ISBN 0-8306-3571-8, LOC 90-36056, 1990, $17.95

4. Customize Your Phone, Steve Sokolowski, 
Tab Books, ISBN 0-8306-9054-8, LOC 88-24795, 1989, $12.95

Good luck, 

/ Jon Sreekanth

Assabet Valley Microsystems, Inc.           |  Fax and PC products
5 Walden St #3, Cambridge, MA 02140         |  (617) 876-8019
jon_sree@world.std.com                      |
Newsgroups: sci.electronics