The SuperCapacitor UPS

All the UPS functions are performed by the LTC4041, which include a supercapacitor charger and a boost converter, plus all the ancillary circuits to make it a complete solution. The circuit is quite similar to the application note, so I will not spend time describing the inner working of the chip, but only the additions to the standard circuit.

When I developed the prototype, everything was working just fine except in the phase when the capacitors were almost discharged, (below the capture of the power supply output).

This effect was due by the internal power supply of the Raspberry which it disconnects after the input reaches about 4V, but upon disconnected the load seen from the buck converter significantly reduces and subsequently its voltage output rises, enabling again the Rasperry power supply which it would raise the load and trip again.

To avoid this lousy behavior Q5 is used to shut down the LTC4041 boost as soon as the power supply is 7.5% below a value set by the R22 and R23 resistors, which they have a double function: as feedback for the boost converter and as input for the comparator which drives SYSGD.

Using the signal SYSGD, you can drive BSTEN, which, when low, disables the boost converter, and, if the voltage of the supercapacitor is below 2.5V, the LTC4041 goes in lookout mode and prevent the boost converter from starting again. (below the power supply behavior with the Q5 working)

I extensively tested the circuit to verify that SYSGD only trips when the supercapacitors are almost discharged, here below the response of pulse load of 2A with a duty cycle of 200ms Off and 5ms On. It sows the difficulties of the boost converter to maintain a stable voltage when the supercapacitor is close to complete discharge.

To reduce the number of unique components, the voltage divider of the supercapacitor charger feedback is the same as R22 and R23. The maximum voltage charge is then set to 5V, to extend the life of the supercapacitor, I recommend the version with 3V working voltage, but you can use any of the three members SCCT20 family, in my prototypes I used the cheapest one without any issue.

The ripple of the boost converter is quite high, around 100mV with a strange tooth shape waveform which disappears when the supercapacitors are at 3/4 of the charge, this behavior is also present on the development board from Analog Devices used to develop the prototype.

Once the supercapacitors are partially discharged, the ripple settles in this waveform.

Raspberry Power Supply

To provide a clean and stable power supply to the Raspberry, I used a Simple Switcher from Texas Instrument. Since the goal is to have a low ripple and clean power supply, I choose to use the chip with the FPWM option.

The output and input capacitors are ceramic to improve transient response, and the component placement follows the datasheet's suggestions. I added a 51pF capacitor to increase the stability of the feedback loop. The feedback point has been taken after the current sense resistor of the UPS to improve voltage stability on high load.

The overall ripple at 2A is about 20mVpp.

In theory, the power supply can deliver up to 3A, but due to the constraint of the copper available, the maximum load is around 2,5A, the case temperature of chip settles around 110ºC.

To prevent the power supply to work with an input voltage too low, a voltage divider based on R6 and R7 is used to set a minimum start working voltage of 9.5V and a shutoff of 7V.

Soft Latching Power Switch Circuit

The design of the soft latching power switch required quite some time, I search the internet extensively to find a good inspiration, but almost all the circuits were designed for 5V or 12V power supply and adapting them for the required working voltage range (9 to 24V) was often not feasible or impossible. I tried the omnipresent EEVBlog solution, but I wasn't pleased with its performance. Other circuits couldn't work with a large capacitance as load, and others didn't work at all.
So as the first iteration, I decided to use a specialized IC solution using the MAX16054 chip and clamping its working voltage with a zener. (here below the solution)

Unfortunately, due to the input supply range, the lowest current consumption in OFF state was around 200uA; I could improve it with the new series nanoPower MAX16150, but the chip lacks a SOT case version.

The MAX16054 solution was a decent starting point, but I wanted to develop a reliable switch with virtually no standby current consumption, to use eventually on other projects without any worries of OFF state consumption, and input voltage. In the end, after more extensive research, I stumbled in this circuit:

Frankly, I do not know who the author is, I found it among a bunch of other samples, but the idea was intriguing and worth to be built and tested. To optimize the values of the components and to improve the switch stability I developed a PSpice simulation using Microcap 12 (many thanks to Spectrum Software for making it free software) Below the circuit in his final design:

It is essential to use the exact PSpice model of the P-Mosfet to have an accurate simulation.
The Mosfet is a little oversized for the application, but the idea was to have a standard circuit for different applications, and a 25mΩ RDSon resistance is always a good thing.

I added the JP1, wich shorts U1A to keeps the switch always ON. The capacitor C5 adds some stability at the power-up and improves the overall stability of the switch, and the value can't vary very much; otherwise, the system will stop working. To reduce the required PCB space, I used a complementary transistor couple in a single package.

I used two components to protect the inputs from transients that can be present in a typical alternator source power supply: TVS1 with a standoff voltage of 26V and a clamping voltage of 42V and a P-Mosfet Q1 to protect the input from a reverse voltage miswiring.

Interface with the Raspberry

I tried to implement an interface with the Raspberry with discrete components, but in the end, a microprocessor was the cleanest and most straightforward solution. For the first iteration, I used an 8pin PIC16, but when I realized quite a few people have a programmer for the PIC, I switched to an ATTiny25, which was more than enough to accomplish all the functions and due to his popularity, almost everyone has a way to program it.

It is imperative to program the ATTyny25 when the board is disconnected from the Raspberry since most of the programmers have a +5V power supply, which automatically destroys the GPIO of the Raspberry.

I carefully read the datasheet of the ATTiny, which states it doesn't allow any tension above 0.5V on any pin when the chip is not connected to the power supply, this to avoid any damage to the internal diodes used to protect the inputs; I believe if the current is around 100uA nothing will happen, but I wanted to follow the datasheet specifications, and I decided to use two Mosfet Q4 and Q6 to isolate the pins when the chip is not powered.
For the analog input since any particular speed is required, I decided to use a 200KΩ resistor voltage divider with a capacitor of 100nF enough to supply the internal ADC and create a very smooth signal to prevent false readings. (below a picture of my workbench testing the ADC performance with tooth shape signal and yes, I like to watch StarTrek when I work on my circuits...)

The ATTiny25 Firmware

For the software, the basic idea is to create an interface which it would not require any script to be implemented inside the Raspberry memory. Thankfully all the commands to control the Raspberry could be implemented with two dtoverlay statements in the /boot/config.sys file, precisely:

dtoverlay=gpio-poweroff,gpiopin=21  
// Instruct the raspberry to perform an immediate shutdown

dtoverlay=gpio-shutdown,gpio_pin=16,active_low=0  
// When high signals the Raspberry can be powered off safely

The firmware for the ATTiny25 is a simple state machine which controls the three Raspebbry signal based on the two input from the LTC4041: one is the CAPGD which tells the ATTiny25 the supercapacitors have been used, and the other is an analog voltage which represents the charge voltage of the supercapacitors.

I preferred to monitor the state of charge of the supercapacitor to trip the shutdown command because it is the only solution that guarantees that there is always enough charge to ensure a safe shutdown. At power-on, the interface will keep the Raspberry in reset state till the supercapacitors are fully charged.

The tension at which the supercapacitor trips can be easily changed in software once the board has been tested with the maximum load and the software installed.

#define MIN_VCAP 3600U    // Minimum SuperCaps voltage in mV to start shutdown

For simplicity, I developed the software using PlatformIO; the ATTiny25 can be programmed with the ICSP connector.

Mechanical construction

I designed the board to fit like a HAT matching the same mounting holes of the Raspberry. For the GPIO connector, I preferred to use a passthrough solution with a removable female-male extension; this solution prevented the manual soldering of 40 pins. During the component placement, I suggest to insert a couple of pins in the SMD passthrough connector to center it with the holes on the PCB; the tolerances are quite small.

By using a passthrough connector, the board is .5mm larger; special attention is required for designing the case.

On the board are present several J3 connectors to be used for the different iterations of the Raspberry. The supercapacitors, being very compact, were placed horizontally with any interference from the Raspberry's components. There is also the space to fit a small dissipator on the CPU.

I designed the PCB in two layers, but I added a four layers version for better EMI and heat dissipation.

Case and heat dissipation

Since the power supply and the Raspberry produce quite some heat, I found the best way to keep them cool is to fix the case vertically facing the USB connectors towards the ground; in this way, natural circulation is produced, and the components do not overheat.

I designed the board, keeping in mind the 3B+, and subsequently updated to fit into a 4B, but I believe a new case with forced ventilation should be necessary if the user wants to harvest all the power from the B4.

For the case of 3B+, I took inspiration from this project on Thingverse, even if I redesigned it from the ground up with fusion 360. There is some space for six 8X3mm round cylinder magnets to be placed on the bottom side of the case to hold it against a metal surface.

Conclusion

I hope this project will find some interest, and I believe many applications can find it useful where the power supply is not stable, or good 5V rail is not readily available.

Due to the cost of the project at the moment, I'm not planning to resell as a complete board on Tindie (unfortunately is more expensive than the Raspberry itself), but in case there are enough requests, I would eventually make available the four layers PCB version.

License

This project is released under the Attribution-NonCommercial ShareAlike 4.0 (CC BY-NC-SA 4.0).