Self balancing robot

Showroom for MicroPython related hardware projects.
Target audience: Users wanting to show off their project!
stmfresser
Posts: 22
Joined: Sat Jun 20, 2015 11:48 am

Re: Self balancing robot

Postby stmfresser » Tue Nov 15, 2016 1:44 pm

i've built my self balancing robot and trying to port the c code into micropython. Unfortunately micropython is too slow on STM32F407 Board.
Is there any better µcontroller which is for micropython optimized.

https://www.youtube.com/watch?v=jPH4uLOQLpM

User avatar
deshipu
Posts: 1074
Joined: Thu May 28, 2015 5:54 pm

Re: Self balancing robot

Postby deshipu » Tue Nov 15, 2016 2:00 pm

Can you tell us what exactly is too slow? I'm sure the code can be improved to run faster in the critical places.

Online
User avatar
pythoncoder
Posts: 1639
Joined: Fri Jul 18, 2014 8:01 am

Re: Self balancing robot

Postby pythoncoder » Tue Nov 15, 2016 2:26 pm

Indeed. I'm not alone in having used MicroPython for this purpose without needing any serious optimisation. Someone - I forget who - has flown a quadcopter which is a considerably more demanding proposition.

Are you sure speed is the problem? I experienced major difficulties which turned out to be entirely mechanical in origin. Vibration affecting the sensors.
Peter Hinch

stmfresser
Posts: 22
Joined: Sat Jun 20, 2015 11:48 am

Re: Self balancing robot

Postby stmfresser » Tue Nov 15, 2016 4:42 pm

my python control loop code runs 30ms, it's getting slower with the time, my C control loop runs 10ms. The balance control loop needs max. 10ms.

Online
User avatar
pythoncoder
Posts: 1639
Joined: Fri Jul 18, 2014 8:01 am

Re: Self balancing robot

Postby pythoncoder » Tue Nov 15, 2016 5:54 pm

In which case there is room for improvement. My control loop has an explicit delay to set the loop time to 5ms. Have you read the tutorial on improving MicroPython speed? See the list of tutorials herehttp://docs.micropython.org/en/latest/pyboard/reference/index.html.
Peter Hinch


Return to “Hardware Projects”

Who is online

Users browsing this forum: No registered users and 1 guest