Coupons
Help
  • FAQ
    browse most common questions
  • Live Chat
    talk with our online service
  • Email
    contact your dedicated sales:

DIY Fluid Simulation Pendant (Part 1): Theory and Building the First Pendant

Author : Hackett Wang | PCB Manufacturing Engineering & Technical Content Specialist

November 25, 2026


The result is a handcrafted, gold-plated pendant with a custom-designed circuit board capable of running a real-time fluid simulation. The project combines software development, embedded electronics, PCB design, precision metalworking, electroplating, and mechanical assembly.

Gold-plated pendant with an integrated fluid simulation display

I built a fluid-simulation pendant: a piece of handmade jewelry that runs a real-time FLIP fluid simulation. The enclosure is gold-plated, and the display is protected by a watch crystal.

 

Project Overview

I had wanted to create a real-time fluid simulation for a long time. The eventual goal was to build a three-dimensional virtual snow globe. That project made some progress, but during its development I conceived the Simsim concept, and this pendant was based on it.

The development process produced several other interesting ideas and projects. In that sense, the pendant became their starting point. The project was not only about fluid simulation; it also revealed unexpected advantages of display-driving techniques such as diagonal Charlieplexing.

 

Technical Architecture

The FLIP simulation is based on the work of Matthias Müller, particularly the "How to Write a FLIP Water Simulator" tutorial in the Ten Minute Physics project. Rather than directly porting the example code, I reimplemented the simulation to understand how it worked.

The hardware uses an STM32L432KC microcontroller with an ARM Cortex-M4 core and floating-point unit. The processor is overclocked to 100 MHz. Other major components include an ADXL362 ultra-low-power accelerometer, an MCP73832 charging controller for a LiR2450 battery, a very-low-power TPS7A02 voltage regulator, and a TPS3839 voltage supervisor. All of these components are integrated on a 0.8 mm-thick, four-layer PCB.

The principal technical features are as follows:

  • Compared with a conventional matrix layout, diagonal Charlieplexing reduces the required number of vias by approximately half. Via count is often a limiting factor when routing a fine-pitch LED display, so this change is significant. The arrangement also places LED pins from the same network end to end. As a result, a solder bridge between those pins does not affect operation. This makes it possible to place the LEDs more closely together.
  • DMA circular mode can drive a display matrix with no processor overhead. By coordinating two DMA data streams, the same technique can drive a Charlieplexed matrix with no additional software overhead.
  • A lookup table is required to map each LED to its pixel position, but changing the mapping then costs almost nothing. Any display network can be connected to any microcontroller GPIO pin, provided that the mapping table is updated. This makes PCB routing surprisingly simple, even though the resulting circuit is unconventional.
  • Directly driving a large display with GPIOs can cause insufficient brightness because the on-resistance of the output FETs limits current. In a Charlieplexed display, only one pixel is illuminated at a time. The effect of the output resistance is therefore reduced to uniform dimming across the display. The overall brightness can even be controlled by changing the device supply voltage.
  • The same principle can be applied to a conventional matrix by forcing the display to illuminate only one pixel at a time instead of an entire row. Normally this would increase the display-driving overhead, but DMA can handle the additional switching activity without consuming processor time.

 

Writing the Fluid Simulator

The implementation followed the Ten Minute Physics tutorial, but I deliberately avoided reading the original source code as much as possible. Reimplementing the algorithm independently was a useful way to understand the underlying principles.

In an Eulerian fluid simulation, fluid motion is produced through a process called advection. FLIP uses a different approach: the advection step is omitted, and particle motion is used to transport the fluid.

Some parts of the tutorial did not explain the implementation in detail, particularly particle collision handling. At first, I did not implement a hash grid because development began on a desktop computer and the optimization could be added later. However, even with a simple collision detector, it was necessary to understand what happens when particles collide.

When particles approach one another, they are separated by an impulse that is inversely related to their distance. Simulation stability depends on choosing an appropriate impulse. This is similar to the over-relaxation step used when solving incompressibility, which can correct the result in a surprisingly effective way.

I initially wondered why particle-to-particle collision handling was necessary after incompressibility had already been solved and the velocity field from the Eulerian grid had been fed back into the particles. Without the collision step, however, the entire fluid collapses into a chaotic mass of overlapping particles. The collision calculation is therefore essential rather than redundant.

A hash grid introduces a noticeable cost, both computationally and conceptually. The final code includes a switch between naive collision detection and hash-grid collision detection. Even for a very small simulation measuring only 8 × 8 cells, the difference is obvious. The hash-grid implementation provides a substantial speed improvement.

During development, I produced many strange effects that were not entirely fluid-like. When rendered as particles, most of them looked like different kinds of frog eggs. I saved a collection of unusual screenshots, although I no longer remember exactly what caused some of them, including this ring-shaped structure.

Unusual particle pattern generated by the fluid simulation

The example code in Ten Minute Physics contained a small bug in the boundary condition at the left edge, which prevented the fluid from ever becoming stationary. After correcting the boundary condition, the fluid and particle cluster still did not stop moving completely because there was no viscosity or friction except at the walls.

Nevertheless, the particles condensed into structures that reminded me of crystal lattices. Regularly arranged particle groups often contained dislocations or grain boundaries. This was an early screenshot of the behavior.

Early fluid simulation showing crystal-like particle structures

When the fluid was pushed into a corner, it formed a shape resembling a Triforce.

Fluid particles forming a triangular pattern in a corner

The yellow image shows particle density, meaning the number of overlapping particles in each grid cell. This provided a useful way to create visual effects. If the fluid is concentrated in one corner and the gravity direction is suddenly changed toward another corner, a shock wave forms when the fluid hits the wall.

Particle-density visualization of a fluid impact wave

The effect lasts for only one or two frames, but the circular ripple formed by the dense particles is visually striking. It emerges naturally from the rules of the FLIP algorithm. If the animation is paused at the right moment, the shock wave can be seen directly at the particle locations.

Two competing shock waves propagating through the simulated fluid

Less than two weeks after publishing the Simsim concept, I created the Simsimsim demonstration program. It served as an internal test tool for determining how far LED density could be reduced while preserving the visual impression of fluid motion.

Simsimsim low-resolution LED fluid simulation

The program also provided an approximate estimate of the memory required when the simulation was ported to bare metal. Many problems can be solved by adding lookup tables, but the memory required by those tables grows rapidly as the simulation diameter increases.

The STM32L432KC has 64 KB of RAM, which is not a large amount. A simulation with a diameter of 16 requires only 26 KB, however. Even so, confirming the memory requirements before committing to hardware was essential.

 

Building the First Pendant

Before designing the PCB, I had to convince myself that the Charlieplexed display concept was practical. Many Charlieplexed display routing schemes are available. I found information about an arrangement called twistyplexing, which is optimized for hand-wired circuits.

As the advantages of diagonal routing became more apparent, I decided that a working prototype was necessary before committing to a PCB design.

Building the small display took considerable time. A laser-cut card was used to hold the LEDs, while a souvenir MCH2022 badge supported the entire assembly.

Hand-built LED display used to validate the Charlieplexing concept

The process reminded me of a paper about knots that I once read but have never been able to find again. The Ashley Book of Knots is often described as the "Bible" of knot tying and contains a large number of knots that have been used for centuries. When their topologies were later described using mathematical notation, some of the knots turned out to be equivalent, at least from a topological perspective.

They had been cataloged separately because there was no rigorous language for describing them at the time. Mentally transforming one knot into another is extremely difficult. The same issue applies to circuit routing: humans are often poor at recognizing that two visually different arrangements can have the same underlying connectivity.

Of course, the physical method used to tie a knot can affect its performance, so two topologically equivalent knots may still have different practical applications. However, the broader point remains that human intuition has surprisingly limited ability to reason about structures of this kind.

Hand-wired LED matrix with diagonal interconnections

The 8 × 9 matrix was connected to an L432 development board. The blue wire on the right was connected to the chip's BOOT0 pin. That pin was not otherwise exposed, but it had been needed years earlier while debugging a flash programmer.

The unpleasant experience of hand-soldering the enamel wires convinced me to design a PCB as soon as possible. The plan was to create a general-purpose diagonally routed Charlieplexed LED array so that future projects would not require the same laborious wiring.

Diagonal Charlieplexed LED array connected to an STM32 development board

Despite that plan, a hand-wired prototype remained the fastest way to verify the concept. I successfully ran the FLIP simulation on the L432, first as a small 8 × 8 square and then as the upper-left corner of a hypothetical fluid-simulation pendant.

Thinking about the possible routing patterns for a Charlieplexed display raised another question: how many useful arrangements remain undiscovered simply because nobody has considered them? It is natural to wonder whether a computer algorithm could search for new possibilities.

Conventional autorouters are well known for producing unsatisfactory results. That may change if large neural-network models are eventually applied to routing problems. For automatic routing to become practical, however, the constraints must be described accurately.

Some components must occupy particular locations, and the routing must match the netlist generated by the schematic. In this project, the schematic was not fixed. Because a lookup table was used, it did not matter which display network was ultimately connected to which GPIO pin.

The search space was even broader than that. All LEDs had to remain within the display grid, but it did not matter which LED occupied which position. The lookup table for a conventional Charlieplexed matrix is completely different from the lookup table for a diagonally routed version.

Constraints reduce the search space, and with enough constraints a brute-force solution can become practical. In this case, however, the constraints were unusually broad and far fewer restrictions applied than in a conventional circuit design. It seemed unlikely that an automatic router could produce a better Charlieplexed display in the short term.

There were also deeper "non-constraints." In a later project where space was extremely limited, some traces were routed across unused microcontroller GPIO pads. This violated the implicit rule that different nets should not touch. Setting those pins to high impedance in firmware was simple, but recognizing that possibility expanded the search space even further.

 

Traditional and Diagonal Charlieplexing Layouts

A conventional Charlieplexed matrix follows the arrangement shown below.

Traditional Charlieplexed LED matrix routing pattern

Labels on both sides make the arrangement easier to understand, although only one side is strictly necessary because the connections can be routed diagonally. In this arrangement, each LED requires at least one via.

A diagonal arrangement compressed into an approximately circular shape looks like this.

Diagonally routed Charlieplexed LED display layout

With 16 GPIO pins, up to 240 LEDs can be driven. The display required 216 LEDs, but one edge had to be assembled around the missing corners. I initially handled this somewhat casually by deleting unused LEDs and moving the nearest ones into the empty positions.

This created several LEDs that did not match the original pattern. It later caused trouble because a solder bridge on that edge became significant. With more careful planning, the entire display could probably have been given end-to-end connections, making it immune to this type of soldering error.

The display was intended to be circular, but it ended up as an octagon. In the Simsimsim program, LED positions were generated according to their distance from the center. At a diameter of 16, rounding down or rounding toward the center can produce an octagonal outline. I considered removing some corner LEDs to make the display more circular, but eventually decided not to.

Overall, the first pendant PCB was easier to design than expected. The GPIOs did not need to source large currents, so the back of the board did not require extensive routing. The reduced via count also simplified the layout, and there was enough space to move the remaining vias as needed.

First pendant PCB layout with a rounded outline

Rounding the internal PCB corners was handled with a plug-in.

I panelized the boards manually because I needed a way to hold them in the pick and place machine. A PCB manufacturer can create the panel, but the resulting layout must then be accepted, and the component-position file must be adjusted accordingly.

I created the mouse-bite tabs manually by placing two drill holes at each boundary and drawing a ring of solder mask to mark the PCB edge. The milling cutters commonly used to separate these boards have a diameter of approximately 2 mm. Most internal edges are easy to round, but the mouse-bite areas must meet another curved outline.

Creating the quarter-circle arcs between the mouse-bite tabs in KiCad was particularly tedious. In retrospect, drawing them in another application and importing a DXF file may have been more efficient.

In KiCad, I first placed the circular outline of the board and then intersected it with the panel support arms. After zooming in extensively, I adjusted the ends of the intersecting lines so they met the circle precisely and used them as the start and end points for the arcs.

A bent metal wire was used to retain the battery and provide a point for attaching the chain. It worked mechanically, but the solution was crude. The search term for a PCB-mounted gold-plated spring contact is "RFI shield finger."

PCB-mounted spring contact used to retain the battery

I later upgraded the contact to a larger model with longer travel, although I did not update the 3D model.

There was sufficient space around the LiR2450 coin cell. The original design was smaller, but I enlarged it while searching for a magnetic charging connector.

In 2023, many inexpensive smart rings appeared on the market. Some used 4 mm magnetic charging connectors. I originally ordered them to remove the curved batteries inside, because those batteries were not available in small quantities. However, a magnetic charging connector was also attractive for the pendant if a suitable part could be found.

Searching for "4 mm magnetic charging connector" produced many parts that extended much farther into the enclosure than acceptable. They were clearly designed as through-hole components, even though the total thickness of a smart ring may be only 3 mm.

Low-profile 4 mm magnetic charging connector

By the time this project was documented, the selection of available connectors had increased substantially. The 4 mm part that had been difficult to find was now appearing on the first page of search results, possibly because it was simply a new product that had not yet been indexed. The part number was WNRE CX-4MM-JZ.

Magnetic charging connector for the pendant

Different 4 mm connectors are not necessarily compatible with one another. Even when their electrical and magnetic polarities are the same, a cable designed for one connector may not attach securely to another. A possible explanation is that the larger connector has a stronger magnetic field while the cable uses a weaker magnet, reducing the chance that the cable will attach to nearby metal objects and cause a short circuit.

 

Machining the Metal Enclosure

The video shows the overall process, which mainly involved drilling brass and machining several recesses. A press-fit rear cover was much faster to produce than a fine threaded cover.

I did not have precise reference dimensions for the press-fit cover. Instead, I made an informed estimate. The first press-fit cover did engage, but it was slightly loose and could not remain secure under tension. Adding an O-ring eliminated the looseness and also provided a water-resistant seal. The O-ring allowed considerably looser machining tolerances.

Recording the machining process was challenging because this Hardinge lathe was smaller than the large Colchester lathe I normally use. My magnetic tripod was too large, and the headstock did not have a flat surface where it could be mounted.

Several magic arms solved the mounting problem.

Camera mounted near the lathe during enclosure machining

The camera position was inconvenient and made the process take longer. Ideally, a large support would have held it securely, but vibration from the lathe motor caused the footage to shake unless the camera was supported from multiple directions. A better recording method would be useful for future work on this lathe.

Halfway through the metalworking, I decided to make a second pendant with a watch crystal covering the display. Watch crystals are available in many diameters and thicknesses, with either flat or curved profiles. However, I could not find reliable information about their dimensional tolerances or the corresponding dimensions of the metal part that holds them.

I made a small test piece for a 27.5 mm-diameter crystal. There should presumably be documentation describing how to machine a watch case for a particular crystal, but the information I found focused mainly on replacing crystals during watch repair.

A gasket sits between the glass and the metal. With a gasket thickness of 0.45 mm, the total diameter of the retaining recess would be 28.4 mm.

Test piece for the 27.5 mm watch crystal

The crystal pressed into place perfectly, with just the right amount of force. The selected diameter appeared to be correct. The glass broke later, after I became overconfident about pressing crystals into place without specialized tools. Testing the limits of a process can be useful for calibrating judgment.

Flat watch crystals are inexpensive, so I continued machining the second enclosure. Cutting the 28.4 mm front recess would normally be inconvenient after the part had been separated and had to be re-chucked. Soft collets solved this problem. Soft collets can be machined to fit the workpiece, but several collets already available happened to match the 28 mm internal diameter.

Machining the crystal recess with a miniature carbide boring bar

The miniature carbide boring bars were particularly useful.

The milling itself was straightforward, although I had initially been too cautious. The same operation was completed much faster on later pendants. A plastic mandrel in the square collet block worked well and could be reused for subsequent enclosures.

Machined recess for the press-fit rear cover

The finished recess was visually pleasing. The O-ring added contour to the press-fit rear cover and became a design feature rather than something to hide. Concealing it would have required tighter tolerances and would also have made the enclosure more difficult to open because there would have been no room to insert a case knife.

The attachment ring was soldered with hard brass solder. Jewelry makers use several solder grades. Even so-called soft jewelry solder is harder than ordinary electronics solder. The usual approach is to use the hardest, highest-melting-point solder for the first joint and progressively softer solder for later joints, preventing earlier joints from remelting.

I suspected that both joints could be made with the hardest solder, but for all the pendants I used soft solder on the second joint. This was electronics solder, and I intentionally chose lead-free solder after receiving negative comments on an earlier project. The choice was somewhat ironic because the brass alloy itself contains a significant amount of lead.

Soldered brass pendant enclosure and attachment ring

I later discovered that this lead-free solder was incompatible with gold plating and would not adhere properly to the surface. The result did not look especially bad, but silver-bearing lead solder had previously accepted the plating without difficulty.

For the first few pendants, I kept the solder fillets as small as possible. Later, I became concerned that a gap could compromise the overall seal, so the solder fillets were made more prominent.

Gold-plated brass enclosure after soldering

I gold-plated the parts using a brush-plating process. The surface preparation on the first two pendants was poor, and the plating emphasized the machining marks. I was rushing because the PCBs were due to arrive shortly.

Brown spots sometimes appeared during plating, although I was not certain what caused them.

Brown spots visible on the plated brass surface

A planned step after plating was polishing the parts with a very fine abrasive, commonly known by jewelers as rouge. This removed the marks and produced a polished surface, or at least it would have produced one if the underlying machining marks had not been so prominent.

Polished gold-plated pendant enclosure

 

PCB Assembly and Debugging

The metalworking was completed somewhat hastily, but the PCBs had arrived. This was the first board directly after surface-mount assembly.

First assembled pendant PCB after reflow

There were more solder bridges than expected. I had used a different grade of solder paste for PCB as an experiment, and smaller stencil apertures would probably have produced a better result.

The 0402 LEDs were extremely small, making it difficult to remove bridges between them. As noted earlier, most of the bridges did not affect operation because the end-to-end LEDs generally belonged to the same network. The few LEDs relocated along the edge were exceptions. Even though most bridges were electrically harmless, they were visually undesirable and had to be removed.

One design oversight was that I forgot to expose the microcontroller reset pin. The display occupied the entire GPIOA port, while the SWDIO and SWCLK debug signals were also located on that port. This was not a problem during normal operation because those pins could be disabled in software. During development, however, it prevented new firmware from being programmed into the board.

The workaround was to reset the chip immediately before programming, but this required adding a bodge wire.

Bodge wire added to expose the microcontroller reset function

The first PCB became the development board. At that stage, I had still not found the desired magnetic charging connector, but an older connector confirmed that the charging circuit worked. A 3D-printed coin-cell holder also allowed the development board to be powered from a battery.

Development board powered by a coin cell

A bus keeper on the accelerometer interrupt line caused several display faults. Soldering a resistor directly onto the trace improved the situation.

Wire-mounted resistor used to correct the accelerometer interrupt fault

I eventually added a diode, which solved the problem completely. Before that, I had replaced the resistor with an LED. This had the additional benefit of making signal changes visible when the board was gently moved.

I also applied several other bodge-wire corrections, mainly to prevent the circuit from being pushed into a soft-lock state. Battery undervoltage detection was implemented in software, which simplified the circuit, but it made me sufficiently uncomfortable that the next PCB implemented the function in hardware.

The simple enclosure had no buttons and no convenient way to open it. I wanted a method to reset the chip when necessary, so I built a circuit that monitored the charging connector.

Reset circuit triggered by activity on the charging connector

Some data sheets and development boards recommend placing a 100 nF capacitor on the STM32 reset line. I was not certain that it was necessary, but I preferred having a predictable and reasonable capacitance at the pin rather than relying on a small, unknown parasitic capacitance.

A pulse generated when the charger was connected passed through a small capacitor into the base of an NPN transistor. The transistor amplified the current and pulled the reset line low. The final version also included the recommended 100 nF capacitor on the reset line and a pull-down resistor on the transistor side of the signal capacitor, maximizing the pulse voltage when the charger was connected.

The charging connector could easily be shorted while it was approaching the mating contact. In that situation, the resettable fuse became hot and reduced the output voltage. Although charging began again when the voltage recovered, the slowly rising supply was not sufficient to trigger the reset circuit.

This was acceptable because a reset could be initiated by attaching the magnetic end of the cable first and then connecting the USB plug. In the redesigned PCB, hardware undervoltage detection also meant that the reset circuit was no longer essential. It was mainly included as a precaution.

The magnetic connector was secured with epoxy, and epoxy was also used to fill the small opening for the charging LED. Under a microscope, a tiny resin meniscus was visible around the opening.

Epoxy-secured magnetic charging connector

The PCB was soldered directly to the enclosure to provide mechanical stability and an electrical connection to the battery ground.

PCB soldered directly to the metal pendant enclosure

After several assembly and disassembly cycles, the foam spacer was adjusted, the spring contact was replaced with a taller one, the overall display brightness was reduced, and various other display faults were corrected.

Pendant assembly after mechanical and display adjustments

 

Shake-to-Wake Operation

Once the rear cover was closed, nothing except the charging connector was accessible. That was somewhat intimidating because the accelerometer was the device's only user input.

The original plan was to activate a deep-sleep mode by rotating the pendant at the end of its chain. This motion is easier to detect than most gestures: the firmware only needs to determine whether the Y-axis value exceeds a threshold for a certain period.

Using the same movement to wake the pendant would have been elegant, but it would require more complicated wake-up logic. The device would first have to wake, check the condition, and then return to sleep if the condition was not satisfied.

A simpler solution was to increase the threshold for the accelerometer's motion-detection interrupt. Setting the threshold to 6 g made accidental wake-ups unlikely, while a gentle shake was still sufficient to reactivate the device.

This shake-to-wake method worked well because it consumed no more power than normal sleep operation.

Finished fluid simulation pendant

The final result worked reasonably well, but there was still room for improvement.

Hackett Wang | PCB Manufacturing Engineering & Technical Content Specialist Hackett Wang | PCB Manufacturing Engineering & Technical Content Specialist

Hackett Wang is a PCB industry professional at AIVON with experience in customer support, pre-production engineering review, customer quality, and technical content. He focuses on the point where design files meet factory process and writes from real order issues rather than textbook rules. At AIVON, he reviews and develops content on manufacturability and production practice, helping engineers prepare files so a design can enter production with fewer delays.

Related Tags


2026 AIVON.COM All Rights Reserved
Intellectual Property Rights | Terms of Service | Privacy Policy | Refund Policy