Interrupt Trigger Inconsistency

Discussion related to "under the hood" OpenMV topics.
rajeshktym
Posts: 31
Joined: Wed Mar 07, 2018 7:04 pm
Location: KOCHI
Contact:

Interrupt Trigger Inconsistency

Postby rajeshktym » Thu Oct 31, 2019 12:30 am

Code: Select all

import time, pyb

from pyb import Pin

ms_count = 0
trigger_delay = []
def Average(lst): 
    return sum(lst) / len(lst) 

def callback(line):
    global ms_count
    global trigger_delay
    trigger_delay.append(ms_count)
    ms_count = 0

extint3 = pyb.ExtInt(pyb.Pin("P3") , pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_DOWN, callback)

while(True):
    time.sleep(1)
    ms_count += 1
    if len(trigger_delay)>3:
        average = Average(trigger_delay) 
        print(average,trigger_delay)
        trigger_delay.clear()
Hi, I am using above code for verify consistency of Interrupt trigger, but it give below result
  • 358.25 [359, 357, 355, 362]
    354.75 [355, 356, 354, 354]
    353.75 [351, 355, 353, 356]
    357.75 [354, 357, 360, 360]
    357.0 [355, 356, 357, 360]
    358.5 [360, 356, 358, 360]
    357.5 [361, 358, 353, 358]
    357.75 [359, 358, 360, 354]
    352.75 [348, 351, 355, 357]
    357.5 [360, 357, 355, 358]
    355.5 [356, 360, 353, 353]
    355.5 [359, 357, 350, 356]
    352.5 [350, 354, 350, 356]
    355.0 [359, 353, 350, 358]
    357.0 [357, 358, 355, 358]
    353.75 [350, 352, 354, 359]
    355.0 [353, 356, 355, 356]
    355.5 [354, 354, 354, 360]
    356.25 [359, 357, 356, 353]
    357.0 [354, 360, 354, 360]
    356.75 [357, 355, 355, 360]
    357.75 [356, 362, 355, 358]
    353.75 [352, 354, 350, 359]
    357.0 [355, 359, 353, 361]
    354.25 [352, 357, 350, 358]


Is this normal or some thing I can improve though code?
User avatar
kwagyeman
Posts: 3717
Joined: Sun May 24, 2015 2:10 pm

Re: Interrupt Trigger Inconsistency

Postby kwagyeman » Thu Oct 31, 2019 2:01 am

If USB is connected then that will make the interrupt have jitter as the USB bus when being serviced has a higher priority.
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests