Looking for architecture advise because I think what I have could be a lot better. (Timers, second core, interrupts) #15348
paulbuzzby
started this conversation in
General
Replies: 1 comment
-
hi paul, i had similar question(s) while ago when i started with micropython on esp32 and 8266. eventually, i started using asyncio and i have found this to work nicely for me. the async approach offers a structured way to set up and handle tasks, more so than fiddling around with timers. the asyncio tutorials from peterhinch were perfect to get the hang of it. of course i cannot tell if this is applicable to your case, although i do similar things: read sensors, perform tasks. monitoring performance with an logic analyser, ms response times are certainly doable. hope this helps - erik |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have ported a code base from arduino c to micropython to run on the RP2040. The code is to run a robot micro mouse.
The high level architecture looks like
I have a main code loop that sets up what the robot does and at certain points waits for moves to be finished.
There is an update loop that executes 200 times a second via a timer using the following line
systick = Timer()
systick.init(mode=Timer.PERIODIC, freq=200, callback=Update)
I also have DC motors with encoders on the robot and am using the quadrature_encoder code to get encoder pulses from each motor.
The encoder counts works very well and I think this is not handled by the CPU at all.
Technically this all seems to work. I have no thread-specific code and I don't know how the timer interacts with code executing in the main loop beyond that it does work
My question(s).
Should I be using some sort of thread framework for any of these and if so what examples can you point me to?
Can I get any of this to run on the second RP2040 core that is available? I believe this all works on a single core for now
What other approach might I be missing as the "correct" micropython way to run this sort of thing?
My main focus here is speed of execution and anything i need to do to make sure I don't get code clashes, memory issues or leaks.
Thanks
Paul
Beta Was this translation helpful? Give feedback.
All reactions