Let's Make Robots! | RobotShop

Two Wheeled Inverted Pendulum fuzzy controller

self balance

I controlled my balance robot using a a two fuzzy logic controller 1-one for (IMU feedback) using as input the angle and change in angle , the output is a PWM1 . 2-second for (encoder feedback) use a wheels velocity as input and the output is a PWM2 . PWM=PWM1+PWM2 (motor Control)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Please provide more details. I am currently trying to program a self balancer but having difficulties getting the feedback loop tuned.

it is so hard to tuning a mebershipe function parameters , but you have to try and try until you get it right 

look :

Based to eFLL (Embedded Fuzzy Logic Library) ,for Arduino we created a two Fuzzy controller one for pendulum tilt and second for wheels velocity, the total of their output gives the control signal to stabilize a TWIP as showing in figure 

first controller (IMU feedback)


the system has two inputs (angle and angle change) and one output (PWM). Each one from input used five fuzzy sets (VN: Very Negative; N: Negative; Zero; P: Positive; and VP: Very Positive) as shown in figure 5 for Angle and figure 6 for change of angle



The output PWM had five sets (VN: Very Negative; N: Negative; Z: Zero; P: Positive; VP: Very Positive) as shown in Figure 8.


      The fuzzy set limits were later adjusted for practical implementation as will de described later. The fuzzy rules are summarized in Table 1.


a)       Second Fuzzy controller  (Wheels Velocity controller)


the system has one inputs (Wheel Speed) and one output (PWM). input used three fuzzy sets (N: Negative; Zero; P: Positive)




what do you mean about the change of angle ? and thanks

I made a same thing by using LQG ,but my robot dosn't seem a stable ???


I know that my problem come from "stats estimator" "LQE" and my state space modulation.


anyone can help, I will be happy for that.



LQG uses the Kalman filter. I have observed (no scientific backing) that angles presented to the Kalman filter, that I got from Arduino code on the web, take about 8 state changes to propagate thru the filter. I was taking samples every 10msec but found the PWM to bring it vertical was still being applied after the robot had passed thru the vertical orientation. Not a good explanation but the motor was assisting in the falling motion.

Changed the sample period to 2 msec and things got a little better. Also played with the filter parameters to get a faster response. Faster also means less stability.


what do you mean change of angle ?