My latest project

Hi folks.

It is good to be back and having a working Arduino.

I am wanting to make a little device and this is the code - so far.

There are unresolved problems/issues with the power supply and other things but they are still beyond this part.

Where I am stuck:
Well, a few places.

1 - This is used on a phone line. Eventually it will detect if the line is: ringing, free or busy.
Free is 50v DC.
Busy is 12-ish v DC.
(There is also the problem of polarity as well, but that’s another “problem”)
Ringing is pulsed 80v DC from memory.

So in the code it looks at an input - pin 12 - and sees if it is high or low.
If it is high it turns the LED on.
If it is low it flashes the LED.
(or vice versa.)

The idea is:
When connected to a “working” line, the LED comes on. That shows there is power on the line.
If the line is BUSY the LED blinks.

This has to be done by the blink without delay function which is around line 78.

Thing is that I can’t get the LED to do anything but blink.

Line 49 writes to the input pin - via pull up resistor - to set it high or low.
This is just for testing purposes.

So, why can’t I get the LED to just stay on?

The debug lines don’t help me as they tend toward the BLINK status.
Though sometimes they change, but the LED keeps blinking.

Also changing the blink time counter doesn’t seem to change the frequency of the LED blinks.

Stuck.

dialerV1.zip (1.39 KB)

I can't open that attachment - it doesn't seem to be a valid ZIP file. (We've had problems in the past where attachments can't be accessed properly.) Is the code small enough to include within the body of your post?

I couldn't open your zip file (I tried a couple times downloading it...).

Just out of curiosity, how are you scaling the voltage on the phone line down to something that works on 5V logic? (And a trick if you aren't sure about voltage polarity of the phone line signals, run the phone line through a bridge rectifier before hitting your circuit. This is essentially the same thing that abs() does in programming.)

If you draw too much juice from the phone line, it switches the line off the hook and will become 'busy' How are you interfacing with the phone line?

I fixed it. For some reason, the last 16 bytes of the zip file were truncated…

V1.ino (4.03 KB)

  if (line_status = 1)

Not what you meant to type, I suspect.

There is a device called a DAA it is required for an interface to a phone line in nearly all countries. The polarity of the talk battery (off Hook) is sometimes reversed from the loop battery (for sensing off hook) and a trick that ‘sometimes’ works well is to use a common NE2H neon lamp and a 47K series resistor across the L! & L2 terminals. Lay the lamp across an LDR and you have a safe Arduino Ring detector… A DAA can be hand made but I don’t recommend it at all… But it’s your house and not mine.
Good DAA’s have isolated on/off hook detection isolated ring detector, better DAA’s add a relay (DPDT) to connect to the line (answer/disconnect) and good DAA’s add an isolated audio path, Best DAA’s add 4 wire audio 600 - 900 ohm isolated single or balanced lines for both the transmit and receive pair.

Bob

UKHeliBob:

  if (line_status = 1)

Not what you meant to type, I suspect.

That would do it! In fact, it is like that all over the code.

    if (loop1 - loop2 > delay_count)    //  Line is busy, blink LED every second on/off
    {
      Serial.println("**********************");
      loop2 = loop1;
      if (LedState = LOW)
        LedState = HIGH;
      else
        LedState = LOW;
      digitalWrite(13,LedState);
    }

This whole section won't work. Aside from the = issue, the if statement is not terminated, and the digitalWrite(13,LedState) is inside the if(LedState) loop when it should be outside of it.

the digitalWrite(13,LedState) is inside the if(LedState) loop when it should be outside of it.

It is outside the preceding condition - note the absence of braces.

So that is a valid IF statement (other than the = instead of ==)?

Yikes!

Yeah, thanks for the reminder about the = vs == and not being the same.

It has been a few months and I had "fallen in to that trap" - again.

Got it working now.

Thanks to all.

Shall look into these DAA things.
I am prototyping a test device so it isn't exactly for my "home" but for use by people working on phone lines.

Retroplayer:
If you draw too much juice from the phone line, it switches the line off the hook and will become 'busy' How are you interfacing with the phone line?

Well, at this stage, I am not sure. I know about not pulling too much current through or it will busy the line.

I will just need enough power to power the arduino.
Hopefully I can do that easily.
I am not wanting internal batteries, as I want to make it as SMALL as possible to be hand held, and my hands are small.
Of course the speaker is going to be a problem as well as they aren't usually small.

I may add a feature/function to LISTEN to the line if it is busy - that is the "spare" button.

And I also realised that I assigned the "line_status" input as a button as well. Ooops.

So now the code is doing what I want. Just to find out more about these DAA thingies and that sort of stuff.

Then I can move to the next step. I have an I2C DTMF dialer chip so that will go on the I2C bus.

I shall have to dig up some old phone circuits and re-learn how they work again as it has been a LONG time.

It's been several years, but I dinked around with this stuff once. I built a line interface that could detect on/off hook and also provided a transformer tap to listen to(or even inject) audio into the loop. I'll try to list some things I remember from messing with it.

  1. I could get away with drawing 2 or 3 mA from the line without pulling it off hook. Despite what a lot of people said, the phone company never noticed or said anything. Powering up an Uno board is out of the question as lighting one LED exceeds the current limits that you could draw, but you could juice up a stand alone mega chip if you are careful about the power usage. I was able to "steal" enough power from the line to power up a PIC chip and an LCD for a line powered caller-id device using a software modem.

  2. It was difficult to sense the line voltage and determine a good threshold for what was on hook and off hook. You also need non-polarized, but high value and high voltage capacitors to use in a line interface. I ended up taking some from a donor telephone.

  3. The voltage from the CO was approx 48V DC when the phone is on hook. You cannot attach any circuitry that is referenced to a true earth ground. The CO puts the positive end of their supply to ground at the CO. At your house, it's several volts below ground potential. This means you can't connect any AC powered test equipment to look at the phone line as ground current will flow from the phone line to earth ground.

  4. When the phone rings, you can expect a healthy 90V AC ringer signal; enough to shock you good if you are handling the wires when it rings. It won't kill you, but it will get your attention real fast.

If you haven't already surmised, this is a somewhat dangerous environment for your arduino. Read all you can and be careful. It was a fun project, but it was frustrating at times.

@ afremont... both at the same time... and I added the part in red... I forgot these people, youngsters don't know about that stuff
an old telephone receiver (earpiece) is a good low level high sensitivity speaker and so is an old school crystal earpiece (the pink ones) and the plastic top is easily opened up with a sharp knife.
As to powering the Arduino... Not going to be easy as you can only draw about 10 mA on some systems... I did phone work both field and CO but it has been nearly 50 years ago. Crezzy Idea but Supercap? kept biased up by another power source. As to required batteries 3 AAA batteries should be more than enough. Led's for normal and reversed Tip and Ring are easy, there are hi output > 20K candela leds that will light quite brightly for less than a mA and as I indicated previously a ring indicator for non electronic (+ 85V ringer voltage) is easily done with an NE2H and a 47K resistor... Btw ringer voltages can range between 80 - 85V to 120 - 140V close to the CO. A lot of this can be a part of the DAA including RI and line control. The monitor function is usually a 50 nF mylar 400V cap in series with the earpiece. The cap end and earpiece end bridge tip and ring. There is a must that isn't obvious and that is that there can be no dc path from tip or ring to earth/ground as all phone lines are nominally 600/900 ohm balanced lines that are never ground referenced.. Makes a loud hum (50/60 Hz) in the earpiece and will activate the line finder relay...

Bob

At my house (and this is the problem with this stuff as everybody's house is a different distance from the CO and their CO uses different equipment than other people's does). I don't remember exactly, but I think that around 5-7mA it tripped the line at my house. My off-hook detector was kinda hokey and tuned specifically to work at, you guessed it, my house. :wink: I used a transformer and put a mylar cap in line with one leg of it to block the DC. Obviously this stuff can be made to work at everyone's house, but if you look inside a phone you'll see that it's not all that easy with a handful of parts. Fun stuff though. Decoding the caller-id with software was a hoot, but I never got it to work 100%, sometimes it would be perfect, most of the time it would have some character in error (probably from AC hum interference), and once in a while it would spew nothing but garbage out. Needed more active processing of the signals or an actual MX Bell 202 modem chip instead.