Shop OBEX P1 Docs P2 Docs Learn Events
Reading Audio Frequency — Parallax Forums

Reading Audio Frequency

Keith HiltonKeith Hilton Posts: 150
edited 2004-12-09 04:12 in BASIC Stamp
tongue.gif·I hooked up the diagram on page 91 of Matt Gilliland's "The Microcontroller Application Cookbook #2" The diagram shows a
dynamic microphone feeding an audio signal to a LM324, with the
LM324 feeding a 74HC14 schmitt-trigger.· The output of the 74HC14 is then fed to a BS-2.· Instead of using a dynamic microphone feeding
an audio signal to the LM324,·I used a sign wave audio generator.
I got some really interesting results.· The frequency on the DEBUG screen was not the frequency value I was feeding in, it was way off.· As I
increased frequency from the audio generator, the DEBUG screen frequency decreased.· As I decreased frequency from the audio generator,the DEBUG screen frequency increased. Is this problem related to the 74HC14, because it inverts the signal?· tongue.gif When I got rid of the x=x*2 in the program, the frequency on the DEBUG screen was more like the frequency being put in by the audio generator.· I still had the increase and decrease reverse·problem. I hooked up a LCD display and it read the same as the DEBUG screen.· Here is the program:
'{$STAMP BS2}
x VAR word
here:
PULSIN 0,1,x
x=x*2
DEBUG ? x
Pause 1000
SEROUT 8, 16468, [noparse][[/noparse]254,1]
SEROUT 8, 16468, [noparse][[/noparse]DEC x, "HZ"
GOTO hereturn.gif
Wonder if a simple inverter would solve the increase decrease problem?
Wonder why the book had the x=x*2 when this simply doubled what the audio frequency generator said it was putting out?· The SEROUT's where not in the book, I just included them to check the DEBUG screen.· THE LCD read the same as the DEBUG screen. I am trying to make me a guitar tuner that displays frequency on the LCD screen.tongue.gif

Post Edited By Moderator (Jon Williams) : 12/9/2004 2:48:44 AM GMT

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-09 02:55
    If you only need to update your LCD once per second, then use COUNT; otherwise you will have to calculate the frequency of your input using F = 1 / T.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • Keith HiltonKeith Hilton Posts: 150
    edited 2004-12-09 03:31
    Thanks Jon, I assume the DEBUG screen and the LCD are both showing the width of the incoming pulse in microseconds and I can see how there could be a difference
    in frequency and time in the input signal. I will check out COUNT, and check back with you. Thanks!
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-09 04:12
    You would do something like this:

    Main: 
      COUNT 0, 1000, hertz 
      DEBUG HOME, DEC hertz, CLREOL 
      GOTO Main
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
Sign In or Register to comment.