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.
11 years, 1 month ago.
Create an rising edge interrupt from an input voltage and calculate the period of waveform
I am a complete newbie to programming and I am trying to create a rising edge interrupt from an input voltage waveform and then to calculate the period of the waveform. I have the following program so far which basically acts as an ADC and displays a voltage value back to my PC. Any help or example programs would be greatly appreciated.
- include "mbed.h"
Serial pc(USBTX, USBRX);
AnalogIn AinV(p15); sets pin15 as the analogue input pin and names it AinV
float ADC_Voltage_data; defines ADC_Voltage_data as float
int main() { pc.printf("ADC Data Values... \n\r"); creates an opening message while (1) {
ADC_Voltage_data=AinV*3.3;multiplyed by 3.3 to give the correct voltage reading
pc.printf("Voltage %f",ADC_Voltage_data); prints voltage data to the terminal pc.printf("V\n\r"); adds the V after number
wait (0.5); waits 0.5 seconds before reading anolg input pins 15 and 16 } }
2 Answers
11 years, 1 month ago.
I have a breadboard set up where a sinusoidal input voltage is input via pin 15 and then it is displayed on the PC which is the above code. But from the original input I have also designed a Schimtt trigger to create a square wave from the original sinusoidal wave I was hoping to input this into the mbed via a different pin and then create a rising edge interrupt to calculate the period and eventually the frequency of the waveform which is going into pin 15.
Thanks any help would be greatly appreciated.
11 years, 1 month ago.
Is it a full-scale signal? In that case just use InterruptIn instead of AnalogIn, which can give you a rising edge interrupt.
I have a breadboard set up where a sinusoidal input voltage is input via pin 15 and then it is displayed on the PC which is the above code. But from the original input I have also designed a Schimtt trigger to create a square wave from the original sinusoidal wave I was hoping to input this into the mbed via a different pin and then create a rising edge interrupt to calculate the period and eventually the frequency of the waveform which is going into pin 15.
Thanks any help would be greatly appreciated.
posted by 21 Oct 2013