Article

How to properly tune a PID

There are hundreds of guides on the Internet on how to adjust a PID and they can all be summarized in the following simple steps:

  • Set KD and KI to zero and increase KP until the system corrects the error and starts oscillating. That would be the maximum KP
  • Increase KD until the KP oscillation stops.
  • Increase KI slightly so that the system fully corrects the error.

They seem like three simple and quick steps, but the reality is that in the end it becomes a sort of trying to guess the constants and after hundreds of tests and hours, if you are lucky, you get a relatively stable PID. It is a rather cumbersome task that rarely achieves a completely satisfactory result.

Let's forget about all that and try to obtain KP and KD mathematically.


PID comparison video

LibreServo v2 Schematics

PCB para test LibreServo LibreServo v2 PCB

I had pending for months to upload the schematics to the web. The schematics are exactly the same with which I made the LibreServo v2 PCBs but with the texts corrected in position so they read better.

In previous posts as you can read in the article of the first LibreServo test board and in the conclusions of the second LibreServo test-board, the LibreServo changes were massive in each and every aspect. Virtually every component was overhauled and moved to a two PCB, four-layer design.

New version of the 3D encoder parts


LibreServo encoder assembly video

To know the position of the servomotor axis, LibreServo uses the AEAT-8800 16-bit encoder. This encoder replaces the potentiometer that the servomotors have and with it we get much more precision and allows the servomotor to rotate 360 degrees.

To achieve this, LibreServo makes use of a tiny 10.2x11.2 mm PCB to which a 3D printed part of the same size and shape as the original potentiometer is attached. This 3D printed part consists of 3 small parts, a 4x7x2mm bearing and a small 6x2.5mm diametrically magnetized magnet. Only a glue point is needed to fix the magnet. The rest of the parts, bearing and PCB are designed to be snap-fitted and fixed.

LibreServo commands (part two)

I have spent a lot of time on the command part of LibreServo and I think it is one of the most important parts of the project, it is how LibreServo is presented to the user. It offers a flexibility and possibilities that I have never seen in any manufacturer.

The documentation of the commands will be divided into two articles, this article is more focused on examples and explanation of execution and the other article is focused on the description of LibreServo commands.

LibreServo has a task manager for the high-priority engine management part and a separate low-priority task manager for sending data to the user only (commands GX). This must be taken into account since the order and timing will be independent between the commands to receive data and the rest of the commands.


[...]

LibreServo commands (part one)

I have spent a lot of time on the command part of LibreServo and I think it is one of the most important parts of the project, it is how LibreServo is presented to the user. It offers a flexibility and possibilities that I have never seen in any manufacturer.

The documentation of the commands I will divide it in two articles, this article is more focused on the description of the commands and the second part is focused on examples and explanation of execution in LibreServo.


[...]

Last steps for first official release


Music with LibreServo

Although I had many parts of the code already done, the truth is that putting all the code together and making all the functions and internal structure non-blocking has been a much more laborious task than expected. In addition, I have programmed dozens of commands and the first version of the LibreServo Software is much more complete than I had originally anticipated.

Updated LibreServo software (version v0.1)

After several months of work, LibreServo has finally reached version 0.1 in the software. What does this mean? It means that LibreServo is still in Beta version, but it is mature enough to present itself in society. This will be only the first of several entries that I will be uploading these days.

I have updated the Github of LibreServo with the latest files and I will try to keep it updated.

In the next few days I will upload the documentation of LibreServo commands, but in case anyone wants to read the code itself, I have made two small diagrams to help understand how LibreServo works.

Motion curves

S-curve graph S-curve graph. Position, acceleration and velocity.

A servo motor is a motor that maintains a given position, but how does it get to that position?

A normal servomotor only receives the final position by PWM and always goes as fast as it can to that point. A smart servo motor, on the other hand, usually receives a command that tells it the end position and how fast it has to reach that position, at which point the smart servo motor starts to calculate the path to the end position. There are several ways to trace the route, those are the motion curves.

LibreServo in Hackaday

LibreServo v2 and Hackaday

Little more to say, it was something I really wanted to do since years ago, but if I don't have time for the project itself and the website, even less to have the project also on another website.

The project is progressing quite well lately and I think it's about time to make it more known in the community. Although it is on hackaday, it will be on LibreServo where all the information will be more up to date and in greater detail.

LibreServo expands to Hackaday