Shop OBEX P1 Docs P2 Docs Learn Events
Tone Detection with BS2 — Parallax Forums

Tone Detection with BS2

RonKRonK Posts: 7
edited 2010-08-24 16:15 in BASIC Stamp
I am pretty new to the board – my one and only Basic Stamp project was about a year ago and worked out well. I want to make a change to the project. I’ve searched the forum but have not found the answer.

In that year-old project I used a BS2 and read simple input from a PC through a serial interface. The BS2 program then used the input for control of an output device.

I want to eliminate the PC program and replace it with pre-recorded audio tones for control. The clear tones would then provide the control information rather than the PC. I was unclear from the board whether I could read simple tones directly to a pin on the BS2, use COUNT of PULSIN to measure the frequency of the tone, and then act accordingly.

I have a software tone generator, so I can accurately generate a tone of say 1850 Hz for several seconds and save it in an MP3 file format on a simple portable AAA-battery driven audio player. The audio stream would then consist of several minutes of control tone - each tone lasting 10s of seconds. I would then attach the audio-out (mono earphone) of the audio player via mono cable and jack to the BS2 and program, detect the frequency of the audio input, and use it for pre-set control. The tolerances are very large – any reading in the range of 1800-1899 (or it could even be a larger interval) would result in the same control action. The audio ranges are only used for control information and will not be audible – I don’t need to drive any speakers.

What I could not figure out from similar questions previously posted to the board was whether I could directly wire the audio input to a pin on the BS2 or need additional circuitry. There was some indication from previous posts that I need to use OpAmp, Schmitt triggers, condition the input to TTL levels, and some other suggestions.

I also reviewed the posts regarding DTMF circuits and processing and that would be an alternate approach. I believe I understand what to do to implement control with DTMF - and I can generate Dual Tones. But is there some thing simpler than that?

So the question is what is the simplest approach to wire the audio tones for control information to the BS2? Can I just directly wire the audio-in Positive lead to a pin on the BS2?

Thanks ahead of time.

Ron Karpf

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-08-19 10:07
    I would go with an external tone detector. There are some reliable DTMF tone decoders that will work nicely with a BS2. Here's a single tone detector using a cheap LM567: Tone Detector
  • RonKRonK Posts: 7
    edited 2010-08-23 14:25
    Mike:

    I looked at the single tone LM567 circuit you suggested and don't want to use it because I would be using may different tones in the WAV file for input.

    Is there a relatively straightforward way to attach the audio player output (earphone) to the Basic Stamp 2e? The frequency of the tone has all the control information. I don't need to an exact frequency into the Basic Stamp - a good approximation would do. I have no need to play the audio through a speaker. Once I have recognized an input tone, I can act on it in PBasic and then forget it.

    I have a PBasic program that has been working that takes control information from Serial input from my laptop computer. I just want to replace the source of the control information so rather than have computer keyboard input it uses audio player tone input.

    The reading I've done this past week seemed to indicate that I needed to take the audio out into an OP Amp like the LM324, LM386, or LM7411 audio amplifier. The output Op Amp would then go to a Basic Stamp pin and maybe then use the PULSIN or COUNT functions to measure the frequency.

    Would that approach work? If it does - any suggestions as to which OpAmp to use.
    And do you know of any similar sample circuits/code that might be available?
    Or is there a simple approach of do you have suggestions for a better approach?

    Thanks.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-08-23 16:20
    A simple op-amp clipper that would square off the input signal and limit it to voltages the BS2 input could handle (0 to 5V) would work fine. I'm away from my computer at present. Maybe someone else could suggest a link to a suitable circuit.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-08-23 20:24
    This circuit will clip the input between -0.6V and +5.6V and bias the analog input near the Stamp's 1.4V input logic threshold:

    attachment.php?attachmentid=72687&stc=1&d=1282620004

    -Phil
    347 x 213 - 2K
  • RonKRonK Posts: 7
    edited 2010-08-24 16:15
    Phil and Mike:

    I got it to work with an LM386 OpAmp. I started work on it before I saw Phil's circuit and never got to the two diode circuit.

    Thanks for you help.

    .. Ron Karpf
Sign In or Register to comment.