PID parameters for self-balancing motorcycle

Hello,

I came across this topic while struggling for balance with the self-balancing motorcycle.

I know this topic hasn't been posted for a while now, but I thought I would share my experience in case someone will find the same issue in the future.

The "secret" to make the controller work perfectly is to accurately evaluate the bias. My problem is that all those manual tests suggested by the course notes required too much precision for me. Also, the USB cable or any slight change of the position of the battery would change the actual value of the bias.

So I started seeking a method for the controller to automatically evaluate this bias every time, and I found that the integral of the torque command (the one after the manual switch) over time is a good bias value. It also helps to compensate for the centrifugal force in a big radius turn.

The drawback is that the bias will constantly change, causing the system to lose stability momentarily. But in this way, I went from a very stable system that saturated the inertia wheel speed in less than 20 seconds, to a slightly unstable system that stands upright indefinitely every time I switch it on.

I hope someone will find this useful.

1 Like

Hello, everyone,

I've been working on this project for weeks and I'm not getting anywhere.
My individual components are working perfectly. ( rear wheel, servo motor )
My big problem is to calibrate the wheel of balance.
When I run the program and set up the bike, the bike stands up and is also in the middle. The only problem is that the balance wheel starts to rotate too fast (it rotates over 6000 revolutions within a few seconds).
I have already changed all parameters and I can't find the error.
I hope someone with the same problem can help me.

Booster44

booster44:
Hello, everyone,

I've been working on this project for weeks and I'm not getting anywhere.
My individual components are working perfectly. ( rear wheel, servo motor )
My big problem is to calibrate the wheel of balance.
When I run the program and set up the bike, the bike stands up and is also in the middle. The only problem is that the balance wheel starts to rotate too fast (it rotates over 6000 revolutions within a few seconds).
I have already changed all parameters and I can't find the error.
I hope someone with the same problem can help me.

Booster44

Change the bias. The inertia wheel accelerates too fast because you're not targeting the actual center of equilibrium.

If you don't want to manually change the bias every time the mass distribution of the bike changes, you need to find a way for the system to adjust the bias automatically. As I said in my post before yours, in my case the integral over time of the torque command (after the manual switch, so you don't start integrating when the weel is not working) was a good estimate of the bias.

I hope this helps.

Thanks a lot Angelo. :slight_smile:

You've been very helpful.
And I understand where my mistake lies.
Could you send me the parameters you set?

Thanks a lot :slight_smile:
Booster44

So my exact question is, how did you manage to write the integral of the torque command into the preload regulator.

Booster44

Hi booster,

I took the torque command after the manual switch (first attached picture), and gave it in input to a subsystem I called bias generator (second attached picture) in which there is discrete-time integrator.

As you can see, I have enabled a reset connected to a constant block. This block is connected to a push-button outside the subsystem. I use it every time I need to reset the integral.

Then, I directly add the output of the block to the theta angle before it enters the controller subsystem.

I hope this helps.

Hello, Angelo :slightly_smiling_face: ,

Thank you very much !
For sending us the screenshots. The bike keeps its balance better than before.
But not yet permanently. Some value does not fit apparently yet.
I do not know any more.
Can you send me pictures of every single component for comparison ? With this you would help me a lot.

I thank you in advance.
Beautiful and healthy days

Booster44 8) :wink: