My Own DC-DC Buck Converter

Dc-to-DC Back converters have a lot of advantages over traditional linear voltage regulator solutions. Most of these advantages are related to the smaller size of these circuits, in comparison to their linear counterparts, as well as their higher efficiency and lower power consumption to name a few.

I am by no means a power supply guy, and as such, I usually buy my power supply modules. The same also applies to boost and buck converters. I am usually quite comfortable leaving the design of these critical parts to those who actually know what they are doing.

It thus seemed like a reasonable challenge to actually try and design and build one by myself, and that will be the story behind this post.

Finding a suitable driver IC

This journey started at a very strange place. When I decided to go ahead and build this Buck converter module, I had no specific driver IC in mind. I was thus browsing through the long list of dc-to-dc- buck converters on my component suppliers’ website, randomly pulling up a datasheet to take a closer look, mainly looking for something with as few external components as possible, while also having a decent current supply capability, as well as being able to operate on an input supply of 4v to about 24v, which is well within my usual range…

I eventually settled on the MPS MP9943. Definitely not the cheapest but still affordable, and in a QFN8 package, so that I am still able to actually solder it to a PCB!

-Wide 4V to 36V Continuous Operating Input
Range
-85mΩ/55mΩ Low RDS(ON) Internal Power
MOSFETs
-High-Efficiency Synchronous Mode Operation
-410kHz Switching Frequency
-Synchronizes from 200kHz to 2.2MHz
-External Clock
-High Duty Cycle for Automotive Cold-crank
-Internal Power-Save Mode
-Internal Soft-Start
-Power Good Indicator
-Over Current Protection and Hiccup
-Thermal Shutdown
-Output Adjustable from 0.8V
-Available in an QFN-8 (3mmx3mm)
package

and with a peak current supply of up to 3A – Not too bad at all.

The actual design

As mentioned already, I am not ( or at least I don’t see myself) a power supply design expert. I believe I am perfectly capable with the linear stuff, by switchmode was never my strong point 🙂 This prototype will just be based on the recommended design in the datasheet, at least for the first version, and then, later versions may feature some customisation as actually needed.

From the picture above, we can see that there are indeed not a lot of external components required. And in my humble opinion, the efficiency vs load also seems to be quite reasonable.

I thus went ahead and started reading this datasheet in detail. I found two typical-use circuits with recommended component values, from which I build my prototype.

I chose to combine these two circuits to give me a variable output module, that will be selectable between 5v and 3v.

I also chose an inductor with a 6A maximum current rating, as the datasheet states that we should choose one with at least a 25% higher current rating than our peak requirement. My logic here was that 100% would be a good number, as the inductor would in theory never saturate?? as well as produce less heat etc ?? Please comment on this, as I may be barking up the wrong tree here 🙂


The schematic above is what I came up with. A jumper will allow the selection of the output voltage, as this is determined by the value of the resistor at R8, in my case 13K or 7.68k… I also assume that that resistor can later be replaced by a 20k trimpot or similar to give a truly variable output.

PCB Layout

The PCB layout was an attempt to follow the datasheet recommendations as closely as possible, while still having my own design. I am also aware that I may have wasted quite a bit of space, but for now, my focus is on getting a working design. I can always try to squeeze it into a smaller space later.

Manufacturing

I choose PCBWay for my PCB manufacturing. Why? What makes them different from the rest?

PCBWay‘s business goal is to be the most professional PCB manufacturer for prototyping and low-volume production work in the world. With more than a decade in the business, they are committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests. As one of the most experienced PCB manufacturers and SMT Assemblers in China, they pride themselves to be our (the Makers) best business partners, as well as good friends in every aspect of our PCB manufacturing needs. They strive to make our R&D work easy and hassle-free.

How do they do that?

PCBWay is NOT a broker. That means that they do all manufacturing and assembly themselves, cutting out all the middlemen, and saving us money.

PCBWay’s online quoting system gives a very detailed and accurate picture of all costs upfront, including components and assembly costs. This saves a lot of time and hassle.

PCBWay gives you one-on-one customer support, that answers you in 5 minutes ( from the Website chat ), or by email within a few hours ( from your personal account manager). Issues are really resolved very quickly, not that there are many anyway, but, as we are all human, it is nice to know that when a gremlin rears its head, you have someone to talk to that will do his/her best to resolve your issue as soon as possible.

Find out more here

Assembly

After receiving the PCBs back from the factory, and receiving the components from the supplier, I started on the assembly. While uneventful, It was worth mentioning that this project does require a stencil. The DFN-8 package is quite small (only 3mmx3mm), with eight leads, so that makes for some tiny spacing between them. As it is also a leadless package, I did not want to chance to have too much solder paste in there.

As we can clearly see in the picture above, the pads are super tiny. The other components are 0805 ( for reference).

My standard way for assembling DFN packages is to actually level the part of the PCB while reflowing the PCB with a hotplate. Then, when the solder has all melted and is in a liquid state, I carefully place the part with tweezers and remove the PCB from the hotplate.

Alternatively, I remove the PCB from the hotplate first, leaving it to cool down a bit, and then, using a hot air gun with a small nozzle, reflowing only the area where the part needs to be placed, and carefully placing it onto the melted solder.

Both of these methods seem to be working quite well, for me at least, but the hot air method does however have the risk of a bit of solder splatter, which may form unwanted bridges… The part also gets heated a bit, as it has to be held in place for a few seconds to prevent it from being blown around by the hot air.

Testing


I am quite happy to report that the module works as expected, with a steady output of 3.31v and 5.08v respectively at no load.

Under load, I tested with a 1A and 2A load respectively, both voltages are also stable. Ripple, as measured by myself, and using a “not too good” digital oscilloscope, seems to be about 110mv peak-to-peak.

Using better probes, and a better scope, I may be able to get a better and more accurate reading.

Conclusion

This was quite an exciting project, with setting myself a challenge, and actually achieving what I set out to do. While I am sure that the module in its current state may actually not quite be perfect, and that it surely has a lot of room for improvement, I am satisfied with its performance, and just plainly, the fact that it actually works!

Breadboard Power Rail Bridge

This is a sort of tongue-in-the-cheek project, that started with good intentions, and ended up wholly over-engineered and sort of “broken” due to adding “added features” like LEDs and an additional power header.

What was the initial intention?

[This is what I actually wanted to achieve]


My breadboards all have interrupted power rails, and it is thus always necessary to bridge them with jumper wires to have a continuous rail. This is needed because I very often have more than one project on a single breadboard, and do not want to have to use separate power modules for each. I also tend to test out some part of a circuit on a separate part of the breadboard, before incorporating it into the main circuit.

[ I completely overdesigned this, ending up with something completely different from what I wanted]


Wire jumpers are definitely the easier and fastest, but having been struck by a “what if I do this instead” moment, this tiny PCB was designed and subsequently sent to manufacturing…

So does it work?

Yes, it works, for its intended purpose of bridging the power rails, but that is where the wheels come off. Let me explain, trust me, it will be fun, and we can all laugh at it in the end…

Breadboard power rails are usually marked Red for positive, and Blue or Black for negative… Most people on this planet are also right-handed, and would thus place a power module on the right-hand side of a breadboard ( although some won’t..) Being left-handed myself, and still trying to please right-handed people, my power module will be “upside down” on the left-hand side of a breadboard… which is fine with me, as I remember to swap the colours of the rails in my mind, making red negative and blue positive… not a big issue is you always do it that way…

So what went wrong…

While designing this, I initially planned on a simple PCB bridge, with a jumper on the positive line, acting as a switch, and a continuous ground that is always connected.. all fine, problem number 1 being that I looked at the colours of the power rails while designing it, measuring the gaps etc to get the spacing just right…

Problem number 2 is that the top and bottom rails are in the same configuration, Red at the top, blue at the bottom… and thus plugging in a bridge into either should be ok… and it really should have been, if I did not decide to add a status LED on each side of the bridge, and an additional power header… because turns out that I forgot that the bridge at the top will in effect be “mirrored” when plugged in ( and thus having components that are reversed polarity) – mirrored, due to the fact that you now have to plug the top rail bridge upside down into the breadboard, because it will otherwise interfere with the prototyping space

[This was the direct effect of my lack of attention to detail – and yes, it works perfectly in this configuration – if we ignore the wasted space on the top half of the board]

[This is the practical reality – one bridge must be installed ‘upside-down’]

Lesson learned; I can be quite scatterbrained at times, especially when juggling a few projects and customers at the same time ( I am only human anyway ). Thus this project, although it looks nice, and can be useful, needs to go back to the drawing board for a complete redesign, without all those “added features”

The Schematic


The schematic is straightforward, with no surprises. Two LEDs ( polarity sensitive ) and then those headers and jumpers, which also need up being polarity sensitive – in a manner of speaking

Quite different from what I originally wanted to do

Manufacturing

I choose PCBWay for my PCB manufacturing. Why? What makes them different from the rest?

PCBWay‘s business goal is to be the most professional PCB manufacturer for prototyping and low-volume production work in the world. With more than a decade in the business, they are committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests. As one of the most experienced PCB manufacturers and SMT Assemblers in China, they pride themselves to be our (the Makers) best business partners, as well as good friends in every aspect of our PCB manufacturing needs. They strive to make our R&D work easy and hassle-free.

How do they do that?

PCBWay is NOT a broker. That means that they do all manufacturing and assembly themselves, cutting out all the middlemen, and saving us money.

PCBWay’s online quoting system gives a very detailed and accurate picture of all costs upfront, including components and assembly costs. This saves a lot of time and hassle.

PCBWay gives you one-on-one customer support, that answers you in 5 minutes ( from the Website chat ), or by email within a few hours ( from your personal account manager). Issues are really resolved very quickly, not that there are many anyway, but, as we are all human, it is nice to know that when a gremlin rears its head, you have someone to talk to that will do his/her best to resolve your issue as soon as possible.

Find out more here

Conclusion

This project served many purposes beyond the actual use of the PCB that was designed. In a way, I am quite happy that I screwed up so badly on this one – here is the reason why:

Because I do quite a lot of PCB design each month, for customers or personal projects, I often tend to get a bit over-confident, and also rush things through,
while believing that I will catch every mistake before I send something off to production. Normally, I am quite good at that, and my error rate is actually quite low… But, This month, being quite busier than usual, and having had a fair amount of distractions, served as the perfect lesson to drag me down a notch or two, and remind me that I have to be way more attentive, especially when things are going hectic, and there are a few projects to juggle around at the same time.

The second reason why it is a good thing when the wheels come off like this, once in a while, is that it serves as a perfect example of what your PCB manufacturer’s actual job is. So, this is especially for the new guys that may not know this: Your PCB Manufacturer has only one job – To manufacture your PCB EXACTLY AS YOU DESIGNED IT – Scary, right? Sure, they will let you know if your design falls outside of their tolerances of capabilities. They will let you know if your board fails a flying probe test if you have that kind of arrangement with them… But it is NEVER their job to correct or attempt to change any of your design files.

So, what is the moral of the story, regarding both of the points that I made above?

If you screw up on the design, it is your, and only your fault. Nobody else is to blame, ever. The buck stops with you, the designer.

Breaking out of the Chip Shortage – Attempt #3

The ATMEGA4808 provides a very attractive solution to replace the trusted ATMEGA328 or standard Arduino UNO /NANO.

These chips are slightly more difficult to get hold of than the ATTiny chips, and cost a little bit more ( about the same as what the ATMEGA328 used to cost before the mess with COVID-19 and resulting supply chain shortages + inflated costs), but they offer all of the functions of the ATMEGA328, with a few other enhancements that will definitely be very useful.

The extras include:
– Hardware interrupts on ALL GPIO pins; This is way more than the standard 2 interrupts on the ATMEGA328 ( We are not talking about the Pin Change interrupts, but real hardware interrupts, that can be triggered on RISING, FALLING, CHANGE, HIGH and LOW state of each pin

– Up to eight (8) PWM pins as opposed to the 6 on the Arduino UNO
– Up to eleven Analog inputs
– An Analog Comparator module
– Configurable Custom Logic (CCL)
– EVENT System (EVSYS)
– Peripheral pin swapping

It is also worth mentioning that these chips have accurate internal oscillators, capable of clocking the chip at up to 20MHz, further reducing the number of external components required to get a minimal configuration running…

Order your own version of this development board

The Prototype PCB

While I have had a Nano Every “Clone” lying in a drawer for quite a while now, I did not really pay a lot of attention to it. That was, until I needed an ATMEGA328 for a project, and could not find any for sale, or at least at a price that I was willing to pay for it… That incident was the spark that ignited this entire exercise, to find a suitable replacement…

The Nano Every “Clone” in my possession, used the ATMEGA 4808 chip and turned out to be the Thinary Nano 4808. I had quite a lot of problems with the provided core, as well as getting peripherals like I2c and SPI to work. This led to further investigations, and finally, I decided on building my own and to use the MCUdude/MegaCoreX Arduino Core to program it.

This led to the following prototype:

ATMEGA4808 Development board prototype

I did not bother with too much detail on the silk screen here, as the goal was to get a working board, test it, and then later, design a refined PCB.

What is important to note is that the board runs at 5v, but provides a single 3.3v output as well. Logic levels on the GPIO is also 5v. Use level converters for 3.3v only addons…

The MEGA4808 is programmed via UPDI, so we have a UPDI Header on the right-hand side of the PCB. It is also possible to use the Optiboot Bootloader, to flash the board in true Arduino style through a USB connection to a computer.

A CH340N USB-to-Serial converter chip is used instead of the CH340G that is common on the UNO clones. The CH340N provides only the USB D+ D- signals, as well as Rx, TX and RTS. RTS is being used to auto-reset the chip after flashing…

In comparison to the CH340G, which also required a crystal oscillator, but provides all the modem control signals, which, are usually not even broken out, the CH340N made much more sense.

PCB Bottom.

A power LED, as well as an indicator LED on pin 7 was also included.

Assembled PCB, Top Layer.

Assembly and Soldering

I normally assemble all my projects by hand and reflow-solder them with a hot plate. for this project, I decided to do things a bit differently, which ended up being a bit awkward, but still resulted in a perfectly useable PBC.

As you will know by now, I only do written articles, as I don’t consider myself ready for the Youtube and video thing, as well as because I believe a well-written article, with detailed pictures, is easier to understand than a video…

Well, today, we will have both… This article, with its writeups and pictures, as well as a short assembly and soldering video, with no sound, sped up 5x, as I did not want to bore anyone with a 25-minute silent video…

Let us begin then…

PCB and Stencil

We start with a blank PCB and the laser-cut stainless steel stencil that I got from PCBWay.

Solder paste applied

Solder paste is then applied with the stencil and a scraper, and afterwards, the stencil is removed… The PCB is now ready for component placement…

From here on, we will go to the video footage… showing component placement, with some awkwardness due to the camera being in the way, as well as hot-air soldering, with the same awkwardness, as I was forced to use my right hand ( I am left-handed), not to block the camera view…

Begin quite new to the video thing, I have also not quite figured out the editing software, so the video is in native resolution… not zoomed…

After assembly

After assembly, I checked for solder bridges and was quite happy that there were none. This also meant that the board worked perfectly the first time around… as it should…

Order your own version of this development board

Manufacturing

I choose PCBWay for my PCB manufacturing. Why? What makes them different from the rest?

PCBWay‘s business goal is to be the most professional PCB manufacturer for prototyping and low-volume production work in the world. With more than a decade in the business, they are committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests. As one of the most experienced PCB manufacturers and SMT Assemblers in China, they pride themselves to be our (the Makers) best business partners, as well as good friends in every aspect of our PCB manufacturing needs. They strive to make our R&D work easy and hassle-free.

How do they do that?

PCBWay is NOT a broker. That means that they do all manufacturing and assembly themselves, cutting out all the middlemen, and saving us money.

PCBWay’s online quoting system gives a very detailed and accurate picture of all costs upfront, including components and assembly costs. This saves a lot of time and hassle.

PCBWay gives you one-on-one customer support, that answers you in 5 minutes ( from the Website chat ) , or by email within a few hours ( from your personal account manager). Issues are really resolved very quickly, not that there are many anyway, but, as we are all human, it is nice to know that when a gremlin rears its head, you have someone to talk to that will do his/her best to resolve your issue as soon as possible.

Find out more here

Picture Gallery

Get Started with the ATMegaTiny202

As I have hinted in my recent two posts about UPDI programmers, I am currently looking for a solution to replace the ATMEGA328P chip used in standard Arduino devices, like the UNO and NANO.

The global chip shortage seems to be still hitting hard, with these devices (Arduino UNO, NANO), and even bare chips being quite hard to get hold of, and when you do, they are quite more expensive than they used to be.

This sent me on a new journey, to find a new chip, that is easy to use, inexpensive, and easy to get hold of. I have found 3 of these chips, starting today with the ATMEGATiny202,

ATMEGATiny 202



The ATtiny202 is a microcontroller using the 8-bit AVR® processor with a hardware multiplier, running up to 20 MHz and 2 KB Flash, 128B SRAM, and 64 bytes of EEPROM in an 8-pin package. The series uses the latest technologies from Microchip with a flexible and low-power architecture, including Event System and SleepWalking, accurate analog features and advanced peripherals.

With only 8 pins, of which we can practically use only 5 ( 6 if you have an HV UPDI programmer ). This makes it a desirable solution for small projects, with its current price of about 0.59 USD per chip ( SOIC8 PACKAGE, Element14 ) , not breaking the bank either. Not needing an external oscillator, and requiring only a single 100nf bypass capacitor, (not counting the UPDI resistor) it can indeed be a very very cheap way to get a project done… Providing of course that you don’t need a lot of Program memory or RAM, and are not trying to do too many super fancy or complicated things.

ATMegaTiny202 Minimal Breakout, on Breadboard with MakerIoT2020 Multipurpose Uart/UPDI Programmer

The wide operating voltage of 1.8v right up to 5.5v also makes it quite flexible.

My initial prototype

Getting started with a new chip is also a bit of an issue, as there are many new things to learn, recommended supporting components, and also firmware and cores that need to be installed. I have decided to build a quick breadboard-capable PCB, with all 8 pins broken out in a single row, feel free to change the straight header pins to a 90-degree version at your convenience, it takes up even less space that way.

The PCB contains only the bare minimum required components for the chip to function, but I also added onboard I2C pullup resistors, with a jumper to select them. ( Most I2C modules usually have these already, but as I build most of my own breakouts myself, I decided to include these).

A single LED brightens things up a bit, connected to pin PA3, making it possible to run a blink sketch…

The rest of the components include a 100nf bypass capacitor and the very important 470ohm UPDI resistor.

ATTiny202 Breakout-Blank PCB-Top
PCB Top view, unpopulated
PCB Bottom, unpopulated

Programming the board

I use the Arduino IDE quite a lot, and also assume that most makers and hobbyists out there will do the same. Luckily we have access to a special Arduino core, the megaTinyCore, that provides us with all we need to program this tiny little chip, provided of course that you have a UPDI programmer.

See the link above for installation instructions, as well as detailed documentation. Replicating all of that here will be an unnecessary task, as the author of the core, SpenceKonde, has already done an excellent job.

One very important thing to note on this board is that there is NO RESET PIN.
You have to manually cycle power to it, but, I have found that initiating a UPDI upload to a running chip works every time, and makes it unnecessary…

The reason for the lack of a reset pin lies in the fact that the reset is shared with the UPDI pin, and enabling it, will rob you of the UPDI functionality UNLESS you have an HV UPDI programmer, which at this time seems to be hard to find/expensive item ( Hope to build my own soon). Once again, see the above link to the core documentation for the full information on the reset pin issue…

I can not stress enough how important it is to sit down and READ the core documentation, with attention, before doing anything with this chip and core. you will learn a lot, about the chip, new features, possible problems, and how to avoid them, and also some customised GPIO functions etc…

Schematic

ATTiny202 Minimal Schematic

Manufacturing

PCB Layout

The PCB is a double-layer PCB, with the signal traces on the top layer, power traces, and the ground-plane, on the bottom layer. the Dimensions are 26.035mm x 18.669m. All SMD components are 0805. This board does not need a stencil for assembly and can be hand or hot-air soldered in a few minutes with no problems.

As many of my existing readers will know by now, I choose PCBWay for my PCB manufacturing. Why? What makes them different from the rest?

PCBWay‘s business goal is to be the most professional PCB manufacturer for prototyping and low-volume production work in the world. With more than a decade in the business, they are committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests. As one of the most experienced PCB manufacturers and SMT Assemblers in China, they pride themselves to be our (the Makers) best business partners, as well as good friends in every aspect of our PCB manufacturing needs. They strive to make our R&D work easy and hassle-free.

How do they do that?

PCBWay is NOT a broker. That means that they do all manufacturing and assembly themselves, cutting out all the middlemen, and saving us money.

PCBWay’s online quoting system gives a very detailed and accurate picture of all costs upfront, including components and assembly costs. This saves a lot of time and hassle.

PCBWay gives you one-on-one customer support, that answers you in 5 minutes ( from the Website chat ) , or by email within a few hours ( from your personal account manager). Issues are really resolved very quickly, not that there are many anyway, but, as we are all human, it is nice to know that when a gremlin rears its head, you have someone to talk to that will do his/her best to resolve your issue as soon as possible.

Find out more here

Picture Gallery

Multipurpose USB UART Module

USB-to-Serial converters are some of the most used modules on my bench. I have quite a few of them, most of them are the cheap online type that can be had for a few dollars.

As part of my new project, where I am seriously looking for an alternative chip to replace the ATMEGA328, which has become almost impossible to get, and super expensive when you do get it, I needed to get hold of a UPDI programmer.

There are many available online, from cheap to more expensive, but I wanted to build my own, as it did not seem too difficult to do.

As another part of my daily tasks, I also use a lot of ESP-type chips, which have a particular procedure to upload code via an external serial adapter.

The idea was thus to design a USB UART module that has multiple purposes, as well as being easy and cheap to assemble.

  • Be able to program ATMEGA328 Chips via Serial
  • Be able to be used as a standard USB-to-UART adapter
  • Be a UPDI programmer
  • Have a selectable target voltage between 3.3v and 5v
  • Have all modem signals (RTS, CTS, DSR, DTR) broken out.
  • Be able to auto-flash and reset an ESP32 or ESP8266 device, or similar
Breadboard Prototype Multipurpose USB-to-UART/UPDI Programmer

What is on the PCB?

The PCB is powered by the PC USB port. The target device voltage is selectable between 3.3v and 5v. The device mode can be changed from UART to UPDI mode with a jumper. An additional header specifically for ESP32/ESP8266 devices is provided, giving access to the FLASH and reset signals for the ESP device.

The USB to serial conversion is taken care of by a CH340G Chip, which provides all the relevant modem signals as well.

All signals, with the exception of the “RING” signal, are broken out onto the main header.

Note that there are NO status or POWER LEDs on the board. This was on purpose, as these sometimes interfere with the UPDI programming mode.

Prototype PCB – Assembled

PCB – Top
PCB – Bottom

Connecting to different devices

ESP32 or ESP8266 Devices

When in UART mode, the device can be used to upload code to an ESP32/ESP8266 automatically, similar to a standard dev board, without requiring you to press and flash and reset buttons.

This is achieved by connecting the device as follows:

UART MODULE SET to 3v
UART VCC to ESP 3v
UART GND to ESP GND
UART RX to ESP TX
UART TX to ESP RX

(Connections for Auto Upload/Reset)
UART RST ( on ESP-Flash Header) to ESP RST
UART GPIO0 ( on ESP-Flash Header) to ESP GPIO0

It will now be possible to flash and auto reset the connected ESP device from the Arduino IDE, and possibly others as well…

Arduino (Atmega 328P)

In the current version of the prototype, you have to connect it as follows:

UART Target voltage set to 3v or 5v depending on what type of board you are uploading

UART Tx to Arduino Rx
UART Rx to Arduino Tx
UART VCC to Arduino 3v or 5v ( depending on the target voltage required by the board you are flashing)
UART GND to Arduino GND

To allow for auto flash/reset on the Arduino, a 100nf capacitor is required between the UART DTR line and the Arduino Reset pin. This capacitor has NOT yet been fitted onto the PCB, as I usually use ICSP to upload these. Future versions of the PCB shall have this included.

ATMEGA4808/4809 and or ATTiny with UPDI Interface

This device is currently an LV-only UPDI programmer. Connections are as follows:

Set Target voltage on J1 of the UART/UPDI programmer.
Set The Device mode on J2 to UPDI mode

Connect VCC and GND from the Programmer to the target chip/board
Connect Programmer UPDI pin( shared with RxD) to Target UPDI pin.

General use UART for use as Serial monitor/Terminal

Set target voltage on J1
Set device mode to UART on J2

Connect VCC, GND from UART to the target device,
UART Tx to Target Rx
Uart Rx to Target Tx

Optionally connect required modem signals, RTS, CTS, DTR, and DSR as needed

Manufacturing

The PCB for this project has been manufactured at PCBWay.
Please consider supporting them if you would like your own copy of this PCB, or if you have any PCB of your own that you need to have manufactured.

PCBWay

Some Links to things used in the project

MakerIoT SMD Prototyping Breadboard
Order this PCB from PCBWay

A Soft Start Circuit Experiment

Every single project that we build needs an On/Off switch. Hardware switches are big and clumsy and can be quite expensive. Most of them also don’t look very good.

This post will be about an experiment that I recently performed, building a reliable soft start circuit, or latching circuit.

Full disclosure: I did not design this circuit. Full credit to the designer, who shall be mentioned later.

As such, This shall be about my experiences with this great little circuit, and also to show off the neat little prototype PCB that I designed and had manufactured for this experiment. It only took a few minutes to design, and even less to assemble.

The Schematic

Schematic

How does it work?

To answer this, let us look at what components are in the circuit first.
Q1 is a P-Channel Mosfet. I chose the SI2301, because that is what I had lying around.
T1 and T2 are NPN BJT transistors, I chose S8050’s here, and also tested 2n2222a’s with great success.
Other components are 3 100k pullup resistors, 1 1M pullup and an 1k dropper resistor for the indicator LED.

In the off state, R1 (100k) keeps the gate of Q1 tied to the supply voltage, thus keeping the MOSFET switched off.
T1’s collector, also connected to the MOSFET Gate, are thus pulled High, with the Base of T1, although pulled High, connected to the Drain of Q1.

Q1 is still off, so that base will be low, for now at least.

The collector of T2, is pulled up to the supply voltage via R4, and also, through the push button, to the base of T1.

The base of T2, is pulled up via a 1M resistor to the drain of Q1, and a 22uf to 47uf electrolytic capacitor to ground.

The emitters of both T1 and T2 are grounded.

When you press the switch, the base of T1 goes high, and this switches T1 on, pulling the gate of Q1 to ground, switching it on. This now pulls the base of T1 high through R2, latching it on, and keeping Q1 switched on. This also pulls the base of T2 high through R3. As T2 is now also switched on, the junction between the collector of T2 and the switch is now for all purposes a ground.

Now, when you push the switch again, the base of T1 is pulled down to ground via T2. This switched off Q1. As the capacitor on the base of T2 can now discharge, the circuit is reset, and the next press of the switch will turn it on again.

How big a load can be switched?

Obviously this depends on the rating of the MOSFET at Q1. In my experiments, a load of about 150mA was easily controlled, but more than that, started to somehow drain the cap at C1 too fast, and the circuit would reset.

This is not a problem to me, as the circuit is ideal to switch a relay, which in return can switch the main load.

What other issues did I encounter?

The SI2301 seems to have a small amount of leakage, which allowed a few millivolts to activate T1 or T2. I solved that with the addition of a 10k pulldown to ground, on the base of T1.

This does not seem to be the case with other MOSFETS, and I believe changing the value of R1 to provide a stronger pullup, might solve this issue.

Where does the circuit come from?

I found the circuit, and explanation on the excellent Youtube channel EEVBlog.
The owner, Dave, does an excellent job of explaining how this works. All credit to Dave for this excellent circuit!

It has zero current consumption in the off-state, and very little when on.

Manufacturing

The PCB for this project has been manufactured at PCBWay.
Please consider supporting them if you would like your own copy of this PCB, or if you have any PCB of your own that you need to have manufactured.

PCBWay

Conclusion

I believe this is a great little circuit to keep around, with many excellent use scenarios. It does need a bit of fiddling to get to work perfectly every time ( as you can use many different P Channel Mosfets and NPN BJT transistors)

It provides an excellent alternative to a mechanical switch, and for my own use, the PCB Module is small enough to be mounted into an enclosure with another project with ease.

8Ch NMOS Breakout Module

As a companion module to my recently published 8Ch PMOD breakout board,
I decided to do a similar PCB, but with NMOS devices instead. This opens up more possibilities for proper testing and prototyping, as PMOS and NMOS devices has different use applications, and most importantly, can sometimes even be combined for a particular purpose, like an H-Bridge motor driver, for example.

8Ch NMOS Breakout

What is on the PCB?

As NMOS devices function quite differently from their PMOS counterparts, it did not make sense to reuse the PMOS board, and just change the devices… although some people may be tempted to think you could…

The N Channel Mosfet basically “works in mirrored mode” from a P Channel one, and is used to do so-called ” LOW Side switching” which means that your load connects to the positive power rail, and then to the DRAIN pin of the MOSFET, with the source being connected to ground… ( It can sometimes also be used the other way around… but lets not go there now….

The current prototype PCB contains 8 BSS138 NMOS Mosfets, in my case, with is capable of about 800mA of current… All source pins are internally connected to ground. This forces you to use this module as a low side switch…

Two 10-way 2.54mm headers are provided, with a ground pin on Pin 1 and 10 of each of these.

The Drain pins of each NMOS device is available on the top header, labeled D1 through D8, and the Gate pins of each respective NMOS device is available on the bottom header, labelled G1 through G8.

Each gate has a pull-down resistor to ground, to keep it from flapping around, as well as a gate resistor. In my case, I selected to use a 10k pulldown, and a 1k gate resistor, as that is sufficient for my general needs…

Each NMOS device also has a LED signal indicator, to assist in visual confirmation of a specific channel’s state.

PCB Top Side

The Schematic

Schematic

Using the breakout

The module is very easy to use, and as briefly mentioned above, you are only required to connect one side of your load to the positive supply rail, and the other side to the drain pin of your choice.

Connect the ground pins of the module to your ground rail.

The Gate pin, with a corresponding number to the drain you have selected, can now be connected to your GPIO of choice on a microcontroller.

Drive the pin High to switch on the load, drive it log to switch off. Easy.

Please note: While the NMOS devices used on the board can handle quite a lot of current, (800mA in the case of the BSS138), it is not recommended to try and pull too much current through a single channel. The PCB traces can safely handle about a maximum of 300 to 400mA per channel.

PCB Bottom

Manufacturing

The PCB for this project has been manufactured at PCBWay.
Please consider supporting them if you would like your own copy of this PCB, or if you have any PCB of your own that you need to have manufactured.

PCBWay

Example code for using the breakout (Arduino)

// Example code for 8Ch NMOS breakout
int Gate1 9;
int Gate2 10;

void setup() {
  // drive the two gate pins low to ensure NMOS devices
  // are in a positively known state at startup
  digitalWrite(Gate1,LOW);
  digitalWrite(Gate2,LOW);
  // Set gpio to output mode
  pinMode(Gate1,OUTPUT);
  pinMode(Gate2,OUTPUT);

}

void loop() {
  // Toggle the two channels in an alternating pattern
  digitalWrite(Gate1,!digitalRead(Gate1));
  digitalWrite(Gate2,!digitalRead(Gate1));
  delay(1000);  

}

8-Ch P-Mos Breakout

While prototyping our projects, we Makers often need to interface devices with a higher current draw, like motors, or RGB lights, to our microcontrollers. These typically are unsuitable for connecting directly to an Arduino, ESP32 or Raspberry Pi’s GPIO pins. This is usually the time when we start grabbing transistors or MOSFETs.

While I normally keep a few leaded transistors and MOSFETs in the lab, These are not always convenient to use, as they may be in big packages or have the wrong specifications for the task that we are trying to perform.

SMD versions are more common in my lab, but they come with the problem of being small, and also completely unfriendly to the breadboard environment.


I have thus been playing with an idea to make a series of dedicated breakout boards for just this purpose. Having an easy way to test a specific MOSFET for a design, and having more than one of them handy, without all the wiring issues, and using the bare minimum of those DuPont wires!

I came up with the following prototype, which, while not completely optimised yet, already makes things easier. The breakout board provides 8 P-Channel Mosfets, with a single source connection, and individually broken-out Drain and Gate pins.

LED indicators on each channel provide a visual indication of the status of each P-Mos device, and the breakout can also be mounted directly into an enclosure if needed.

What is on the PCB?

Each channel comprises a P-Channel Mosfet, in this case, a SI2301, which has a suitably low gate voltage, a pullup resistor on the gate, to keep it from floating, a status-indicating LED and a current-limiting resistor for the LED.

No gate resistor was added, as this would change depending on the actual MOSFET, as well as the microcontroller that you use. The Gate pullup resistor can also be left unpopulated, in case you need to do something specific there.

Two rows of 10-way, 2.54 header pins are at the top and bottom of the PCB, to make using the breakout on a breadboard possible.

The Pinouts are as follows

H2 – Top V+ D1 D2 D3 D4 D5 D6 D7 D8 GND
with Dx corresponding to the Drain pin of each MOSFET. All the Source pins are internally connected together, as I assumed that I will use the same source voltage on each channel anyway.

H1 – Bottom V+ G1 G2 G3 G4 G5 G6 G7 G8 GND
with Gx corresponding to the gate pin of each MOSFET.

V+ and GND for each header is internally connected, to make it possible to supply V+ and Gnd on any of the two headers.

PCB Top Layer

The Schematic

Schematic

Using the Breakout

Using the breakout is straightforward. Connect a source voltage to either of the V+ pins and Ground to either of the GND pins. ( the ground is used internally for the status LEDs)

Connect your load, with the positive to a drain pin, let us say D1, and the load ground to your breadboard, or power supply ground. Connect the corresponding gate pin, in our case G1, to the microcontroller pin of your choice, through a suitable gate resistor, and pull it high at setup, to ensure that the MOSFET stays off. Pull low to activate as needed.

Please note that you should not try to switch excessively large currents through a single MOSFET Channel, as the PCB traces can realistically only handle approximately 300 to 400mA per channel.

Note 2: If you are driving an inductive load, it is considered good practice to add a flywheel diode on the load as well. This will protect the MOSFET from back EMF when the MOSFET is switched off.

PCB Back

Manufacturing

The PCB for this project has been manufactured at PCBWay.
Please consider supporting them if you would like your own copy of this PCB, or if you have any PCB of your own that you need to have manufactured.

PCBWay

Example code for using the breakout (Arduino)

// Declare Gate driving GPIO pins
int gate1 = 10; 
int gate2 = 11;


void setup() {
// Set the GPIO pins as outputs and drive them HIGH
// This keeps the channels switched "OFF"
  digitalWrite(gate1,HIGH);
  digitalWrite(gate2,HIGH);
  pinMode(gate1,OUTPUT);
  pinMode(gate2,OUTPUT);

// Writing to the GPIO's before setting their pin Mode,ensures that the
// GPIO's are in fact initiated in a know correct state.

  Serial.begin(115200);

}

void loop() {
// In the loop, we just toggle the GPIOs, thus
// alternatively switching the channels on or off
  digitalWrite(gate1,!digitalRead(gate1));
  digitalWrite(gate2,!digitalRead(gate1));
  delay(1000);
  }

Redesigning my MCP23017 breakout

In a previous post, I designed a breadboard-friendly MCP23017 breakout module. A few months have passed, and after using the module for a while, some issues came to light…

In this post, I will show you how I have fixed those issues, and then I can continue testing/using the new generation prototype, and hopefully, it can become the final revision of this project.

Old Versus New

Let us start by looking at the old and new PCB designs…

Old style MCP23017 Breakout – Top view
New style MCP23017 Breakout – Top view

There will not be a lot of obvious differences at first, but if we look closely, here are the changes:
– In the old version, due to the size of the SOIC28 footprint, I had to place the bypass capacitors, as well as I2C pullup resistors on the bottom layer of the PCB.

  • The new design, using the more readily available ( at least where I live) SSOP28 footprint, leaves enough space for these components on the top layer, thus resulting in a mostly single-layer layout, with only a few tracks on the bottom layer.
  • I2C pull-up resistors can now be controlled by a jumper, enabling or disabling them completely… This helps when adding a few devices to the I2C bus, and rather having the pull-up’s close to the MCU ( as is generally recommended anyway )
  • Other cosmetic changes involve the separation of the data ports (A and B) from the interrupts, reset, Vcc and ground pins. On initial testing of this on a breadboard, it makes using the device a bit easier, and access to the io pins faster. ( In my biased opinion anyway )
MCP23017 Breakout Module
MCP23017 Breakout – New version

Pinouts and connections

I have tried to make all the connections easy to find and use, with the IO ports ( A and B) on opposite sides of the breakout, Numbered A7 to A0 on the top, and B7 to B0 on the bottom.
VCC, GND, SCL and SDA are on a separate 4-way header pin, with the two interrupt pins (I-A and I-B) together with the reset (RST) pin on a 3-way header opposite the power and signal header..

Addressing pins are in the centre of the PCB, marked with a 2 1 0 ( for AD2, AD1, and AD0 respectively), Jumpers to the bottom ( towards port B) pull the pins to ground, where the opposite side will pull the address pins high.

To the right of that, another 3-way jumper enables or disables the I2C pull-resistors on the module, which in this case is set at 4k7.

Manufacturing

The PCB for this project has been manufactured at PCBWay.
Please consider supporting them if you would like your own copy of this PCB, or if you have any PCB of your own that you need to have manufactured.

PCBWay

Some More Pictures

Dual 555 Latching Switch Module

In a recent post, I looked at a single-channel version of this module. While it may be a repetitive post, I will continue, as it shows how easy it is to double up on this circuit to provide more than one latching switch on a single circuit board. The current drawn by this module is so little, even when energised, that it compares favourably with even a microprocessor-controlled solution.

The real advantage will obviously be the cost, as the hand full of discrete components needed for this is way cheaper than a microprocessor alone, and the fact that it doesn’t need any coding makes for an attractive solution.

It is however worth noting that the circuit is quite sensitive to external interference, sometimes resulting in unwanted operation. This does not concern me too much, as 1) This is still a prototype and 2) While it does work as intended, and surely is quite useful, I do not intend using it to switch any high current load, or control any expensive or important equipment.

Since the previous post looked at the base circuit in detail already, I think it will be a good idea to talk a bit about electrical isolation, tracking and keeping the AC and DC sides of a circuit separated completely

In the picture above, we can clearly see that the DC side (near my hand, at the top is contained completely on the right side (top in this case) of the PCB. The hashed copper pour also stops clear of the two relays. There are only four tracks
going to the relay coils, and they are all on the same layer of the PCB.

Also note the square cut-out slot around the common terminal of each of the relays. This provides additional isolation to the relay, as well as the DC side of the circuit, as air is a very good insulator ( at least for 220v at no more than 10A — or so I was taught …) These cutouts will prevent any mains voltage of tracking, think burning towards, towards any other tracks in this area.

The entire left-side top layer ( underneath the relays) are also completely free of copper, to make tracking even more difficult.

If we now look at the bottom layer of this same PCB, we will see that the DC side and its ground-plane are once again completely separated from the relay contact terminals. Also note that the tracks connecting the screw-type connector and the relay terminals are very thick (100mil), straight and as short as possible. All copper around these tracks has also been etched away, further reducing the chances of tracking.

In a production PCB, Warning labels would also be present in the bottom silkscreen of the PCB in this area, warning the user of the possibility of mains voltage in this area. As this is a prototype, and to make the above-mentioned points easier to see, I have not added these labelling on these boards.

Important Disclaimer:
Electricity is NEVER “SAFE”. There are only safe practices and procedures. It is always the responsibility of the user to ensure their own safety. While the design shown above is considered “SAFE” by myself, I only consider it “SAFE” because I am aware of the risks involved in using such a circuit to switch mains voltage, at a certain current, and under a specific use scenario. DO NOT BE FOOLED into simply replicating this circuit, or parts of it, and believing it is “SAFE”. Every use case of a circuit is different, and the devices connected and controlled by it will always differ. Make sure that you ACTUALLY know what you are doing BEFORE using any High voltage/Current and switching it with any electronic device.

Manufacturing

The PCB for this project has been manufactured at PCBWay.
Please consider supporting them if you would like your own copy of this PCB, or if you have any PCB of your own that you need to have manufactured.

PCBWay

Some More Pictures