i am working with a project which is about heart beat measurement with arduino. That is why i have to measure the frequency from my lm324n op-amp. i am using FreqMeasure.h library for measuring the frequency but I get a error. does Arduino 101 not support this library? do i need to do some changes to let it work?
void loop() {
if (FreqMeasure.available()) {
// average several reading together
sum = sum + FreqMeasure.read();
count = count + 1;
if (count > 30) {
double frequency = F_CPU / (sum / count);
Serial.println(frequency);
sum = 0;
count = 0;
}
}
delay(1000);
}
Is there a easy way to measure accurate time between 2 pulse on the 101?
That depends on the interval between the pulses. If they are a week apart, measuring the time to +/- 1 day is trivial. To +/- 1 millisecond isn't much more challenging.
If the frequency is more than once every 4 microseconds, then it becomes more challenging. You have to count a number of pulses, then divide by the time you did nothing but read pulses.
void loop()
{
if (finishCount == true)
{
finishCount = false;//reset flag
// disable interrupts, make protected copy of time values
noInterrupts();
copy_startTime = startTime;
copy_endTime = endTime;
count = 0;
interrupts();
period = (copy_endTime - copy_startTime) / 1000.0; //micros to millis
//debug prints
Serial.print(period); //total time for numCount
Serial.print('\t');
Serial.println(period/numCount);//time between individual pulses