Shop OBEX P1 Docs P2 Docs Learn Events
Detecting Frequency w/ PBasic Stamp — Parallax Forums

Detecting Frequency w/ PBasic Stamp

AusticAustic Posts: 2
edited 2010-10-28 06:06 in BASIC Stamp
Hey guys, I'm a student at Louisiana Tech and I'm looking for some help on one of my engineering projects. My project involves using the Board of Education with the PBasic stamp to detect the frequency of a guitar/bass and have an LED light up based on a specific note played. The method I tried was to use the pulscount command to try to capture the time that the note played would remain over the voltage threshold (which is what the count command measures), but I cannot find a specific pattern to use for a note. Is there a way I can measure frequency via patch cable in a guitar or bass?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-26 08:13
    "Is there a way I can measure frequency via patch cable in a guitar or bass?"

    Well, sort of. You can measure frequency using the COUNT statement, but you need pulses that cross the 0->1 voltage threshold of the Stamp. What's available from the guitar pickup? I doubt that the pickup produces what you need. There are a lot of harmonics in any signal from a stringed instrument. What are you going to do about those? The COUNT statement will count the signal transitions of the harmonics too. Have you looked at the signal using a 'scope?
  • BeanBean Posts: 8,129
    edited 2010-10-26 08:18
    If you find the guitar signal has too many harmonics, try producing a note by lightly touching the string at the 12th fret. This creates a bell like tone that is more "pure".

    Bean
  • davejamesdavejames Posts: 4,047
    edited 2010-10-26 09:05
    Austic,

    Both Mr. Green and Bean have offered some useful insight.

    The notes from pluckinig an open string are chock full of harmonics which need to be filtered.

    One way to do this is to construct a low pass filter for each string's fundamental frequency, then manually switch those filters in/out as needed when measuring a particular string. You've seen the tuners with a slide switch for each note? That's what's being done.

    The output of typical guitar and bass pickups (non-powered type, not EMGs) is in the range of 200mV to 400mV, far below the Stamp's threshold for the COUNT statement. Using an op-amp to buffer and gain the signal would be required. You could run the op-amp with no feedback (gain) resistors and that would force the op-amp output to swing from rail-to-rail, creating a reasonable square wave that the Stamp could easily detect.

    Regards
  • hover1hover1 Posts: 1,929
    edited 2010-10-26 13:06
    My first thought this morning was to do a search on Guitar tuners. I remember a few projects over the past few years. I forgot to post this before I left out on work stuff.

    Do a Google search on:

    Basic Stamp Guitar tuner site:forums.parallax.com

    This brings up a few threads, and shows some OpAmp front ends that people have used.

    Jim
  • davejamesdavejames Posts: 4,047
    edited 2010-10-26 14:33
    ...after pondering this for a while...

    [guitar signal] -> [filter] -> [freq-to-volt converter] -> [A/D converter] -> [Stamp] -> [display]


    In the above, instead of using the Stamp to COUNT and calculate the note value, run the note value into a frequency-to-voltage converter; this will produce a DC level related to a particualr frequency. Run that DC level into an analog-to-digital converter; this will produce a digital number (binary) related to DC voltage level. Then use the Stamp to crunch the numbers and display the frequency value.

    Pros/Cons? Not sure - kinda thinking out loud. Just another way to approach the issue.

    DJ
  • electrosyselectrosys Posts: 212
    edited 2010-10-27 04:42
    I have find this Guitar tuner schem and code for the Basic Stamp for long ago, that could be some help to your project.
  • davejamesdavejames Posts: 4,047
    edited 2010-10-27 10:08
    Electro,

    The use of a Johnson counter is curious - care to elaborate?


    Thanks,

    DJ
  • AusticAustic Posts: 2
    edited 2010-10-27 13:01
    Mike Green wrote: »
    "Is there a way I can measure frequency via patch cable in a guitar or bass?"

    Well, sort of. You can measure frequency using the COUNT statement, but you need pulses that cross the 0->1 voltage threshold of the Stamp. What's available from the guitar pickup? I doubt that the pickup produces what you need. There are a lot of harmonics in any signal from a stringed instrument. What are you going to do about those? The COUNT statement will count the signal transitions of the harmonics too. Have you looked at the signal using a 'scope?

    Yeah we installed an amp of sorts into the breadboard which gives us a gain of R2/R1. So we put a huge resistor for R2 and ran a few 10 ohms in parallel to give us a pretty large gain; enough to pass the threshold.
    ...after pondering this for a while...

    [guitar signal] -> [filter] -> [freq-to-volt converter] -> [A/D converter] -> [Stamp] -> [display]


    In the above, instead of using the Stamp to COUNT and calculate the note value, run the note value into a frequency-to-voltage converter; this will produce a DC level related to a particualr frequency. Run that DC level into an analog-to-digital converter; this will produce a digital number (binary) related to DC voltage level. Then use the Stamp to crunch the numbers and display the frequency value.

    Pros/Cons? Not sure - kinda thinking out loud. Just another way to approach the issue.

    DJ

    That is actually a really interesting idea. I'll give that a shot and see what comes from it.

    I'll post an update on the progress of the project as soon as I work out some kinks. Thanks a ton for all you guys' help!
  • electrosyselectrosys Posts: 212
    edited 2010-10-28 05:02
    @davejames
    The use of a Johnson counter is curious - care to elaborate?

    Yes, it is very fine looking circuite/code for a Guitar tuner. Unfortuately I can't remember the web link of
    this Guitar tuner, I have find it for same times ago and I'm thinking to try to make it...well, some day.

    Take care
    EL
  • hover1hover1 Posts: 1,929
    edited 2010-10-28 05:17
    electrosys wrote: »
    @davejames


    Unfortuately I can't remember the web link of
    this Guitar tuner

    Take care
    EL

    Here is the thread that contained that schematic.

    http://forums.parallax.com/showthread.php?p=641934

    Jim
  • electrosyselectrosys Posts: 212
    edited 2010-10-28 06:06
    @hover1
    Thanks a lot :)
Sign In or Register to comment.