Voip Desk Phone - with the help of a PIC 2 - The SoftwareReading a Desk Phone keypad, translating the keys to ASCII and doing anything with them requires more than the 50 lines of code that Proton Basic Lite will allow. Using a simple routine - that could certainly be optimised - I just had enough room to scan the keyboard and send a key number via the serial port. Proton Basic has a built in routine for scanning keyboards (INKEY), but it is only able to scan 4x3 and 4x4 keypads, the Desk Phone matrix is 5x4. I could have decided to proof the phone using Proton Basic's INKEY function, ignoring the keys on row 1 - the memory buttons, but as my method of programming the 16F876 uses the LVP pin shared with port B3, I do not have a port with a full 8 bits to use. My own routines will be able to split the keypad across 2 ports, the Proton Basic Lite INKEY function cannot do this. PICC-LiteWith PICC-Lite, we do not get the functions for accessing the chips hardware, the HI-TIDE will provide a framework, including initial routines for setting the chip up, but we have to supply the routines to handle any other functions. They do however, include samples showing how this can be done. I found that the init routines set up by the IDE failed to set the Serial Port BRG correctly, I just changed the value to one that I use in other projects and every thing was fine. The Voip Desk Phone programThe program code is here:- Voip DeskPhone files . It's main function is to scan the keyboard and send the translated keys to the PC via the serial port. As each row of the keypad is scanned, there is a small delay to allow the lines to settle, this also reduces the possibility of a key bounce. Each scan of the keyboard will only return 1 translated key - even if more are pressed, and before a key press is detected, at least one scan has to return no keys - even if a key is kept pressed down, we will only see 1 key press. Each time the keyscan routine is called, the PORTB line that monitors the handset Hook switch is checked. If it changes state, a key is returned, One for Off hook, One for On Hook. These are translated by the PC RS232 to KB software and passed to the XTen window so that it will pick up or put down a line. The Desk Phone call led is not used by the program (the phone cannot detect a call) so it is simply turned on whilst the keyboard is being scanned, showing us that the phone is working. (Note, the code is not ideal, I have only just started using PICs and the PICC-Lite compiler. I hope to get back to it and re-write it as I find better ways to do things. As it stands, it works for me.) As the key layout is hard coded into a table, you will need to change this for different keyboards, but I have included the .hex file should your set-up be exactly the same as mine.The files work with a PIC 16F876A using a 20Mhz ceramic or crystal clock. When the handset is lifted, a RETURN char is sent to the serial port (Xten VOIP software interprets this as a line pick up and gives us a dial tone or answers an in comming call. When the handset is replaced, a 'P' is sent. On the PC, the RS232 to Keyboard program (Bill Redirect http://www.symcod.com/BillSerial_KB/index.html) is used to feed the Xten window with the keys from the keypad, I set it to translate 'P' as ^h or CTRL-h the Xten software treats this as a HangUp instruction). I also translated the M2 and M3 keys as backspace and backspace. I plan to use the other keys later to store and replay numbers using the PICC EEProm memory. As the circuit does not know when the phone rings, I have 2 sound cards and instruct Xten to Ring using the main sound card, the mic and speaker lines from the VOIP Desk Phone go to the other card. When a call comes in, Xten pops up, ringing the Speakers and I lift the handset to answer the phone. At the end of the call, I replace the handset and Xten hangs up. My VOIP Desk Phone cost me about £14 for the Phone - I see that similar models are now available for less in the local supermarket, a few pounds for the PIC chip and Ceramic Clock, some bits from my Junk Box and some time. I have a working Voip Phone - better (for me) than one of the USB models, but not as good as a full Ethernet Voip Phone. With my extra sound card, it does not matter that the phone does not have its own sound card. I have also learned a bit more about interfacing PIC and using the PICC Lite compiler etc. Note If you have more than 1 sound card, it is worth trying them both as the Mic input device, you may find one has a better audio than the other. With 2 cards, using the XTen software, it does not matter what combination of Handset Mic, Handset Speaker and Ringer Speaker you use, just find the combination that works best with your phone and sound card combination. With only one sound card, you have a couple of options, 1) you get no audible Ring signal, you just use the phone when in front of your PC, or 2) add a relay into the Hook Switch circuit so that the audio can be switched from an external speaker to the handset when the phone is picked up.
UPDATE |
![]()
Introduction |