PiRTC - PCF8523

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
tjf
 
Posts: 6
Joined: Mon Sep 04, 2017 6:12 pm

PiRTC - PCF8523

Post by tjf »

The PiRTC - PCF8523 module has an interrupt pin and PCF8523 can be programmed to generate a periodic pulse on this pin.
Using Python 3.4 one could wire this output to a GPIO an receive a high precision clock interrupt (e.g. based on 4.096 kHz with timer A, a pulse every 10 ms).
Now the question: Is the Raspi 3 with Python 3.4 fast enough to respond to a GPIO Interrupt every 10 ms and do some work in the Interrupt routine?
Anyone any experience with this?
Thank you.
Thomas

User avatar
pmeloy
 
Posts: 24
Joined: Tue Sep 19, 2017 2:26 pm

Re: PiRTC - PCF8523

Post by pmeloy »

Hmm no replies. Better late than never!

Your question really comes down to what do you need to do in 10ms? If you want it to play a 90 minute movie, that's not going to work. If you want it to read a DHT sensor that has a 1000 ms computation time, that's not going to work either. On the other hand, 10 ms can be a huge amount of time if what you want to do is fast in the first place. Just sitting there, the Rpi is doing thousands of things in 10ms and that's only using one processor.

What is it you want to try and do?

User avatar
tjf
 
Posts: 6
Joined: Mon Sep 04, 2017 6:12 pm

Re: PiRTC - PCF8523

Post by tjf »

Scanning some switches and IR-Sensors in a timer tnterrupt routine.
Best regards
Thomas

User avatar
pmeloy
 
Posts: 24
Joined: Tue Sep 19, 2017 2:26 pm

Re: PiRTC - PCF8523

Post by pmeloy »

Scanning shouldn't be a problem at all. Its what you do with them after they've been scanned. Depending on how things are laid out you could use events (interrupts) to call a function when a trigger point is reached. The events happen independent of the main thread but I believe the processing (the function called) suspends the main thread while that function is active. If processing the response to an event is really time critical you can get fancy and have the event handler start a/some thread(s) to hand off the processing to other processor(s), greatly increasing what can be done in that 10ms.

I haven't personally attempted something with that kind of response speed but I would think there might be a problem if the function called by an event gets called a second time before its completed processing the first event. I don't know what language you're programming in (not that I'd be an expert on any of them even if I did) but if it doesn't accomodate re-entrant functions (allowing a second processes to run the code while the first is still going) then that will likely cause headaches. Thats were threads are handy. If the event function just starts a thread to deal with the event that will take almost no time at all.

Of course the threads you call could have problems if they try to access hardware while another thread is busy using it. I just ran into that with threads trying to share the I2C bus. I had checks in the threads to see if the bus was busy by checking a global variable and do a while x==y;sleep(0.1). Learned the hard way that the global variable isn't global inside a thread so when one did trigger the while loop it just sat forever waiting because changes in the main loop aren't seen in the thread.

There's some way of doing what I was attempting but because my processes are so slow I just put the check in the main loop prior to creating that thread.

It gets quite mind boggling at first.

User avatar
tjf
 
Posts: 6
Joined: Mon Sep 04, 2017 6:12 pm

Re: PiRTC - PCF8523

Post by tjf »

Hi
In my case I have 3 Python threads (one for tkinter main loop and 2 for me). Therefore I wanted a time critical routine to be connected to a 10ms interrupt.
In the meantime I found that someone has tested the Interrupt response time for the Python GPIO package. A few micros.
And: I now tested the concept with a waveform generator (10 ms square wave signal).
I found that it works very well for small interrupt routines.
It's just a pity, that I cannot use the timer output of the Adafruit RTC module when one use the kernel driver for the rtc.
Thanks and best regards
Thomas

User avatar
pmeloy
 
Posts: 24
Joined: Tue Sep 19, 2017 2:26 pm

Re: PiRTC - PCF8523

Post by pmeloy »

So don't use the kernel driver for the clock. Write a script that reads it and sets system time at boot let the fake hw clock package take care of time which you use the RTC for whatever you want.

Locked
Please be positive and constructive with your questions and comments.

Return to “Clock Kits (discontinued)”