This project represents what I believe can be a very effective tool for makers in the electronics and micro controllers world: a portable, battery operated, voltage and current controlled power supply you can control via a mobile application on your smartphone.
When it comes to power supplies there are multiple factors influencing their effectiveness, some though are more important than others when you live your passion in the world of micro controllers.
FlexiPower, with its limited power rating, is certainly not intended as a replacement for a benchtop power supply, but when it comes to portability and stability it can probably be classified in the higher ranks.
The design is simple and tries to minimize component costs while still providing a range of capabilities useful for makers in the field:
- dual channel (you can decide to go single channel, by just populating only one and save on components cost)
- maximum supply voltage is 20V with a 20mV resolution
- maximum supply current is 1A per channel
- fine grained current measurement depending on maximum drawn current:
- 10uA resolution for current up to 40mA
- 20uA resolution for current up to 80mA
- 40uA resolution for current up to 160mA
- 80uA resolution for current up to 320mA
- 2mA resolution for current up to 1A
- current limiting resolution of 4mA
- very low output noise, with practically no noise for output voltages equal or lesser than 6V
- remote control over WiFi 802.11 b/g/n
- data logging and output analisys (via remote app)
- recharge from any 1A 12V DC supply, including car outlets
- reverse voltage protection
- dedicated current sensing connector
Dave Jones, author of the core power supply design, has gone through an extensive description of all the critical choices, the design evolutions over time and all the details in a series of YouTube videos: I will try to briefly summarize here only the key parts and my additions.
I've designed FlexiPower as to provide two completely independent supply channels, which I've modularized into their own schematic, and most of the following considerations will apply to each one of those separately.
The power supply is battery powered by a two cells Li Ion or Li Poly battery: this provides a maximum voltage of 8.4V when fully charged. Lower voltages are achieved simply by feeding the battery output into a high current, very stable, linear voltage regulator, the
LT3080, capable to deliver up to 1.1A.
To reach the higher voltages desired at the supply output the battery is fed into a voltage step up circuit, which I've modularized into its own schematics, having a
MIC2253 integrated at its heart. The output of this device can be controlled via a potentiometer (a digital SPI in our case) and enabled at will. With the booster circuit disabled the battery power goes into the voltage regulator with an additional voltage drop of around 0.5V (the schottky diode), that implies the controller logic will enable the booster circuit only when necessary. This reduces considerably the amount of power wasted and thermal dissipation is substantially simplified: the entire power supply can operate fanless.
Measuring the produced voltage is key to perform the necessary variations to adjust the output accordingly so to provide the desired result. We use a precision voltage reference of 2.048V and a simple voltage divider along with the 10 bit ADC built into the micro controller to determine the output voltage with a 20mV precision. The same voltage reference is also fed into a 10 bit DAC which output is then multiplied by a factor of 10 by an OpAmp to get a 20mV resolution in controlling the output desired on the
Current measuring is similarly performed via different paths, depending on the output level, but in both cases it's based on a 1 Ohm shunt resistor network made by ten 10 Ohm 1% 1/4W resistors in parallel: this results in a voltage drop of 1mV per mA and a maximum power capacity way above the required 1W with a precision statistically better than the 1% of each component resistor.
In case of currents lower than 320mA, the
INA219 integrated circuit is used to obtain a very precise reading with a resolution varying from 10uA (yes, micro amps!) for very low currents (up to 40mA) to 80uA.
When the supplied current goes above the capacity of the
INA219 the shunt resistor voltage drop is measured using the micro controller built in 10 bit ADC but an OpAmp is used to remove any disturbance in the readings.
Current limiting is performed in a very simple way: a PWM signal is output from the micro controller into a low pass filter circuit which produces a quite stable voltage between 0V and 1.055V: the filtered output is then fed into the inverting input of an OpAmp in a comparator configuration. At the same time the current sensing voltage is fed into the non-inverting input of the comparator: whenever the shunt resistor voltage drop goes above the value set via the PWM, the comparator output gets pulled to GND and the output is turned off.
The current limiting resolution though is limited to increments of 4.12mA by the 8 bit PWM resolution of the micro controller.
By pushing the channel current limiting PWM signal down to 0% you are actually disabling the channel.
Battery charge &control
A non-grounded power supply has many advantages, one being you are no more subject to ground loops or short circuits as your project will be floating: if that doesn't mean much to you than a device like FlexiPower is what can save your day. As previously stated FlexiPower operates from 2 Li Ion / Li Poly 18650 cells in series (2S1P).
Battery power requires some control, especially when you are operating from rechargeable batteries: you don't want the voltage to get too low to prevent permanent damage and you want to avoid overcharging, to prevent fire and explosions.
The battery pack can be charged via the barrel jack connecting a 12V source capable of around 1A: the
MCP73213 is a tiny little device intended for battery charge management that can have the charge current set with just a resistor.
The FlexiPower micro controller constantly monitors the battery voltage (through a voltage divider as the battery voltage is above the micro controller voltage scale), provides visual feedback (via the RGB LED) and can also control the channels output accordingly.
Feedback & Remote Control
The FlexiPower has been design to have no physical user controls, the only provided feedback is via LEDs:
- an RGB LED is used to display overall system status like power on, battery level warning, connection status, etc...
- each channel has an associated red/green LED used to display the channel status: ENABLED (green) and OVER CURRENT (yellow) condition
- an LED is also used to indicate battery charge condition: when turned on the inlet input is feeding the battery charge circuit
The RGB LED is fundamental for operating remotely and it's driven by an
ESP8266-11 module which provides the necessary connectivity over WiFi (802.11 b/g/n).
On boot the device will activate an access point with a FlexiPower SSID: devices can connect to that wireless access point to control the power supply. The RGB LED will indicate connection status:
- slow blinking green while booting up
- slow blinking blue when waiting for connection
- breathing blue on connection established
- breathing or blinking (depending on connection status) yellow to red on low battery level (depending on battery voltage)
- fast blinking red and white on connection lost (after a few seconds it goes back to slow blinking, color depending on battery level)
I'm evaluating the possibility to let the power supply try to connect a known WiFi network (empty by default), but if that fails it will fall back to the normal sequence. The drawback is the slower bootup, but that would allow the possibility to control the device at greater distance, even via Internet if network configuration allows it.
I wanted to make the supply capable of data logging because more than often my projects run on battery and power consumption is of essence: this implies I try to turn my projects into sleep mode and turn on power only when needed. I wanted to be able to roughly measure current variations over time, but I wanted to do so without pushing a bigger LCD into the design, so the choice went for re-using what almost everyone of us already has: a smartphone.
With a virtual screen come virtual controls, practically unlimited data logging and quite advanced data visualization capabilities. Being a software developer I've already developed mobile apps and I know such control application will be quite easy to develop...
The power supply design is not entirely my own work, actually I consider it an adaptation of the uSupply project (REV C) from Dave Jones, the host of the quite popular EEVBlog. He has been so kind to share his design under the CC BY-SA license and I decided to bring forward his work along the direction I thought would have fit my, and possibly somebody else, needs.
I initially submitted my ideas to Dave in order to work together on this, but he had his reasons not to do so: I'm sure the whole FlexiPower would have been much better with him aboard, but you are free to improve and, if you wish, contribute back.
I've selected Dangerous Prototypes as PCB manufacturer, as a consequence I had to slightly modify some design rules to accomodate their constraints. I was actually well impressed by the result, especially considering I went for vias full tenting and I also had some vias for thermal relief: have a look at the few detailed shots available in the gallery.
The first produced PCB presented a few errors which I have highlighted in the picture below and have been now fixed:
INA219pads were wrong due to a wrong matching between the schematics and the footprint (the part needed to be fixed)
- the two
INA219were using the same I2C address, one of them needed different connection for the address pins (the schematic and PCB needed to be fixed)
- the pads for power in connector J2 needed to be slotted (the part needed to be fixed)
ESP8266module fotprint was wrong (not shown in the picture as on the bottom side) both in terms of pads distance and in pin matching (the part needed to be replaced)
Soldering the components on the PCB took me almost 4 hours just for one channel: this was my very first time with SMD soldering and some components have a real tough footprint. On top of that I also had to troubleshoot the issues mentioned above, which was not an easy task, believe me.
The outcome has been captured in the picture below: note the missing component at CH1.U5, the
INA219 mentioned above was causing a short between SDA and SCL and I had to desolder it. It's not that bad, isn't it?
Obviously nothing works at first try and FlexiPower is not an exception. Here is my setup while debuggin the I2C issues I've encountered using my 6 helping hands rig to keep cables distant in order to avoid potential shorts, an USBasp programmer connected via ISP to the ATmega328P and a simple USB2TTL to tap into the RX/TX lines and have access to the serial interface.
Firmware, which is not yet finished, is being developed using Eclipse Mars plus Sloeber: the configurations I had to apply in order to get up and running have been described in two posts on my blog: one related to the USBasp drivers for Windows 10 and another regarding the production of an ATmega328 binary.