Shop OBEX P1 Docs P2 Docs Learn Events
Measuring signal frequency? — Parallax Forums

Measuring signal frequency?

RatatoskrRatatoskr Posts: 12
edited 2008-05-20 16:18 in BASIC Stamp
Hey, it's me again with the silly questions.

We're trying to connect a guitar to a Basic Stamp (then the stamp to a computer), so we need a way to get the dominant frequency (pitch) of each signal from 6 pickups (1 on each string). Basically what we need to make is a frequency meter (or 6) that can handle the kind of mixed signal a guitar will output. Given that we're currently stuck on how to make a basic frequency meter, let alone how to make it read only the strongest frequency present, we're in need of some ideas. I've found a bunch of tutorials on how to make frequency meters, but they all focus on digital displays and not the actual vital components.

Alternatively, we could try to construct a light pickup using LEDs and photodiodes, though it would have to be pretty precise to not give complete junk.

EDIT: we finally found that parallax makes a/d converters, so we might be okay on that front. The issue is that for this project we would then have to run multiple a/d converters on a single Stamp, while also sending data to the computer. Is this even possible, is there a fast way to turn the sumbers from the a/d into a frequency number, and is there a better way to do this?

Post Edited (Ratatoskr) : 5/20/2008 3:18:12 PM GMT

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2008-05-20 15:40
    The classic way this is done is by sampling the signal (using an A/D converter) at twice the desired frequency. With sound, this is 40 Khz. There's no way in the world that the BS2 can sample sound at 40 Khz, nor with only 26 bytes of RAM do anything with the data if it did.

    Having sampled the sound, you then run a Fast Fourier Transform on the data to pull out the Frequency components. Again, no way in the world can the BS2 run a fast fourier transform.

    People DO make specialized chips,·called "DSP" or "Digital Signal Processor"·for this purpose, which is what most people use for this kind of application.
  • RatatoskrRatatoskr Posts: 12
    edited 2008-05-20 15:55
    Okay then. In that case, what can we do that is possible? Could we perhaps use a light beam interrupt to track the string movement and get a freq. with far less sampling and processing?

    40 kHz really? I thought you had to sample at twice the freq., so about 8 kHz max?
  • LilDiLilDi Posts: 229
    edited 2008-05-20 15:59
  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-20 16:07
    There have been some very simple software speech recognition programs done for the Apple II years ago. They used a very simple input circuit that amplified the input circuit, clipped the waveform, ran the result through a Schmitt trigger and provided the result to the Apple II's processor which did some analysis on it. In particular, it counted the number of transitions which approximated twice the dominant frequency. The Stamp's COUNT statement can do this, but only for one input at a time. Because the signal is crude, you need to do this over a substantial fraction of a second to get a good average and you have to wait for the end of the period to get an answer.

    Do a web search for "zero crossing detector" for some sample input circuits. You could handle six channels with a Propeller, but not with a Stamp.
  • RatatoskrRatatoskr Posts: 12
    edited 2008-05-20 16:18
    So what we've come up with for new plans:

    -putting the signal directly into the computer and dealing with it there with an oscilloscope program
    -using a stock Roland synth setup and translating MIDI for our purposes
    -counting light beam interruptions
    -abandoning accurate readings/compromising realism to just put buttons on the fretboard

    None of which (except the buttons) I have a clue how to do, but we're not out of the game yet.

    EDIT: I like this zero crossing detector, but I don't think the Propeller is an option at this point, time constraints are the issue.

    EDIT again: We may be changing our priorities to favor coolness over completion, so the Propeller+crossing detector could be a solid option. We'd have to get a fairly clean signal to get the crossing detector to come up with the fundamental frequency, no?

    Post Edited (Ratatoskr) : 5/20/2008 6:09:26 PM GMT
Sign In or Register to comment.