Skip to content

Instantly share code, notes, and snippets.

@yaqwsx
Last active February 13, 2022 10:08
Show Gist options
  • Save yaqwsx/82618d9f37e1e09bece4f6eaa27d02d6 to your computer and use it in GitHub Desktop.
Save yaqwsx/82618d9f37e1e09bece4f6eaa27d02d6 to your computer and use it in GitHub Desktop.

This is a draft of an algorithm for determining the minimal rest time required for the build plate to settle. The procedure is not the simples one, but it reflects the underlying physics, therefore, it has a potential to yield low rest time that still ensure that the build plate is static.

Escape resistance of a voxel

When we try to print a layer, the already printed parts of the model create resistance when we move the build plate down. The resistance is given by the viscosity of the liquid we try to push away. The force is not directly proportional to the occupied area, but it also depends on a shape. Consider a 30% coverage with a solid circle and a 30% coverage with 100 small circles. The first case gives much more resistance as the resin in the middle of the circle has get to the outside. However, in the second case, the resin can get out pretty easily as it has to travel only a short path. This is something we want to reflect in our model. We also have to consider the fact that the whole thing is 3D and resin still flows badly in a thin channels (couple of layers), and also, that when we have a suction cup, the resin has nowhere to go. However, if there are vent holes, it is no longer a problem.

Therefore, we define a number, escape resistance of a voxel. It tells us, how hard is to get for the resin from below this voxel into a free spot where it no longer causes resistance. The number is an integer and it is equal to the weighted length of the shortest path from the voxel to the first voxel that has resistance 0. Note that we consider all 4 neighboring voxels in 2D and the the voxels directly below. The weight of the each step S_w in 2D is:

S_w = max(0, C - empty_voxels_below),

where C is the critical cannel height. Basically we say that if there are more than C free layers, we no longer consider it as having an effect on the resin flow.

We can then define a resistance of a layer as a sum of individual pixels resistance. We use this number later to determine how much we need to wait for the build plate to settle.

Determining rest time using the layer resistance.

There exists a maximal resistance, R_max. This is the resistance of a full build plate (proof omitted). Let's say that the user measure how long does it take for the build plate to settle in position for the initial layer. This is the largest rest time T_max.

When we have a layer resistance, we determine next layer resistance as:

T = max(T_Max * sqrt( R / R_max ), T_min)

We use the sqrt function to introduce a non-linearity and make the function less sensitive when the coverage is large, but in principle we could use any function. Just based on empirical observation, sqrt seems like a good candidate. We also bind the minimal value of the function to T_min.

Algorithm for computing voxel resistance

There are two approaches for computing the voxel resistance; Bellman-Ford based one and Dijkstra based one. Dijkstra-based on takes the least steps but is cannot be reasonably parallelized, and also, has probably poor cache coherence.

Just for a reminder, we will use voxel relaxation. Relaxing a voxel means that we look at each of it's neighbors and determine if we can lower resistance of the voxel by taking path from one of its neighbors.

Dijkstra-based approach

Assume all voxels have infinite resistance. Fill all border voxels with their corresponding resistance (that can be computed trivially). First, there will be some voxels that have resistance 0. We can flood fill this. Now, take all the voxels that have resistance 0 and relax all the neighbors, then repeat for resistance 1, 2, 3... Once we visited all voxels, the algorithm terminate.

The correctness of this approach follows from the the monoticity of the resistance. If we relaxed voxel at iteration i its resistance can never be less or equal to i. The only exception to this are voxels with resistance 0, but we handle those separately.

Bellman-Ford-based approach

We simply leverage the fact that we know the length of the longest path in 2D - it will be half of the image width (w) + half of the image height (h). Therefore, we can ((w + h) / 2 + 1)-times relax all voxels. All voxels have the correct resistance at that point. If there was a voxel that has incorrect resistance, that means it can be relaxed once more. However, that is a contraction with the fact that the longest path has length (w + h) / 2.

User input

There are the following parameters the user has to set. They are based on the printer and the resin:

  • T_max - the worst-case rest time
  • T_min - the minimal wait time
  • C - critical channel height from which we consider the channel as no-longer limiting the flow. Basically the number of initial debanded layers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment