# Timer interrupt to achieve trip timing

1. ## Timer interrupt to achieve trip timing

Dear all ,
I am using PIC16F1938.I have used Mplabv 8.86 for coding with hitech compiler v9.86.
I need simple favor implementing this code in timer interrupt.
I have excel sheet attached for reference.
I have overload trip of motor setting 30A with Trip Time 30S. i would like to achieve attached curve using timer interrupt. can someone guide me how it can be implemented.
user can change overloadtrip and timing accordingly.

curve is meant to achieve below function
Lower current higher trip time and higher current lower trip time

•

2. ## Re: Timer interrupt to achieve trip timing

Do you want c code or algorithm ?

What is your Fosc ?

Create a 500ms Timer 1 interrupt if you are using 4 MHz Fosc.
Use a counter variable in timer ISR and increment it once on each interrupt.

If it is 2 then time spent is 1 sec.

So, convert your current (adc value) to required timer trip delay like;

tripDelayCount = -2.000*I + 62.00

I = 1A

tripDelayCount = 60

I = 30A

tripDelayCount = -60 + 62 = 2

So in timer ISR you do like this;

Code:
void timerISR() {
If((TMR1IE_bit) && (TMR1IF_bit)) {
TMR1IF_bit = 0;
//Reload TMR1H and TMR1L

if(++tripDelayCounter >= tripDelayCount) {
tripDelayCounter = 0;
//trip the load
}
}
}

•

3. ## Re: Timer interrupt to achieve trip timing

Hi,

Some thoughts:

Motor is: DC, BLDC, AC 1 phase, 3 phase or anything else?

***

* RMS_current represents the heating in the winding, in either case.
* Usually with motors one takes I^2t overcurrent limiting algorithm.
--> this means if you do it this way you don´t need to take the square root of the current. (which makes processing more fast and easy)

Klaus

•

4. ## Re: Timer interrupt to achieve trip timing

implement an timer for 1 sec using timer
then apply algorithm for trip delay

***
trip delay= 31 - ADC processed o/p
if,trip delay =31 (i.e ADC o/p is 0)
loop up timer for trip delay times to achieve trip delay time

(this logic will only work for ADC o/p ranging from 1-30)
***
make sure that necessary condition should be provided for ADC range beyond specified

--[[ ]]--