Saturday, 28 March 2020
Main Menu
Home Home
Shop Shop
News News
Products Products
Application Notes Application Notes
Publications Publications
Links Links
Support Center Support Center
Downloads Downloads
Forum Forum
Resellers Resellers
Contact Us Contact Us
Updates Updates
MCS Wiki MCS Wiki
Online Help
BASCOM-8051 Help BASCOM-8051 Help
Contents in Cart
Show Cart
Your Cart is currently empty.
Search the Shop

Products Search

User Login


If you have problem after log in with disappeared login data, please press F5 in your browser

RSS News

AN #185 - Phone remote control Print
This AN describes how a remote circuit can be activated using the phone and without logging a call. This is a method that can be used for non-critical applications.

by Don Owen (

The activation involves a person ringing the number of the remote site in a way that the remote circuit decoder can interpret and act on. This decoder module is placed in close proximity to a phone and relies on the audio produced from the phone ring.

For an action to occur, the initiator must let the phone ring for a required number e.g. 4 rings. One minute later, another call is made and the number of rings determines which action occurs, e.g. 2 to turn on circuit 1, 3 for circuit 1 off etc.

There are a lot of limitations to this communication system but it can be useful for many non-critical applications such as turning on a sprinkler system, operating lights and many other possibilities.

Some limitations on this method are that there is no feedback as to whether the wanted action occurred. There may also be a nearby loud noise at the remote end that disrupts the correct action interpretation. A more certain method can be to tap the phone lines but an electrical connection in most cases involves equipment approval from the regulatory body.

The system described above uses a combination of analog circuitry and digital with an ATMEGA8535 processor.

Circuit description

The TLV271 op amp whose gain is set by two slide switches amplifies the microphone electrical output in the decoder module. The closer the module to the phone, the less gain is needed and thus less susceptibility to extraneous noise from external sources. The output from the op amp feeds the LM556, which is arranged as a one shot multi vibrator. The output of the LM556 is fed to an LED for diagnostic purposes as well as a counter input and an input pin of the MEGA8535. There is also a LCD module, which is useful for diagnostic purposes when analyzing the decoder processing. Outputs from the MEGA8535 feed relay circuits whose contacts are brought out via a socket. The relays are arranged so that they donít draw any current from the regulated 5 volts as they connect directly to the input 12V supply, which is from a plug pack.

The decoder is housed in a small plastic box approx 150 x 90 x 45mm with the LCD at the top and the microphone and LED at the front.



Possible external circuit configurations


Apart from just using the contact outputs to activate circuits directly, there are cheap commercially available radio systems where remote power points can be turned on and off by pressing buttons on the transmitter. It is feasible that the floating relay contacts could be used to replace these buttons by modifying the transmit module.

Source code :

' Program: Phone remote control
' Don Owen  28/4/2011 Title : PhoneRemoteControlNewV2.bas

'The sytem operates by placing the receive unit fairly close the phone and
'uses an acoustic means to detect rings. No connection means that there are
'no charges applied and the integrity of the phone circuit is not affected. The
'ring is integrated and applied to the microcontroller.
'The input signal (rings) is applied to a counter as well as an input port pin
'which is continually polled to check if an input pulse is present and if so
'starts a timer. Each pair of rings are separated from further pairs of rings
'by about two and a half seconds. The circuit preceding the micro conditions
'each pair as a single ring before applying the signal to the counter.

'A timer is started which will interrupt after a set
'period. At the end of this period, the number of rings (counts) is obtained.
'If the number of rings detected is equal to the required number then the system
'is ready to observe the next lot of rings where the number of rings sets off
'predetermined actions. If the number received in the first set of rings is
'incorrect (numbers other than 4) then it is disregarded so the process must
'be re-started.
'There has to be a delay between the first and second lot of rings. The person
'who is at the control end needs to delay the second lot of rings by a period
'of about 1 min timed from the very first ring. this includes a period where
'no rings must be detected (about 25 sec) This period can be different to the
'others and if so requires a different value for Timer1.
'The second lot of rings determines the  required action. If a ring number
'has no allocated action associated with it then no action takes place.
'An additional safeguard is to restict the number of rings in the second lot
'to 7 as any more could suggest that it is a real external ring.
'After this, the process is complete and reverts to the start condition.
'This is not a totally fool-proof control system as there is no feedback to
'indicate that an action was successfull and is limited to non critical apps.

'The default internal calibrated 1 MHz RC oscillator is used as the system clock
'Timer calculation for a 16 bit timer
'Using the 1MHz clock and a prescaler of 1024 gives the time per pulse of
'1024/1000000 = 001024
'For a 25 sec overflow
'It will take 25/.001024 =24414  counts
'Therefore Preload = MaxCountOfTimer - 24414
'                  = 65536 - 24414
'                  =41121
'Max time available is 65536 x 0.001024 = 67.1 sec
'** Define working variables,constants, definitions & initialise     **

$regfile = "m8535.dat" 'Uses ATMega8535
Config Portb = Input
Portb = 255                                                 'Internal resistors
Config Portc = Output
Config Portd = Output
Relay1 Alias Portd.6
Relay2 Alias Portd.7

Dim Start_again As Boolean
Dim First_interrupt As Boolean
Dim Second_interrupt As Boolean
Dim Ring_counter As Word
Dim Interrupt_num As Word
Dim First_rings_num As Word
Dim Second_rings_num As Word
Dim Third_rings_num As Word
Const Ring_time = 41121                                     'for 25 sec

Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd., Db5 = Portd., Db6 = Portd., Db7 = Portd., E = Portd., Rs = Portd.5
Cursor Off
Reset Relay1
Reset Relay2                                                'no lcd cursor

Config Timer0 = Counter , Edge = Falling                    'Fed from ring input
Config Timer1 = Timer , Prescale = 1024
On Timer1 Timer1_isr

Stop Timer1
Stop Timer0
'**               Declare subroutines and functions                  **
 Declare Sub Action

'**                        Main                                      **
Locate 1 , 1
Lcd "Remote control"
Locate 2 , 1
Lcd "Over phone lines"
Wait 1                                                      'gives about 4 sec delay

Disable Interrupts 'initial settings
Lcd "Waiting for ring"
Stop Timer1
Stop Timer0
Interrupt_num = 0
Ring_counter = 0
First_rings_num = 0
Second_rings_num = 0
Third_rings_num = 0
Reset Start_again
Reset First_interrupt
Reset Second_interrupt
Timer0 = 0

Ring_wait_check: 'Waiting for a ring
If Pinb.= 0 Then Goto Ring_wait_check

Cls 'Ring detected
Lcd "1st rings period"
Ring_counter = 0
Start Timer0
Enable Timer1 : Enable Interrupts
Timer1 = Ring_time
Start Timer1

 If Start_again = 1 Then Goto Ring_wait                     'waiting for interrupt
 If First_interrupt = 0 And Interrupt_num = 1 Then Action
 If Second_interrupt = 0 And Interrupt_num = 2 Then Action
 If Interrupt_num = 3 Then Action


'**                        Define Subroutines                        **
Sub Action

If First_rings_num <> 4 Then Goto Nothing_doing
If Second_rings_num <> 0 Then Goto Nothing_doing
If Third_rings_num > 7 Then Goto Nothing_doing
If Interrupt_num = 1 Then 'First set of rings valid
 Lcd "Interwait period"
 Set First_interrupt
End If
If Interrupt_num = 2 Then 'Valid as no ring detected in wait
 Lcd "2nd ring period" 'period
 Set Second_interrupt
End If
If Interrupt_num = 3 Then '2nd ring set determines action
 Cls 'which is determined by the num
 Locate 1 , 1                                               'of rings typically 1 to 7
 Lcd "Action =" ; Third_rings_num
 If Third_rings_num = 2 Then Set Relay1                     'Turn on external circuit 1
 If Third_rings_num = 3 Then Reset Relay1                   'Turn off external circuit 1
 If Third_rings_num = 4 Then Set Relay2                     'Turn on external circuit 2
 If Third_rings_num = 5 Then Reset Relay2                   'Turn off external circuit 2

 Wait 2
 Set Start_again
 Disable Interrupts
End If 'Action end so can go
Goto Finish_sub                                             'back to start

Nothing_doing: 'No action as call set is invalid
Lcd "Call not valid"
Wait 2
Set Start_again
Disable Interrupts


End Sub

'**                        ISR's                                     **

Disable Interrupts
Stop Timer0
Stop Timer1
Ring_counter = Timer0
Incr Interrupt_num

Locate 1 , 1
Lcd "Rings = " ; Ring_counter
Wait 1
If Interrupt_num = 1 Then First_rings_num = Ring_counter
If Interrupt_num = 2 Then Second_rings_num = Ring_counter
If Interrupt_num = 3 Then Third_rings_num = Ring_counter
Timer1 = Ring_time
Start Timer1
Timer0 = 0
Start Timer0
Enable Interrupts