Testing the precision of Elegoo Mars – Volume 2: XY plane

As I mentioned in the previous post I am for printing precise mechanical components with Elegoo Mars. I have already tested the dimensional accuracy in the Z-axis direction. If I omit the precision problem near the build platform, it is sufficient enough.

The dimensional precision of the printed components in the XY direction is affected by the following constraints:

  • the display itself. Here I assume it is precise enough. If not, I could tweak display size in the slicer.
  • Exposure and “overgrowth”. If you cure the resin for a long period of time, some of the UV light gets reflected from the resin itself and therefore it exposes the resin around the exposed area. This leads to a bigger outer and smaller inner dimension. There are two ways to compensate for it – you can lower the exposition time or you can compensate in the slicer.
  • Linear shrinkage of the resin. Like all resins (epoxy, polyurethane, etc.) even the UV curable resin change their dimensions (usually shrink) during curing. Usually, the manufacturer provides information about shrinkage in the datasheet or you can try to measure it and compensate for it.

I have a rule – in the CAD I design the components as they should be in reality. I do not want to put any compensation in my CAD models. I want the manufacturing process to take care of them: e.g. the slicer does it itself or I have a script to post-process my CAD models. Luckily, ChiTuBox can compensate for all the sources above.

To compensate for LCD size, you can directly change its parameters in the default setting dialogue of the print. See image below. However, I think there is no need to do that.

To compensate for the overgrowth, you can only tune the exposure time in the ChiTuBox menu. However, this has a problem that incompletely cured layers, which don’t overgrow are in some cases not strong enough to support the print. Fox example with Elegoo Gray, exposure time of 4 seconds leads to quite precise components. However, if there are massive planes, the risk of breaking the prints are quite high.

Luckily, if you export the profile and open it in a text editor, you find out it is just a plain text file with key-value pairs. There are two interesting keys: edgeCompensationPixel and edgeCompensationTimePercent. I expect the first one to shrink the sliced by the given number of pixels using the traditional erode operation on images. It can be used to compensate for the overgrowth. The second one seems to scale the entire slice – which can be used to compensate for resin shrinkage. You just edit the values and import the profile back. A little inconvenient, but better than nothing.

To find the right values I modeled a simple test piece (Fusion 360 model):

These pieces should form a press-fit – they should go inside each other but the joint should hold and it should require some force to put them together.

Then I printed them twice for every setting – one set aligned to X and Y axes, one set tilted by 30 degrees in the Z-direction. The tilted set should verify how the joint behaves when it is not a nice straight line but is formed out of pixels. The printing was time-consuming as you have to print for each setting separately – I haven’t hacked the printer and process to support multi-exposure prints.

My results for Elegoo Gray are 5.5 seconds exposure time and edgeCompensationPixel is 2. I did not compensate for shrinkage as it is probably insignificant for the size of my prints. This gives me nice results really close to expected size and expected fits:

The only downside right now is that ChiTuBox does not support separate compensation for the first layers which are over-exposed to stick well to the build platform. Hope it will be available in the future along with the option to specify compensation parameters in the GUI.

Testing the precision of Elegoo Mars – Volume 1: Z-axis

I have recently bought a new SLA printer – Elegoo Mars. For 250 € it is a wonderful device (I have to admit there are some minor flaws, but for the price).

I am interested in making precise mechanical components with it. Small teaser – you can make herringbone gears with module M0.5 or even M0.3. Wonderful. However, during my experiments, I have found a strange behavior regarding the height of the components. It seems like the first 5 layers have a wrong height. Therefore, I prepared a test piece and performed some measurements.

The test piece is simple – it is a staircase with steps of 0.2 mm in the Z-axis and 1 mm in the horizontal plane. Then I printed the piece several times and measured the height of the steps.

Numbers 1, 2 and 4 were printed directly on the bed. Piece number 4 was printed on supports (3 mm height). See, that pieces 1, 2 and 4 seem to have a thin beginning. My measurements confirm that (direct link to the table):

As you can see the printer is quite precise, however, there seems to be something wrong with the first 1 mm of the Z-axis – once I lift the model on the supports, the problem disappears. Note that I sanded the bottom of the lifted model, as the overhangs are always a little bit convex. I examined the sliced files with Photon File Validator and they seem fine. Therefore there has to be something wrong in the printer – either buggy firmware or hardware error.

I haven’t found the cause of the problem yet – do you have any ideas what could it cause? Does your printer feature the same behavior? Test it and let me know. Here is the Fusion model: https://a360.co/2NlHemW.

DIY Through Hole Plating of PCBs

PCBs in China are dirt cheap. There’s no doubt about that. However, sometimes I’d like to have PCB right away and I also like to challenge myself in mastering technologies. That’s probably why I occasionally experiment with a DIY fabrication of PCBs. I have a nice workflow, where I can make 6/6 mil double-sided PCBs under 45 minutes of time and roughly 15 minutes of work. There’s however one limitation – my vias are soldered through-hole wires.

I’ve been thinking about though hole plating for several years. The general procedure is simple – you have to activate non-copper surfaces (make them conductive) and then you apply standard electroplating procedure. You can find many tutorials on the internet, however, most of the require hard-to-get chemicals for the activation solution. Few weeks ago, I noticed that the local electronic component supplier had started to sell Kontakt Chemie Graphit – a conductive paint. It’s basically a colloidal graphite in an organic solution. It is supposed to be used for making surfaces conductive to prevent static electricity discharges. This could be perfect for activation of the non-copper surfaces! So I gathered all the necesery chemicals and equipment and made a test run.


Continue reading “DIY Through Hole Plating of PCBs”

Testing the WiFi range of ESP32

I have a project, which requires long distance (approximately 1 km) communication, in my mind. Recently I got super excited about ESP32, so I thought why not to use it. After all, CNLorh has shown us that ESP8266 has a surprising range – over a kilometer.

I wrote a simple program for two ESP32s using PlatformIO and the Arduino framework (as working with wifi in ESP-IDF is kinda hell). Here you can find code for the master device, and here for the slave. Basically, Master setups AP, slave connects and the master sends UDP packets. If the slave receives a packet, it toggles an LED. That’s it.

The MH-ET LIVE module

The MH-ET LIVE module

The first test was unsuccessful. I took two MH-ET LIVE D1 modules and went outside. When I went around a corner of 4 storey building, the connection was lost. Sight-to-sight I was able to communicate on 150 meters.

Then I found out ESP32 supports the WiFi LR protocol. By using this protocol it should be possible to sacrifice communication speed and gain increased the range. This protocol can be easily enabled by calling the following function after the WiFi peripheral has started:

esp_wifi_set_protocol( WIFI_IF_AP, WIFI_PROTOCOL_LR )
esp_wifi_set_protocol( WIFI_IF_STA, WIFI_PROTOCOL_LR )

I did a second test. I could walk around the building and the communication was perfect. I didn’t observe a single glitch. Sight to sight I was able to communicate up to 200 meter. If I put the master roughly 2 meters above the ground, I could get 240 meters. Improvement, but not significant. However the reliability of the connection drastically improved with the LR procol. The connection was much better, however it was still rather a disappointment.

As a last resort I tried different hardware – I tried to cut PCB under antenna on the MH_ET LIVE D1 modules and I also tried to use the original ESP32 DevKit-C modules. I got roughly the same results. No improvement.

The MH-ET LIVE module after modification

The MH-ET LIVE module after modification

The last thing left to do was to make the same test with an access points instead one of the ESP32s. I used TP-LINK TL-WR741n. Guess what – no improvement. I got exactly the same results.

To conclude – even ESP32 is a great chip, I am not going to use it for long-range communication. I am aware, that my experiment does not feature controlled environment and a fancy setup. However, this is all I got time for. Have you done some range tests on your own? What are you results? Please, share in the comments or send me an email.

Rotational encoders on the cheap – the capacitive way

Rotational encoders are definitely a must-have even in hobby robotics. When you want an encoder in your project, you have many options:

  • traditional optical encoders (IRCs) – precise, fast, not so cheap and big
  • “ball-mouse like” optical encoders – cheap, fast, reasonably big, poor resolution
  • magnetic encoders – small, wonderful resolution, not so fast and expensive
  • etc.

With two projects in my mind (one really up budget, the second one requiring really small and really fast (>100kHz) encoders) I thought: why not to build a capacitive encoder? Basically a variable capacitor whose capacitance determines the position. It could be cheap (etched on a PCB) and really fast. So I decided to explore possibilities of this approach.


As usual, I started with an overview of existing solutions. Surprisingly, it is hard to find any reasonable resources. I found only two types of existing projects – professional solutions without any documentation for scientific purposes and a really nasty hobby projects which are far-far away from any reasonable results. There was only one exception – Elm Chan’s laser projector, which uses a capacitive encoder for galvanometer feedback.

In his project, he uses a diode bridge and a high frequency AC voltage (>8 MHz) to measure a capacity difference of two capacitors. The circuit should produce a small voltage on a output proportional to the difference. However, I wasn’t able to reproduce his results. My circuit produced a lot of noise and was practically useless. Clearly I am not an analog guy. So I decided to do it in more digital way.

First prototype

The idea is simple – I create a plate capacitor with half-circle electrodes by etching a pattern on main PCB and on a small PCB carried by motor shaft. Then I use the 555 timer in an astable configuration with the plate capacitor for timing. The circuit will produce a square-wave signal with a period proportional to the overlap of the electrodes and therefore, proportional to the shaft position. The frequency can be measured using a timer on a MCU in the input-capture mode. Simple, right?

First prototype of capacitive encoder

After designing a simple PCB, which you can find here, I etched it and populated it. To protect the electrodes from a short and also to create as small spacing as possible (to increase capacity) I covered one of the electrodes with a transparent tape. The diameter of the semicircles is 15 mm (and therefore the active area is roughly 88 mm2. Based on resistor values I used, and the frequency I obtained, the capacity of this capacitor is about 8 pF – 5 times more then I expected (the tape is probably a better dielectric then I expected).

The first tests looked promising – I was able to measure a position, however the whole system was quite noisy and especially sensitive to touch – and mechanical stress. This is probably due to movement of the plates – event they lie on a the tape, if you squeeze them a little, they move closer together and it leads to big increase in the capacity. I also think this setup is quite sensitive to air humidity and temperature. Also it does not allow for continuous rotation because of the wire connecting one electrode to the main PCB. I was thinking about connecting the the other electrode via the motor shaft and the motor case, however, one of my friends had a nice idea (thanks Jiří).

Second prototype

The idea behind second prototype is quite simple – do not move the electrodes, move with a semi-circle of a good dielectric material between two fixed plates. The electrodes are fixed and therefore it is easier to maintain a fixed distance between them. Also, even if the dielectric semicircle does not maintain a constant distance from the electrodes, it makes no difference as the ratio of air and dielectric is the same (and that’s what affects the capacity). For the material I used FR-4 – it is easy to get and has 4 times bigger dielectric constant than air.

Second prototype

Second prototype

I also tried to make two electrodes for the second prototype to get rid of humidity and temperature dependency – I wanted to measure a capacity difference by measuring two capacities and making the compensation in MCU. However it wasn’t a good idea to put the two 555 timers on the other sides of PCB. Even with a decent battery of capacitors, they interfered in their function and produced an instability in the oscillation.

The other side of PCB with a ground plane and without the second 555 timer

When I got rid of one of the second timer and also introduced a ground plane on the other side of the circular electrodes I was surprised with results. To test the capacitor I used ESP32 with a motor control timer in the input capture mode. This timer’s clock tick at 80 MHz and feature a 32 bit counter. First, I arranged the resistors of the 555 timer to get a frequency around 100 kHz (I was aming for really fast encoders). With this setup, the timer makes roughly 800 ticks per period. As the capacitor still has a capacity even when there is no dielectric, the low period was 720 tics and the high period was 860 period – i.e. I got resolution of 140 positions. When the encoder is stable, there is a surprisingly small noise – only +-1 tick. Also I let the encoder run for over two hours and there was no drift in the position. You might think – 140 positions isn’t much, but I can read it at 100 kHz! When I lower the frequency (or if I could get the timers in ESP32 to tick faster) I am able to increase the resolution. So basically it is a trade off between speed and resolution.

What about continuous rotation?

If you read carefully and think a little, there is one small glitch in my setup – I am only able to detect position in the range 0-180° and no more. If I continue the movement above this range, I am not able to tell if I continue or if I am returning back as the capacity decreases the same way on the both sides. There is however a simple solution, which I unfortunately haven’t tested yet.

Electrode pattern

You need two electrodes A and B and a dielectric disk taking 2/3 of the full circle (semi transparent in the image). In this configuration you can always tell in which direction you move.


I would call my work as “proof-of-concept”. I think ultra fast capacitive encoders are feasible if you can measure period fast enough or you make Elm Chan’s circuit to work and use ADC instead. The capacitive encoder can be also a dirty-cheap solution – you need only a space on PCB, two 555 timer, 4 resistors and 4 capacitors. As the capacity of my plate capacitor is roughly 10 pF I think you could reduce its size 2 or 3 times and still get reliable results so not much of a space is necessary.

But always remember – time is money and an “expensive” solution in a form of a magnetic encoder IC might be in the end the cheapest solution.

Thinking about BOMs and Component Management

Let’s start with a disclaimer: I am a hobbyist. I do electronics mainly for fun, occasionally for serious business. All my thoughts are related to the context of single-person hobbyist (such as me) or a small group of hobbyist/semi-professionals such as RobotikaBrno. What I state here, might not be useful for the professionals.

Recent experience with Kitnic made me think again about component management in my projects – choosing, buying, storing and using electronic components. Before I present my idea, let me briefly describe my workflow.

My Current Workflow

Let’s start in the middle; as you could read in my previous posts I store my components in following manner:

  • I have a basic set of 0603, 0805 and 1206 resistors and capacitors in a special boxes (roughly 50 pieces per value).
  • ICs like MCUs and various sensor are stored in a grid of small boxes with labels.
  • Boards, china modules, etc. are stored in several paper boxes.
  • All the other components are in plastic bags with a hand-written label. These bags are kept in groups like transistors, diodes, LEDs, etc…

I also think it a good idea to have some parts on stock. I think everyone is familiar with the situation, when you are making a quick fix and you miss the resistor of the proper value. Ordering a component is time consuming (it takes few days to arrive) and costly (there are the shipping costs).

When I design a board I usually draw a schematics with respect to BOM and my home supplies. That means for example, if a value of a resistor is not critical, I try to match it to one of the values I already have in stock. But I do it only based on what I remember as going through the bags is time consuming. This also works only for my current stock, the stock might be different in a year.

I don’t use BOMs with precise order codes as I am a hobbyist, who populates boards manually and make only 1-5 pcs of a board. I have to care about minimal order quantity and I wonder why are there such a big price differences in practically identical components. When I need to order a component, I generate the BOM for several projects and go through the supplier website finding a component to match my needs with respect to price. I also try to match the components between projects. I don’t care much if I receive my components in reel, tape or a bag (precise order code usually forces me to buy a given packing, which can be in low quantities expensive). The process of ordering components is slow and annoying.

Also there is always a problem to decide what to order and what not to order. I usually base my decisions on my poor memory – I often don’t remember exact quantities I have on stock (and I am lazy to go through it). Therefore I rarely miss a component and usually order something I already have on stock. Also sometimes I order components for a project, which is for some reason left unfinished. Therefore my stock is constantly growing and contains components I will never use again (in my current workflow).

To sum it up – it is a little bit messy. From my experience, I am not the only one having this issue. Even some small companies have it.

What Would Make My Life Easier?

All these problems boil down to common source – component specification. When you use a component in a schematics, you should specify it. People use two methods:

  • They supply the part value (resistance, capacity, voltage etc.) and sometimes they add other criteria (e.g. power rating of a resistor).
  • Or they supply precise part name or event an order code for a supplier of their selection.

The second method might work for large companies producing thousands of boards – it is easy to order the components and the designer has everything about the components under control. It is also a good way to go with ICs and special components on hobbyist boards. However, when it comes to passives as resistors, capacitors, coils, etc., it does not work well for the hobbyist. If you specify the order code, then it is hard to use your stock supplies. If you decide to stick with a single type of your resistors or capacitors for the stock, it can get quite pricy, as you cannot buy the cheaper alternative. Also if you decide to build a board designed by someone else, you either have to match you stock supply with the order codes on the board or order components specifically for the board.

Let’s take it to the extremes to illustrate my point; when I have a small toy board, I don’t care whether a pull-up resistor is 10k or 12k. I want to specify it to be in range 8k-15k, in 0603 package and power rating greater than 0.05W. Nothing else, like manufacturer, height of the package doesn’t bother me. And any component fulfilling this specification will work for me. The same with capacitors – I usually need a given capacity, least voltage rating, package and min/max ESR and nothing else (like dielectric material) doesn’t bother me a lot in many cases.

The previous paragraph was rather extreme. Usually what I aim for is to make following step easy and repeatable for different settings: “I need an order code for the cheapest resistor with this value, at least this power ratig and with a tolerance at least 5%”. And ideally make the procedure automated based on schematics and allow for merging of BOMs and their simplification (e.g. I can replace 5% resistors with 1% resistors).

Let’s be honest – I think many hobbyist does exactly the same thing when order components for their designs. They do this matching by hand. And it can be a source of bugs as the specification isn’t written anywhere – especially if you are not the author of the board and you don’t know what parameters are critical. Well, it is usually enough that you order for a board designed a year ago.

Therefore I would like to keep track of this specification in schematics. I would like to attach attributes with the specification in KiCAD; like “resistance > 10k && resistance < 12k", "package ~= (0402|0603)". Then I could use an automated tool, leveraging for example Octopart, to find a part matching my criteria. Of course, if something needs to be precise, I put precise specification for the component.

Having this option would also motivate me to store my components in bags/boxes with a sequential numbers and the precise part name and keep an electronic track of my components. Then I could just export this “smart BOM”, verify it against my database and find out, that I should use 100n capacitors from bag nr. 42 and the remaining two capacitors can be taken from a bag nr. 87 (as they probably differ in voltage rating, but I don’t have enough of the first variant). This would force me to reuse most of my stock material and I would by only the necessary things.

It would also ease the situation when I need to find an alternative for a component as I miss one component and I prefer to buy it from a local seller to save time. But the seller does not have the precise component. Given the specification, I know which parameters of the component are crucial, and which not as much. The same case is the situation when I want to build someone else’s board and use as much stock material, as possible.

The Tools

I am not aware any of any ECAD program out there, which would support such a specification of components. Is there something out there I miss? Even a third party service I am not aware of? Do you see any flaws in the component parameter specification? If so, please let me know!

For me the outcome is: This can be easily added to existing tools like KiCAD and Eagle – both of them support attributes. What is needed is a format of these attributes to specify the constraints. Then we can easily build tools on top of it, which will make our life easier.

Morse Thing

Let’s start with a disclaimer: This is a one afternoon project, without a lot of planning, made only from home-available supplies.

As I wrote in the previous article, I organized a night game for K-SCUK 2016 few weeks ago. The message of the game was clear — nothing complicated, just “wow”. To accomplish this task, I wanted a stage with technical gadget. The idea of the Morse Thing was born.

The Morse Thing
The Morse Thing

Continue reading “Morse Thing”

Navigation Thing

Let’s start with a disclaimer: This is a 4-day project, without a lot of planning, made only from home-available supplies.

I’ve been helping to hold K-SCUK (a week long outdoor seminar for high school students interested in informatics and biology) for few years now. This year was no exception. I was put in charge of the night game, which was supposed to uncover some information about K-SCUK background story. I decided to go for a simple game with “wow effect” instead of a game with sophisticated rules and deeper message. I wanted a simple and enjoyable experience for the contestants. To accomplish that, we prepared linear route in a forest with several stops featuring a simple task (a cipher for example). This alone wouldn’t be enough to provide a memorable “wow” experience.

The NavigationThing
The NavigationThing

Continue reading “Navigation Thing”

The New Way of Storing and Organizing SMD Components

In my previous article I briefly showed the way I store and organize my SMD components. Even it is way better than storing parts in labeled plastic bags, in which the parts are usually shipped, it is still far away from being perfect. I was already looking for a better solution for a six months or so, when I finally found two products, which seemed like a possible solution – Aidetek Box-All Cases and WenTai Boxes.

My SMD Collection
My SMD Collection

Continue reading “The New Way of Storing and Organizing SMD Components”