Rotary Dial Revival


I know it’s been a long time since my last post, but hey, at least I have an excuse…  he’s 2 and a half and knows no rest or the meaning of the phrase “staying still” 🙂

This is (hopefully) only the 1st part of a series, based around this ’70s Rotary Dial Phone from Eastern Europe. I inherited it from my grandad when he passed away a couple of years ago. This is the same phone that I remember from when I was a kid and would play with at my grandparents’ house… ok, ok, I’ll stop here with the nostalgia 🙂

So I can personally confirm it’s at least 35 years old, but probably more like 40 or 50. Most importantly it has quite a sentimental value for me, which means I have to be careful what I do with it !

The new brain for the transplant will be a Tilda Mk4 EMF 2018 badge (if you don’t know what EMF is, then please go and check it out, I can’t recommend it highly enough !). The main reason is obvious, this badge is actually a mobile phone ! In addition, it also runs MicroPython which should make its programming and use a breeze… or so I thought initially, more on this later.

The connection between the 2 is pretty straight forward: 3 wires, one with VCC and 2 others that will be either Closed/Open depending on:

  1. if you’re in the middle of dialing(CLOSED) or not(OPEN)
  2. each pulse that count the number that is being dialled (a pulse is a OPEN -> CLOSE action)

The small breadboard that you see in one of the pictures with a handful of resistors and capacitors is my attempt at hardware debouncing the buttons. It does work pretty well, though I’m still lost as to why one of the signals, the dialing/no dialing one seems to be getting lots of noise for the other one (ie. when one is dialing, the pulse signals appear very clearly, however every other pulse triggers a change on the dialing/no dialing line) !?

The unexpectedly challenging bit was finding which pins on the Tilda board to use, as it seems that all available ones are assigned a function. Also, most of the buttons on the front use a I2C *port expander* , which means I would have to poll them, whereas I wanted to use interrupts to sense the pulses coming from the rotary dial.

I therefore decided to sacrifice 2 of the Joystick pins, the Left and Right ones, which are connected *directly* to CPU pins and on which I can register ISR callbacks.

I also had to update GPIO_PinConfig gpioPinConfigs[] in MSP_EXP432E401Y.c in micropython/ports/ti/boards/MSP_EXP432E401Y_CC3120_EMF3 and recompile / flash the firmware, in  order to allow these pins Interrupts to be triggered on *both* rising and falling edges.

Here’s the code. After much struggle with timings and noise on the lines, and with the fact that the MicroPython port for this board doesn’t implement all the features, finally it seems to be working reliably !

"""Rotary phone dial"""

___title___        = "Rotary Phone Dialer"
___dependencies___ = ["ugfx", "machine"]
___categories___   = ["EMF"]

import ugfx
from machine import Pin
import utime

dialing = False
currentNumber = ""
lastDigit = -1


# for Rising/Falling see ti/boards/MSP_EXP432E401Y.c
pinDialStart = Pin(Pin.GPIO_JOYL, Pin.IN) # PullDown, BothEdges
pinDialPulse = Pin(Pin.GPIO_JOYR, Pin.IN) # PullUp, BothEdges
timeLastStart = utime.ticks_ms()
timeLastPulse = utime.ticks_ms()

'''
def callbackDialStart(p):
    global pinDialStart, timeLastStart, timeLastPulse, dialing, currentNumber, lastDigit
    currentTime = utime.ticks_ms()
    # debounce
    if(currentTime - timeLastStart > 300 and currentTime - timeLastPulse > 100):
        if(pinDialStart.value() == 1 and dialing == False):
            dialing = True
            lastDigit = -1
            timeLastStart = currentTime
            print("Dial START:  /  " + str(currentTime))
        elif (pinDialStart.value() == 0 and dialing == True and lastDigit >= 0):
            dialing = False
            lastDigit = lastDigit + 1
            if(lastDigit >= 10):
                lastDigit = lastDigit - 10
            currentNumber = currentNumber + str(lastDigit)
            timeLastStart = currentTime
            print("Dial STOP:  /  " + str(currentTime))
'''        
    


def callbackDialPulse(p):
    global pinDialPulse, timeLastPulse, dialing, lastDigit
    if(dialing and pinDialPulse.value() == 0):
        currentTime = utime.ticks_ms()
        print("Pulse: " + str(currentTime))
        # debounce
        if(currentTime - timeLastPulse > 40):
            lastDigit = lastDigit + 1
        timeLastPulse = currentTime
    

# external interrupts from the dialer
#pinDialStart.irq(handler=callbackDialStart)  # this is VERY NOISY, keeps getting triggered around pulses !
pinDialPulse.irq(handler=callbackDialPulse)



#pBell = Pin(Pin.GPIO_FET)
#pBell.on()  # takes it to GND (whereas off() takes it to 3.3V)


# initialize screen
ugfx.init()
ugfx.clear()
# show text
ugfx.text(5, 5, "NUMBER", ugfx.BLACK)

# MAIN loop
while True:
    currentTime = utime.ticks_ms()

    if(currentTime - timeLastStart > 300 and currentTime - timeLastPulse > 200):
        if(pinDialStart.value() == 1 and dialing == False):
            dialing = True
            lastDigit = -1
            timeLastStart = currentTime
            print("Dial START:  /  " + str(currentTime))
        elif (pinDialStart.value() == 0 and dialing == True and lastDigit >= 0):
            dialing = False
            lastDigit = lastDigit + 1
            if(lastDigit >= 10):
                lastDigit = lastDigit - 10
            currentNumber = currentNumber + str(lastDigit)
            timeLastStart = currentTime
            print("Dial STOP:  /  " + str(currentTime))

    ugfx.text(5, 20, currentNumber, ugfx.RED)
    #utime.sleep_ms(100)


# closing
ugfx.clear()
app.restart_to_default()

6 Responses to Rotary Dial Revival

  1. Pingback: A rotary dial phone revival #VintageElectronics #BadgeLife #MicroPython #Upcycling « Adafruit Industries – Makers, hackers, artists, designers and engineers!

  2. Pingback: Rotary Dial Phone Revival – 4 – Final | Robotics / Electronics / Physical Computing

  3. Pingback: Rotary Dial Phone Revival – 2 | Robotics / Electronics / Physical Computing

  4. Pingback: A Conference Badge Breathes Life Into A Rotary Phone

  5. Jonty says:

    Oh! If you’re having problems with the micropython port or other badge issues, do ask the team about it – we might be able to help! badge@emfcamp.org

Leave a comment