This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Frequency detector possible?

Hi. Can anyone think of a way to use the nRF52832 (probably Timer) to detect approximately 125KHz-150KHz variable square wave down to about a 1Hz resolution? I'd like to detect frequency changes at about 100 times a second though. Ideally I'd like to do this without any external hardware (like a heterodyne mixer). Thoughts? Thanks!

(FINAL answer at very bottom. The answer is YES, the nRF52832 can be used even with a SoftDevice to accurately detect a few hundred KHz signal down to a few Hz resolution)

  • Simple answer - no; the high impedance output cannot drive "hard" and the coax cable capacitance will therefore produce a very soggy rise and fall at the I/O pin on the uC - which is very susceptible to noise and bounce and hence incorrect counts.

  • Well, interesting: It doesn't appear to be the signal at the input. Instead it appears to have something to do with a conflict with the SoftDevice: When I disable running the SoftDevice (but still initializing it), I get a bad count exactly every 65 times the IRQ is called to capture the count. All other counts are dead accurate. When I run the SoftDevice (even without connecting to it via BLE), some counts are bad but randomly so - not every 65 IRQ reads.

    I'm on to SOMETHING, but not sure what... Investigating...

  • Coax == antenna/Ariel, odds on radiated interference from the stack, oh except I see you have disabled it. Usual to use a twisted-pair differential driver at the source, such as RS485 which is cheap and reliable, with termination at the receiver. I doubt that your sig gen has that but the end design could include it.

  • Here's the latest. I'm totally confused so if anything pops into anyones head, please let me know. If not, I'll just move on with the project and "fix it in post" using a few pole software LPF. That's an ugly solution since I don't know why this is happening, but I can live with it I think.

    First, I verified the signal integrity right at the input pin to the µC. It looks nice with the expected amount of edge ringing. I tried pulses with a 3ns raise/fall time and with a 300ns raise/fall time. There is no difference in the bad frequencies reported so the input pin seems pretty tolerant of sloppy vs clean edges. I do see the ringing disappear at about 30ns (with the same quantity of bad frequencies still reported) but that is expected. I tried other voltages too with still the same results.

    But here's what's weird: When I disable initializing the BLE SoftDevice and I disable calling the BLE process loop, I get about 4-10 bad readings over 3000 readings recorded. When I just initialize the BLE SoftDevice but do not call the BLE process loop, I get about 10-20 bad readings over 3000 recorded (so it goes up). When I initialize and call the BLE process loop as in normal operation, I get about 20-40 bad readings over 3000 recorded (goes up even more). This doesn't change if I connect to the BLE Peripheral device and send data to the Central - I still see about 20-40 bad readings.

    Strange...

    Anyway, thanks everyone! 

Related