Reset circuit problem

Thread Starter

Balaji J

Joined Jan 30, 2018
4
Hi this is balaji
I am new Lerner on pic controller i am design and program for water level cintroler but problem is I have loaded the program reset button press 3or more time the program works .what is the problem please help me.
 

ErnieM

Joined Apr 24, 2011
8,377
Hi Balaji, welcome to the forums.

Can you please provide more details? Is it only the first time you run the program you need to keep hitting reset or every time you power up? Is everything else working?

A schematic may help here if it shows how this reset button works.
 

be80be

Joined Jul 5, 2008
2,072
1 k is to small you'll end up burning up you pic you need a minimum of 4.7 k I use 10 k

Screenshot from 2018-02-01 02-15-22.png
 
Last edited:

Thread Starter

Balaji J

Joined Jan 30, 2018
4
thank you ae80be,

as per your suggestion i have to change 1k to 10 k. but problem is in portA pin con't read the digital inputs.

PORTA is pull up with 10K

case1: PORT A = 0X00 moter off
case2: PORTA = 0XFF moter on

// Lcd pinout settings
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D4 at RB4_bit;

// Pin direction
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D7_Direction at TRISB7_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB4_bit;
//connection end

#pragma config PWRT = ON
#pragma config MCLR = ON
void main()
{

CMCON = 0x07;
ADCON1 = 0x06;
TRISA = 0x0F;
TRISE.RE0 = 0;
TRISE.RE1 = 1;
TRISC = 0x00;
TRISD = 0x00; //PORT D as Output
PORTD = 0X00;



Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);

while(1)
{

if (PORTA==0X0F)
{

PORTC.RC0=0X1;
PORTC.RC1=0X1;
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"WATER LEVEL");
Lcd_Out(2,1,"10% MOTERON");
}

if (PORTA==0X00)
{
PORTC.RC0=0X0;
PORTC.RC1=0X0;
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"WATER LEVEL");
Lcd_Out(2,1,"100% MOTER OFF");
}
}
please find attached schematic pics
please help me

PIC.png PIC2.png
 

Picbuster

Joined Dec 2, 2013
1,047
You test on portA all BITS high or low is that what you want?
If you only want to test one port you should address it like PORTAbits.RA0 or depending at compiler RA0 ( 0 is wanted Pin)

Picbuster
 

be80be

Joined Jul 5, 2008
2,072
His test is wrong your test the whole port if only one pin is toggling low the test never becomes true.
Plus your circuit does not match your code.
 

be80be

Joined Jul 5, 2008
2,072
Just because it is working in proteus does not mean much LOL.
Proteus kind of fixes simple mistakes.

Code:
if (PORTA==0X0F)
That code is saying you have 4 switches AN0 to AN3
that test is only true if there all high.

Code:
if (PORTA==0X00)
This code is only true if all 4 are low
If you only have 1 switch that will never happen on real hardware

In Proteus you can set them to what ever you want with hardware you would need the real thing.
4 switches
 
Top