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.

Saturday 2 December 2017

Fretting corrosion

Long ago I noticed friction fit connectors are not reliable in 3D printers: hydraraptor.blogspot.co.uk/2011/06/reliable-connections. For example, 0.1" Molex connectors that are rated for 3A burn out when only carrying 1A motor currents. Even signal connectors on HydraRaptor lose contact and need re-seating occasionally. I figured it must be due to vibration and / or thermal expansion and contraction.

It is one of the reasons I choose the Melzi electronics for Mendel90, i.e. because it has screw terminals instead of Molex connectors that are common on other boards like RAMPS. While looking at some connectors for another project I came across the term "fretting corrosion", which is exactly the problem that causes failed connections when you have vibration or thermal movement. There is a marketing video explaining it here:


Basically contact mating points need to be gas tight to prevent corrosion and any relative movement breaks the gas tight seal. You can now get connectors that have sprung female parts to absorb any motion and prevent this mode of failure. Worth considering if you are designing a 3D printer.

Monday 7 August 2017

Will it burn

I always intended to put lots of different tool heads on HydraRaptor but after being a milling machine for a while it got stuck as a 3D printer until I started making Mendel90 kits and then it sat gathering dust.

Back in 2009 I bought a 1W 808nm infra red laser diode to experiment with but I never got around to trying it out until recently.


I bought it on eBay for £292, which seems very expensive now, but the seller claimed it has a spot size of only 13um x 120um. That would give a power density of 640 W/mm2, assuming a rectangular spot. In comparison a 40W CO2 laser with a round spot of say 0.25mm would give a power density of 815 W/mm2, so I expected to be able to cut through wood and plastic a few mm thick with it.

Inconveniently, the anode of the diode is connected to the case. 

It came with a driver board that takes 11-18V and a TTL enable signal and produces a constant current drive.


It is all a bit last century with through hole components and a relay. I looked at the switching waveform and found that the relay added an 8.2ms delay and there was a 2.95ms rise time.

The blue trace is the enable signal and the yellow trace the output voltage.

The two TO220 devices had their markings ground off but it was trivial to trace the circuit and work out what they are: a 7810 10V regulator and an LM317 variable regulator wired as a 1.25A constant current source.

Laser didoes are very easily destroyed by overshoot transients of even a few micro seconds duration, so most of the circuit seems to be to avoid those. R2 and C3 seem to be to stop inductive spikes from the relay getting onto the 10V rail. R4 and C6 are probably to filter any relay contact bounce but they also make the rise and fall times very slow. D1 is a mystery because it can never be forward biased, so might as well not be there.

I hacked the PCB and reconfigured the circuit to replace the relay with a MOSFET, speed up the edge rate and added a big red LED to warn me when it was on. I have a pair of Thorlabs LG9 safety glasses to protect my eyes.
Here is the new switching waveform: -


This time the yellow trace is the enable signal. The blue trace is the current waveform measured with the hall effect current sensor mentioned in my last post. The small delay turning on is while the output capacitor charges enough for the diode to start conducting. The rise and fall times are now less than 1ms which seems more reasonable.

The forward voltage of the diode is about 2.2V at 1.25A giving a power dissipation of 2.75W and an efficiency of 36% assuming the output is 1W. I mounted it on an old PC CPU cooler which was complete overkill.


I made a rough estimate of the thermal resistance of the heatsink with the fan on by attaching a 50W resistor that has the same case style as the laser. The heatsink itself is about 0.23°C/W and the case of the resistor a little more, 0.48°C/W in total. So the temperature of the diode casing will rise by less than 1°C.

These dashes were made by waving a random piece of black plastic (most likely ABS) in front of it while the 100 Hz test waveform above was driving it.


With continuous power it makes deep scars.


Holding it steady I was able to slowly drill all the way through the 1.75mm thickness but it left a ring on the surface. The exit hole was clean though. By all accounts ABS doesn't laser very well.


With these rough manual tests I established the focus length was about 35mm, which I needed to know to be able to design a mount for HydraRaptor, so that I could position it relative to the Z probe to give me auto focus.

I also established it has no effect at all on white paper because that reflects red light and this is near IR, so it will behave mostly the same as red light. It also had no effect on some Kapton (polyimide) film because that is transparent to red light. With near IR you can only cut materials that absorb the red end of the spectrum. If they are transparent or reflective to red they are unaffected. In contrast, CO2 laser light is far infra red with a much longer wavelength and that is absorbed by most things including optically transparent materials like glass and clear acrylic and white materials like paper.

I designed HydraRaptor in 2D and that was all it needed at the time because it was made from flat sheets of MDF and had no 3D printed parts. In order to be able to add new parts to it I decided to re-model it in 3D in OpenSCAD.


I mounted the heatsink on a printed bracket that aligns the laser with the centre of the table and also supports a radial blower and duct for air assist. That is a jet of air that blows the smoke away from the cut and the lens.


I made a steel plate bed to protect the XY table and allow me to hold down the work piece with magnets. An L shaped bracket made from DiBond allows repeatable alignment with the back left corner of the bed. I used that corner to allow oversized sheets to hang over the front right where there is maximum clearance.


The hole in the corner of the L is needed because an internal corner would otherwise have a radius equal to the tool radius that cut it.

The first task was to find the exact focal point and I did that by burning a line of spots from different heights into the paint surface of an off-cut of DiBond and looked for the smallest one. I have hundreds of these off-cuts from making Mendel90 kits and because the paint is a thin layer on top of aluminum it seems like a good way to measure the spot size.


After I had established the focal point I then needed to establish how big the spot is. I have a microscope and a graticule slide but it was too hard to align it by hand. The alternative method I came up with was to make a line of spots 0.1mm apart so that I could compare the spot size with their pitch and use the ratio to work out the size.


As you can see the spot isn't quite aligned with the outer case of the laser. The size works out at 0.16mm by 0.07mm. This is a lot bigger than the 0.12mm x 0.013mm advertised and only gives a power density of 90 W/mm2. The bright area in the middle where it looks to have cut to full depth is 0.036mm wide.

Laser spots don't have well defined sharp edges. An ideal laser has a Gaussian intensity distribution which falls off  away from the centre asymptotically to zero. The beam diameter is sometimes defined as where the intensity drops to half the maximum and other times where the intensity drops to 1/e2 ≈ 13.5%. So my power density calculations are somewhat naive.

The beam starts off long and thin because it comes out of the edge of the chip die. The cleaved edges form the two parallel mirrors. Whereas I think of lasers having a parallel beam, the beam from a diode laser diverges at tens of degrees. And it diverges faster in the axis at right angles to the die than it does in the axis parallel to the die. So although it starts out wide and short it ends up tall and thin.


Not only that, but the beam also has astigmatism. That is: the point that the beam diverges horizontally from is further back then the point it diverges vertically from. So focusing it to a round spot requires tricky anamorphic optics. Mine just has a plain lens that is rotated in a screw thread to adjust the focus, so it can't correct the elliptical beam shape.

My next experiment was to work out what travel speed I can engrave at. This will be different horizontally and vertically because the energy density applied to the material will depend on the area swept out as well as the power and time. This will make motion planning interesting as the speed will need to vary depending on the slope of a line and so will the kerf compensation. Alternatively the laser could be mounted on a rotary axis to keep it pointing along the axis of travel for maximum detail. That would need a very accurately aligned axis though to avoid the spot wandering as it rotates. A round spot would be a lot easier to deal with!

I engraved a 5x5mm crosshatch with each line at a different speed. Speed reduces from left to right and bottom to top. The speeds are 5mm/s, 5/2mm/s, 5/3mm/s. ... 5/13mm/s.


By looking at the cross over points one can tell if the maximum engraving depth has been reached or not. So it needs go as slow as about 0.5mm/s horizontally to not show the vertical lines.

Note that it never goes deep enough to reach the aluminium skin. It looks bright but when I check for conductivity with a mulitmeter I have to scratch away the white layer to get contact. I think there must be white primer underneath the black paint and that reflects the laser, stopping further ablation.

Here is a 5x5mm rectangle engraved with a raster of lines overlapping 50%.


I don't know what gives it an apparent texture.

While doing these tests it soon became apparent that I needed fume extraction because removing even a tiny amount of paint smelt unpleasant. I thought I might get away without it for shallow engraving as there are many open frame laser engraving machines on the market. My first attempt was to add an 80cfm fan close to the edge of the bed that sucks air and blows it down a 1" pipe that I hang out of the window.


It produces quite a powerful suction and this reduced the smell but not enough. I switched to tests on balsa wood because I thought it would be less toxic. I have a lot of 2mm sheets left over from the early days of RepRap when it was used as a bed material for PLA before better options were discovered.

It still smelt very smokey, so I decided to make an enclosure. I had always intended to do this. Way back when I bought the laser, I also bought some brushed aluminum DiBond sheets big enough to make a cover but ended up using most of them for other things. I did have two left to make the front and top and some black off-cuts from Mendel90 production long enough to make the sides.

The width of HydraRaptor is 511mm and that is bigger than the X axis of my CNC router, which is 450mm. By hanging it over the side of the bed so it just cleared the gantry I was able to route one side at a time. I made some tooling holes in the corners of the door cutout that allowed me to turn it around 180° but maintain accurate registration. If it had been 1mm wider it would not have fit the router!


The door is an acrylic one I recycled from my Mendel case. I might replace it with DiBond to remove the need to wear safety glasses. It is sealed around the edges with rubber sealing strip tape. The enclosure isn't airtight because there are holes for wires to the z-axis driver, etc, but it is under significant negative pressure when the fan is running, so they are not a problem. I cut an 80mm hole opposite the extractor fan to get a good stream of air across the bed.

The enclosure removes any smell in the room while it is engraving wood but the smokey smell remains inside the machine even after a couple of weeks.

I did a larger grid test (50mm x 50mm) to see what speed I could cut through 2mm thick balsa wood but found it didn't matter how slow I went it did not go right through but it did give a wider charred area. The speed is 5 / n mm/s, where n is the line's index.


Here is the underside: -


Just a few pin prick holes and some surrounding char where the slowest lines cross.

I did another test where instead of reducing the speed by the line's index I kept the speed constant at 3mm/s (5 mm/s for y) but repeated the line n times. I found this gave far less char and actually cut all the way through.


So horizontally it took 4 passes at 3mm/s to cut through and vertically 6 passes at 5mm/s. Working out the power energy density as passes * power / speed these are more or less the same, which is odd considering the big difference in beam width.

The next test I tried was to cut out a square using four passes at 3mm/s in both directions.


I was disappointed to find it didn't cut all the way through so I re-ran the grid test above and the laser power dropped to zero and it never lased again. The left edge of the wood was not very straight where I cut it with a knife and it left a small gap that allowed the laser beam to hit the steel plate below. What seems to have happened is the reflection was enough to destroy the diode's mirrors. It still takes the same power but gives no output. This is known as Catastrophical Optical Damage.

Where the beam had previously gone all the way though to the steel it had created black stains so that stopped any reflection. So it looks like I should have painted my steel plate black. I was also lucky that the DiBond didn't engrave down to the aluminium surface as I expect that would be an even better mirror.


So a disastrous end to the experiment!

I have ordered a 2.3W blue laser from China so I will continue experimenting with that when it arrives. I also have a 12W IR fiber laser to play with but that requires a serious power supply and cooling system, so I will get more experience with lower power lasers before I attempt to power that up.


Sunday 30 July 2017

Adding weight

Sometimes it is desirable to make 3D printed items with heavy bases, so that they stand up or are not easily moved. An example is this base I made to hold two tiny PCBs.


They are Hall effect isolated current to voltage converters that I plan to use to measure stepper motor current waveforms in conjunction with an oscilloscope. They don't have any mounting holes, so I clamped them by the corners and screwed them onto a printed base.

I wanted the base to be heavy to stop them being dragged around by the scope leads. A while ago I saw a Youtube video by Warner Berry where he used lead shot to make printed parts with heavy bases. He prints parts with no bottom layers, so the honeycomb infill is exposed. He fills that with lead shot and then pours in epoxy resin. When that has cured he sands the base flat and sticks on a rubber sheet to make them non-slip.

I found lead shot on eBay sold for filling diving belts but I also found steel shot sold for filling teddy bears and that was much cheaper and available in smaller diameters. Steel has about 2/3 the density of lead, so it is a cheaper way of adding weight if you can accommodate 50% more volume. It also has the advantage of being non-toxic of course.

I got the smallest size, which is 1mm balls, on the basis that they will fill a space slightly better than larger sizes. The downside I found was that when pouring them they tend to bounce and fly all over the place. They don't vacuum up because they have a very high weight to air resistance ratio being spherical. I had to use a magnet to capture them. In hindsight I think 2mm balls would be easier to handle.

Instead of printing infill without bottom layers I simply made the whole base hollow. It doesn't need any infill for strength because it is going to be filled with resin. It is quite a large area to bridge without infill but it gets covered, so it doesn't matter how ugly it prints.


The screws go into brass heat fit inserts that I press in with a soldering iron. In hindsight I should have capped the holes to prevent resin getting in them.

After I filled it with the steel shot I poured in two part polyurethane resin that I had left over from an experiment nearly 10 years ago:hydraraptor.blogspot.co.uk/2008/03/hdpe-pu. I was amazed it still worked. It is probably better for this application than epoxy resin because it is less viscous, so should fill the gaps more easily.

Here it is after I sanded it down: -


Not the best casting as I under filled one corner and there are some bubbles, but it doesn't matter at all in this application.

I covered it with a sheet of adhesive backed neoprene rubber. It is probably not the best choice of rubber because it seems to be quite slippery.

The end result weighs 80g which feels quite heavy for something this size and is just about heavy enough to not be dragged around by scope leads. If I was making it again I would make it a bit deeper and try to find a better non-slip rubber.

Another way to encapsulate the shot would be to pause the print and pour them in before before the top layers are printed. They would then rattle of course, which might be annoying. On a moving bed machine like Mendel90 there would be a limit to how much weight you could add without lowering the acceleration. Also adding weight might cause the bed to drop in level slightly giving an uneven layer. Neither would be problems on HydraRaptor because its moving table weighs 9kg and has a load capacity of 125kg!

Friday 16 June 2017

Mooshimeter Mod

Last year I bought a Mooshimeter wireless 2-channel multimeter. It is a multimeter front end that links to your mobile phone with Bluetooth and displays the results in an app.


It is handy because you can read it remotely, it can measure voltage and current simultaneously and display power, it can log to an SD card and graph the results. It can also speak the results.

Despite all these good features my "go to" multimeter is still my EEVBlog branded Brymen BM235. So my Mooshimeter sits in a drawer for most of its life. When I get it out it usually wants to do a firmware update, which needs fresh batteries. Because it has no off switch the best you can do is put it into shipping mode. It still flashes its LED occasionally, so the batteries run down over a period of several months and are then not up to doing a firmware update.

Devices with no proper off switch are a pain if you only use them rarely because the batteries are always flat when you come to use them. This is particularly a problem because modern Duracell batteries seem to leak and corrode as soon as they are flat. This didn't used to be the case. I found some very old ones that I had abandoned in outdoor devices that I expected to be corroded to hell but in fact they were not corroded at all, despite being well past their use by date. In contrast I have had many corrode recently that were flat, but still well within their use by date. I have stopped buying Duracell and now use Costco's own Kirkland branded ones. It is too early to say if they corrode or not.

So I normally remove the batteries from devices I use rarely but with the Mooshimeter this involves removing the casing that is held together by two screws. I decided to add a switch to it but it has a cat III safety rating and cutting a hole in the case would void that.

I had two ideas to get around this: the first was to put a normally closed reed switch in series with the batteries and 3D print a cradle with a magnet in it to turn it off. My second idea was to use a mercury tilt switch to turn it off when placed upside down. I ordered both but as the mercury switches arrived first I implemented that and it works well.


I decided the easiest point to break the battery circuit was the link between the two cells. For some odd reason that is a copper fill rather than just a track. It is on the top side of the PCB so I had to desolder one of the contacts to get at it.  Fortunately the battery contacts have thermal relief connections so I just cut two of those to isolate the pad.


I then made an insulating washer out of Kapton film. I used that because it is very thin and can handle soldering temperatures. I stamped it out with a hole punch but I found it very difficult to get the hole concentric. This is my third attempt that was just good enough:


And here it is in place:


I reinserted the clip over the top and resoldered it. I then soldered the tilt switch between the two now isolated battery terminals.


When upright the contacts are bridged by the mercury, which is very low resistance. When I turn it upside down the mercury flows to the top of the bulb and isolates the batteries.

So all I have to do is remember to place it upside down in its case. If you want to attach the meter to something moving then the reed switch idea is the one to go for. I think it can probably be mounted in the same place if you use a neodymium magnet. You can get it nearer the back of the case by mounting it on the other side of the PCB but I don't know if that affects clearance distances for class III.