Closing the hole after cutting a triangular mesh

Once a triangular mesh is cut by an intersecting plane, the resulting halves are no longer a water-tight mesh, because some holes are created by the cutting action of the plane.

In the image here, the volume of a [solid] hat was cut by a vertical plane, splitting it in two. In order for this half to be back a 2-manifold triangular mesh, all the triangles with black edges have been added to create a flat surface that covers what the cut plane would otherwise reveal (the inside of the hat).

The problem is how given a certain polygon, like the red polygonal line here, a collection of triangles can be created to cover entirely all the area delimited by such a perimeter (aka polygon triangulation).

The problem gets even more interesting once we consider that some meshes can present holes inside these perimeters obtained after cutting the mesh with a plane.

Fortunately, there are different algorithms to solve that problem, and I will settle with the so-called Ear clipping. Fortunately, the…

Cutting a triangular mesh and keeping the pieces

When we use a plane to cut a triangular mesh, several cases can be considered. If there is a non-null intersection between the plane and a given triangle, there are mostly five different cases:

The plane contains one vertex of the triangle: not very useful for cutting purposes if the rest of the triangle lays above the cutting plane and we want to keep all that is below.The plane contains two vertices of the triangle, then the intersection is a line segment but we will only keep that triangle if the other vertex is below the cutting plane.The plane contains three vertices of the triangle: that is a keeper.The plane does not contain any vertices of the triangle, but there is an intersection with two of the edges: this is what we will talk about today here.A fifth case can be considered when the plane contains one vertex but the two other are on opposite sides of the plane, and it can easily be incorporated to the previous case. The following picture shows us a couple of triangles of a m…

Enterprise WPA and ESP32

I recently gave Adafruit's IO service a try. You can get a few data sensor feeds recorded and graphed on the web. They have a somehow limited version for free and a more complete offering for paying customers.

A current project required to record a few sensor samples per minute and Adafruit's free service seemed to fit the bill. I was using ESP32 with BME280 sensor to gather humidity, temperature, and atmospheric pressure and to store it somewhere in the cloud.

I was testing this on campus, where we have a corporate wifi network that uses a Radius server for PEAP authentication. I assumed ESP32 could only use WPA with a pre-shared key but I was wrong. I googled around and found that some people were using it with Eduroam. Eduroam is a European-wide Academic wifi network and it is present in our campus too, so what harm was in trying?

I found this code that might work so I tried it out, and it did work at the first try! Brilliant!

But there were a couple of details that did not…

Improving dcservo accuracy

Not being an expert in motor control, I created dcservo project to make a basic platform to create cheap servomotors that could replace stepper motors on certain systems, like 3D printers. I chose to implement a full PID controller but that might have been a bit overkill.

I was talking today to a more knowledgeable colleague who asked me why I needed a PID. My answer was that without the integral action I was getting a significant position error in the steady state, and the derivative action, though a really small value, was needed to keep the system from overshooting. However, he suggested me to focus only on a simpler, proportional controller with a twist: most of my position error is coming from the fact that there is a dead zone where motor does not respond to control action.

It is true, though the motor will move faster the higher the PWM value it is applied to the motor drive, it is also true that low values (between 1 and 50 in my test system) do not cause the motor to move.

I …

Marlin's Bézier vs sinusoidal speed profile

Bugfix-1.1 branch of Marlin firmware does include a fifth-degree (quintic) Bézier polynomial for the speed profile. If you want to use it enable S_CURVE_ACCELERATION define. You can have a look at the source code, luckily well commented so we can understand where it is coming from.

I was curious to check how different that curve was from the sinusoidal speed profile I mentioned in a previous entry. Although the source code comments are very thorough on how they reach their expression, in layman's terms is something the speed along a move is

s(t)= (6*t5-15*t4+10*t3)*|v1-v0|+v0
where v1 is the final speed, v0 is the initial speed and t varies from 0 to 1 to trace the motion.

I was surprised on how it looked quite similar to the sinusoidal case, so I went on and did a comparison with the sinusoidal s-curve:

And the result is that there is not much of a difference so I don't expect much different behavior when using one or the other. 

Too much pressure

A local company built a ram extruder for us. Not very different from a syringe extruder but massive in terms of size and pressure.

Our assumption was that parts had been sized properly, so we did not question the 8.7Nm NEMA34 stepper, nor the 5mm-thick acrylic tube with a 60mm internal diameter. After all, it was not the first time they have built a similar contraption to be used with clay.

Unfortunately, though we try to be very gentle on the extrusion test, we manage to break the tube in a few minutes. Luckily for us, it cracked without sending debris around. We did not expect that at all and when we contacted the seller all sorts of questions were asked, questions we did not have an answer for, like "what was the operating pressure?". I did not have a clue as I was just trying to get the stepper rotating very slowly. Their diagnose was we did it wrong as we set the nominal current (6A) for the stepper driver.

From torque to pressure So I was determined to figure out how …

One table to run them all

In previous entries, I have delved into the idea of using different shapes for the speed pattern for a motion using steppers and have presented how the timing can be based on a look-up table. Such a table would be pre-calculated and flashed with the firmware. But a single table provides a pattern for a given max speed, acceleration, number of steps and speed shape.

You can use that for timing the steps of the motor and it will accelerate properly as many steps as entries on your table. But it won't be practical if we want to change any of these parameters for other movements.
The idea I am not yet sure this works as expected, but first tests look ok, finally, as it took me a while to figure this out.
I have created a lookup table as the graph above, where each entry contains the delay needed for each step, for a movement of 1000 steps total, where speed will increase to 2Π while time goes till 2Π too. Maximum speed for each different motion pattern will be different though, but th…