PDA

View Full Version : Decoding Pulse Telephone



Ioannis
- 3rd May 2016, 23:27
I need to decode 3 digits from a dial telephone.

It pulses at a rate of aprox. 10Hz and as many pulses as the digit dialed.

I need to decode say a number like 100.

The problem is thatthe user does not always dial at the same time space each digit.

Also if wrong digit are dialed, it should reject them (obviously).

The idea of using Pulsin is rejected because it times out pretty quickly. Maybe timer1 is good idea, but I have to consider also the time between digits.

Any idea welcome.
Ioannis

pedja089
- 3rd May 2016, 23:42
I had somewhere rotary dialer from old phone, and first pulse should be longer than rest of them(I think that phone with IC do same thing when switched to pulse dialing).
First hook up phone to scope, you need 100R resistor 12V PSU and phone. So dial few number and get timing for first pulse and period for rest of them.
Logic would be wait for long pulse, than count impulses, with timeout period that is twice long as period that impulses are repeated. And reset timeout on each received pulse. Create something like SERIN works. It should be easy.
For measuring time you can use timer, or loop with pause 1 inside and count how many time loop are repeated, or timer with interrupt, and in ISR just increment some variable, etc...

richard
- 4th May 2016, 00:21
most dials have a 66/33 mark/space ratio and fixed impulse rate of 10 impulses / second , there is also a fixed minimum interdigital pause between digits built into the dial mechanism . a pause in dialing longer than the 66/33 ratio will always indicate a new digit or the end of dialing

Ioannis
- 4th May 2016, 10:47
Thanks for the info. Did not knew there is a 66/33 ratio. Soon the scope will reveal the case.

Ioannis

keithdoxey
- 4th May 2016, 22:48
Its a long time since I did my BT apprenticeship (40 years!) and I no longer have any of my notes but this thread triggered something in my brain about the minimum Inter Digit Pause being 450mS as that is the amout of time that was needed for a strowger switch to detect the end of the dialled digit and sweep the bank looking for a free outlet. If its a rotary dial tone you wont be able to get the minimum below about 1 second as thats how long it takes to turn the dial for the next digit but if its Pulse Dial push button phone then the minimum Inter Digit Pause will be determined by the dialling chip in the phone.

Ioannis
- 5th May 2016, 08:50
OK, Thanks Keith.

The first pulse does not seem to be different than the rest.

The pause between digits is between 500-750ms according to the phone.

Each pulse is 1Hz or 600/400msec ratio.

Ioannis

Art
- 5th May 2016, 14:54
If I recall correctly there’s a switch to tell the dial is in the home position to tell it was the end of a set of pulses,
or that a set of pulses is about to arrive if you want to look at it that way.

You can avoid any debounce hardware. All you have to do is pick whether you’re going to count rising or falling edges,
and look for a decent consecutive samples of the switch in one position, and then the same number of samples indicating
the switch is in the opposite position to qualify a rising or falling edge of the dial switch.

Ioannis
- 5th May 2016, 15:09
Thats interesting. I see two pair of wires coming out of the dial. So one pair is sure the digit pulser, the other might be exactly that, the home position. Maybe they used that to mute the earpiece?

Sure I can make good use to it.

Ioannis

Art
- 5th May 2016, 15:25
The other wire might be for the rotary switch normally open and closed positions.
I found code I did if it helps. This was to time dialling zero (ten) to calibrate a dial.
The LED should land int he middle, but most dials are a little off.
It happens to know the number dialled too, though the hardware wasn’t for displaying it.

https://www.youtube.com/watch?v=iJGvLOB53C8



'
'
'************************************************* **********************************
'* *
'* [email protected] *
'* Brek Martin 2013-14 *
'************************************************* **********************************
'
'
DEFINE OSC 20 ' but we are really using 8 MHz
DEFINE NO_CLRWDT ' watchdog is cleared manually
LCD_DATAUS CON 50 ' LCD timing
LCD_COMMANDUS CON 2000 '
'
'INTCON.4 = 1 'enable portb.0 interrupt
'OPTION_REG.6 = 0 'interrupt on falling edge of portb.0
'
'
INCLUDE "Elapsed.bas" '
'
'
'
' execution time!
'
CMCON = 7 ' set portb to digital
trisb.7 = 0 ' set LED outputs
trisb.6 = 0 '
trisb.5 = 0 '
trisb.4 = 0 '
trisb.3 = 0 '
trisb.2 = 0 '
trisb.1 = 0 '
trisb.0 = 1 ' set rotary dial switch input (pulse)
trisa.1 = 1 ' set rotary dial switch input (home)
'
@ clrwdt ; clear watchdog timer manually
'
flashrate var byte
timea var byte
index var byte ' declare values for LED test startup
indexb var byte
bpattern var byte
dialcount var byte
'
oldlast var byte
'
errstart:
'
@ clrwdt ; clear watchdog
bpattern = %00000001
dialcount = 0
flashrate = 8
timea = 64
'
FOR indexb = 0 TO 6 ' fancy led test startup
FOR index = 0 TO 6
@ rlf _bpattern
portb = bpattern
pause flashrate
NEXT index
FOR index = 0 TO 6
@ rrf _bpattern
portb = bpattern
pause flashrate
NEXT index
flashrate = flashrate - 1
NEXT indexb
portb = 0
'
@ clrwdt ; clear watchdog timer manually
'
extint = 0 'reset external variables
freq = 0
ticcnt = 0
'
ready var bit 'declare internal variables
ready = 0
counting var bit
counting = 0
thetime var byte
thetime = 0
'
lasta var byte' 'bit to check for last rising edge
lasta = 0
'
'
Gosub ResetTime 'Reset Time 00:00:00
'
'
'
cycle: ' main routine - 3D Cube user program
@ clrwdt ; clear watchdog timer manually
'
'
IF porta.1 = 1 && counting = 0 THEN
portb = %11111110 ' dial not home indicator
ready = 1 ' set ready to count time status
thetime = 0
bpattern = 0
'
ELSE
'
IF counting = 1 THEN
'
IF portb.0 = 0 THEN
portb = %11111110 ' flash LEDs on for break
pauseus 50
portb = 0
ELSE
portb = 0 ' flash LEDs off for make
ENDIF
'
ELSE
portb = 0
ENDIF
ENDIF
'
'
IF ready = 1 THEN ' check ready to count status
IF portb.0 = 0 THEN ' look for first falling edge
gosub StartTimer 'start clock timer
thetime = 0
dialcount = 0
timea = 64
counting = 1
ready = 0 ' lock routine
ENDIF
ENDIF
'
'
IF counting = 1 THEN ' check counting and dial at home position
'
IF portb.0 = 1 && lasta > 3 THEN ' look for last rising edge otherwise is overwritten
thetime = Seconds*100
thetime = thetime + Ticks
ENDIF
'
oldlast = lasta
'
IF portb.0 = 0 THEN ' dial switch debounce in software
lasta = lasta + 1
ELSE
lasta = 0
ENDIF
'


IF lasta < oldlast THEN ' increment dial pulse counter
dialcount = dialcount + 1
ENDIF



'
IF porta.1 = 0 THEN
gosub StopTimer
counting = 0
'
timea = 10
'
IF dialcount < 10 THEN ' check that zero was dialed
goto errstart ' or error condition
ENDIF
'
Gosub ResetTime 'Reset Time 00:00:00
ENDIF
ENDIF
'
'
'
'
IF thetime > timea && thetime < 75 THEN ' LED time display
bpattern = %00000010 ' dial too fast
ENDIF
IF thetime > 74 && thetime < 85 THEN
bpattern = %00000100
ENDIF
IF thetime > 84 && thetime < 95 THEN
bpattern = %00001000
ENDIF
IF thetime > 94 && thetime < 105 THEN
bpattern = %00010000 ' ideal time
ENDIF
IF thetime > 104 && thetime < 115 THEN
bpattern = %00100000
ENDIF
IF thetime > 114 && thetime < 125 THEN
bpattern = %01000000
ENDIF
IF thetime > 124 THEN
bpattern = %10000000 ' dial too slow
ENDIF
'
portb = bpattern
pauseus 500
portb = 0
'
'
goto cycle ' end main routine - do the next cycle
'
'

AvionicsMaster1
- 5th May 2016, 15:31
Though I doubt it, European phones may be different than in the USA but here in the USA only two wires, a pair, are needed for a phone to work.

The other pair at one time was used for enhancements and power. Those old phones often had several incandescent light bulbs that wouldn't allow the main line to function because the current draw was excessive. Typically nowadays those wires are used for a second line inside the house.

I think the home position you articulate is really time. If the handset is on the phone long enough the circuit resets and waits for the pulses or the tones. When I was younger you were cool if you didn't use the dial to call someone. You had to be talented enough to bang on the phone cradle the correct number of times to dial a phone. Ah the good old days.

I'm pretty sure all the pulses are the same time on/pause ratio. You just need to count the number of pulses and not wait too long to dial.

keithdoxey
- 5th May 2016, 23:20
Thats interesting. I see two pair of wires coming out of the dial. So one pair is sure the digit pulser, the other might be exactly that, the home position. Maybe they used that to mute the earpiece?

Sure I can make good use to it.

Ioannis

The dials in British phones had 5 contacts. 2 of them were the pulsing contacts which were normally closed and pulsed open for the dial pulses. The other three contacts were normally open and are referred to as the "Dial Off Normal" contacts. They placed a short across the earpiece to prevent acoustic shock and also a short across the carbon granule microphone to prevent the back EMF surges from welding the granules together.

http://www.britishtelephones.com/howdial.htm

Keith

Art
- 6th May 2016, 10:48
Yes only two wires are needed for the phone in Australia too. I'm assuming there's access here to only use the dial mechanism.
None of our phones have an even make/break ratio though. It's maybe because the relays at the other end will close
quicker than they will open.
Old exchange equipment was the reason I was tasked with calibrating the dials.

A prettier example for counting the digits using the same method here:
https://youtu.be/mxxvJtatNx8

Ioannis
- 9th May 2016, 21:16
OK, this is what I came up for decoding rotary dialer. It reads and decodes the pulses and compares 3 digits from the EEPROM. If one has different needs just change the arrays accordingly.



clear

read 0,array[0],array[1],array[2] 'array holds the stored digits to compare.

INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts

'wsave var byte $20 system 'depends on the PIC used

'::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, _Timer1, PBP, yes
endm
INT_CREATE
ENDASM

@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts

goto main

Timer1:
time=time+1 'Interrupt every 0,131msec for a 4MHz PIC clock
if time>7 then 'time resets every 0,8 sec approximately
time=0
endif
@ INT_RETURN

main:

digit[0]=0:digit[1]=0:digit[2]=0 'clear array every time it loops here

for i=0 to 2 'three digit counter. Change this for more
get_digit:
while !dial:pause 10:wend 'wait for dial rotation
get_next
time=0
while dial
if time>1 then main 'every digit takes around 10 ms. If times gets 1
wend 'then it sure timed out
digit[i]=digit[i]+1 'increment digit value
time=0 'reset time variable
while !dial 'wait for next high edge
if time>4 then next_digit 'if time is more than 500-600ms then
wend 'next digit has arrived
goto get_next
next_digit:
if digit[i]<>array[i] then error 'if digit and array are different then wrong number dialed
next i

high green:pause 1000:low green:goto main 'SUCCESS!

error:
high red:pause 1000:low red:goto main 'WRONG DIGITS!!!

end


Ioannis