ep.hobbyiest
Full Member level 4
- Joined
- Jul 24, 2014
- Messages
- 212
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 18
- Activity points
- 1,487
yes sir.
calculation i am doing include value of capacitor and inductor.
I want to find out the answer for
F=1/(2*pi*(C*L)^(1/2))
and
C = 82*10^(-6))
L = 0.001*10^(-9).
so which method can gives correct answer.
Looking ahead to the fact that we will have a square root operation, it might be better to select calculation scaling factors that add to an even number so that the square root will given an integral power of 10.
#include <math.h>
...
volatile float Cval=82e-6;
volatile float Lval=0.001e-9;
volatile float Freq;
//volatile so the compiler doesn't do it at host
...
//in main()
Freq=1/(2*M_PI*sqrt(Cval*Lval));
//now I show via a buffer I prepared...
memcpy(&ToSendDataBuffer[26], &Freq, 4);
//and just 'cos I don't like floats I sent the float as ascii too...
myftoa(Freq,&ToSendDataBuffer[34],0);
DisplayNum(0x80,(unsigned int)ans);
void DisplayNum(unsigned char add,unsigned char num);
void DisplayNumFloat(unsigned char add,float num){ //display it in MHz
unsigned char i;
unsigned char mess[5];
unsigned int Kh; //too cheap
Kh=(unsigned int)(num/1e3);
for(i=5;i>0;i--){
mess[i-1]=(unsigned char)(Kh % 10)|0x30;
Kh=Kh/10;
}
//actual
DisplayNum(add++,mess[0]);
DisplayNum(add++,mess[1]);
DisplayChar(add++,'.'); //this one I'm expecting you to change
DisplayNum(add++,mess[2]);
DisplayNum(add++,mess[3]);
DisplayNum(add++,mess[4]);
}
...
and in initialization()
DisplayNumFloat(0x80,ans);
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?