Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC 16f877 with pump and solenoid running for long days. and watchdog

Status
Not open for further replies.

kareem_nabil

Newbie
Newbie level 2
Joined
May 5, 2020
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
39
Good Day.

i'm designing a machine that runs Air Pump , Solenoid ,and some relays .this machine must work continuously without any shutdown for at least 10 complete days. what key points should i consider during design and fabricating and of course the code .

2- I've tested the machine for about 20 hours. it works fine .but after that .the micro controller seems hanged up. pump stopped but the solenoid kept working and the LCD displayed black squares. after making a reset it worked fine again . i think this could be solved with watch dog. but i've never used it. i've enabled it's register from project option. but when i simulated it on Proteus . the micro controller keeps resetting .
i'm using mikroC pro for PIC v7.2.0. please tell me how to enable and use the watch dog.
also what's the regulations and recommendations for design long time running machine.

here's a part of my code:


Code C - [expand]
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
void main() {
 
TRISA.RA4=1 ;
PORTC=0; //reseting ports
PORTB=0;
PORTD=0;
PORTA=0;
TRISB = 0x00 ; //all portb is output
TRISD = 0x3f ; //All PortD is input excpet pin 6,7
TRISC = 0xff ; //all portc is input
 
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
 
buzzer = 1 ; //buzzer on for 300ms
delay_ms(300);
buzzer = 0 ;
Lcd_Out(1,1,codetxt_to_ramtxt(intro1));
Lcd_Out(2,1,codetxt_to_ramtxt(intro2));
Lcd_Out(3,1,codetxt_to_ramtxt(intro3));
Delay_ms(1500);
Lcd_Cmd(_LCD_CLEAR);
flow_rate =600.00;
 
 
while(1)
{
 
 
if (RR10 == 1)
{
cycle = 6.0;
RR = 10;
}
else if (RR15 == 1)
{
cycle = 4.0;
RR = 15;
}
else if (RR20 == 1)
{
cycle = 3.0;
RR = 20;
}
else if (RR25 == 1)
{
cycle = 2.4;
RR = 25;
}
else if (RR30 == 1)
{
cycle = 2.0 ;
RR = 30;
}
else{cycle = 0.0 ;
RR=0 ;
}

 

The watchdog is just a counter, when it reaches maximum count it internally causes a system reset. The instruction to clear it sets it back to zero.

1. enable the watchdog
2. reset it in your program loop.

The idea is your program resets it while running so normally you would place it in a loop, possibly your main() loop or maybe before a routine you know will take a long time to complete. If you program crashes, the watchdog counter DOESN'T get cleared so it forces your program to restart.

You need to post the whole code for us to help with errors, without knowing what 'RR' and 'cycle' are it doesn't make any sense and without any comments it is difficult to see what it is supposed to do.

Brian.
 

The words solenoid and reset appear together quite often; carefully check the PCB layout looking for possible crosstalking traces, keep in mind that solenoids are devices that have high inductance, creating voltage spikes when de-energized, inducing current through the circuits in their neighborhood. The addition of snubbers close to the solenoid connector, or even spreading decoupling capacitors at power buses could attenuate these artifacts.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top