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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
| #include <main.h>
#define LCD_ENABLE_PIN PIN_D0
#define LCD_RS_PIN PIN_D2
#define LCD_RW_PIN PIN_D1
#define LCD_DATA4 PIN_D6
#define LCD_DATA5 PIN_D5
#define LCD_DATA6 PIN_D4
#define LCD_DATA7 PIN_D3
#define buzzer PIN_D7
#use fast_io(a)
#include <lcd.c>
#include <flex_kbd.c>
char k;
unsigned long int lecture;
float v, Ifuite,Imax;
int j=60;
void keypad()
{
lcd_init();
kbd_init();
lcd_gotoxy(1,1);
printf(lcd_putc,"Entrer les");
lcd_gotoxy(1,2);
printf(lcd_putc,"parametres");
delay_ms (1500) ;
lcd_init();
printf(lcd_putc,"Imax=%c",k);
while (TRUE)
{
k=kbd_getc();
if(k!=0)
lcd_putc(k);
if(k=='#')
lcd_putc("\fTension\n");
if (k=='*')
lcd_putc("\fTemps\n");
}
}
void test()
{
if ( Ifuite < Imax)
{
output_low(pin_c0);
lcd_init();
printf(lcd_putc,"test OK \r");
output_high(pin_c1);
delay_ms(1500);
output_low(pin_c1);
}
else if ( Ifuite >= Imax)
{
output_low(pin_c0);
lcd_init();
printf(lcd_putc,"test NOT OK \r");
//output_high(pin_d7);
output_high(pin_c2);
delay_ms(1500);
output_low(pin_c2);
}
void main()
{
lcd_init();
printf(lcd_putc,"Bienvenue \r");
delay_ms (1500) ;
lcd_init();
printf(lcd_putc,"sagemcom \r");
delay_ms (1500) ;
keypad();
lcd_init();
printf(lcd_putc,"start test \n");
delay_ms (1500);
printf(lcd_putc,"test en cours \r");
output_high(pin_C0);
delay_ms (1500);
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_INTERNAL);
lcd_init();
set_adc_channel(0);
delay_us(20);
while(true)
{
lecture=read_adc();
delay_us(20);
v=lecture*0.0048828125;
delay_us(10);
ifuite=v/1.5;
delay_us(10);
lcd_init();
lcd_gotoxy(1,1);
printf(lcd_putc,"I=%fmA",Ifuite);
lcd_gotoxy(1,2);
printf(lcd_putc,"Ttest=%d",j);
j=j-1;
if(j==0)
{
lcd_init();
test();
}
}
} |