We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hi there i am interfacing the v to f converter AD645 to 89s52 i am going to used this v to f converter as an ADC.but i trapped in some problem the value is not displayed on the display(7 SEGMENT)the routine for the display is working properly as i tried it with the test value following code give you the clear idea.
#include<reg52.h> #include<define.h> #include<intrins.h> /*****************function declaration***************************/ void disp_wait(void); void disp(unsigned int); unsigned int cal();//v2f /**********************************************************************/ unsigned char number_code[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//7_seg unsigned int i,j,k,l,val;//7_seg unsigned int No_Of_Count,Over_Flow_Occours,No_In_Counter,No_In_CounterHI,No_In_CounterLO;//v2f unsigned int sec_1 = 0; //v2f /********************* interrupt setting (routine)*************************/ void TMR_1(void) interrupt 3 //v2f {Over_Flow_Occours++;} void TMR_0(void)interrupt 1 { TF0 = 0; //reload timer TR0 = 0; TH0 = 0x63; TL0 = 0xbf; disp(val); // call display sec_1++; // dec upto 1 sec if(sec_1 == 50) { sec_1 = 0; No_Of_Count = cal(); TR0 = 1; } else {TR0 = 1;} } void disp(unsigned int val) { unsigned int tempreg,i_digi,j_digi,k_digi,l_digi; unsigned int val_2,val_3; tempreg = val; i_digi = tempreg % 10; val_2 = tempreg / 10; i = i_digi; j_digi = val_2 % 10; val_3 = val_2 / 10; j = j_digi; k_digi = val_3 % 10; k = k_digi; l_digi = val_3 / 10; l= l_digi; DECOD1 = 0; DECOD2 = 0; DECOD3 = 0; P0 = number_code[i]; disp_wait(); DECOD1 = 1; DECOD2 = 0; DECOD3 = 0; P0 = number_code[j]; disp_wait(); DECOD1 = 0; DECOD2 = 1; DECOD3 = 0; P0 = number_code[k]; disp_wait(); DECOD1 = 1; DECOD2 = 1; DECOD3 = 0; P0 = number_code[l]; disp_wait(); } void main(void) { P0 = 0x3f; P1 = 0xff; P2 = 0xf8; P3 = 0xff; IE = 0x8A; TMOD = 0x51; /* Timer 0 as timer in mode 1 ; Timer 1 as counter in mode 1 */ TH0 = 0x63; TL0 = 0xbf; TR0 = 1; while(1) {} } /**************************dly routine's*******************************/ void disp_wait() { unsigned int w1=0; unsigned int w2=0; for(w1=0;w1<=20;w1++) { for(w2=0;w2<=22;w2++) {} } } /**********************************************************************/ unsigned int cal() { unsigned int w1 = 0; unsigned int w2 = 0; unsigned int Value;//count in 100 msec period Over_Flow_Occours = 0x00; TR1 = 1; // run countrer and give dly for 100 msec for(w1 = 1;w1<=40;w1++) { for(w2 = 1;w2<=930;w2++) {} } TR1 = 0; // stop the counter TH1 = ACC; // get value from TH1 to ACC ACC = No_In_CounterHI; // move value(HI) form ACC to No_In_CounterHI No_In_CounterHI = No_In_CounterHI * 100; TL1 = ACC; ACC = No_In_CounterLO; // move value(LO)form ACC to No_In_CounterLO No_In_Counter = No_In_CounterHI + No_In_CounterLO; Value =(Over_Flow_Occours*512) + (No_In_Counter);//calculation for no of count. Value = 2345 ; //test value val = Value;//No_In_Counter; return(val); // return No_In_Counter [No_In_Counter == vtg] }
for ad654 click on www.analog.com/.../AD654.pdf page no. 8 and 9 will give you the clear idea