Different behavior of different Duemilanove models

Hi there,
we started using Arduino for a museum exhibit project a couple of months ago and it’s really great stuff you put out there. One thing we did was to connect the Arduino Duemilanove and a WaveShield with an old dial-plate phone such that you can dial a number and depending on the number a different track is played from the WaveShield (photo below)

When we got the first prototype up and running we ordered more Arduino boards since we need to build 4 phones. After putting them together, it turned out they did not work - we first thought this is due to a slightly different techical layout of the phone. However, it turns out that as long as we use the original board, everything works, whereas with the new boards it doeesn’t. After taking a closer look, I could recognize some differences. Here’s a picture of the “old” and the “new” board (photos below)

Excuse me for any misnaming, but I’m rather a programmer and don’t know much about electronics :wink: But what I can see is that there are different capacitors/resistors (e.g. next to the RXTX LEDs: old ones labeled 102 and 103, new ones labeled 102, 103 and 1001). Could this be a reason for the whole setup not working anymore?

Here’s some more general information on how this setup works: we power the phone via 5v out and we connect two analog inputs to two different solderings. One is for identifying if someone picked up the phone, the other one is for identifying what number was called: there are impulses - a slight increase in voltage - when the dial rotates back, one 40ms impulse per number (dial 1: 1* 40ms, 2: 2 * 40ms and so on). I will append the code at the end (leaving out the WaveShield setup stuff for better overview)

Problem now is, with the new boards, I cannot detect any distinct voltage changes (also tried different wiring variations) and therefore the whole thing doesn’t work… :frowning: As I said, it works fine with the old board…

Could someone tell me if or why the two boards could act differently (we tried multiple of the “new” ones, same result) and if there’s a way to get this thing running again?

Thanks a lot in advance!
Markus

PS: Since this is my first post I’ll have to post the linked images in a reply :wink: See below

#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"


boolean playLoop = false; //used to play the welcome sound as a loop
char welcomeFileName[] = "bittew~1.wav";
char freizeichenFileName[] = "freize~1.wav";
int audioDelayTime = 200; //ms to wait before next audio file is played

//Varialbes for dial stuff
long lasttime = millis();
long starttime = 0;
long lastCountIncrease = 0;
int count = 0;
boolean above = false; //ist der gemessene Wert über 1000?
boolean phoneUp = true;
int phoneDownValue = 1020; //threshold value for picking up phone
int dialingValue = 900; //threshold value for dialing impulses
long lastHoererChange;

//Other stuff
float Vin; //Used to eliminate voltage peaks

void setup() {
  pinMode(1, INPUT);
  pinMode(5, INPUT);
  //pinMode(13, OUTPUT);
  //Serial.begin(9600);
  //Read first value to determine if phone is up or down
  long val = analogRead(1);
  if(val < phoneDownValue) {
    phoneUp = false;
  } 
  lastHoererChange = millis();

  //Audio setup
  ...
}

void loop() {
  //Calculate voltage adaption ratio: analog pin 14 has reference voltage (1.1V)
  int reference = analogRead(14);
  Vin = (1.1/reference)*1023;
  float correctionFactor = 1.1/Vin;

  long val = analogRead(1)*correctionFactor;
  long val2 = analogRead(5);

  if(val2 < phoneDownValue) {
    if(phoneUp) {
      lastHoererChange = millis();
      phoneUp = false;
    } 
    else {
      if(millis() - lastHoererChange > 100) {
       // phone down;
        if(wave.isplaying) {
          wave.stop(); 
        }
        return;
      }
    }
  } 
  else {
    if(!phoneUp) {
      lastHoererChange = millis();
      phoneUp = true;
    } 
    else {
      if(millis() - lastHoererChange > 100) {
      //Phone up
        if(!wave.isplaying) {
          delay(audioDelayTime);
          playfile(welcomeFileName);
        }
      }
    }
  }
  
  if(val > dialingValue) {
    if(!above) {  //value above threshold for first time
      starttime = millis();
      above = true;
    } 
  } 
  else if(above) { //value below threshold for first time
    long duration = millis() - starttime;
    if(duration < 40) {
      count++;
      lastCountIncrease = millis();
    }
    above = false;
  }
  if(millis() - lastCountIncrease > 100 && count != 0) {
    //dialing process is over, play file
    delay(audioDelayTime);
    //Let's hear some stories, depending on the dialed number
    switch(count) {
    case 1:
      playfiletut("01.wav");
      break;
    case 2:
      ...
    }
    count = 0;
    //if phone is up and wave is finished, start playing the welcome sound again
    if(!wave.isplaying) {
      delay(audioDelayTime);
      playfile(welcomeFileName);
    }
  }
}

Alright, so here's the pictures:

  • Phone
  • "Old" (working) Duemilanove
  • "New" Duemilanove

Can you try switching the microntrollers between the two boards? The boards look identical otherwise. The 1002 vs. 101 thing isn't significant, it's just two different ways of naming the same resistance value (100 ohms).

Where did you buy the boards from?

--
Check out our new shield: http://www.ruggedcircuits.com/html/gadget_shield.html

I noticed that on the inputs you do not enable the internal pull up resistors. How have you got these wired? Are there external pull up or pull down resistors.

If there are none then that is your problem, it could be that the old board is just happening to float in the right direction for you.

@RuggedCircuits: Thanks for the clarification, good to know they're the same :slight_smile: I tried switching the microcontrollers and that kind of did the job. Thanks for the hint. New one working now, old one not working anymore :confused:

I think we bought all or most of the boards via Tinkersoup (http://www.tinkersoup.de), one of them as part of a Fritzing Starter Kit (which might eventually be the "working" one), all others separately. So what does it mean? Were the microcontrollers somehow damaged during transport or something like that? (I am still able to upload new sketches - I will try out some of the examples tomorrow morning to see if everything works as expected) It also turned out that some of the boards get quite hot really quick - any connection there?

@Grumpy_Mike: There goes my lack of knowledge... I read alot on the Arduino page but never happened to come across that pullup/pulldwon thing, thanks for the pointer. Should I always use them? The thing is, the phone is powered via the Arduino and I get relatively stable readings - one is always at 1023 but stays below as soon as you pickup the phone, the other one is around 600 and goes above 900 when dialing. This was all trial and error, but it works very stable (multiple tests on multiple days, duration up to 15h). Should I use the pullup/pulldown anyway? If this is common practice I will of course apply it :slight_smile:

Thanks,
Markus

I can only theorize, but there are lots of counterfeit components out there. It could be that however your distributor got the boards, they were initially loaded with counterfeit components. That's just one theory, it could very well be your circuit/software is "on the edge" and manufacturing variability from one lot of micros to another is enough to make the system non-functional.

You should not enable pullups on analog inputs. However, depending on the circuit you have connected to the analog inputs, you might not get repeatable results from chip to chip. Perhaps you can give us more details on your schematic of how you have things wired?

--
Check out our new shield: http://www.ruggedcircuits.com/html/gadget_shield.html

Should I use the pullup/pulldown anyway?

In the absence of a schematic then yes.

The trick is never to have an input connected to nothing, for each state of a switch there must have a path to ground or +5V for the input pin. It is likely that if you wire up the switches correctly it will work on both boards.

Thanks guys, I really appreciate this. I'm trying to get into this whole electronic stuff as good as possible, but school's a long time ago and I'm often pinched for time... :wink: I'll keep going on...

Anyways, here's the schematic of the phone (original from 1963) and how I wired up my Arduino. It's my first try so I hope this helps. You will probably start crying or die laughter, since I did not even connect back to GND, but as I said this was all trial and error and I tried many many different wiring variations such that I could detect both picking up the phone as well as dialing a number. This was the only one that worked...

Here's the captions. I translated everything from German, hope I got the right terms:
a and b: actual telephone signal wire
W: alarm clock wire
E: GND
M: Microphone
GU: Cradle switch
F: Telephone receiver / speaker
NS...: Number switching contacts
G: control wire for connecting additional equipment
V1 - V4: connection possibility for transistor amplifier
Z1, Z2: Connection possibility for additional handset

(If you speak German, here's the correct terms but with a simplified schematic: Datei:Schaltplan FeAp611.png – Wikipedia)

Cheers,
Markus

PS: Let me know if you need any further information on the phone or the pulse dialing method

There is no use to speculate without knowing how you connected it.
For intermediate fun, this is how an analog phone works:

If needed I can explain the switches...

Edit:
Oh, sorry - it seems our mails crossed...

The main thing is that you have no ground connection. Your design had only worked by chance!

I should have become suspicious when you said: "A SLIGHT increase of voltage"

You most likely need no analog input at all, as the dialing pulses are very clear, although they bounce considerably!! I try to look up a better wiring ....

I just tried no find an old phone - well, none in the household anymore ...

So, theoretically you should just connect (a) through a - say - 1k resistor to +5V and (b) to ground. Also connect (a) to a DIGITAL input.

How will it work:
The 1k works either as an pull-up or as a current source (both concepts apply). When the receiver is on the hook you will see a HIGH signal.
When the reciever is picked-up (a)/(b) will become closed (through R which is around 100 Ohms and the ring coil) and you will see LOW.

Dialing will open the circuit in a typical 40% 10 Hz PWM pattern for exactly (N+1)/10 seconds, where N is the digit (0=10). At least I think there is one pulse more than the digit...

As already said, the switches bounce considerably... I have not yet looked through your code - you need a good debouncing.. Many methods can be used, as the signal (40ms LOW + 60ms HIGH) is well defined

Hi deSilva,

thank you very much for your efforts. I tried it out yesterday and in the meanwhile, it works like a charm :slight_smile:
Dialing worked fine right away, however there was no going from high to low when hanging up the phone. So I used an additional digital input and connected it to G (contact for additional equipment) which gave me LOW for hangup and dialing and HIGH when the phone was picked up.

Thanks a lot,
Markus

I am very pleased!
When you pick-up the receiver there is a voltage devider, consisting of the 10k to Vcc and on the other side R (generally 100 Ohms) and the ring coil. Maybe R can be a little bit hihger (1k) and the resistance of the ring coil be also around 1k. In that case the voltage will not be brought down enough to let the digitalInput see a LOW....

While you are dialing, those two elements are shortcut.

If you want to test it, cou can use the analog input again...
An increase of the pull-up from 10k to 47k should also help.

Nevertheless, the use of G is fine.


P.S.: Have you considered to inject some sounds into the phone (by Tone or any more elaborate synthesizer)?

It should be easily accomplished by just connecting the tone output pin to (a) through another 10k resistor.

I have not tested this for lack of one of those fine telephones. Maybe the base voltage can be too low (5V against 48 to 60V line voltage from PTT)

Edit

I was thinking of something like this
http://code.google.com/p/tinkerit/wiki/Cantarino
Good old fashion phone quality ;D

OK, I reckon I’m slowly beginning to understand how all that stuff works together :wink:

We are actually using a WaveShield that is connected to the original handset speaker. When you pick up the phone, you hear a voice saying “Please dial a number” in an endless loop. As soon as you dial a number, you will hear a ring-back tone two times and after that a story is played back that somehow deals with telephones - mobile phones, relaying, maintenance, …
We have a total of four phones that will be set up in an “Audio Lounge” as part of a museum exhibit about German phone history from the very beginnings to the 1990s. The exhibit will take place in Konstanz from November on, if anyone’s around.

We’ll also build one of those into an original phone booth that will stand outside the museum and will be equipped with a motion detector and an additional speaker, inviting people to come in :smiley:

We also have some more Arduino stuff going on, for example a multiuser tracking system integrated into a multitouch table that is based upon an Arduino Mega, some Multiplexers and 80 IR distance sensors plus connection to C#/WPF (which does the actual tracking algos). We’re still building that one, but I’ll probably post some more information on our progress (and problems) here - if anyone’s interested :wink: As soon as we’re finished I will of course share the final schematics and code

Cheers,
Markus