Mrunal Ahirrao
Full Member level 2
- Joined
- Nov 26, 2012
- Messages
- 133
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 1,298
- Location
- India
- Activity points
- 2,213
View attachment 1.jpgHi all! I am trying to make PIC to work,but its working in unusual way! I have used PICs many times and have a good experience on it, but from today, I am not able to make PIC to work as usual. The problem I am facing is, I am actually developing water level controller using PIC16F628A and I have used three float sensors for it. But one sensor which is connected to Mcu's pin is behaving unusually. actually the logic is to make RB7 pin to '0' when RB1 is '0' but instead the RB7 flips to '0' just when I touch with my hand to the RB1 pin! Any help would be appreciated. I have tried changing with different ICs but faced same problem. Below is my Code and above is my PCB design.
Code:
/
sbit OLow at RB0_bit;
sbit ILow at RA2_bit;
sbit BM at RB7_bit;
sbit OHigh at RB2_bit;
unsigned short SUBS;
void main() {
TRISA=0b00100100;
TRISB=0b00000111;
CMCON =0x07;
//ANSEL=0;
//OSCCAL=0b11111100;
OPTION_REG=0b00110000;
BM=0;
//SUBSW=0;
SUBS=1;
do{
if(SUBS==1&&OLow==0)
{
delay_ms(30000); //Rechecking whether Olow==1
if(BM==0&&OLow==0){
delay_ms(30000);
if(BM==0&&OLow==0){
delay_ms(30000);
if(BM==0&&OLow==0){
delay_ms(30000);
if(BM==0&&OLow==0){
delay_ms(30000);//Recheck completed
delay_us(200);
if(ILow==1)
{
BM=1;
SUBS=0;
}
//SUBST();
}
}
}
}
}
//delay_us(200);
if(ILow==0)
{
BM=0;
SUBS=1;
}
if(OHigh==1)
{
BM=0;
SUBS=1;
}
}while(1);
}
Last edited: