Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
measure the value of vx via digital volt meter
for eg if vx = 7v
then select
R1 = 1k , R2 = 2.5k
//========= Main loop ==============
CRLF();
do
{
j=0;n1=0;
PIR1bits.TMR1IF=0; // raz flag interrupt
WriteTimer1(15537); // 19,99mS
T1CONbits.TMR1ON=1;
while(PIR1bits.TMR1IF==0)
{
ADCON0=1; // ADON=1 et choix de canal
ADCON0bits.ADON=1; //GO
n1++;
Delay10TCYx(1);
ConvertADC(); // Start conversion
while( BusyADC() );
Table_sinusoide[j] = ReadADC();
j++;
}
T1CONbits.TMR1ON=0;
PIR1bits.TMR1IF=0;
Put_RS('N');
Put_RS('=');
Write_Word_(n1,0);
CRLF();
mini=1024;
maxi=0;
for(j=0;j<n1;j++)
{
M=Table_sinusoide[j];
if (M<mini) mini=M;
if(M>maxi)maxi=M;
Drapeaux.Fill=1;
Write_Word_(M,0);
Drapeaux.Fill=0;
Put_RS(';'); // separateur de champs
k=1+ (j & 0x0003);
LCD_Erase_Line(k);
k=sprintf(txt,"%04d ",M);
LCD_puts(txt);
Tempo(10000L);
}
CRLF();
LCD_Erase_Line(4);
ecart=maxi-mini;
k=fprintf(_H_USART,"Maxi=%04d Mini=%04d Peak2Peak=%04d \n",maxi,mini,ecart);
k=sprintf(txt, "Maxi=%04d Mini=%04d",maxi,mini);
LCD_Erase_Line(1);
LCD_puts(txt);
k=sprintf(txt, "Ecart pk2pk =%04d",ecart);
LCD_Erase_Line(2);
LCD_puts(txt);
// 928 is the nb of point between maxi-mini of sinusoide for
// a voltage input of 1,6V efficae + 2,5V DC as offset
Voltage=(float)ecart*235.0/928;
print_flt(Voltage,1,0); // on RS232
fltToa (Voltage, txt,2);
LCD_Erase_Line(3);
LCD_puts(txt);
Tempo(500000L);
CRLF();
}
while(1);
}