Experimenting with ESPs… (part 2)

One of the few projects that has moved a little lately is my ESP-based IoT-experiments (which started here). As mentioned then, I had just managed to crack how to do the mains-powered PCB layout I originally wanted to make so that’s what I have been spending time on building and refining since. Having a mains-powered board makes more sense when you need mains power for a relay anyway, otherwise a plug-in USB supply is just as good (or actually better/safer). The board is shown here in full prototyping mode, it is going into a case – of some sort – very soon.

Apart from adding mains power to the board I also removed the original DHT22 sensor and replaced it with an off-board BME280 instead. That was super smooth and it works even better than the DHT, not to mention that it also measures barometric pressure. I’ve been looking at other sensors as well (UV, air quality, light intensity etc.) but they don’t really make a lot of sense for my immediate application (which is remote monitoring of temperature and humidity in my basement).

Since I finished my original version I’ve made a few enhancements to the software and so now I’ve got the code for both LCD and web-UI mostly finished and especially the web part was a great learning experience. As mentioned in the previous post, it’s also a learning experience I am not sure I would have been able to complete without the help of the excellent ESP- and Arduino tutorials by Rui and Sara at Randomnerdtutorials.com, so obviously very grateful for those.

Now I can still do more improvements to the software but instead of picking at it for another six months I think I’ll try and package it up shortly and then publish it here so that someone else can hopefully have a go at it as well. Stay tuned! (but as usual, don’t hold your breath while you wait…)

Buying “suspicious” parts…

With the current trend in audiophile parts being that all the “old” audio grade parts that we know and love are either being discontinued outright or at least replaced with something in impossibly small surface mount packages, it’s almost inevitable that we all at some point face a choice between giving up on a project and sourcing parts from “questionable” channels such as eBay or Aliexpress.

Here are the questions I personally ask myself before buying something and while they are definitely not a guarantee against wasting your money, they might help someone decide when to take a (calculated) risk and when to pass up what otherwise looks like a good opportunity.

Read more of this post

Trial and errors….

Like most blogs, social media showcases etc. this page is to some extent a massive display of selection bias – you only see the stuff that works, and only when it works. You never (or at least rarely) see the things that don’t work. Because of that, I just thought it would be funny to at least give you a few examples of the memorable mistakes I’ve made during the life time of this blog – along with the lessons I’ve (hopefully) learned from them.

Read more of this post

Experimenting with ESPs… (part 1)

…ESP8266’s that is (if you hadn’t guessed that 🙂 ).

Although I am not directly involved with it, I have several colleagues at work that are looking at Industrial IoT applications for various use-cases. Quite a few of them have built personal home-automation systems of one sort or another, and as I would actually like to do a ittle bit of monitoring/control around my house as well I started looking at options a while back.

My old Ampduino project was of course a big inspiration, but the Arduino lacks onboard wifi which is a big drawback, even for “IoT” at home, and so the ESP8266 was a very logical step up. The original plan was to build from scratch using “raw” ESP-12 modules, but after a bit more research I stumbled upon the Wemos D1 mini. I then decided to go back to the original “Ampduino” approach of building a baseboard for a ready-made module instead. This gives a good amount of flexibility while at the same time ensuring that USB, programming and all other standard functions work as they should.

For once, I decided that I was going to get started on the software-part of this immediately (that’s usually my weak spot) and since I have had to wait three weeks for the fist PCBs to arrive I’ve made very good progress. Two things helped me along though: Firstly that I found a basic sketch at RNT that did a rudimentary version of exactly what I wanted, namely control via a web-UI. Secondly, I had a standard NodeMCU-board which I could pop in a protoboard immediately. That made it feasible to start getting individual pieces of the code together as soon as the PCB-order was submitted and then subsequently assembling the pieces of code into the “real” thing later on. My prototyping efforts while the v1.0 boards were in the mail also gave me input to v1.1 boards, so I can actually start placing those orders in a couple of weeks (no point doing it now because all the PCB factories are closed for Chinese New Year).

As usual for this type of project I’ve ended up making several versions of the board. The “original” version is USB- or DC-powered and has an onboard relay and an onboard DHT22 temperature/humidity sensor in addition to a couple of spare in/outs (analog/digital). The smaller version shown here ditches the onboard relay and instead breaks out a full set of SPI-pins. This allows connecting an SD-card adapter so that data from either the onboard DHT22 sensor or any of the other inputs is saved to a local card as well as being displayed on a web interface and a local LCD/OLED display (via I2C).

The original plan was to do a mains-powered version but I couldn’t get a good design together at the time and so I went DC-powered instead. However, I think I’ve cracked it now so the next run is going to include a mains-powered version as well. Other changes for v1.1 will be some routing improvements and (most likely) doing away with the onboard DHT22-sensor and replacing it with the option of one or more offboard sensors based on the BME280 and/or the DS18B20 sensors.

Board sizes are from app. 50-75mm squared, so these are quite compact and versatile. More updates and also some code samples later on 🙂

Distractions….

Once again I find myself in a period where “real life” is intruding significantly on my build time. Not only at work (which is the normal reason), but also in my personal life. Therefore, the progress I am managing on my projects is mostly so incremental that it doesn’t really make sense to write about it – it would be the DIY-equivalent of a book with every page as a separate chapter!

However, the inspiration for projects is still there and both the various online forums and my blog-feed serve as good sources of new ideas and inspiration. One recent example that I specifically think is worth mentioning is this post on Arduino “watchdog timers” for standalone Arduino projects where a self-reset capability in the event of an error is a good idea. Like all the other posts on the site, this is very comprehensively documented and easy to follow and in this case it’s a topic that I didn’t think about but immediately thought would be useful.

And the best part is that even if you are busy, sketching out a simple PCB doesn’t take that long – does it? 😀

(note: hat-tip to the referenced wikipedia-article for the image below)

Linear PSUs are better…

…aren’t they? 😀

No, I don’t really want to start up that discussion here because in my opinion it’s much more complex subject than most audiophiles believe. However, one thing that is obvious is that as more and more small audio components run on single DC rails from an external PSU (streamers, DACs, headphone amps etc.), a fairly large market for aftermarket “upgrade” PSUs has opened up. Some manufacturers (e.g. Auralic) even offer separate PSUs as upgrades themselves. Well, a linear PSU is normally a relatively simple thing so why not DIY it?

Since I now have a DAC, a preamp, a streamer and quite a few other things that run on single-rail DC this seems a worthwhile project and it’s actually been on the drawing board for a while. I did have a bit of trouble getting started on the circuit and layout though, and I didn’t manage to really break the deadlock until remembered a design called STEPS by headwize/head-fi user Tangent from (many) years ago. The design isn’t up anymore, but thankfully I managed to locate it on the wayback-machine.

It’s basically a standard LM317-based PSU, but with a few tweaks added to tease as much performance as is possible out of the LM317 regulator (or one of its many derivatives). My version isn’t a straightforward copy of the STEPS, but I owe a big thanks to the the STEPS all the same. Compared to a “normal” LM317-based circuit this one includes:

  • A simple mains filter on the primary side of the transformer.
  • A snubber circuit on the secondary side of the transformer.
  • Space for high-speed/soft recovery diodes and snubber caps.
  • Space for 2+2 18mm filter capacitors in C-R-C (pi-filter) configuration before the regulator.

Everything else looks like the “high-performance” circuit variation from the data sheet of any LM317-type regulator. The onboard transformer is a 25VA Talema PCB-mounted toroid type meaning the design should be good for most applications requiring less than app. 20W power. The 15VA type transformer will fit as well and allow for mounting in a 1U enclosure, but the constraints on heat sinking and capacitor height might then be an issue.

The pictures show the completed 12V prototype for my Arcam IRdac as well as a partially completed 16V board for an Auralic Aries Mini (a recent purchase) – I’m waiting for a transformer in the mail before I can finish that and test it 🙂

LED-tester deluxe…

A few months ago I stumbled upon a presentation thread for an “LED-tester” circuit by Muffsy-creator H. Skrodahl on a Norwegian audio forum. Two things immediately occured to me:

1) I want one!
2) I think I can improve this a bit 😀

So rather than simply downloading his posted Eagle files and ordering boards from there, I started doing my own board instead. With the final result arriving earlier this week it’s time to put it to the test.

The basic idea is to use an LM317 regulator as a variable Constant Current Source (CCS) to test unidentified LEDs and confirm what currents are required for acceptable brightness – something that isn’t always easy to guess based on the published specs. I’ve kept the basic circuit intact but my modifications basically consist of:

– “Real” connectors for all connections instead of just solderpads.
– Additional outputs for LED connections to allow direct plugging in, permanent wired connections and also temporary connections via test leads/crocodiles clips.
– Space for a stereo pot to give a bit more mechanical stability.
– Optional “high-current” mode for testing constant-current LED bulbs as a supplement to just normal LEDs.
– Four real mounting holes to allow the board to be fixed to a bit of scrap metal or similar for use in a lab environment.

I need to do a bit more validation on the prototype before I publish my board files, but at least I can confirm that it works and that it is a very useful way to identify the operating parameters of e.g. LEDs in pushbutton switches.

Hard times ahead for Audio DIY?

It’s no secret that as mass-market electronics become increasingly compact and integrated, the availability of parts that are DIY’er friendly is shrinking rapidly. Most of Toshiba’s audio transistors (bipolar and JFETs) have disappeared, most of the high-voltage parts used for Stax amps have gone as well (together with the CRT TVs they were intended for), Onsemi killed a load of small-signal transistors not long ago and more and more semiconductors are disappearing in their through-hole versions and moving to SMD-only.

This has been going on for at least a decade, but I think a recent diyaudio thread highlights the issue and deals another crushing blow: A while ago Texas Instruments (TI) acquired National Semiconductor, and now TI has decided to discontinue a large chunk of audio-grade parts. You can see the whole list at Mouser here but among the “highlights” for the audio DIY’er are:

  • The LM3875 – discontinued with no replacement (!!)
  • The LM4780 – discontinued with no replacement (the listed LM4766 isn’t really comparable and will not fit the many LM4780-designs already out there)
  • The LM4562 – DIP-package discontinued, but SMD still available.
  • The LME497x0-series and many other LME49xxx opamps – all DIP-packages discontinued. In some cases the SMD-package stays available but some devices are going completely (like the LME49990)
  • The LME498x0 power amplifier drivers – discontinued with no replacement.
  • The LME496x0 buffers – discontinued with no replacement.
  • etc.

Now, according to the PCN the last order date isn’t until September next year and last delivery is in March 2017, but there is no doubt to me that this isn’t the last notice we’ll see of this type in the coming years. Also, there is a risk that some distributors will drop the parts earlier to avoid building up excess stock making parts difficult to source even before the official deadline, and in any case many designers will be reluctant to use parts that are marked EOL.

Certainly, my next Mouser-order will include a few spares of some of these parts and I can only advise you to do the same 😦

Building an Electronic Load

One of the tools that I sometimes need but haven’t bought yet is an electronic load for testing circuits such as power supplies. Of course you can make do with fixed resistors (and I have so far), but you practically never have the right value/wattage to hand when you need to test something (in my case, usually on a Sunday afternoon…grr!).

The solution is a programmable electronic load, or basically an adjustable current sink (or a “reverse power supply” as some people call it) that can simulate the load from any fixed resistor within reason. I haven’t bought one of these yet, partly because I didn’t feel I needed it enough to justify the expense, and partly because I am rapidly running out of space to store instruments that are only used occasionally.

Some weeks ago I started toying with the idea of building one myself to at least get started. I’d seen some nice designs on Tindie, but wanted something that was capable of higher power and something which I could more easily tweak for myself. A bit of googling turned up a few promising pages, most notably this one on Kerry Wong’s (excellent) blog.

I liked Kerry’s design as a starting point, mostly because it is relatively well documented and the control code is Arduino (which I can work with). I therefore started revising the circuit to suit my needs and laying out a PCB for it as well.

Key changes from the original:

  • I’ve scaled it down from three pairs of MOS-FETs to two because that is what I could fit on the Eagle board (being constrained by the freeware version).
  • I’ve replaced the parallel LCD connections with I2C to simplify the PCB layout and free up Arduino pins.
  • I’ve mounted the controller (an Arduino Nano v3) onboard. That wasn’t the original plan, but the space was there so why not?
  • I’ve broken out a pair of analogue Arduino pins, a pair of digital Arduino pins plus a second I2C-connection that can be used for other purposes. Top of the list for me would be a real-time clock (RTC) module for data logging purposes and some sort of thermal sensing and fan control, but I am sure there are many other potential uses (web-interface anyone? 😀 ).
  • plus a bunch of other minor tweaks 🙂

This is still work in progress, but I have received the prototype boards in hand and I have started the assembly as you can see from the pictures. Still to do:

  • Do the mechanical work on the heat sink (in progress)
  • Rewrite the software to work with the I2C-display (also in progress, but might take me a while)
  • Test whether the damn thing works! 🙂

EDIT 13th March 2016: The schematic for my v1.0 PCB can be found here. There are at least two know issues that need to be corrected. 1) The “sense” pin (A3) is connected directly to the output but should actually have space for a voltage divider. 2) The spare opamp (IC1B) should have pin 6 and 7 connected together and pin 5 connected to AGND.

EDIT 19th August 2019: I’ve published the untested project files (with some minor tweaks) here if anyone wants to have a go at finishing this project themselves.

PCB Layouts Part 1 – Workflow

I get asked (surprisingly) often about my PCB layouts and how I do them. Flattering obviously, but also a bit strange as I don’t really consider myself an expert on PCB layout at all. However, I can share are some “workflow” tips on laying out a board in the most effective way based on my experience.

Note that the below is based on using the freeware version of Eagle, but much of it should translate to other software packages without much difference.

The first step is to draw the schematic in the schematic editor. If I start from someone else’s published schematic I’ll normally print a copy on paper and mark on that which parts sizes I expect to use. This then becomes the reference for drawing the schematic in the editor. Once the schematic is drawn in it’s basic form I’ll check it, rename the parts and then run an electrical check to verify that nothing has been missed. If I am going from a published schematic I normally stick to the part names from the original schematic (because that makes for much easier troubleshooting if something’s amiss later on), otherwise I will make up something that is logical to me, usually going from input to output.

Then it is time to switch to the board editor. Most of my PCB layouts start out with mounting holes placed in the four corners (because that’s normally where I want them) and a ground plane drawn in the top layer. If I have a specific board size in mind I’ll restrict it straight away, otherwise I will keep the full area and then reduce the size as the layout progresses. I will also load my own standard design rules and tweak the parameters (mainly clearance) if required before I start, because then I will not make something that I have to revise later when the DRC (design rule check) fails.

I generally then start the actual layout process by placing the key components as I want them. Key components usually mean:

  • Power and control devices (transistors/ICs and potentiometers/switches) that must extend over the edge of the board
  • Power devices that need an onboard heat sink (heat sink is placed as well of course)
  • Other ICs plus their associated decoupling parts as close to the IC as possible
  • Key connectors (if they need to be in a certain position I fix that, otherwise I put them on the specific board edge where I believe it makes most sense to have them).

After this, the fun (or frustration) starts. Using the schematic on one side and the “ratsnest” command in Eagle to recalculate wires I start moving first the major and then the minor parts of the circuit around and positioning them to yield as short and as neat traces as possible. This requires several iterations and usually also putting the board away and coming back to it later because I tend to “go blind” after staring at the layout for too long at a time. Other tips that I use to simplify the layout process include:

  • Every time I make a major change, I save the board as a different file version with a new revision number, because sometimes layout changes turn out to be “dead ends” and then it’s easier to return without having to do massive amounts of rework. Some of my more complex designs have 10-15 file revisions before getting to the final layout.
  • I normally do the basic layout using one trace width, generally the smallest width I expect to use in the circuit. Once I have a layout I am reasonably happy with mechanically, I can enlarge key traces without having to do a lot of fiddly rework and without risking that I miss something. In general I also stick to using a few standard trace widths which makes it easier to quality check the layout later on in the process.
  • I normally start with 45 degree trace angles for simple and consistent routing, and the in the last round of tweaks I may change some traces to be “odd” angles instead if it significantly helps the layout.

Once the layout is beginning to shape up and all traces are routed, I will start the actual layout screening process. This usually involves generating gerber files for the circuit and rendering them with circuitpeople.com and looking at each layer in isolation. For the copper layers I mainly try to look at a) whether the individual traces follow the most unbroken and logical path and b) whether the individual signals will flow through consistent trace widths. If not, i go back and make corrections accordingly. Once I start checking Gerbers, I also start adding text elements to the board because I now have a reasonable idea of where there is space for them.

I then pretty much repeat this process over and over again until I believe I can’t make any more improvements. Again, putting the board away for a day or more often helps and I often find that even a short break from something I am happy with means that when I come back I can make bigger optimisations than I though possible when I left it. Often during these breaks I also think up new features that may be worth including, such as multiple footprints for key components, additional labelling for connectors etc.

Eventually I get to a point that I am happy with the layout and then it is mainly the last checks of both the individual layers (using gerber renderings from circuitpeople) and the full board (using renderings from gerber-viewer.com, which allows displaying of multiple layers at the same time) plus the last tweaks to the silk screen. The last step is usually confirming that ERC and DRC are still error-free, and then printing off a sample of the board layout at 100% to check the final size. Seeing the board printed in actual size gives me a better impression of the size, even if I already know how big e.g. a 2” x 2” board is.

I will then place the PCB order and mark the last Gerber version with a tag in my Eagle project folder so that I can see later that this was the file version I sent off for manufacturing.