Sunday, 9 March 2025

MEGAphone Fabrication of the first module PCBs

I've been busy working on the schematic and PCB design for a bunch of the modules for the MEGAphone lately.  The first batch of those I had sent off for fabrication by PCBWay, and they have finally arrived. So let's have a look at what we have:

Well, that's a bit hard to see what's going on, so let's look at each in turn. My lighting here isn't that great right now, but it should be enough that we can identify each PCB from it's packing label.

First we have the audio jack PCB:

Then the high-efficiency DC:DC converter:
The Audio Codec board:
SIM and SD-Card carrier:
Cellular modem carrier:
MPPT Battery Charger board:
Low-current DC:DC converter module:
And finally, the MEMS microphone carrier board.

 So let's look at where this gets us to in terms of the milestones:

Milestone 2.1.2 High-efficiency DC-DC converter module to power the various sub-systems: Schematic -- done -- see https://c65gs.blogspot.com/2025/02/megaphone-2a-dcdc-converter-module.html and https://github.com/MEGA65/megaphone-modular/tree/main/modules/high-efficiency_dc-dc_converter

Milestone 2.1.3 High-efficiency DC-DC converter module to power the various sub-systems: PCB Layout -- done -- see https://c65gs.blogspot.com/2025/02/megaphone-2a-dcdc-converter-module.html and https://github.com/MEGA65/megaphone-modular/tree/main/modules/high-efficiency_dc-dc_converter

Milestone 2.1.4 High-efficiency DC-DC converter module to power the various sub-systems: PCB Fabrication -- done -- see the photos above.

Milestone 2.3.2 Battery management and energy harvesting module to allow USB-C, integrated solar and external 12/24V vehicle battery power sources, and efficient management of the integrated rechareable battery: Schematic -- done -- see https://c65gs.blogspot.com/2025/03/megaphone-battery-management-and-energy.html, https://github.com/MEGA65/megaphone-modular/tree/main/modules/battery-connector, https://github.com/MEGA65/megaphone-modular/tree/main/modules/input-power-selector, https://github.com/MEGA65/megaphone-modular/tree/main/modules/usb-c-power-in, https://github.com/MEGA65/megaphone-modular/tree/main/modules/solar-and-dc-connectors, and https://github.com/gardners/mppt-charge-controller/tree/8d80fb90b56f2cbbb3eda396a8fb4dab4cb2aabd

Milestone 2.3.3 Battery management and energy harvesting module to allow USB-C, integrated solar and external 12/24V vehicle battery power sources, and efficient management of the integrated rechareable battery: PCB Layout -- done -- see https://c65gs.blogspot.com/2025/03/megaphone-battery-management-and-energy.html, https://github.com/MEGA65/megaphone-modular/tree/main/modules/battery-connector, https://github.com/MEGA65/megaphone-modular/tree/main/modules/input-power-selector, https://github.com/MEGA65/megaphone-modular/tree/main/modules/usb-c-power-in, https://github.com/MEGA65/megaphone-modular/tree/main/modules/solar-and-dc-connectors, and https://github.com/gardners/mppt-charge-controller/tree/8d80fb90b56f2cbbb3eda396a8fb4dab4cb2aabd

Milestone 2.3.4 Battery management and energy harvesting module to allow USB-C, integrated solar and external 12/24V vehicle battery power sources, and efficient management of the integrated rechareable battery: Fabrication -- done -- see photos above

Milestone 2.4.2 Cellular modem communications module, including SIM card module: Schematic -- done -- see https://c65gs.blogspot.com/2025/02/megaphone-sim-card-sd-card-module.html, https://c65gs.blogspot.com/2025/02/megaphone-cellular-modem-module.html, https://github.com/MEGA65/megaphone-modular/tree/main/modules/cellular-modem, https://github.com/MEGA65/megaphone-modular/tree/main/modules/sim-and-sd-card

Milestone 2.4.3 Cellular modem communications module, including SIM card module: PCB Layout -- done -- see https://c65gs.blogspot.com/2025/02/megaphone-sim-card-sd-card-module.html, https://c65gs.blogspot.com/2025/02/megaphone-cellular-modem-module.html, https://github.com/MEGA65/megaphone-modular/tree/main/modules/cellular-modem, https://github.com/MEGA65/megaphone-modular/tree/main/modules/sim-and-sd-card

Milestone 2.4.4 Cellular modem communications module, including SIM card module: Fabrication -- done -- see photos above

Milestone 2.5.2 Internal microphone and speaker module: Schematics -- done -- see https://c65gs.blogspot.com/2025/02/megaphone-mems-microphone-module.html, https://c65gs.blogspot.com/2025/02/megaphone-audio-codec-speaker-driver.html, https://github.com/MEGA65/megaphone-modular/tree/main/modules/mems-microphone, https://github.com/MEGA65/megaphone-modular/tree/main/modules/audio-codec

Milestone 2.5.3 Internal microphone and speaker module: PCB Layout -- done -- see https://c65gs.blogspot.com/2025/02/megaphone-mems-microphone-module.html, https://c65gs.blogspot.com/2025/02/megaphone-audio-codec-speaker-driver.html, https://github.com/MEGA65/megaphone-modular/tree/main/modules/mems-microphone, https://github.com/MEGA65/megaphone-modular/tree/main/modules/audio-codec

Milestone 2.5.4 Internal microphone and speaker module: Fabrication -- done -- see photos above

Let's see how this looks on the block-diagram, to get a sense of the overall progress represented by this work:



Not bad -- and as we can see, some of these modules are reused in multiple places, so we have knocked off most of the orange boxes, too.

The main difference between what was planned and how I have progressed is that I've tended to further break down some of the modules, to make their designs simpler.

From here, I'll decide whether the next step is to assemble these modules, or whether I'll do the PCB design for more of the remaining modules on the schedule. Probably a mix of the two.  Certainly I can prepare the bill of materials for each of the modules I've already designed, and order those parts ready for assembly, since they will take a week or so to arrive, in any case.

Wednesday, 5 March 2025

MEGAphone Battery Management and Energy Harvesting Module

This post has turned into a bit of an epic, as it turned out to have a couple of modules (solar MPPT tracker and prioritised power input selection and over-voltage and reverse-polarity protection) that took quite a bit more effort to get right.

So, we have a DC:DC regulator. Now we need a way to get energy into the battery. This module has a few more requirements, because of the different energy sources we intend to support. 

1. Requirements Analysis

There are also a few requirements that we have to keep in mind, even though this module isn't directly responsible for satisfying them (in italics):

Requirement 1.1.2.3: Proof-of-concept charger module based on a given USB-C power delivery module (no need for data).
Requirement 1.1.2.4: Power isolation mechanism to allow conflict-free operation of the USB-C and alternative power inputs to the MEGAphone (back-flow and over-voltage protection, for example)
Requirement 1.1.1: Integrated LiFePO4 or other similarly safe and robust chemistry battery cell.
Requirement 1.1.2.1: Integrated battery capacity of at least 30Wh.
Requirement 1.2.2.1: Means of accepting (including connector) dirty DC power between ~9V and ~40V using a MPPT to maximise efficiency with a solar panel.
Requirement 1.2.3.1: Means of accepting DC power from integrated solar panel at input voltages of 2V to 20V with a MPPT.

So, we have to accept power from USB-C, solar, and "dirty DC" -- which itself might be a solar panel. I'm going to break this down into several modules, to make my life easier.

Requirement 1.2.3.1 is a bit annoying, because the 2V I have specified is not commonly supported. We can resolve this problem by using readily available panels that have a nominal voltage of 6V, e.g.:

https://core-electronics.com.au/0-5w-solar-panel-55x70-seeed-studio.html

Those 55x70mm panels are 0.5W, and have a nominal voltage of around 6V. It should be easy enough to tile four of those on the rear, to give about 2W solar charging capacity on-board. Those could be put in two parallel strings of 2 panels to yield ~12V.

But remember that we also want to support external panels that might have higher voltages. Ideally, we'd allow upto ~40V, so that this module could also accept power from automotive sources.

So let's now look at the options for MPPT ICs. We don't need high current output, as the battery is only 30Wh, and charging in 1 hour would require 10A, so probably "a few Amps" would be tolerable -- but if we can, I'd like to support fast charging in an hour or two if a high-current source is available.

These various requirements make the design of this module more complicated.  Fortunately, I'm not the first (or last) person to want to do this kind of thing.

For example, there is this video and github project for exactly the kind of thing I want:

https://github.com/bytesizedengineering/mppt-charge-controller

It's even been designed using KiCad, which means I can adapt it easily. I hadn't planned on putting a little display to show the battery charge state, but I can always leave it off -- or if space and topology of the boards allow it, I could still include it.

The unit itself is fairly small. It does use an ESP32, which is possibly a bit of an over-kill, but if that's the cost of making this module more quickly, then it's probably worth it, as this is one of the most complex modules that I'll need to design.

I'd likely still redesign the board to fit the castellated module system, but that would be the only change I'd make, to minimise risk, I think. Oh, except that I'll also need to change the battery charger part of it to handle a single-cell LiFePO4.

That project uses a BQ24650, which does apparently support LiFePO4 cells. The battery charge voltage is set through a voltage divider:

This makes it super simple to change the output voltage of the charge circuit. The question is what voltage to charge to.  

ChatGPT claims that 3.6V should be ok, but may lead to damage over time if that voltage is held after the battery fully charges. 3.45V -- 3.55V on the other hand should allow the battery life to be much greater, but at the loss of ~10% of the battery capacity. 

As we are using a 10Ah LiFePO4 cell with a capacity of ~36Wh, that would still leave us >30Wh, which is above our requirement, so it sounds like a good trade-off. 

Looking at the schematic and ESP32 firmware, it also looks like it is possible for the ESP32 to be able to turn the charger off, and also to measure the battery voltage. Thus I could in a later version update the ESP32 firmware to do that, and then allow charging to the 3.6V 100% level.  But we don't need to for now.

So back to the R2 & R1 calculation, we want V_BAT=3.5V, so:

3.5V = 2.1V x ( 1 + R2/R1)

Thus 1+ R2/R1 = 3.5V / 2.5V = 1.4.

Keeping R1 at 100K in the module, we just need to change R2 to 140K. That's a standard size, so no problem there.

Otherwise the only requirement adjustment forced on us by this module is the maximum input voltage is ~28V, rather than 40V. This means that while we could easily accept 12V car power and 20V USB-C power, we couldn't safely accept 24V truck power, as the voltage on trucks typically peaks around 30V. It's pretty close, and I suspect that it would work in practice. So we'll live with it. 

2. Requirement Variations

So let's summarise our requirements relaxations that we have applied:

Relaxation of Requirement 1.2.2.1: Maximum input voltage reduced from 40V to ~28V.
Impact: (1) 24V truck systems may peak out of range when alternator charging. (2) Some larger solar panels may be out of spec. However, given the ~30Wh battery size, this should not be a problem. Impact acceptable.

Relaxation of Requirement 1.2.3.1: Minimum solar panel input voltage increased from 2V to 6V.
Impact: Some very small panels, especially those consisting of few cells in series, no longer in specification.  However, small panels (eg 55x70mm) are readily available with 6V MP voltages. Thus the impact is acceptable.

3. Solar MPPT / Dirty DC Input & Battery Charger Module

Those changes to the requirements have been recorded in the repository, so now we are good to go with adapting the module to fit one of our modules.

Let's list our planned changes:

1. Change board outline to appropriate sized castellated module.

2. Add castellated pads for VBAT and GND_BAT. This will be how battery power reaches the rest of the system.

3. Route ESP32 UART RX and TX to castellated pads to allow querying and control of the module in the future (e.g., to ask battery charge level, and charge system status).

4. Route 3.3V rail from charge source (not from the battery) to castellated pads, so that any galvanic isolation for the UART can be powered from the charge source, so that when there is no charge source, the MPPT charger is fully depowered, so that it doesn't discharge the battery.

5. Route LOAD_ENABLE and VCC_LOAD pins to castellated pads, to allow for a switchable load at VBAT. Not sure that we will need to make use of these, but it seems silly to not make them available.

6. Route charge source voltage to castellated pads instead of a terminal block.

I think that's it -- It really is a testament to Bytesizedengineering in their design of this module, that it has pretty much everything that I need (and then some).  I was hoping to find something like this, as it is saving a lot of time and trial-and-error.

We will, however, also need another module to address Requirement  1.1.2.4. It looks like the LM74700-Q1 with an external MOSFET is a good approach here, as they have losses of only ~40mW on input, and disconnect the power source when current tries to flow in the reverse direction. We'll need one for each input, so three replicates of that module, which is fine -- it's another advantage of the module based approach.

Okay, so that's everything we need to know right now, and I can dive in to adapting the MPPT tracker... except that I need to update KiCad first, because it was created using a newer version.

A week or so has passed, and a few things have happened in the meantime:

1. Zach, the author of the module I am looking to adapt kindly replied to my email asking about licensing of his design, and has indicated that it's GPLv3, which is good, because that's what I'm using for this repo as a whole.

2. Zach also indicated that it has some bugs and problems. I'm hoping to learn a bit more about that, so that I can update the module if necessary. But for now, I'm working on the assumption that it works well enough for what I need.

3. I've implemented a tool that can procedurally generate my castellated module footprints and symbols for KiCad.

So now I can easily play around with what size module I think I need, and if it turns out wrong, or has the wrong number of pins, I can easily generate a new one.

Okay, so I'm making some progress, and currently trying to work out how the power supply to the various ICs on this module work.  There are several, and they need 3.3V, but I can't yet see where that comes from. Ah, it comes from the AP63203 that is powered from the input source, i.e., the ESP32 and friends will only power on if there is a DC source. So that's good.

Then as I've dug deeper, the ACS712 current sensors seem to need VCC=5V, not the 3.3V they have been given in the design. But it seems that people have found them to work with VCC=3.3V. Resolving this is tricky, as it will output a signal of up to VCC, so giving it 5V will mean I need to add a level converter. Conversely, feeding it on VBAT will mean that it can go below 3.3V. But as it's only a current sensor for power input and charge output, maybe that's tolerable: It will only be able to mis-behave if VBAT is too low, but we can measure VBAT directly on the ESP32, so if VBAT is low, but the ESP32 is on, we can just make sure the ESP32 firmware tries to charge the battery in that case.

The ACS712 might be interesting to have elsewhere in the system, because it would let us measure the current draw from the battery to monitor power better, but that can wait.

So back to this module: The ACS712 can be powered from VBAT in the first instance, and if it proves to be a problem, I'll deal with it. I'll route the VCC lines for the two ACS712s to a pad on the module, so that this can be done off-module if required.

The ACS712 comes in 5A, 20A and 30A sensing versions. With VCC=5V, the 5A version will reach 3.3V on its output only at >= 4A, while for the 20A version it will be > ~7A, or for the 30A version > ~12A. So one option is that we just make sure that the thing never gets more than that level of current fed into it. But that's hard to force.  But we could just put a 3.3V Zener diode to clamp the voltage at 3.3V, to make sure that the ESP32 doesn't get fried.

For the battery charge current side, we can set the charge current limit using RSR1 according to the BQ24650 charge controller's datasheet. If we limit it to 4A, then we will keep the ACS712 sensing the battery charge current <= 3.3V, which avoids the need to clamp the output of that ACS712.

Now, because the LiFePO4 battery is ~3.6V max, and assuming that the BQ24650 isn't horribly inefficient, and that it requires an input voltage on the panel/DC source >5V, then the current flowing through the input ACS712 must be lower than that of the output one. And if the output one is safe at 4A, then the input one will be, too.

So all up, this means that we can charge the battery at up to 4A, for a total charge time of ~2.5 hours in the ideal case, without needing to clamp the outputs of the ACS712.  That would correspond to a charge rate of 4Ax3.5V = 14W, which feels good enough.

So the question is whether we need to provide a 5V supply for those ACS712's, or just take the chance with 3.3V.  I could add an AP63205 to provide the 5V that they need. Hmm... Let's just follow the Wisdom of the Internet (tm) and run them on 3.3V, but provide a separate pad for their VCC, so that by default we can connect them together, but can separate them and provide an external 5V source if required.

I've spent the last few hours mashing everything around to fit in the module, and then dealing with design rule violations in KiCad, to make sure that I haven't messed anything up. There were a lot related to silkscreen stuff, a few of which are hard to resolve due to components with pads that intersect their own silkscreen elements. But there are less than a dozen of those now, so I can easily see if there are real problems.

Here is how it looks now:

The large oval and hole-throughs is for the ESP32 module that it uses.  This also means that we need to use the cut-out to allow the hole-through pins of the ESP32 to clear the carrier board PCB. In other words, the ESP32 will sit up above the carrier board, rather than just having components in the cut-out behind the module (though it has a few components on the reverse side, too).

The presence of components on both sides of the board will make it a bit trickier for me to assemble.  I'll likely reflow the main component side using a hot plate, and then hand-solder the small number of components on the rear-side. If I got a fancy reflow oven I could use high-temperature solder for the components on the main side, reflow that, and then flip it over and use a lower-temperature solder for the reverse side and reflow that below the melting temperature of the solder on the main component side, so that nothing falls off.

But before I am ready to send the board off for fabrication, I want to do my usual thing of adding component values and part names to as many of the SMD components as possible, to make it easier to field repair or scavenge for parts in the future.

In the process of that, I have found that there was no part number identified for the dual-MOSFET. It looks like one of these should work.

Okay, noted that, and added all the silkscreen annotations. Hopefully I haven't missed any. Here is the result:


4. USB-C Charge Input Module

So the next cab off the rank for this one, is the USB-C charge input module. I'm planning to use the cheap-off-the-shelf USB-C Power Delivery Boards available everywhere online, e.g.:

https://www.amazon.com.au/Type-C-Trigger-Module-Supports-Output/dp/B08LDJBN8P?th=1

https://www.aliexpress.com/item/1005005592678176.html 

https://www.aliexpress.com/item/1005005825523151.html

https://www.aliexpress.com/item/1005005624948801.html 

The exact layout of these modules seems to change with the day of the week, and the ones I have here look similar but not identical to any of those.  This includes the exact positioning of the power output pads, which is really annoying. 

The ones I have here are 11x17mm, with 1mm extra over-hang for the USB-C connector. But I've seen others as large as 13x27, so I should probably try to make the module allow for this variety in size, even if the actual module I design takes only the exact model I found.  As there are no other parts on the module, it won't be hard for people to redesign.

Importantly, they aren't even standardised on whether the + and - terminals are on the left and right. So apart from making the module big enough, there's no real point in me trying to make it accept the different flavours of these things.  But even so, I'll do something fairly simple, in that I'll make the pads for it long and wide, so that some random selection of these things will work on it. They all have hole-through for the power out, which can be fairly readily tacked down onto tinned pads on the module, so the pads on the module don't need to be precisely placed.  I'll go over this more when I get it fabricated and assemble it using the modules I have here.

So apart from the topological angst, this module is super simple, as it only needs two pins: Power out and GND. There really is nothing more to it, and this is the result:


On the PCB layout the huge pads I have created are quite obvious. The white guide lines on the silkscreen are there to help get the module correctly centred and straight, so that if the USB-C port has to fit through a hole in a case, it can be lined up easily. 


This actually brings up an important point for these castellated modules, in that the ones with connectors on the edge of the PCB have to be positioned accurately on their carrier. In practice this probably is easiest done by inserting the edge connector through the case with the carrier board under it, and then solder tacking one or two pins down, or failing that, taping them together, so that they stay in relative position during soldering. If doing it that way, I'd strongly recommend soldering just one pin, and then making sure it's still correctly positioned while it's easy to deal with.

5. Power Source Isolation Module

I thought I had written up some notes somewhere on how to deal with this elegantly. But apparently not. Anyway, the problem boils down to accepting power via USB-C, the solar/dirty power input (6V -- 30V) or the internal solar panel as fall-back.

After having a chat with ChatGPT about it, it looks like something like the https://www.analog.com/media/en/technical-documentation/data-sheets/ltc4417.pdf might be a good option -- it allows selection between three power sources, with separate under and over voltage thresholds for each, including prioritisation. It accepts inputs from 2.5V to 36V, so that all sounds good so far. Let's look at a typical application for this IC:


So basically the IC senses the input voltages, and then picks which external set of MOSFETs to turn on. It also provides output signals that let something else check which voltages are currently valid, and thus allow it to infer which source is being used.  This will be handy for indicating charge status, and showing the user which source is being used for charging, and which other source(s) could be used for charging if required.

The IRF7324 MOSFETs that they recommend are a problem, however, as their breakdown voltage is only 20V. We need >30V, ideally >40V or higher, just to make sure.

The datasheet recommends the Si4909DY as an alternative when higher maximum voltage is required. So we should probably use that.

We do have another problem, though, in that if the input voltage spikes, e.g., from automotive power sources, then we can still fry things.  A Transient Voltage Suppression (TVS) Diode can help us with short spikes, by routing them straight to GND. For longer duration spikes (and also for the shorter ones) we might want to have an N-channel MOSFET that we activate when we are over-voltage via the Zener.

For example, to keep the MPPT charger comfortably below 28V, we could use a BZX55C27 with a 10K resistor to provide 0.1mA of current to switch an N-channel MOSFET to clamp the power rail to GND, which would then cause excess current to flow, while also reducing the output voltage until something like a PPTC self-resetable thermal fuse kicks in and reduces the voltage and current that passes through it.

We should only need all that on the dirty DC / external solar input, as USB-C is well-behaved, and the internal solar panel has an open-circuit voltage <10V.

So let's start piecing the schematic together for this. I've laid out the schematic with the MOSFETs and the selector IC. But I need to work out the resistor values for the selector logic. I also need to make sure that the priority order is right. I can safely use the same resistors for all three, allowing 5V to 28V. That said, increasing the minimum voltage for the dirty DC a bit might make sense, if it is using a large panel, and gets pulled down to 6V or so, it might not be very efficient. But I think I'm overthinking things. Also, there is great advantage in having common resistor values to ease assembly etc.

The under and over voltage comparators compare to 1V, so we need a resistor ladder that results in V_UV = 1V @ 5V, and V_OV = 1V @ 28V. I ended up messing about with a little spreadsheet to find values that are close enough. It looks like R3 : R2 : R1 = 246 : 51 : 11 gets us V_UV = 1V @ 4.97V, and V_OV = 1V @ 28V exactly. So let's scale those up. 246K, 51K and 11K are all common values, so we'll simply use those.

So this is what this part looks like:


 

So that's that part. Let's now turn our attention back to the input spike protection on the dirty DC. We can use a Zener diode to detect when the input voltage goes >28V. If we then put a resistor below the Zener, we can feed its output into the gate on a Thyristor, which is a bit like a sticky MOSFET transistor. It we put the Thyristor between the input voltage and GND, it will crow-bar the input rail to GND if the input voltage climbs above 28V. A pull-down resistor on the Thyristor's gate will help prevent it triggering erroneously.  If we then put a PPTC resetable fuse in place, when the Thyristor triggers it will activate, and everything should come to a grinding halt, instead of letting the smoke out.

For the Thyristor we can use one of these https://www.digikey.com.au/en/products/detail/stmicroelectronics/TN5015H-6G-TR/7598651, and for the Zener diode one of these https://www.digikey.com.au/en/products/detail/diodes-incorporated/SMAJ28CA-13-F/765424

Okay, except that this idea has a problem: The resetable fuses have a really slow activation time -- like ~30 seconds. So instead let's look at having an N-Channel MOSFET that allows the power in normally, then use the Zener diode to develop a gate voltage to switch the MOSFET to isolate the power from the thing. Then we just need to have a Zener and MOSFET that have the maximum voltage tolerance possible.

We can use a beastie like this: https://www.digikey.com.au/en/products/detail/infineon-technologies/IPD70R600P7SAUMA1/6579133 that can tolerate 600V and 50A.  That one has the problem that its forward resistance is a bit high, which could cause it to dissipate several watts when 5A is flowing through it. 

A better alternative might be https://www.digikey.com.au/en/products/detail/infineon-technologies/IPF067N20NM6ATMA1/20841807 which has a forward resistance of only 6.3mOhms, and a lower gate threshold voltage (i.e., the voltage when it begins to activate) of only ~3.7V to boot. That has to be subtracted from the maximum voltage (28V) that we want to accept.

Annoyingly there is no model for the IFP067N20NM6ATMA1 in either digikey or snapeda. Did I mention that I hate having to make footprints and symbols myself? Fortunately mouser.com seems to have one.

Okay, so for the TVS/Zener diode, it looks like a SMM4F24A-TR should work. It has a threshold voltage around 24V, add the 3.5V gate voltage for the MOSFET, and it should start switching the MOSFET on to disconnect the power source at around 27.5V.

Well -- after all that, I've had to redesign it somewhat, when I realised that the MOSFET needs more sophisticated control.  I decided to try out Grok 3 Beta in the process, and was quite impressed at its ability to look at just a photo of my schematic and critique it. It wasn't perfect, but it was a considerable help at designing the MOSFET-based over-voltage protection circuit.

Here's how the whole thing looks now:


The top-half is the prioritised input selector, while the bottom left part is the over-voltage protection for the dirty DC input, so that it can handle "load dump" conditions etc on automotive power, for example, that can spike up to 60V or so. I've designed it so that it should tolerate 200V. Basically if the voltage gets near 28V, it will disconnect the negative terminal using an N-channel MOSFET.  

After that I realised that I also need to add reverse-polarity protection -- which will basically work as an inverted version of the over-voltage protection, but with a P-channel MOSFET.  But this is tricky, because P-channel MOSFETs have a higher resistance when conducting, which means more heat generation. The SQJ457EP-T1_GE3 looks possible, and would generate ~0.5W of heat when 5A flows through it, and costs less than $2.

So now it's time to lay out the PCB. Getting the components laid out is the first part, then we need to know which signals we need to expose on pins, which in this case is:

DIRTY_DC_IN+, DIRTY_DC_IN-, GND, INTERNAL_SOLAR_+, USB_C+, VOUT, /VALID1, /VALID2, /VALID3, /SHUTDOWN, ENABLE

So that's 11 pins. I'll make a module with a few extra pins, just to make sure, since it's a little bit of mucking about if I discover I need extras after -- but not too much, since I made the procedural module footprint generator.  Then we just need to know the size of the cut-out area.

Except that as I went to look at the size, I realised that I was missing a few 3D models for components, and when I added in a couple of those, I found they were either wrong, or for parts that weren't actually available. That's the peril of using AI to help design it :/  It'll be fine, but it does mean I won't get it done tonight. 

Well, it's been quite the slog, but I now have the PCB layout finalised:


 

6. Solar and External Power Connection Module

Whew! I'm glad that the remaining module for this set of requirements is super simple -- just a connector for the battery (but I'll probably throw on the connectors for the internal solar panel, as well as the external dirty DC / solar power. I'm currently undecided on the best connector for that. Maybe I'll just make it a bog-standard DC barrel jack, the same as on the MEGA65, so that you can charge the MEGAphone using a MEGA65 power supply as well. But part of me would like to have something a bit easier to adapt a solar panel onto. But probably all the good options are a bit physically big, even for the MEGAphone.

The internal solar panel will use the little 2-way connector that came with it -- if I can find any description of what it is. It's the same type and pitch as a 4-pin Grove connector I think, but just 2 pins.  I think the mating connector is a https://www.digikey.com.au/en/products/detail/jst-sales-america-inc/S2B-PH-K-S/926626.

For the DC barrel connector, I'll go for something compatible with the MEGA65 power supply, just for commonality and convenience.  While I'm at it, I might have a go again at finding the connector for my Librem 13 laptop, whose connector got damaged on a flight when someone tripped over the cable.  I emailed Purism to ask them the exact part number, since I'm sure it's an off the shelf component, but didn't ever get a response from them. I just opened the laptop up again now to check the part for markings -- but it has none. I did in the process, however, discover that it's the power supply plug rather than the jack in the laptop that is faulty -- so that's a much easier repair. 

(I also had a look at one of the USB-C PD modules I'm planning to use for the MEGAphone, and it looks like there is space enough there, if I file out the connector cutout on the case, and file down a positioning lug for the old barrel jack, and make some other retainer for it.  Tempting! But that's a squirrel that I'll be ignoring for now.)

Okay, so back to the DC barrel jack for the MEGAphone, I'm thinking a https://www.digikey.com.au/en/products/detail/tensility-international-corp/54-00127/9685436 should work.

As expected, this board was fairly quick and easy to do, because of it's simple nature:



 



7. Internal Battery Connector

This is an even easier one. We just need a 2-pin screw connector or similar to anchor the unterminated leads from the internal battery, which could be fairly fat copper.  The main nuisance is that such screw terminals are quite tall, but we should be able to accomodate them somewhere, even if we need a cut-away on the stacked PCB above it.

Something like https://www.digikey.com.au/en/products/detail/w%C3%BCrth-elektronik/691210910002/10668428 should work.



 

There really isn't much to say about this. The board is just a convenient way to mount a connector.

8. Requirements Verification

So that's the last of the boards that we need to satisfy these requirements -- but let's make sure that we have everything covered off:

Requirement 1.1.2.3: Proof-of-concept charger module based on a given USB-C power delivery module (no need for data). -- Satisfied in 4. USB-C Charge Input Module
Requirement 1.1.2.4: Power isolation mechanism to allow conflict-free operation of the USB-C and alternative power inputs to the MEGAphone (back-flow and over-voltage protection, for example) - Satisfied in 5. Power Source Isolation Module
Requirement 1.1.1: Integrated LiFePO4 or other similarly safe and robust chemistry battery cell. -- Satisfied by 7. Internal Battery Connector
Requirement 1.1.2.1: Integrated battery capacity of at least 30Wh.
-- Satisfied by 7. Internal Battery Connector (as it can take a massive battery)
Requirement 1.2.2.1: Means of accepting (including connector) dirty DC power between ~9V and ~40V28V using a MPPT to maximise efficiency with a solar panel. -- Satisfied by 6. Solar and External Power Connection Module and 3. Solar MPPT / Dirty DC Input & Battery Charger Module
Requirement 1.2.3.1: Means of accepting DC power from integrated solar panel at input voltages of 2V6V to 20V with a MPPT.
-- Satisfied by 6. Solar and External Power Connection Module and 3. Solar MPPT / Dirty DC Input & Battery Charger Module 

In short, we have covered all of the requirements with this set of five modules -- even though they are all grouped as a single module in the milestone. Oh well. At least they are done. The MPPT and power input selector and over-voltage / reverse polarity protection circuits are actually the two modules that scared me the most in this whole project, as my expertise is really in digital systems, not this analog power-electronics world.  But I guess I can't really relax until I've built them and confirmed that they work properly.

The schematics are all in the modules/ directory in the source code repository, as usual.