سلام عليكم
أخواني عندي programme حاب أعمل organigramme هل من مساعدة ؟
و شكرا
*********************
*********************
simulation et réalisaion
d'un circuit
avec pic 16f877a
pour afficher la températeur et l'humidité
*********************
*********************
sbit LCD_RS at RB5_bit;
sbit LCD_EN at RB4_bit;
sbit LCD_D4 at RB3_bit;
sbit LCD_D5 at RB2_bit;
sbit LCD_D6 at RB1_bit;
sbit LCD_D7 at RB0_bit;
sbit LCD_RS_Direction at TRISB5_bit;
sbit LCD_EN_Direction at TRISB4_bit;
sbit LCD_D4_Direction at TRISB3_bit;
sbit LCD_D5_Direction at TRISB2_bit;
sbit LCD_D6_Direction at TRISB1_bit;
sbit LCD_D7_Direction at TRISB0_bit;
char *text,mytext[4];
unsigned char a = 0, b = 0,i = 0,t1 = 0,t2 = 0,
rh1 = 0,rh2 = 0,sum = 0;
unsigned long ADRead;
unsigned int vDisp[3];
unsigned char Display[7];
void StartSignal(){
TRISD.rd2 = 0; //Configure RD2 as output
PORTD.rd2 = 0; //RD2 sends 0 to the sensor
delay_ms(18);
PORTD.rd2 = 1; //RD2 sends 1 to the sensor
delay_us(30);
TRISD.rd2 = 1; //Configure RD2 as input
}
void CheckResponse(){
a = 0;
delay_us(40);
if (PORTD.rd2 == 0){
delay_us(80);
if (PORTD.rd2 == 1) a = 1; delay_us(40);}
}
void ReadData(){
for(b=0;b<8;b++){
while(!PORTD.rd2); //Wait until PORTD.F2 goes HIGH
delay_us(30);
if(PORTD.rd2 == 0) i&=~(1<<(7-b)); //Clear bit (7-b)
else{i|= (1<<(7-b)); //Set bit (7-b)
while(PORTD.rd2);} //Wait until PORTD.F2 goes LOW
}
}
void main() {
TRISA = 0X01;
TRISB = 0; //Configure PORTB as output
PORTB = 0; //Initial value of PORTB
Lcd_Init();
while(1){
Lcd_Cmd(_LCD_CURSOR_OFF); // cursor off
Lcd_Cmd(_LCD_CLEAR); // clear LCD
StartSignal();
CheckResponse();
if(a == 1){
ReadData();
rh1 =i;
ReadData();
rh2 =i;
ReadData();
t1 =i;
ReadData();
t2 =i;
ReadData();
sum = i;
if(sum == rh1+rh2+t1+t2){
text = "T: .0C";
Lcd_Out(1,1,text);
text = "H: .0%";
Lcd_Out(1,9,text);
Lcd_Out(1,3,Ltrim(mytext));
ByteToStr(rh1,mytext);
Lcd_Out(1,12,Ltrim(mytext));}
else{
Lcd_Cmd(_LCD_CURSOR_OFF); // cursor off
Lcd_Cmd(_LCD_CLEAR); // clear LCD
text = "Check sum error";
Lcd_Out(1,1,text);}
}
else {
text="No response";
Lcd_Out(1,3,text);
text = "from the sensor";
Lcd_Out(2,1,text);
}
LCD_Out(2, 1, "Temp:");
//Display = "+125 'C";
Display[4] = 39; //'
Display[5]= 'C';
ADCON1 = 0x0E;
ADC_Init();
while (1){
ADRead = (ADC_Get_Sample(0) * 500) >> 10;
vDisp[0] = ADRead / 100;
vDisp[1] = (ADRead / 10) % 10;
vDisp[2] = ADRead % 10;
Display[1] = vDisp[0] + 48;
Display[2] = vDisp[1] + 48;
Display[3] = vDisp[2] + 48;
LCD_Chr(2, 8, Display[0]);
LCD_Chr(2, 9, Display[1]);
LCD_Chr(2, 10, Display[2]);
LCD_Chr(2, 11, Display[3]);
LCD_Chr(2, 12, Display[4]);
LCD_Chr(2, 13, Display[5]);
//LCD_Out(1, 8, ); // 'Show temperature
delay_ms(200); //200ms delay for waiting
}
}
}