Butchijo
Posts: 5
Joined: Sat Aug 29, 2015 9:54 am

Interrupt on built-in clock every minute

Sat Aug 29, 2015 10:10 am

Hi,

Within a python program i want to execute a program (subroutine) every minute exactly the moment the built-in clock of the raspberry changes the minute.
Is there a way to set up this interrupt.
Also i want to read the minute value as an integer and the second value with .0 accuracy.

I hope somebody can help.

Butchijo

ghp
Posts: 1498
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Interrupt on built-in clock every minute

Mon Aug 31, 2015 5:31 pm

Hello,

there is no 'exactly at' in a python-linux environment. Even in an interrupt driven microcontroller code there are delays from sig cause to interrupt start.
When accuracy of 'exactly' is some 10ms, then try following approach:

Code: Select all

initiate event_queue
thread_1:
    while True
        check clock. 
        if minute changes
             place event on event_queue
        sleep(10ms)

thread_2:
     while True:
         read event_queue
         if event available
             do something useful
Good luck
Gerhard

Return to “Python”