10 years, 2 months ago.  This question has been closed. Reason: N/A

I want to check signal coming on LPC 1768 pin 19.

Hi, I'm sending a signal to pin 19 of mbed. I want to check that how much is the frequency of this signal. I made a low pass filter on breadboard and then connecting mbed to it and after that connected it to the oscilloscope. But I cant see anything variation.

Im using the code below shown in picture;

/media/uploads/RavneetSingh/audio_code.png

Try to send it via Serial to your PC, then you can check how much is coming exactly, instead of only knowing if it is larger or smaller than 0.3.

posted by Erik - 06 Feb 2014

Not possible to use serial pin. i already put some other functions on it. :(

posted by Ravneet S 06 Feb 2014

You have the LPC1768, the serial connection to your PC is always available. It could be that you already send something else to your PC, in that case, disable it and send this. You can re-enable it later, but first you need to know what you are getting from your AnalogIn. By the way, what kind of signal are you putting on it? (So the source, and things like bias circuits).

posted by Erik - 06 Feb 2014

Well Im passing Audio signal to the filter (capacitor and resistor) and then it goes to the pins 19 and 20 (AnalogIn). So based on this I want to check the frequency on those pins.

posted by Ravneet S 06 Feb 2014

2 Answers

10 years, 2 months ago.

If you just need the frequency you could use an InterruptIn and measure the time from rising to rising edge.
Lerche

How can I do that ?

posted by Ravneet S 06 Feb 2014

Have a look at the handbook. Here you'll find information about interruptin and timers. You can use the timer like in the example.

Lerche

posted by Christian Lerche 06 Feb 2014

Just wondering to know that if input source is put through the AnalogIn Pin19 and then is it possible to check the signal value through pin 18 (AnalogOut) ?

posted by Ravneet S 06 Feb 2014

#include "mbed.h"

InterruptIn analog_input(p19);
Timer timer;

void freq_interrupt(){
    printf("Frequency: %f",(float)(1/timer.read()));
    timer.reset();
}

int main() {
    analog_input.rise(&freq_interrupt);     // Attach interrupt to fire whenever a rising edge occurs
    timer.reset();                          // Resets the timer to zero
    timer.start();                          // Start the timer
    while(1){
        //Do something in here... 
    }
}
posted by Christian Lerche 06 Feb 2014

Hi Chris, I just tried this code but still I'm unable to succeed. Basically, I want to check the frequency of the signal that came into the pin 19 and 20. I Just cant figure it out.

posted by Ravneet S 06 Feb 2014

#include "mbed.h"
 
InterruptIn analog_input(p19);
Timer timer;
 
void freq_interrupt(){
    printf("Frequency: %f",timer.read());
    timer.reset();
}
 
int main() {
    analog_input.rise(&freq_interrupt);     // Attach interrupt to fire whenever a rising edge occurs
    timer.reset();                          // Resets the timer to zero
    timer.start();                          // Start the timer
    while(1){
        //Do something in here... 
    }
}

Try reading time instead. Anything? What's the peak voltage on the pin?

Lerche

posted by Christian Lerche 06 Feb 2014

3.3 Volt

posted by Ravneet S 06 Feb 2014
10 years, 2 months ago.

I doubt that you'll get reliable measurements using a raw audio signal input. First, I would run your LPF signal into a comparator (like the LM339) in order to square up the edges of the raw signal. Then, you can use the InterruptIn and Timer classes to measure time between rising edges. You may still get some noise spikes, though. Also, note that you can't run the InterruptIn on p19 or p20 of the LPC1768. Check the documentation for the InterruptIn class.

Damn, forget these darn pins. Good memory!! Thanks

posted by Christian Lerche 06 Feb 2014

Yea I have noticed when I tried to use those pins for InterruptIn then there was no result. Isnt there any way that if I send any signal on pins 19 and 20 then check that signal through pin18 ( pin18 is AnalogOut). InterruptIn doesnt seem to work properly.

posted by Ravneet S 06 Feb 2014