Desktop Furuta Pendulum

May 20, 2022

Building another pendulum

Decided to build another one, they're the perfect office toy. Did very minor CAD changes, like making the tower slightly longer, and the wall on the translucent pieces slightly thinner so they would be more transparent.

October 27, 2021

Missy likes balancing robots

February 25, 2021

The swing-up controller

After having implemented the up-right controller I searched into swing-up controllers. I found an old Ben Katz blog post where he built his own furuta pendulum and he was nice enough to share his controller. I really suggest to read this blog entry if you're interested behind the math of the up-right controller and the swing-up controller, and/ or enjoy control theory. I decided to give Ben's swing-up controller a try, it is basically a energy shaping controller that applies torque when it adds energy to the pendulum, or alternatively, with a negative sign, removes energy to the pendulum (swing-down controller). The control law is as follows:

u = K5* cos^4(pendulum position) * pendulum speed *(9.81*(1-cos(pendulum position))-0.0075*(pendulum velocity)^2)

 To transition between the up-right controller and the swing-up controller I set an angular position threshold, if the pendulum is inside +- 0.5 radians it will use the up-right controller, otherwise it uses the swing-up controller to swing back up. I found that this transition wasn't as robust as I wanted because sometimes when the up-right controller kicked in it couldn't "catch" the pendulum and balance it. Through trial and error I found that saturating the up-right controller (setting very big gain values) did a better job at "catching" the pendulum, but made the motor vibrate very harshly when balancing the pendulum. With this new knowledge, I implemented an extra controller for the "catching"; if the pendulum comes from a swing-up and is inside the angular position threshold the catching controller kicks in and if the pendulum stays inside a smaller angular position threshold (0.2 radians) for more than 200 milliseconds the regular up-right controller kicks in. This resulted in a very robust transition between swing-up and up-right controllers, having a very high success rate of catching the pendulum.

Furthermore, in the very rare case the motor drifts too far off the 0 position, and as a security measure to protect the encoder cable, I implemented a very basic P controller that overrides the swing-up and up-right controllers when the motor spins more that 23.5 radians in either direction, and brings the motor back to 0.

February 24, 2021

The space-state controller

One cool advantage of using a Janus Controller (or a Dagor Controller) is the possibility of building one-board projects. I connected the Quadrature Encoder directly to the two open GPIOs of the Janus controller (not forgetting to add the pull-up resistors) and put the control method of the brushless motor to voltage mode. Voltage mode allows to spin the brushless motor in terms of voltage, it doesn't not use any type of controller which would just make the system more complicated and harder to tune. I implemented a very simple controller for the balance of the pendulum, with the following control law: 

u = K1 * pendulum position + K2 * pendulum speed  + K3 * motor speed 

Where u is the voltage applied to the brushless motor. To calculate the speed of the pendulum and the motor I take their present position and subtract their past position and divide it by the sample time. This approach generally gives a noisy signal, which is why I pass both signals through a software low-pass filter; other approaches, such as a moving average, can be also used to smoothen the signal. The pendulum upright is considered 0 degrees, which is implicitly the controller's set-point. 

It wasn't terribly hard to hand-tune the parameters of the controller, and after a few minutes changing the gains and the amount of filtering, the pendulum started to balance. However, one problem was suddenly apparent, given that I did not use a slip-ring the encoder cable started to choke when the motor spun one too many times in the same direction. I considered buying a slip ring to avoid this problem, but I soon realized I could just add a fourth term to my control law. This fourth term is the motor position (considering a 0 set-point), which makes the pendulum to want to gravitate near the 0 motor position and never drift too far off, thus avoiding the choking of the encoder cable. The new control law looks like this:  

u = K1 * pendulum position + K2 * pendulum speed  + K3 * motor speed + K4 * motor position

I can tune how strong I want this gravitational effect to be by tuning the constant K4. It's important to notice that too big of a value for K4 the balancing can be negatively affected. I looked for a value that would warranty that I never spin more than 3/4ths of a turn in either direction.

February 22, 2021

New control balance project

Ever since I built the Ball and Wheel balance system for my Digital Control Class I wanted to try another control balance project. I decided with the furuta pendulum because it doesn't require a lot of different components and should be fairly simple to design and control; plus, I've always wanted to build a small one as a desktop demonstration toy. 

It's very nice to work with such systems with brushless motors and I still had one Janus Controller left-over from its development, so I figured this would be a good purpose for it, instead of using a new Dagor Controller. I gathered everything that I needed: Janus Controller, small out-runner brushless motor, quadrature encoder, 4mm steel rod and a few screws, and started the design in SolidWorks.

I don't have much experience with 3D printed gears, but decided to do a simple 2.5:1 reduction stage for two main reasons. The first reason is to make the shaft of the drive gear hallow for the cable of the encoder to fit through, it would be best to use a slip ring in such a project, but I didn't have one and I wanted to stick with materials I already had (leftovers from other projects). The second reason is to smooth out a little bit the cogging torque the brushless motor has, this motor is a 700KV 4234 drone motor with only 7 pole pairs. Cogging torque is the torque needed to oppose the torque that is generated due to the interaction between the permanent magnets on the motor's rotor and iron teeth of the stator, it somewhat feels like steps when turning the rotor, like in a stepper motor, but bigger more defined steps.