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.

interrupt routine hanging pic

Status
Not open for further replies.

garg29

Advanced Member level 1
Joined
Nov 17, 2004
Messages
443
Helped
25
Reputation
50
Reaction score
10
Trophy points
1,298
Activity points
3,593
Hi all
m designing a project using pic16f877 (4Mhz)and ds1302.the controller unit drives the relay which furthur drives a star delta strater of three phase motor.
i have to save the runtime of the motor on power failure.so as soon as the power fails my system generates an interrupt and the runtime of motor is saved.
now the problem is as soon as my pic gives start command to relay and relay to starter due to back emf of starter my microcontroller section hangs up ...i have tried following hardware solutions:
1 . adding decoupling capacitors
2. flywheel diode on the relay
3. better ground lines

if i remove the interrupt from the code my controller section works fine..what might me the problem? m sending the part of code for interrupt

.
.
.
.
.
.




void interrupt isr ()
{
if(INTF)
{
INTF=0;
WriteByteToEE(TotalRunTime,0x0B);



}
}


.
.
.
.
.
.
.







void main(void){
.
.
.
.
PEIE=1;
T1CON=0X30;
INTE=1;
GIE=1;
.
.
.
.
.
.
.
}

waiting for reply
 

hi,
which compiler you are using?
 

Hitech picc

Added after 41 seconds:

and also wht does complier have to do with my problem can u please explain?
 

you have problems with harmonics generated from power line and motor ,second problem is back EMF

1- try to isolate the microcontroller with optocopler (between the microcontroller and the relay. i think it will work
2- try to put your controller away from power lines to reduce harmonics
3- use independent power supply (battery,switchmode,..)
4- put tentalium capcitor near to microcontroller (vcc,gnd)
 

relay should attached as close as possible to power supply and separated high current ground return with low current ground return will olso cured
 

Try

void interrupt isr ()
{
if(INTF)
{
INTF=0;
GIE=0;
WriteByteToEE(TotalRunTime,0x0B);
GIE=1;


}
}


I thing that problem couse long time need for writing to eeprom. Try move WriteByteToEE to main.
 

As Tareksamy.

The micro controller should be separated from optoIsolator's to reduce damage of hight current and voltage which may damage the micro controller . SO try to separate the microcontroller from power side and try to reduce the harmonics
 

try using better grounds for microcontroller. it seems noise is coming from ground line. try opto isolation for interrupt pin.
 

    garg29

    Points: 2
    Helpful Answer Positive Rating
i tried this lats......the system response has become somewhat better (but not 100% accurate)....thanks
 

Remove the Surge in the power supply section by using the X-Cap and Y-Cap Capacitance to remove the surge. The Ripples in POwer supply which leads the Voltage fulctuations. The required voltage needed for microcontroller is 5V. Due to surge the output voltgae may vary. Check the required voltage is coming to Controller side in all time.
 

i don't think any problem is with hardware.

I think writing to eeprom is taking more time.Try to move the routine to main program. it is not a good practise of writing huge code in interrupt subroutines.
try to set some bit in the routine and execute the task in the main loop with respect to that bit.

and also check with other interrupts like timer.
because if the timer subroutine is taking much time it will continuously be in that loop only.will not come back to the main loop.


---Keshav

Added after 3 minutes:

Hey forgot to tell

make the bit INTF = 0; after executing the total interrupt routine.I thnk this may be the problem.

--Keshav

Added after 42 seconds:

Hey forgot to tell

make the bit INTF = 0; after executing the total interrupt routine.I thnk this may be the problem.

--Keshav

Added after 1 minutes:

Hey forgot to tell

make the bit INTF = 0; after executing the total interrupt routine.I thnk this may be the problem.

--Keshav
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top