john120
Banned
- Joined
- Aug 13, 2011
- Messages
- 257
- Helped
- 11
- Reputation
- 22
- Reaction score
- 10
- Trophy points
- 1,298
- Activity points
- 0
hello every body,I am having complications for reading frequency and take decisions using the value read;
I am using the T1CKI pin of PIC16F877A,i want to take decisions basing on the frequency I read for that I am using the if statement:
example:
void final()
{
if(1014500<=value1<=1014999)
{
t=25.5;
}
if(1014000<=value1<=1014499)
{
t=25.6;
}
if(1013500<=value1<=1013999)
{t=25.7;
}
if(1013000<=value1<=1013499)
{
t=25.8;
}
if(1012500<=value1<=1012999)
{
t=25.9;
}}
the problem which is major is that this frequency is not read with only 7 digits which me I am using,because of that the PIC takes the wrong decision because it is not seeing the good value;
so can any body help me to first convert the value which is interred on the T1CKI in only 7 digits and then the pic read only that one;I thing the ways is to use the arrays but I am not getting the real values:
see for example when entering frequency =1012300Hz the PIC is reading 1.01229999994216M
in proteus and then the decision become wrong.
So I want to extract
the first digit of the entered number 1
the second digit 0
the third digit 1
the fourth digit 2
the fifth digit 3
the sixth digit 0
the last digit 0
So that the PIC can only base the decision on that number of only 7 digits.
Thanks
I am using the T1CKI pin of PIC16F877A,i want to take decisions basing on the frequency I read for that I am using the if statement:
example:
void final()
{
if(1014500<=value1<=1014999)
{
t=25.5;
}
if(1014000<=value1<=1014499)
{
t=25.6;
}
if(1013500<=value1<=1013999)
{t=25.7;
}
if(1013000<=value1<=1013499)
{
t=25.8;
}
if(1012500<=value1<=1012999)
{
t=25.9;
}}
the problem which is major is that this frequency is not read with only 7 digits which me I am using,because of that the PIC takes the wrong decision because it is not seeing the good value;
so can any body help me to first convert the value which is interred on the T1CKI in only 7 digits and then the pic read only that one;I thing the ways is to use the arrays but I am not getting the real values:
see for example when entering frequency =1012300Hz the PIC is reading 1.01229999994216M
in proteus and then the decision become wrong.
So I want to extract
the first digit of the entered number 1
the second digit 0
the third digit 1
the fourth digit 2
the fifth digit 3
the sixth digit 0
the last digit 0
So that the PIC can only base the decision on that number of only 7 digits.
Thanks