1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| #include "C:\Users\issam\issaaaam\pfe\test hyper\mnt.h"
#use delay (clock=20000000)
#define LCD_TYPE 1
#include <lcd.c>
void main()
{
double r1,r2,somme,i,val,freq,tmoy,point,t;
lcd_init();
lcd_init();
setup_adc_ports(AN0_AN1_VSS_VREF);
setup_adc(ADC_CLOCK_DIV_2);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
set_tris_d(0);
output_d(0);
set_timer1(0);
r2=0;
r1=0;
i=0;
somme=0;
setup_adc_ports(AN0_AN1_VSS_VREF);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);
while(t<10000)
{
t=t+1;
point=(float)read_adc();
point=point*5/1023; //printf(lcd_putc,"\f point:%2.1f", point*4.16);
if((point>1)&&(point<r2)&&(r2>r1)) /*{val=get_timer1()*12.8*0.000001;
set_timer1(0);
printf(lcd_putc,"\f point:%2.1f", val);
r1=r2; r2=point;
}
else {r1=r2; r2=point;
} }}*/
{
val=(get_timer1()*1.6*0.000001);
set_timer1(0);
printf(lcd_putc,"\f temps:%2.1f", val);
r1=r2;
r2=point;
i=i+1;
if(i>1)
{
somme= somme+val;
}
}
else
{
r1=r2;
r2=point;
}
}
tmoy=somme/(i-1);
freq=(1/tmoy);
printf(lcd_putc,"\fTM:%2.1f s",tmoy);
delay_ms(2000);
printf(lcd_putc,"\ffrequence:%2.1f hz",freq);
delay_ms(2000);
if((freq<120)&&(freq>60)) lcd_putc("\f patient sein ");
else lcd_putc("\f patient malade");
} |
Partager