+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Member level 3
    Points: 556, Level: 5

    Join Date
    Oct 2017
    Posts
    57
    Helped
    0 / 0
    Points
    556
    Level
    5

    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

    •   AltAdvertisment

        
       

  2. #2
    Advanced Member level 1
    Points: 2,419, Level: 11
    baileychic's Avatar
    Join Date
    Aug 2017
    Posts
    469
    Helped
    45 / 45
    Points
    2,419
    Level
    11

    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
          }
       }
    }
    Last edited by baileychic; 18th January 2019 at 14:06.



    •   AltAdvertisment

        
       

  3. #3
    Super Moderator
    Points: 72,564, Level: 65
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    14,748
    Helped
    3367 / 3367
    Points
    72,564
    Level
    65

    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
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



    •   AltAdvertisment

        
       

  4. #4
    Newbie level 1
    Points: 133, Level: 1

    Join Date
    Jun 2018
    Posts
    1
    Helped
    0 / 0
    Points
    133
    Level
    1

    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
    Last edited by DEEPAK_HEMBRAM; 27th January 2019 at 18:35. Reason: could be more helpful



--[[ ]]--