Telephone interface questions


Closed Thread
Results 1 to 19 of 19
  1. #1
    Join Date
    Mar 2010
    Location
    Los Angeles, CA
    Posts
    13

    Default Telephone interface questions

    Greetings!

    I'm working on a personal project that involves interfacing a PIC micro to the telephone and dialing out a specific phone number using DTMF tones generated by the PIC. I am using a 16F876A and am following a schematic I found in the old Basic Stamp Nuts & Volts articles (NV 19 Fig 19-1, see attachment). I have recreated the circuit verbatim with the following exception:

    -I am using .1uF capacitors and 100 ohm resistors on the tip and ring lines in place of relays/switches

    I have constructed the circuit and written a really simple PBP program just to see if I can connect, shown below.

    Given all of this, the circuit doesn't work. The code sends the tones to the speaker and to the LCD, so I know that's working, so it's something in the circuit. I have read on this forum that for phone circuits the oscillator should be 20 MHz, but I will admit I haven't tried that yet. I'll do that later today/tomorrow. Just wanted to get this out there in case anyone saw something glaringly wrong with the circuit.

    I'd appreciate any advice anyone can provide, troubleshooting the circuit, etc.

    Code:
    ' PIC16F876 to predefined connections:
    '
    ' PIC 		    LCD		Other Connections
    ' ------		-------		-----------------------------          
    ' OSC1			Resonator - 4 mhz
    ' OSC2			Resonator - 4 Mhz
    ' MCLR			Vdd via 1k resistor
    ' Vdd			5v
    ' Vss			Gnd
    ' RB2           Output to serial LCD
    ' RB4           Output to speaker
    ' RB5           Output to phone line
    
    ' -----[ Revision History ]------------------------------------------------
    '
    ' ----[ Includes / Defines ]-------------------------------------------
    '
    INCLUDE "MODEDEFS.BAS"  'This statement is needed for serout defines.
    
    Define LOADER_USED 1     'Only required if bootloader used to program PIC
    'define osc 20               'Oscillator speed is 20 MHz
    
    ' -----[ Constants ]-------------------------------------------------------
     
    ' -----[ Variables ]-------------------------------------------------------
    '
    ' -----[ Initialization ]--------------------------------------------------
    '
    ' -----[ Main Code ]-------------------------------------------------------
    '
    
    Start:
        serout 2,N2400,[254,1]
        serout 2,N2400,["DIALING...",254,192]
        pause 1000
        DTMFout 4,[1,8,1,8]
        DTMFout 5,[1,8,1,8]
        serout 2,N2400,[#1,32,#8,32,#1,32,#8]
        pause 1000
        Goto Start              ' Loop back and do it all again
    Attached Images Attached Images  

  2. #2
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default

    You can send the PIC tones to the phone handset microphone circuit and read tones from
    the handset speaker circuit if it is easier.

    Norm

  3. #3
    Join Date
    Mar 2010
    Location
    Los Angeles, CA
    Posts
    13


    Did you find this post helpful? Yes | No

    Default Telephone Interface - Got it working...

    Woo hoo!

    I got it working. I had incorrectly wired one leg of the transformer. I dialed out to a couple of phone numbers successfully. I used the default 4 MHz oscillator.

    I'm a bit of a novice at this, so you'll excuse my excessive enthusiasm over seemingly trivial successes...

    I noticed that after dialing out and ending the call, I must disconnect the phone cord from my circuit and reconnect it to a real telephone. Once I confirm a dial tone, I then connect the phone cord to my circuit again and confirm that there is a dial tone in the phone. Then I reset the PIC and it dials out. I'm guessing this has something to do with on-hook/off-hook states. Would a dialing IC in the circuit permit changing the on/off hook states using the PIC? Any recommendations?

  4. #4
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Skarr,

    Just pic'ed up on your post. Have to go to work now but will get back to you tonight on this.

    I'm doing the same type of project.

    BobK

  5. #5
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Skarr,

    If you put a relay in the circuit as indicated then you wouldn't need to plug and unplug your circuit to the phone line. Your program would include a line to turn the relay on such as:

    PortB.1 = 1 'turn line seizure relay on

    Then when you are ready to disconnect from the phone line you would program:

    PortB.1 = 0 'turn line seizure relay off

    Line seizure refers to a relay that disconnects the house phones and connects the phone line to the dialer. This prevents someone from picking up the phone in an attempt to block the call. Then there is another relay with contacts in series with one side of the phone line that would be closed then the dialing would take place. When the phone call is completed, then both relays would be turned off. The phone line is returned to the house phones until the next call out.

    You will need to drive the relay circuit with either a transistor or with a driver package like the ULN2003 or ULN2004.

    I have been in the alarm business for a long time and I am quite familiar with dialers and their circuitry and inner workings. I finally decided I wanted to design and build one of my own just for the heck of it. I am in the beginnings of the design phase and will be happy to share ideas with you on this. I've been getting other work related projects out of the way so I can focus more on the dialer project.

    HTH,
    BobK

  6. #6
    Join Date
    Mar 2010
    Location
    Los Angeles, CA
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Thanks for the response, BobK. I appreciate your assistance.

    I do have a few solid state relays but I'm not sure if they'll work in this application. I think I have some schematics for hooking this up; I'll stumble through and if I encounter a problem I may ask for some help...

    As far as my project goes, I'm helping an aunt with a resuce/service dog. In order to get certified the dog has to perform higher-order functions like dialing a phone in an emergency situation. So essentially it's a dialer circuit with pre-programmed numbers, a large button or two to initiate the call, a small speaker, maybe a small LCD and a microphone, all packaged in an enclosure.

    There are special phones that can be purchased, but at $300, I found that rather offensive and agreed to build something homebrew, convinced that this type of device could be made for well under $50 in parts. So I'm progressing slowly through this, learning as I go.

    Next up is connecting the relays, and adding the switches and microphone. That should keep me busy for a little while.

    What are you building?

  7. #7
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Skarr,

    I don't think the solid state relay would work in this type of situation. However some new devices called MOS relays have been seen in alarm communicator designs for a few years now.

    I took the time to draw out the circuit you posted along with the relays you would need in your interface. It is attached to this post.

    I am currently looking at actually building a receiver first using regular alarm dialers. If I'm still up to it then I will progress to my own dialer. The dialers that I have been using the past 8 years have only cost me between $50 to $75 and I can program them and remotely access with my laptop but the receiver seems more interesting now. I own a few professional receivers that cost over $10K and they can receive multiple types of alarm communications but I will focus on one type that uses DTMF tones.

    Will be out here if needed.

    BobK
    Attached Files Attached Files

  8. #8
    Join Date
    Mar 2010
    Location
    Los Angeles, CA
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Thanks for the schematic, BobK! I'll play around with it later, I won't be able to work on this for a few days.

  9. #9
    Join Date
    Mar 2010
    Location
    Los Angeles, CA
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    I had to figure out how to interface a small SPDT relay (Radio Shack, PN 275-240) to my PIC, and was able to do a little test and turn on an LED, so I have that working. Now it's just a simple matter of hooking the relays to the the tip and ring lines.

    I'm unsure of how to connect all this up to the house phone such that I can dial out with the circuit when I want to, but upon disconnecting from the circuit I regain the house line. It's not clear to me from your schematic, BobK, how I implement that with phone jacks. Any tips?

    Thanks.

  10. #10
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Skarr,

    Take an unused phone cord and cut one end off and strip the red & green wires. Connect them to your project on the incoming telephone line. When you are ready to test, plug the other end of the phone cord into a phone jack. I wouldn't worry about seizing the phone line at this point in your development.

    In actuallity, to use line seizure properly you need to bring the outside incoming phone line to an RJ31X jack and then from there you bring the house phone side to the jack. The RJ31X jack has internal connections that maintain the phone line to house phones until you install the proper RJ45 plug into it. Then your equipment will have a DPDT relay that will maintain the connection until your project goes to call out.

    Digest this and I'll get back to you tonight when I get back from work.

    HTH,

    BobK

  11. #11
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Skarr,

    Look over the attachment and see if you understand the phone line connections as I have them shown. I put some additional circuitry on the drawing I got from MeLabs'LAB-XT schematic. Let me know if I can help anymore. Also let me know if you are interested in buying a used medical alert system. The kind with the large button on the front!

    BobK
    Attached Files Attached Files

  12. #12
    Join Date
    Mar 2010
    Location
    Los Angeles, CA
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Hey BobK, thanks a lot for the updated schematic. I understand the sequence you've described and the schematic now.

    I constructed your updated circuit (minus the "dial" relay) and tested a little circuit by switching two relays to light two LEDs to make sure I understood the connections and wrote the proper code (per your sequence), and that worked. However, when I connected the phone line to the circuit and executed the programs, I couldn't dial out and the relays just switched back and forth.

    I suspect there a grounding issue going on here and that the PIC is resetting itself somehow, but I have no idea how to troubleshoot this. And this only happens when the phone line is physically connected to the circuit; disconnect the line from the circuit jack and the relays work. Any advice?

  13. #13
    Join Date
    Mar 2010
    Location
    Los Angeles, CA
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    After doing some research I learned that I need bypass capacitors in my circuit: one across the PIC's Vss and Vdd pins, and one across the coil of each relay. I added 0.1 uF caps in these locations as well as across the + and - busses of my breadboard. Adding these caps reduced the erratic behavior of the relays but not completely, and I still can't dial out. The circuit works fine if the phone line is not connected to the circuit. Any thoughts?

  14. #14
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default

    What kind of power supply are you using for the PIC®?

    Does this P.S. have an earth connection?

    Is it Switching Power Supply?

    Is it the current supplied enough when relays are ON?

    Do all relays have Diodes for the back EMF?

    Try to have all ground points to one specific point to avoid ground loops.

    Are you sure that your Isolation transformer does indeed isolate the Line from the circuit?

    Post your latest code. May be something is wrong with the code. Ooh, and what about the MCLR of the specific chip? Is it connected to +Vdd? Check its level.

    And by the way, tere is no need to have 2 relays. One can serve as Dial and Hook at the same time.

    Ioannis
    Last edited by Ioannis; - 7th September 2010 at 19:55.

  15. #15
    Join Date
    Mar 2010
    Location
    Los Angeles, CA
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Thanks, Ioannis.

    I have a bench-top DC power supply (EZ Digital Co), grounded, not switching. Current is sufficient to switch relays as far as I can tell. All relays have protection diodes across the coils. MCLR is connected to Vdd. The circuit is essentially that shown in BobK's latest post.

    Not sure how to determine if the isolation transformer is isolating the line from the circuit. I did have this circuit working and dialing prior to adding the relays, if that is of any help.

    I think you may have hit on the grounding problem. My circuit is wired up all over the place on the breadboard. I'm going to rebuild it in a more sensible way and see if that helps. I'll post back when I'm done.

  16. #16
    Join Date
    Mar 2010
    Location
    Los Angeles, CA
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    I finally have some time to get back to this...

    I rebuilt the circuit in a cleaner way so that all the grounds are tied to one rail on the prototyping board, and that seems to have stopped the erratic behavior I was seeing before. I still have bypass caps on both rails of the board and across the relay coil. I have attached a schematic of the circuit I have built so far.

    I can *kinda* get this working with my latest program. When the phone line is plugged in to a phone jack on my board, I switch the relay to connect the red line and dial the number. After a few seconds, I switch the relay back. I was expecting to have the phone line disconnected, but instead, the call continues. I have to disconnect the phone and then remove the phone line from the board in order to regain a dial tone. Not exactly what I was looking for...

    I'm struggling with how to connect the relays to seize and release the phone line. I was looking at the LABXT board schematic and its line seize setup, also attached. It looks like there is a single DPDT relay used to switch the line, with the red line connected to a common pin on the relay. Couldn't that be an SPDT relay or a reed switch instead? What, if any, connections are made to the remaining contacts?

    What I'm also unclear about is how that circuit actually releases the line. I see that when the coil is energized the connection is made, presumably giving you a dial tone, but what happens when the coil is not energized? It seems to me that the phone line would not be released.

    Thanks for helping and suffering a fool.
    Attached Images Attached Images   

  17. #17
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Skarr11, Connect the relay common to the red line (other phone wire).

    Dave Purola,
    N8NTA

  18. #18
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

  19. #19
    Join Date
    Mar 2010
    Location
    Los Angeles, CA
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Thanks for the replies.

    Dave, I hooked up the red line to the relay's common line but no success.

    I'm spinning my wheels here and wondering if I should try a different approach. I've been reading a little about interfacing serial modems with PICs and using AT commands to accomplish the off-hook, DTMF/dialing, and on-hook functions. It appears to be an easier approach since all the phone interfacing is taken care of with the modem. I would need to learn the appropriate AT commands (I've come across a few websites that list them) and understand modem-to-PIC connections.

    Any thoughts or advice before I pursue this? Thanks.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts