Shop OBEX P1 Docs P2 Docs Learn Events
Freq/ADC — Parallax Forums

Freq/ADC

labsmokelabsmoke Posts: 38
edited 2007-12-15 15:21 in Propeller 1
hi.

is there anyway i can both count the frequency and use the sigma delta ADC on the same pin?

im using the demo board and i wish to both count the frequency and read the analog value of the condenser mic...

because when i try to just do exactly that i get strange readings from the freq count, probably because the sigma delta hookup sends out some freq on that pin to calculate the AD value right?



Post Edited (labsmoke) : 12/12/2007 8:15:02 PM GMT

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-12-12 20:16
    The result wouldn't be as you expect it to be, since you have feedback affecting the value on the ADC's input pin, there would be little value gained by counting the number of transitions on the pin. That said, yes you can count the transitions on a pin while performing ADC simulatenously.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • labsmokelabsmoke Posts: 38
    edited 2007-12-12 20:27
    ok, but thats what im attempting right now, but as long as one cog is active with the ADC routine, im getting several MHz in my freq count, and i cant seem to aquire any relevant data from that signal..

    when i stop the cog running the ADC, the frequency reading comes out fine..(naturally)..


    can someone point out some sort of trick? has anyone attempted this?

    ive downloaded the "microphone to vga" snippet. but that routine only measures the signal over a given time period right?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-12-12 20:37
    Like I mentioned, the Feedback pin is toggling the input pin upto 80MHz (this happens when the input value is near Vdd/2) or hardly at all when the input is near 3.3 or 0V. So you are counting a combination of the input signal and the transitions the ADC is performing. Measuring this provides very little usable information. Perhaps if you explain what you are trying to do on a system level, we can find an alternate method for you to accomplish your goal.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • labsmokelabsmoke Posts: 38
    edited 2007-12-12 20:47
    i understand what happens, thats perfectly clear to me, but i just need some help finding as you said, an alternate method...


    what i need to do is measure the voltage and the frequency of a signal, both readings simulatenously on the same wire..store this in two separate variables.. thats it...
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-12-12 20:55
    Ok, we can do that. What you need is an Operational Amplifier (op-amp) configured in voltage follower mode. The + terminal is connected to the input signal and the output is connected to the input of the ADC circuit. You also tie the input signal to a different Propeller pin, this way two copies of the input signal are produced and are isolated from each other so that the ADC measurement does not affect the frequency counting measurement.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • labsmokelabsmoke Posts: 38
    edited 2007-12-12 21:03
    thats excellent advice, but i was hoping on some software based·solution, but i realise that its impossible to get it accurate and stable using my minimum component hookup...

    i shall do it·the opamp way.. its probably best in the long run...





    thanks!
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-12-12 21:05
    Are you using an AC coupled or DC coupled ADC circuit (iow is there a capacitor or resistor which connects the input signal to the ADC circuit)?

    If you are using an AC coupled circuit, splitting the signal to the capacitor and another Propeller pin could get you close to·looking for, but it wont be perfectly issolated (charge can be injected back through the capacitor into the input signal. To what degree this happens is dependent on the capacitor value and the output resistance of the input signal.)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 12/12/2007 9:11:25 PM GMT
  • labsmokelabsmoke Posts: 38
    edited 2007-12-12 21:33
    that sound quite logical, im using the demo board, so its ac coupled with 0.1 uF...
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-12-12 21:41
    Oh, you are using the onboard microphone, unfortunately that is a less than ideal source (iow the output resistance is relatively high and can be affected by whats going on downstream. Go ahead and try the non-opamp method first, but don't be suprised if you end up with a having to add the op-amp anyways)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • Tracy AllenTracy Allen Posts: 6,660
    edited 2007-12-13 16:08
    The signal frequency is contained in the result of the sigma-delta conversion. So, a software only solution should be able to look at the sequence of samples, to extract the frequency, or moreover to extract other waveform parameters. I haven't done that myself, but there have been several stabs at FFT here. Naive frequency extraction could look for the zero crossings of the sample sequence. E.g., a pasm loop runs and looks at the samples that are produced at CLKFREQ/N, and keeps a binary variable for > or < the zero-bias point. Then count that directly in relation to CNT. A little debouncing may be necessary.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • labsmokelabsmoke Posts: 38
    edited 2007-12-13 16:43
    yes, thats exactly what i suspected, but the "how" is to big for me im afraid..



    but ive just bypassed the sigma hookup with a seperate wire that extracts the frequency. its working quite good.. BUT, i need to make the freqcount more sensitive.

    im using this code, this is the "DAT" section, (downloaded from OBEX):



    ········ org

    entry·· mov···· ctra, ctra_············ 'establish mode and start counter
    ······· mov···· frqa, #1··············· 'increment for each edge seen
    ······· mov···· cnt_, cnt·············· 'setup time delay
    ······· add···· cnt_, cntadd

    :loop·· waitcnt cnt_, cntadd··········· 'wait for next sample
    ······· mov···· new, phsa·············· 'record new count
    ······· mov···· temp, new·············· 'make second copy
    ······· sub···· new, old··············· 'get delta
    ······· mov···· old, temp·············· 'set next delta's base

    ······· wrlong· new, par
    ······· jmp···· #:loop

    ctra_·· long··· %01010 << 26 + 6······· 'mode + APIN
    cntadd· long··· 80_000_000············· '

    cnt_··· res···· 1
    new···· res···· 1
    old···· res···· 1
    temp··· res···· 1



    my question is: How can i make this code more amplitude sensitive?

    (Since i dont·know assambler i would really like some help)


    Post Edited (labsmoke) : 12/13/2007 5:52:22 PM GMT
  • Tracy AllenTracy Allen Posts: 6,660
    edited 2007-12-14 18:32
    You could make it sensitive to lower amplitude by biasing the input pin close to the input threshold. That could be done "open loop" by using a potentiometer set to around 1.65 volts, close to the switching threshold, with the capacitor from the microphone coupled directly to the input pin.
    3.3 ------/\/\------ gnd
            10k |
                 |
                 '--/\/\--o---- inpin
                    1M    |
                        ===== 
                           |
                           mic
    



    Or "closed loop": Have the pin self-bias at the threshold point, by using the feedback pin as in sigma delta, but with an added resistor between the feedback and the input pin. The mic still feeds the input pin directly through the capacitor. With zero signal from the mic, the frequency detected will be very high. But a signal from the mic of sufficient amplitude will I think override the "DC" feedback.

    fbpin ------/\/\--o--||---- gnd
                   1M   |   0.1
                         |
                         '--/\/\--o---- inpin
                             1M    |
                                 =====
                                     |
                                   mic
    



    If you want both frequency and amplitude, that will take more work in programming, starting from the sigma-delta sampling. What frequencies and amplitudes are you looking for?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • labsmokelabsmoke Posts: 38
    edited 2007-12-15 15:21
    frequencies from 50 to about 800 hz, using a condensing mic...amplitude therefor quite low...
Sign In or Register to comment.