Continue to Site

# Pulse Width Calculation

Status
Not open for further replies.

#### waqar

##### New Member
Actually what i have made a small pbx with only internal lines no external lines involved so its just a intercom at this stage. Now with this exchange DTMF i.e. tone based telephone sets can be connected as i have used MT3271, I have made my own SLIC circuits, iam using At89c52, MT8816 analog switch.

Now microcontroller detects the Off-Hook through its bit. Now if i want to connect the pulse dialing telephone sets also than instead of using any Pulse Dialer IC which can decode the pulse dialing into a digit we can make use of microcontroller .

So in order to make controller count no. of pulses from a Pulse dialing telephone set it is necessary to count the pulses from the bit where the off hook signal is coming.

Now for this iam doing firstly a experiment to see if controller is detecting pulses correctly or not.

Now one thing to note is this that the pulse dialing telephone sets are key-pad type not the rotary type.

I have made a program which can detect signal digit dialing from a pulse dialing telephone set and if the dialed number is correct then controller perform certain tasks like if digit "1" is dialed a relay starts to connect and disconnect after 0.2 seconds interval.

now the program i have made works on the theory :-

1) controller monitor bit P2.0 for a high signal means off hook,

2) as soon as telephone goes off hook, high signal comes at P2.0,

3) Next controller waits for low signal which shows that any digit is pressed, (here we arte not considering that the telephone may go on hook also)

4) Now it is known fact that the low signal which comes due to digit pressed will stay there for more than 5 milli seconds and similary the high signal will not be less then 5 milli seconds which comes after the low signal.

5) say if digit "1" is pressed then firstly a low signal comes and then after some time which we don;t know high signal comes and then remain high , similarly if digit "2" is pressed , low to high to low to high and remains high signal comes.

6) as a complete pulse that is low and high is received a Register is increment and then this register holds the decimal no. representing the digit dialed...

so am i on the right track is there any other way any one can suggest to detect pulse dialing.

ORG 00H
LJMP MAIN

ORG 030H
MAIN:
MOV P0,#00000000D ;RING RELAY RESET
MOV P2,#00000000D ;off hook port set to receive high signal
MOV R3,#00D ;PULSE COUNTER
JNB P2.0,$;WAITING FOR OFF-HOOK JB P2.0,$ ;WAIT FOR DIALING

LOW_TIME:
CALL DELAY_4MILLI
JB P2.0,HIGH_TIME ;GOTO HIGHPULSE WIDTH CALCULATION
INC R1 ;R1 IS THE LOW PULSE WIDTH COUNTER
MOV A,R1
CJNE A,#20D,LOW_TIME
LJMP ENGAGE

HIGH_TIME:
CALL DELAY_4MILLI
JNB P2.0,PULSE_COUNTER ;GO TO HIGH PULSES CALCULATION
INC R2 ;R2 IS THE HIGH PULSE WIDTH COUNTER
MOV A,R2
CJNE A,#20D,HIGH_TIME

PULSE_COUNTER:
INC R3 ;PULSE COUNTER REGISTAR
MOV R1,#00D ;RESETING LOW PULSE WIDTH COUNTER
MOV R2,#00D ;RESETING HIGH PULSE WIDTH COUNTER
JNB P2.0,LOW_TIME
COMPARE:
MOV A,R3
CJNE A,#01D,DIGIT_2
AGAIN: SETB P0.1
CALL DELAY2 ;0.2 SECOND RELAY ON AND OFF ROUNTINE
CLR P0.1
CALL DELAY2
JMP AGAIN

DIGIT_2:
CJNE A,#02D,DIGIT_3
AGAIN1: SETB P0.2
CALL DELAY2
CLR P0.2
CALL DELAY2
JMP AGAIN1

DIGIT_3:
CJNE A,#03D,DIGIT_4
AGAIN2:
SETB P0.3
CALL DELAY2
CLR P0.3
CALL DELAY2
JMP AGAIN2

DIGIT_4:
CJNE A,#04D,DIGIT_5
AGAIN3:
SETB P0.4
CALL DELAY2
CLR P0.4
CALL DELAY2
JMP AGAIN3

DIGIT_5:
CJNE A,#05D,DIGIT_6

DIGIT_6:
CJNE A,#06D,DIGIT_7

DIGIT_7:
CJNE A,#07D,DIGIT_8

DIGIT_8:
CJNE A,#08D,DIGIT_9

DIGIT_9:
CJNE A,#09D,DIGIT_0

DIGIT_0:
CJNE A,#00D,ENGAGE

ENGAGE:
JB P2.0,LOW_TIME ;in correct digit dialed
LJMP MAIN

DELAY2:
MOV R4,#04D
K1: MOV R5,#10D
K2: MOV R6,#50D
DJNZ R6,$DJNZ R5,K2 DJNZ R4,K1 RET DELAY_4MILLI: MOV R4,#04D L1: MOV R5,#10D L2: MOV R6,#100D DJNZ R6,$
DJNZ R5,L2
DJNZ R4,L1
RET
END

#### TheAnimus

##### New Member
How about using a TMR file register, with incriment set on a pin, u could enable the incriment on the pin when u expect a pulse, and disable it when the phone is on the hook etc.

I have never looked at a pulse phone so i have no idea if this would work. I can say on another note, its easy to have 3 op-amps to detect each frequancy that comprises a Touch Tone phone.

Status
Not open for further replies.

Replies
8
Views
943
Replies
0
Views
3K
Replies
1
Views
2K
Replies
3
Views
2K
Replies
5
Views
5K