Sunday 15 April 2018

ESP8266 contention during programming

To put the ESP8266 into serial programming mode it needs to be reset with GPIO 2 held high, GPIO 15 low and GPIO 0 low. On the other hand to start it executing flash GPIO 0 needs to be high during reset. I have seen lots of circuits on the web, for example the NodeMCU board and Adafruit's  Huzzah board that pull GPIO 0 to ground with a switch and / or with DTR from a USB to serial adapter.  Reset can be driven from RTS to automate programming with the Arduino IDE.

A lesser known fact is that when the ESP8266 goes into programming mode it outputs a 26 MHz clock on GPIO 0 with considerable drive strength and fast edges. Shorting this to ground or DTR is not good at all as it causes massive contention and generates a lot of noise. This can cause programming to fail unless there is some hefty decoupling on the supply rail. The simple solution is to put a resistor between GPIO 0 and whatever is pulling it low. Here is what the signals look like with 10K between GPIO 0 and DTR from an FTD1232.


The oscillation doesn't show up at full amplitude with a slow time base but I can assure you it is full swing with plenty of overshoot due to not being terminated. You can see a bit of it coupled onto the TX line and this is when it is through 10K. Imagine how noisy things get when it is fighting with the FTD1232 DTR line and winning.

Another lesser know fact is that when the ESP8266 is in reset its GPIO lines get pulled up internally. You can see with 10K pulling it down the GPIO line only goes down to about 0.7V during reset.

Before reset my application is driving GPIO 0 low. RTS goes low a short time before DTR, so it briefly becomes an input and gets pulled to 3.3V by DTR before it pulls it low again. This explains the spike on the left.

I haven't seen any circuits published that avoid this contention.

Tuesday 3 April 2018

Printed ESP-12 module breakout adapter

I plan to make a few projects based around ESP-12F WiFi modules. These are postage stamp sized modules containing an ESP8266 chip plus 4MB of flash. The ESP8266 chip is a 32 bit MCU with an integrated WiFi transceiver and TCP/IP stack. They come programmed as a WiFi modem but they can be reprogrammed with the Arduino IDE to do other things in addition to the WiFi. Great for IOT applications because they are so small and cheap (less than £2) but reasonably powerful. A lot more powerful than an Arduino, for example, but with less I/O.


The solder pads are on a 2mm pitch, so they are often used with a breakout board to adapt them to 0.1" pitch for breadboard or perfboard, etc.  That adds cost and increases the size somewhat because the through hole pins need to be outside the perimeter of the module. I solved the problem another way, by using a 3D printed wire guide that routes wires from the 0.2mm pitch holes to the nearest 0.1" hole, minimising the space used and costing virtually nothing.


The holes in the module are quite small so I use stripped wire wrap wire. I push it through the module, down through the guide, which routes it to the correct hole in the perfboard. I fold the top over, solder it to the module and trim it. I do the four corners first and pull them tight and solder underneath to secure the module.

Here is a module mounted on perboard.


It doesn't use any extra board space outside the 0.1" holes it uses. I.e. the adjacent holes are all usable.

I didn't break out the end connections because they are not very useful. They are all GPIO lines used internally for the flash. I read it is possible to free up two by removing the can and re-configuring the flash chip to use a two bit interface instead of four bits, but that is too much hassle for me.

Here is the OpenSCAD that produced the adapter: -

The only notable thing is the squeezed wall definition, see my previous post.





Avoiding voids

The thinnest practical wall you can print, (with Skeinforge at least), is two extrusion widths wide. Any bigger leaves a gap, until you get to three extrusions wide, and then you get infill in between them.

If the wall is exactly two extrusions wide then they only touch tangentially and have a weak bond because the edges of the filament are rounded.


I discovered that if you make a wall even thinner then Skeinforge still lays down two paths equal to the extrusion width but places them closer together. This is because it always offsets inwards by half the extrusion width, even if the resulting paths overlap. I found I can make use of this to squash the plastic together, making a stronger wall with less voids.

An optimum amount of squeeze is to place the nozzle aperture just free of the flat part of the first path when extruding the second. The width to make this happen is $extrusion\_width - layer\_height / 2 + nozzle\_aperture / 2 + extrusion\_width / 2$.


Of course, despite what Skeinforge thinks, the plastic volume can't overlap, so regardless of where the nozzle is the minimum width the wall can be is $2 * extrusion\_width - layer\_height * (1 - π/4)$ due to the volume of plastic extruded, i.e. if it manages to completely fill the voids. This is shown below: -


The grey area is where the edge would have been with the wall two extrusion widths wide. There isn't much difference, and depending on the viscosity of the plastic, the real width should be somewhere in between. But the big difference is the walls are strongly fused together. The top void should be completely filled because it is right under the nozzle, leading to a smoother top surface. And the bottom void has more chance of being filled due to the back pressure caused by the filament having to flow more to the right.

To put some numbers to the diagrams, these have been drawn to scale for 0.25mm layer height and 0.5mm extrusion width, 0.4mm nozzle. The requested wall width is 0.825mm but the volume of plastic means it must be at least 0.946mm, only 0.054mm less than the original 1mm wall.

I made a test script that makes a box with two 1mm walls and two 0.825mm walls.


Here is a corner of the box under a microscope. The wall on the left is seamlessly fused and the wall on the right clearly has a void.


The wall comes out a bit thinner than the theory predicts, I am not sure why, maybe the increased pressure causes the plastic to feed a bit slower.

I used this technique to make the Mendel90 fan guards a lot stronger part way through production because I had some fall apart one day when my filament was a bit undersized.

It would be nice if the slicer could do this automatically, so you can keep a 1mm wall in the design, but it would make it by extruding one side of the wall as normal but the other side it would offset the nozzle to fill the voids and then extrude a little more plastic to make it still 1mm thick.

In fact it should really do this anytime it is extruding against another extrusion path. E.g. when doing multiple outlines and when doing infill. I.e. the only time the tool path of the nozzle should be down the centre of the extrusion path is when there is nothing either side, or it is enclosed on both sides. And in each of these three cases a slightly different flow rate would be needed to get the new exposed edge in the correct place.