Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
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;
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
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
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 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... } }
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 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
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.
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 2014Not possible to use serial pin. i already put some other functions on it. :(
posted by Ravneet S 06 Feb 2014You 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 2014Well 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