**** BEGIN LOGGING AT Mon Oct 31 02:59:56 2022 Oct 31 13:08:29 Hello Oct 31 13:09:00 So I am trying to do a time sensitive operation in python. How can I use the pru to set a timer interrupt? Oct 31 13:13:05 uart0_person: that sentence doesn't really make sense Oct 31 13:13:29 if you want a timer in python, neither a timer interrupt nor pru is of any relevance Oct 31 13:14:40 conversely, if you need the sort of timing accuracy that requires pru, then use pru rather than python Oct 31 13:15:35 Ok, let me reformulate Oct 31 13:15:55 I want the timing that pru provides for a python script Oct 31 13:16:12 yeah sorry that sentence still doesn't make sense Oct 31 13:16:24 why not? Oct 31 13:22:21 the limiting factors for timing precision in python code is the general slowness of python and the timing unpredictability of any process that runs in linux userspace Oct 31 13:22:34 there's nothing pru can do to change either of those things Oct 31 13:23:13 so it's better if I code the pru with C Oct 31 13:24:48 what sort of timing accuracy are you looking for anyway? Oct 31 13:25:01 it's for a pid Oct 31 13:25:26 I want the samples to always have the same interval between the Oct 31 13:25:30 them* Oct 31 13:25:43 samples of what? Oct 31 13:26:03 and you haven't actually answered the question Oct 31 13:31:21 there are many solutions for any given problem, pru may be appropriate for some purposes or overkill for others Oct 31 13:32:19 like, if you program PRU in assembly you may be able to execute code with 5ns or 10ns timing precision... but that may be complete overkill in many cases Oct 31 13:33:45 I want to make a pid that gets called at regular intervals and I want to make sure these intervals are precise. I discovered I could have that using a timer interrupt Oct 31 13:33:58 I don't know how precise they need to be Oct 31 13:34:25 but I want it to be more precise that just using a python script and using the time library Oct 31 13:35:45 if you don't know how precise they need to be, then how do you know python isn't meeting your needs? Oct 31 13:36:18 if you want something better, step 1 would be using e.g. C instead of python Oct 31 13:36:23 also, 14:25 <@zmatt> samples of what? Oct 31 13:37:37 if you're talking about sampling the ADC then the right solution is to configure the ADC to use whatever sample rate you desire and stream the sample data using iio Oct 31 13:38:36 then the samples are taken at an exact interval (with the only variability being due to clock jitter, which is negligible) and your program can be synchronized to the rate at which adc data becomes available Oct 31 13:39:15 it would be samples of a flow meter arriving via uart Oct 31 13:39:28 lol, and what baudrate are you running at? Oct 31 13:41:03 and do you need to poll the flow meter or does it sample periodically for you? since in the latter case you obviously don't need any sort of timer Oct 31 13:41:19 wait sorry, not uart Oct 31 13:41:22 it will i2c Oct 31 13:41:30 it will be i2c Oct 31 13:42:18 it has a fast response of 5ms Oct 31 13:42:34 5ms is not fast, 5ms is slow as hell Oct 31 13:42:53 sorry,  < 5 m Oct 31 13:42:55 %ms Oct 31 13:42:57 5ms Oct 31 13:43:42 yeah, I forgot it doesn't matter if you have a quantum computer if the one transmitting the samples isn't as fast Oct 31 13:44:00 nothing you do via i2c is particularly fast, a single data transfer takes hundreds of microseconds Oct 31 13:44:02 I was only thinking the program needs to be fast, but forgot about the hardware Oct 31 13:44:43 is python good enough for 5ms? Oct 31 13:45:32 in the end it'll depend on the actual code you write Oct 31 13:45:49 python is in general not great for performance Oct 31 13:53:02 ok Oct 31 13:53:10 I am not great at estimating these timing parameters Oct 31 13:53:51 I will first try in python and then see how fast it goes Oct 31 13:53:59 so build a test and measure Oct 31 13:54:36 in the end, how you write your code will matter more than your choice of language Oct 31 13:56:16 I have this bad habit like, imagine you have a situation which you have two options but if you choose wrong, it won't cause damages, you could just go and test it and you know which is right and which is wrong Oct 31 13:56:34 I have the habit that I think I need to research everything about it before making a decision Oct 31 13:57:19 instead of just making a code and testing , I keep fixated on finding how to use a pru timer Oct 31 13:58:01 pru has nothing to offer for you Oct 31 13:58:04 in this context Oct 31 14:04:57 pru isn't even useful/needed if you wanted to use a hardware timer in python, but additionally, using a hardware timer in python wouldn't actually get you better timing than using a normal timer Oct 31 14:08:25 hmm, does python's asyncio not have a decent periodic timer API built-in? that seems dumb Oct 31 14:12:26 ? Oct 31 17:21:09 hello **** BEGIN LOGGING AT Mon Oct 31 21:41:32 2022 **** ENDING LOGGING AT Tue Nov 01 02:59:56 2022