Thread in Micropython

Hello! I hope this question is not too silly. I have to run three function at the same time in micropython so its obvious i need threading. My main problem is that i can not reach the “us level” (microsecond time) with the “asyncio” library in Micropython (just the millisecond time). Does anyone have any ideas on how I can achieve the microsecond time? I mean with other libraries or maybe with a built-in modul? Thank you so much for your answer! (i am using Pyboard)

Hey, @zyimmi ,

I think the problem here is the micro python is around 100x slower than native code, so even if you could get a microseconds resolution time stamp, it would not be very meaningful at micropython time scales…

Other than this not very helpful comment I’m afraid I don’t have anything to offer on this topic…

1 Like

I use micropython a lot and I think I’d need you to go back and edit your comment before it seems to make sense. If you just want to access time.ticks_us(), uasyncio does not interfere with that. You seem to have an awful lot of stuff jumbled up and I can’t help with untangling that, you just have to patiently go over the systems and learn more and then things will become apparent.

I’m sorry I don’t have any good documentation on the subject. I know it’s a drag, but this stuff just isn’t plug and play. It could be, if we had better pedagogical materials. Instead all we have is dozens of “get started” things and then the datasheets and primitive code documentation.

Micropython is generally not a good idea for a motor driver. Neither, in general, is rolling your own, so although libraries etc. for micropython would be cool they don’t really make sense. Making one very general purpose arduino based board and set of arduino libraries and several reference designs using the modules, completely open source and well tested and honed, makes sense. And then making more for various other niches.