Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Start stop timers using two different interupts

  1. #1
    Junior Member
    Join Date
    May 2019
    Posts
    10

    Start stop timers using two different interupts

    Hi All
    I've had a look through google and cant quite find the answer. So please bear with me.

    Im wanting to look at the phase difference between two voltage or current inputs. What i would like to do is half rectifiy two inputs and feed one into interupt one and another into intrupt two. And start and stop the timer based on the interupts rising . Im aware i can do this using comparators but would like to try this way because i'm not looking for phase angle between current and voltage im looking at trying to build a bridge circuit to tell me the difference between one instrument transformer and another.

    The examples of found using timers are using the same interupt for the timer.

    As this project is still at theoretical stage I dont have any code to share but if this is a possible way of doing it, i would appreaciate it if you could point me in a direction of some examples

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    980
    Each interrupt can capture the timestamp when it fires, the main code can wait for these to change and take the
    difference perhaps?

  3. #3
    Junior Member
    Join Date
    May 2019
    Posts
    10
    Thats a good idea, I really just need to sit down and build the circuit and give it a go. Thanks for the feedback

  4. #4
    Senior Member
    Join Date
    Aug 2013
    Location
    Gothenburg, Sweden
    Posts
    414
    For comparing phases by time difference between two input channels the timer clocks must be synchronised, so you should use two Capture Compare channels connected to the same timer, on the other hand then they will share interrupts so some little code is needed to find out which or both channels has fired. Look in the code for FreqMeasure or FreqMeasureMulti to see a good example of the details of period measurement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •