r/ControlTheory • u/HotelFirm3622 • 6d ago
Technical Question/Problem Need help with self-balancing robot
Hi all, I'm working on a self-balancing robot, im a senior student whos already taken control systems and I was just wondering on whether simulating this robot is feasible in simulink. I asked claude to help me with the equations of motions and transfer functions and this is what I got. I was wondering if this transfer equation seems reasonable, im using two DC motors, and I gave it my motor datasheet, I just need some help understanding how to actually use this now in Simulink, how can you tune PID on simulink, and I was very surprised to see why PD doesn't work on it's own, from my research on other self balancing robot builds they recommend never using an I term. Thanks!




•
u/2dof 6d ago
You can simulate this in simulink, it is just simple LTI model but since You want build sel balancing robot ( inverted pendulum on wheel ) - do not use this crap regenerated/rewrite/copied by Claude:
Whole idea of designing any type oc inverted pendulum/balancing robot is write nonlinear equation of motions , then do linearization around zero (degree) to get LTI model and synthesize controller ( all equation , with explanation You will find www and books (also in www) (but if even You would write equations form Euler-Lagnange theory there is worth it)
There is example example in simulink of inverted pendulum on cart, and also a lot of user implementation - usually there are references to source books.
and here what You got:
- gutted equations out of context - there is no self balancing root any more ( see for comparison: https://www.laccei.org/LACCEI2020-VirtualEdition/full_papers/FP556.pdf )
- stupid Claude's "magic: ( see equations (1) and velocity equation (x'' - above (15) ) - WTF? (make no sense )
•
u/Barnowl93 5d ago
Is it doable? Yes. Very. You already have the dynamic equations. Do have any experience with Simulink? If not those two free courses will be good for you https://matlabacademy.mathworks.com/details/simulink-onramp/simulink https://matlabacademy.mathworks.com/details/model-dynamic-systems/otslmds
If you Google it you'll find some examples too.
Since you're already using claude, connect your claude code to simulink using simumink agentic toolkit and use that to guide your learning... https://github.com/matlab/simulink-agentic-toolkit
•
u/Cu_ 6d ago
The reason rhat P or PD doesn't work here is because of the zero at the origin. One closed-loop branch of the root locus always ends at the zero at the origin. Since you have a RHP pole (lets call it p) the root-locus branch runs on [0, p] and the pole stays in this region for every gain. Consequently, we can never stabilize the system because we need to move the pole to the LHP for stabilisation.
Regarding how to tune the controller: I don't have the details from the top of my head but look at the Åström book (it's free online) on loop shaping. That should give you all the details on what you actually want the loop-transfer function L(s) = C(s)G(s) to actually look like.
•
u/urcousin5242 5d ago
I did my final year thesis on this if you pay i can give you The full simulation and the thesis paper