• Linking to the cellphone module

    BelgianTinker10/19/2020 at 16:41 0 comments

    Intro

    The A6 SIM module that I bought is this one. In this page I explain how I connected the phone and the Arduino to the GSM shield and what code I use for receviving and making a call.

    Arduino to A6 connections

    Connections between the Arduino and the A6 module are quite straight forward. I did have two issues that I didn't direclty debug:

    Power: Connecting the Arduino to the laptop I use for code development and routing the 5V out of the Arduino to the A6 module does not allow for enough current draw for the module to fully function. Full functionality is acheived by powering the A6 module seperately. Later using the AC/DC module as described in the previous page, enough power is provided for full functionality.

    Communication: In hindsight it sounds very stupid, but make sure you connect the Rx port ofthe Arduino to te Tx of the A6 and vice versa. We want to receive what one module is sending out by the other module.

    A6 to phone connections

    The only thing needed to connect to the A6 module is the horn of the phone, which contains to wires for the microphone and two for the speaker. Since the first plan was to connect the horn to the phone and the A6 module has a Jack input I bought a solderable converter. Using the Jack plug and connecting it to the A6 only gave me the functionality of the microphone, not the speaker of the horn. After that I connected the horn directly to the pins on the A6 module and everything was fine.

    Incoming call detection

    A lot of examples out there, but I wanted a way to detect it with a simple command, which is why I went with te option below:

    {` 
             //Rigistering the "RING" being transmitted by the SIM module == incoming call
             if (ringer.indexOf("RING") > 0) {
               Call_receive();
             }
             `}

    where ringer is a String variable containing the most recent information available as received from the A6 module.

    The SIM-card

    Only one thing to say here, don't go to cheap on the SIM. I was happy like a child when I had and the A6 module and my SIM card, the latter bought after searching the web for the operator that give the the best rates without a monthly subscription. I went to bed crying that day. couldn't get it to receive cell connection, while most of the other communication was fine, could read the sim card number etc. I later tried with a SIM from a more prominent provider and everything worked instantly...
    Still haven't figured out why the other SIM didn't work.

    The Code

    The code used for the entire project can be found below. Feel free to reach out should anything be unclear.

    {` 
    // Global variable definition
    /// Varialbes mainly for receiving a call
    int ringstate = 0;               // state of the bell
    int hornstate = 0;               // is the telephone horn lifted or not
    int hornstate_prev = 1;          // previous state of the hrn
    String ringer = "";              // detecting an incomming call
    char letter;
    
    /// Variables mainly for making a call
    float pulscount = 0;             // measured state of the 'digitalPin_cnt' signal
    float pulscount_prev = 0;        // previous state of the 'digitalPin_cnt' signal
    float reset = 0;                 // measured state of the 'digitalPin_reset' signal
    float reset_prev = 0;            // previous state of the 'digitalPin_reset' signal
    int count = 0;                   // variable counting the amount of pulses received when dialing a number
    String PHnumber = "";            // string capturing the full phone number dialed
    unsigned long timer;
    
    // Arduino PIN selection
    int digitalPin_cnt = 6;          // Pin 6 is input connected to the number pulses of rotary dial
    int digitalPin_reset = 7;        // Pin 7 is input connected to the single pulse showing rotary dial usage
    int digitalPin_ringer_out = 8;   // Pin 8 is output to the relay swithing the ringer on and off
    int digitalPin_horn = 9;         // Pin 9 is input connected to the horn sensor detecting a picked up horn
    
    void setup()
    {
      pinMode(digitalPin_cnt, INPUT);
      pinMode(digitalPin_reset, INPUT);
      pinMode(digitalPin_ringer_out, OUTPUT);
      pinMode(digitalPin_horn, INPUT);
    
     //Begin serial communication with Arduino and Arduino...
    Read more »

  • Ringing the Bell

    BelgianTinker10/19/2020 at 16:39 0 comments

    Intro

    The ringer of the phone is actuated by a hammer and an electromagnet. Alternating current through a solenoid, continuously polarises the magnet two different ways. This makes the hammer swing both ways, hitting the bells.

    During the days of the actual phone this was done with around 100 Volts at a frequency of 20 Hz, but I am hoping that 12 V and 50 Hz will do the trick.

    AC/DC

    I want the phone to be working continously and not have to hassle with batteries. Since I anyway need the AC circuit for the bell, I plan to use the power from an outlet, convert it to 12 V DC for the electronics and tap from the incomming AC supply for the bell. The ACDC converter I ended up buying is very similar to this one.
    A simple 5V relay shall be used to actuate the solenoid intermittently with 1s intervals. The figure below shows the electromagnetical actuator in this phone:

    Mechanism bell
    Fig.1 - Mechanism of solenoid and hammer for ringing the bell of the phone.

  • Reading the Rotary dial

    BelgianTinker10/19/2020 at 16:37 0 comments

    The phone

    Intro

    I recently bought an old RTT 72 phone and I wanted to give it a second life.
    The first idea was to only reuse the horn of the phone such that I would be able to connect my cellphone through the jack connection. This soon became too little of a challange so I wanted to make the phone a full stand alone unit that can be used to make and receive calls.
    For this I shall request the help on an Arduino.

    Fig.1 - Front of the rotary dial mechanism.

    The rotary dial

    No rotary encoder was needed to read in the signal, as the original mechanism could be used. Two digital inputs are needed to cature the numbers.
    One changes state the entire time the dial is turning and the other one gives a certain amount of pulses, equal to the number dialed.
    So, two digital inputs are reserved on the Arduino. The figure below shows the two parts of the mechanism registering the dialed numbers.

    Fig.2 - Rear of the rotary dial mechanism showing the two components.

    Two resistors and a connection to the ground are needed to correctly measure the signals. At first I tried hardware interrupts to register the pulses, but the result whas not as expected. More detailed investigation with the 'Serial Plotter' of the Arduino IDE at a high CAN rate showed that the signals sometimes switched states when not expected, So I moved to using normal digital inpus and compared two values measured consecutively with a 10 ms delay.

    Below an extract of the Arduino code I used for this part:

    {` 
    int digitalPin_cnt = 6;          // Pin 6 is input connected to the number pulses of rotary dial
    int digitalPin_reset = 7;        // Pin 7 is input connected to the single pulse showing rotary dial usage
    
    float pulscount = 0;             // measured state of the 'digitalPin_cnt' signal
    float pulscount_prev = 0;        // previous state of the 'digitalPin_cnt' signal
    float reset = 0;                 // measured state of the 'digitalPin_reset' signal
    float reset_prev = 0;            // previous state of the 'digitalPin_reset' signal
    int count = 0;                   // variable counting the amount of pulses received when dialing a number
    String PHnumber = "";            // string capturing the full phone number dialed
    unsigned long timer;
    
    void setup() {
      // start serial communication
      Serial.begin(9600);
      // set pin modes
      pinMode(digitalPin_cnt, INPUT);
      pinMode(digitalPin_reset, INPUT);
      // initiate the timer
      timer = micros();
    }
    void loop() {
      delay(10); // to filter out erractic signals
      pulscount = digitalRead(digitalPin_cnt);
      reset = digitalRead(digitalPin_reset);
    // detect the pulses of the number dialed if the rotary dial is in motion
      if (pulscount == 0 && pulscount_prev == 1 && reset == 1) {
        count = count + 1;
        timer = micros();
      }
    // If the rotary dial is no longer in motion the number dialed is captured
      if ( reset == 0 && reset_prev == 1) {
        PHnumber.concat(String(count % 10)); // a modulo operator because the '0' is 11 pulses
        count = 0;
        Serial.println(PHnumber);
        timer = micros();
      }
    //If 'PHnumber' is not empty and nothing happens within 3s you capture the fully dialed number
      if (micros() - timer >= 3000000 && PHnumber != ""){
        Serial.println(PHnumber);
        PHnumber = "";
        timer = micros();
      }
      pulscount_prev = pulscount;
      reset_prev = reset;
    }
             `}