Brien Cheow
Newbie level 6
P= Old ADC0 value.
n= First peak time taken
a=Second peak time taken
v= Difference in time between the two peaks
b=Difference in time converted to seconds
f=Calculation for beats per minute
s=Counter for every 10ms overflow from timer0.
Somehow i cannot seem to get int a to copy value of s at second peak of my sin wave. Where as for n i can get it to copy value s when the peak of my sin wave reaches. The thing is that it constantly copies the s value when a peak reaches as compared to what i initially planned, that was to hold value for first peak and a will hold value of s on second peak.
Any help is greatly appreciated and thank you in advance
n= First peak time taken
a=Second peak time taken
v= Difference in time between the two peaks
b=Difference in time converted to seconds
f=Calculation for beats per minute
s=Counter for every 10ms overflow from timer0.
Code:
{
h= (ADC0>>4);
for(l=0; l<127; l++)
{
if(p<h+5)
{
p=h;
}
else
{
n=s;
break;
}
}
for(l=0; l<127; l++)
{
if(p>h-1)
{
p=h;
}
else
{
break;
}
}
for(l=0; l<127; l++)
{
if(p-1<h)
{
p=h;
}
else
{
a=s;
break;
}
}
v=a-n;
b =v*0^01;
f = (1/b)*60;
for (l=0; l<127; l++)
{
if(p>h-1)
{
p=h;
}
else
{
break;
}
}
}
}
Any help is greatly appreciated and thank you in advance