Yet another frequency measurement question

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 I've googled and found lots of questions from people trying to get something done about how to measure frequency. Every answer starts with "what frequencies?". And the next question is "include archive". OK, so the archive is attached. In the event more than one project is in it, I'm using "ADC_Differential_Preamplifier01.cydsm" and no other projects in the workspace.

   

 

   

Platform is CY8CKIT-049-42xx. I sucessfully implemented the example project ADC_DiffPreamplifier.pdf:

   

   

 

   

Here's the circuit implemented from the example:

   

 

   

   

 

   

The difference is that I have implemented Rg as the round gray variable resistor to the right of the breadboard. Input is a cheapy Electret Condenser Microphone from Amazon. My R1 and R2 are 99xx ohms, so very close to 10k. Anecdotally, Rg is somewhere near 3k. 

   

 

   

Notice on the o-scope, there's a 500mV p-p signal. Yeah, that's 60 Hz with a 1.25 second period additional signal on it that's about half its amplitutde. Thankfully, the microphone seems perfectly suited to this dual op-amp differential amplifier (referred to as the first half of an instrumention amplifier). 

   

 

   

So what frequencies?

   

 

   

80 to 120 Hz with great resolution. 65 to 140 is the total range I care about. And definitely nothing below 65... I desire to rid this world of 60Hz. I'd really like to know when a primary frequency heard is near 100 or 110 Hz and be able to differentiate within 1Hz all around there. 

   

 

   

From all that I've read, it would seem most people are focussed on higher frequencies and the sampling in the example seems MUCH too frequent. Most software FFTs seem to be in the dozens of points, while it would seem I need hundreds if not thousands of points to effectively sample ~100Hz. 

   

 

   

I'm a total noob to this stuff, but can't suck too bad if I've managed to coax a CY8CKIT-049-42xx to do this much. I'd appreciate any and all advice, pointers, and clues about how to accomplish this mission via software, logic in the PSoC, or both. I'll keep researching...

   

 

   

Thanks,
Chris 

0 Likes
22 Replies
Anonymous
Not applicable

 Oh here's a pic of DC coupling of the same. The circuit is biased around 4VDC. Center gradient is at 0VDC. 

   

 

   

   

 

   

Interestingly enough, when there's input, it would seem the DC bias drops to 2.5V and the signal is AC p-p from there. The above waves were made by rubbing my foot back and forth across the bottom of the Tower PC all of this is sitting upon.

   

 

   

I have no doubts that the PSoC will be able to detect the frequencies I'm wanting. I couldn't immediately notice if there are higher frequencies, but tapping my foot on the floor is pretty easy to see on the Scope.

   

 

   

Thanks,
Chris

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Important is the matching of the10K's, analysis attached. That controls your

   

CMR thru the OpAmp diff stage. So sounds like your 60 Hz is not CM ?

   

 

   

www.dropbox.com/s/plck7e95v7pw33c/CMR%20Analysis%20IA.pdf

   

 

   

Note Aol G matching affects CMR as well -

   

 

   

    

   

          http://www.cypress.com/?app=forum&id=2492&rID=82151     IA CMR Analysis

   

 

   

80 to 120 Hz with great resolution. 65 to 140 is the total range I care about. And definitely nothing below 65... I desire to rid this world of 60Hz. I'd really like to know when a primary frequency heard is near 100 or 110 Hz and be able to differentiate within 1Hz all around there.

   

 

   

Attached 2 different freq measuring approaches.

   

 

   

www.dropbox.com/sh/prpc74bdga7yijz/AAAeC-Dmmn5sYbWwRrl0-ZUoa

   

 

   

Insofar as getting rid of 60 Hz a Sallen Key notch filter, or a twin T passive Notch a

   

possibility.

   

 

   

Image result for twin t notch filter

   

 

   

Again you will have to do the analysis of the filter to establish 60 Hz rejection.

   

 

   

Of course PSOC 3, 5LP, have DFB block which could be used. Or use MAC in

   

PSOC 4 to implement an IIR filter.

   

 

   

Where are you measuring the 60 Hz, at output of OpAmps ? Are you using

   

scope differentially or single ended ? Former preferred or float the scope.

   

 

   

www.google.com/url

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Hi Dana,

   

 

   

You're amazing, I see you replying everywhere. And always with great information. You've given me some things to look at and consider. For this project, I hope to use the PSoC4 as I intend to embed it in a product for sale. Every $5 spent at design raises MSRP $35~50 and the attractiveness of low price must always be paid attention to. I've got a couple of the PSoC5 -059 kit boards, too, but am trying to resist the urge of using them for this. 🙂 

   

 

   

Here's my scope hookup and I'll try removing ground,too, to see how that works.

   

   

 

   

Scope lead is on P1.2 side of the left resistor. Scope ground is on P1.3 side of the right resistor. 

   

 

   

 

   

I'm going to play around with various analog circuits today to see what I can do with 60Hz and also "see" what the ADC's values are...

   

 

   

Thanks,

   

Chris

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

You're amazing, I see you replying everywhere. And always with great information.

   

 

   

Thanks for the compliment, but there are several supporters of the site that train me

   

as well.

   

 

   

I see your R's are 5 percenters, that will lower your CMR drastically, mismatch, so take a look

   

at the ap note, or use some of the online tools to help -

   

 

   

    

   

              

   

          

   

http://www.ti.com/lit/ml/slyb119a/slyb119a.pdf     TI Tools

   

http://www.ecircuitcenter.com/Circuits.htm     More Analog Tools

   

http://www.johansondielectrics.com/x2y-for-instrumentation-amplifiers.html#.VYMwtUZHQ3A

   

http://masteringelectronicsdesign.com/differential-amplifier-output-common-mode-voltage-calculator/     CMR Calc IA

   

   

 

   

   

 

   

When you do scope differential measurments be aware that not all scopes

   

have good CMR themselves channel to channel when making measurements.

   

So consult their specs as well.

   

   

 

   

Regards, Dana.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Take a look at this case, using 1% Rs, a CM Vin of .1 V, look at

   

the output CM V, its awful.

   

 

   

   

 

   

.1% R's yields 40 mV of output CM. Note this tool does not take into account

   

Aol differences in the OpAmp causing CMR limitations, the Aol delta can can be 40% or more.

   

 

   

Regards, Dana.

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

 @un3x,

   

Looking on you schematic and photo attached, I think that the microphone is not hooked up properly. The electret mic has opamp inside which needs to be provided some 1.5V thru resistor and AC output has to be decoupled by capacitor - look on the data sheet or online. That OPAMP has already a gain of about 1000, so you may not need another amplification in PSoC.

   

Secondly, if you do need some further amplification, use PGA inside PSoC , do not make differential amplifier.

   

odissey1

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Thanks odissey1, I found a couple circuits on-line to try out. I'm not the first hobbyist to use these. I attached a PDF printout from EE stackexchange of one circuit I'll try. I sorted through my parts bin and still have a 2n3904 from school 20 years ago. 

   

 

   

I'm going to solder 90 degree headers on another -049-42xx board so it stands up and I have better access to the breadboard. 

   

 

   

Dana, I measured those two resistors and they are both 987 ohms. Seems I've been in this rodeo before; along with the 3904, I found a 741 IC. Obviously, I won't trust 5% to production, but during R&D, I can hand pick parts to get things just right.

   

 

   

Thanks,

   

Chirs

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Here is an interface for the mic you could try using PSOC OpAmp.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Wow, thanks Dana, that looks like a great design! 

   

 

   

I just tried the below circuit with pretty good result, other than 800 hz spikes that come from nowhere:

   

   

 

   

Oh, and yeah, those are the same 800Hz spikes on the scope above. They didn't seem as obnoxious then as they are now. The above circuit I credit to Stack Exchange EE site. Instead of aiming for a 20 Hz low fc, I'm shooting for 50~60 Hz. And if I can figure it out, I'll shoot for a fc high of some thing under 800 Hz. Heck, I wouldn't care if it was 200 Hz.

   

 

   

I'll work on that circuit next... Once the O'scope shows data I like, I'll work on reading the ADC values...

   

 

   

Thanks,

   

Chris

0 Likes
Anonymous
Not applicable

 Hi Dana,

   

I tried that Texas Instruments circuit and I believe it doesn't have enough gain for the ADC to measure frequency, I'm measuring only about 100mV p-p. I'll take tomorrow away from circuits and get back on it Monday.

0 Likes
Anonymous
Not applicable

 OK I'm going to try the PSoC5 and see what that gets me. If it requires little or no discreet components, then the labor savings is worth "twice the price". Having seen what PSoC4 delivers, what new special magic is in the 5 that I can take advantage of? I have seen PGAs can implement OpAmps, so there's already a bonus: more OpAmps.

   

 

   

Thanks,

   

Chris

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Brief overview -

   

 

   

    

   

          

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              

PSoC 1

PSoC 3

PSoC 4

PSoC 5

8-bit M8C core

8-bit 8051 core (single-cycle)

32-bit ARM Cortex-M0

32-bit ARM Cortex-M3

up to 24 MHz, 4 MIPS

up to 67 MHz, 33 MIPS

up to 48 MHz, 0.9 DMIPS/MHz

up to 67 MHz, 84 MIPS

Flash: 4 KB to 32 KB

Flash: 8 KB to 64 KB

Flash: 16 KB to 32 KB

Flash: 32 KB to 256 KB

SRAM: 256 bytes to 2 KB

SRAM: 3 KB to 8 KB

SRAM: 2 KB to 4 KB

SRAM: 8 KB to 64 KB

8 x 8 MAC

24 bit Digital Filter Block

32 x 32 single cycle

24 bit Digital Filter Block

Switch Cap Filters, BP, LP, HP…DTMF generation

 

 

 

I²C, SPI, UART, One Wire, LIN, FS USB 2.0, Powerline

I²C, SPI, UART, LIN, FS USB 2.0, I²S, CAN

I²C, SPI, UART

I²C, SPI, UART, LIN, FS USB 2.0, I²S

 

 DMA

Up to 16 UDBs

DMA (4M Series)

 DMA

Up to 16 UDBs

1 Delta-Sigma ADC (6 to 14-bit), 131 ksps @ 8-bit, also SAR

1 Delta-Sigma ADC (8 to 20-bit), 192 ksps @12-bit

1 SAR ADC (12-bit), 1 Msps @ 12-bit;

1 Delta-Sigma ADC (8 to 20-bit), 192 ksps @12-bit, 2 SAR ADCs (12-bit) 1 Msps @ 12-bit;

Up to four DACs (6 to 9-bit)

Up to four DACs (8-bit)

Up to two DACs (7 to 8-bit)

Up to four DACs (8-bit)

Up to 64 I/O

Up to 72 I/O

Up to 36 I/O

Up to 72 I/O

Operation: 1.7 V to 5.25 V

Operation: 0.5 V to 5.5 V

Operation: 1.71 V to 5.5 V

Operation: 2.7 V to 5.5 V

Active: 2 mA, Sleep: 3 μA, Hibernate: ?

Active: 1.2 mA, Sleep: 1 μA, Hibernate: 200 nA

Active: 1.6 mA, Sleep: 1.3 μA, Hibernate: 150 nA

Active: 2 mA, Sleep: 2 μA, Hibernate: 300 nA

Requires ICE Cube and FlexPods

 

On-chip SWD, Debug

On-chip JTAG, SWD, SWV, Debug, Trace

 

CY8CKIT-001 Development Kit

CY8CKIT-001 Development Kit

CY8CKIT-040 Pioneer Kit

CY8CKIT-001 Development Kit

CY8CKIT-030 Development Kit

CY8CKIT-042 Pioneer Kit

CY8CKIT-050 Development Kit

 

CY8CKIT-049 Prototype Kit

 

 

 

 

 

   

   

 

   

Regards, Dana.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

The M series, just out, has DMA, 4 OpAmps.....

   

 

   

0 Likes
Anonymous
Not applicable

OK, I lied. I worked on the circuit. I need to travel tomorrow, so I spent tonight on it... 

   

 

   

I found a bandpass circuit on wiki (the very bottom of page, just hit end) that I made some tweaks to:

   

   

 

   

 

   

Which then seems to simulate exactly to what I'm looking for:

   

   

 

   

And then I implemented with the PSoC4 on OpAmp 0 and the output pretty much just stays on 5V.....   Any suggestions?  I'm calling it a night. 

   

 

   

Thanks!

   

Chris

0 Likes
Anonymous
Not applicable

Oh, here's the circuit in a more understandable format:

   

 

   

 

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Not sure what the circuit is doing with DC + feedback in it, which you

   

would normally do for a comparator circuit to establsih hysteresis.

   

Of is that the point of the circuit ?

   

 

   

In any event make a V divider on NI input to put it at Vdd /  2. That

   

will bias circuit into its CM range. Make those two Rs ~ 470K for starters.

   

 

   

But I notced you still have a very low output per smulation because G is

   

~ 100, still not enough to trigger logic ? Was that simulated with a G = 11 ?

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Hi Dana,

   

 

   

Thanks for your advice, yes I was thinking the output needing bias, but was late and didn't compare to previous designs. And thanks, too, for simulation advice. I'm possibly worse than a novice with this; last time I did anything of the kind was with pSpice at university. 1997, I think... 

   

 

   

Thanks,

   

Chris

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

The spice stuff has gotten a lot easier, gui frontends, schematic capture.

   

So you can whip out a sim of that circuit in ~ 10 minutes. You can get Tina TI

   

for free, Orcad limited for free (will do most stuff you want to do), there are

   

even sims online at some of the semi vendors.

   

 

   

The only thing that is limiting in my estimation is a number of vendors models

   

are purposely brief, limited, so the sim on fine issues, like R-R OpAmps input

   

stage crossover distortion. Most models do not have it.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Ok crap, I already The Beers before doing much tonight, however, mimicking the 1k ohm resistor on v minus input to +5v made no difference.

   

 

   

And where did you see the G number? I opened the QUCS file and saw no mention of it. 😛 

   

 

   

Thanks,

   

Chris

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

The G for a NI OpAmp is ( R5 / R6 ) + 1

   

 

   

Regards, Dana.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Here is a spice model for an electret that works with LTspice, free

   

to download and use -

   

 

   

home.comcast.net/~rc1618/WM61A%20Electret%20Microphone%20Model.htm

   

 

   

www.circuitlab.com/forums/audio-electronics/topic/cgzaeyjn/component-request/

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

I've got a circuit that works well now, but can't figure out how to reliably detect it via PSoC. I had an interrupt routine on the AOC but that's not correct... for period, I need another method. To do all this, I've brought my o-scope back to work. Home isn't conducive to my need to pay enough attention to this...

   

 

   

Thanks,

   

Chris 

0 Likes