While I wrote this for my Lenovo Thinkpad P73, this is likely equivally relevant to P53, P72, and P52.
Thinkpad P73 vs P70, not a win all around: only one 2.5" drive instead of 2, and a badly designed power system
So, when lenovo came out with the Thinkpad P70, I wasn't very happy because if you had a 90W power supply, it refused to charge from it, at any rate whatsoever. I was not impressed, but eh, at least it would still power the laptop so that its batteries didn't go flat while plugged in.
Well, leave it to lenovo engineers to make things worse the for the P73. The minimum power supply was raised from 135W (170W recommended) to 170W (230W recommended) which is understandable, but lenovo decided to ensure that the laptop will not take any power from any power supply that does not identify itself as 170W or more. This means that even ifit only needs 40W to sustain itself without digging into the batteries, it will completely refuse to use a 90W or even 135W power supply for anything at all, and kill the battery instead. Lenovo, you just plain suck, there is no excuse for this.
P70 vs P73, they look pretty similar
*Update*: it seems if that if you get a cheaper nvidia chip with the P73, it is then configured to accept 135W power supplies as the minimum required. That said, it will still refuse to work with any regular 90W power supply or external battery back, unless you force it with the center pin resistor swap.
While I have no plans to use windows on that machine, I thought I'd just try it out to see how it does on power. This is where I was impressed, windows can idle at less than 10W for more than 11H runtime, while I'm lucky if I can get linux at 15W. This is definitely a place where linux should do better, of course, it's not as if Lenovo put any work into making linux more efficient on their hardware either:
*Update* : with tlp and using the nouveau driver just enough to turn off the nvidia chip, I'm now able to tune the laptop down to 10W, almost matching windows.
See tlp issue 494 for details on how to setup tlp to run in low power mode when power is plugged in.
Another disappointment is that the P73 is mostly the same size and weight than the P70, but it has less room for storage. It has a bunch of empty spaces that aren't used for anything, and it can't use two 2.5" SATA drives anymore, like the P70 could. Worse, the now single 2.5" slot uses a lenovo only ribbon cable that does not ship with the laptop and basically means you cannot even add a 2.5" drive without that special ribbon cable, which isn't in stock yet. Well done... Ah yes, the battery is also not hot swappable, even if it is replaceable (unlike a Mac laptop where everything is sealed shut).
this shows the unobtanium lenovo cable for the now only single drive that fits, along the unused space
Ok, stop complaining, just buy a bunch of 170w or 230W power supplies and move on with your life
those 170W/230W power supplies are huge. They also weigh as much as some small notebooks (!)
I have 12V to 20V car adapters, those won't work anymore
I have external battery packs for extended runtime, and I haven't found a single one that can deliver the amps a P73 tries to needlessly require
Tricking the P70 and P73 into accepting a power supply it wouldn't otherwise use
Lenovo uses the a center pin resistor to know how much power they can draw from the power supply, see: http://www.thinkwiki.org/wiki/Power_Connector .
For the P70, I built this power supply adapter with a resistor bridge to tell the laptop how big it should think the power supply, is:
It's basically a configurable version of this. Yes, lenovo, I thank you for the hours I wasted opening up power supply plugs and replacing the center pin resistors:
Here's how the P73 responds:
- 230W works fine 4.6k => I have seen power supplies work with 170W but fail at 230W, so the laptop does draw more
- 170W works ok 1.9k (1.8k also ok)
- 130W rejected 1k
- 90W rejected 550
The rejected power supplies will be used to charge the laptop if it is shutdown, but they will not be used in any way otherwise. On the P70 the laptop would at least use the power supply to keep the laptop alive, and use half battery half external power supply. Not so with the P73, it just ignores it entirely.
This is utter bullshit as I have plenty of 90W power supplies, including 12V car converters, or a 90W external 20V battery pack I can't use anymore.
You can go read my Hacking a thinkpad slim tip adapter to output more than 90W (required to charge a Thinkpad P70) page for details, including this nice battery pack I couldn't use anymore:
*Update* : so, actually with some serious tlp hacking (basically I told it to force battery mode even if a power supply is plugged in), I've managed to throttle the laptop enough, even when plugged in, so that it only uses 20W. At that point, I'm actually able to use my old external battery pack, as well as a 90W power supply, as long as I lie to the laptop and pretend they are 230W power supplies with the resistor trick. In my tests with windows, it was not possible to throttle the laptop enough when plugged in, not to have it overwhelm a smaller power supply (not that 90W is small for a laptop that normally uses 20-30W when it's not charging batteries).
If you scroll to the bottom of the page, you'll also see a terrible buffer lipo hardware hack I did that allows to use the battery pack with higher amp draws, but it's a bit ridiculous (and bulky).
See tlp issue 494 for details on how to setup tlp to run in low power mode when power is plugged in.
Without the tlp hack or the buffer lipo hack, when I lie to the laptop and tell it is connected to a a bigger power supply, manage power draw with what I run, and disable battery charging in software, but the laptop will still draw the power supply for over 100W when you plug it in for a fraction of a second, and refuse it if the voltage drops.
Obviously this would not be a problem if the laptop simply had a 90W power supply mode where it throttle things down and turned off battery charging. This is mostly what the P70 does.
In the meantme, on top of hacking my power supplies, I also made this for my laptop, it looks silly and makes the thinkpad not look like a professional laptop, but well, that's lenovo's fault:
this takes any power supply and replaces the center tip resistor with a 1.9k one to emulate a 170W power supply
From talking to Lenovo, they don't think that this is really a problem, so since I'm an engineer, I made my own external battery pack, but I otherwise recommend to road warriors to avoid thinkpads from now on, given the backward power design in this one.
Making a Thinkpad P73 compatible external battery pack
I did some testing and confirmed that the laptop is very picky about power supplies. It even rejects a 19.7V 20A power supply I had, because it's 19.8V and not 20V. Same thing for amps, it needs to be able to draw maybe around 5A for a short time to accept the power supply (they sure are putting a lot of effort into making sure the power supply is not under-spec'ed).
Prototype with 150W step up converter which takes my 16V lipo to 20V while delivering enough amps to make the laptop happy:
it works, and the laptop thinks it's connected to a 230W power supply thanks to the center pin resistor.
Here's a quick demo:
Version 2 was to have a way to recharge the battery pack while it's being used. I've used this to use the battery pack as a buffer to absorb peaks from the laptop without tripping an external power supply, including in a car limited to 100W or a plane power supply limited to even less:
this works in theory, but the lipo charger is quite slow and wouldn't keep up for long, but I made a better version shown lower down
Lenovo's P73 airplane mode simply stops using the external power supply and reverts to batteries. Sigh...
Oh yes, let's talk about airplane mode. The lenovo engineers thought of everything: if they detect that the power supply drops a few times in a row, they offer a nice setting which is supposed to make the plane more airplane friendly. How friendly you ask? Well, you could throttle down the CPUs, disable battery charging, do smart stuff like that. Or, if you're lenovo, you can have airplane mode simply refuse to use the power supply altogether. Thank you lenovo, you wrote a feature that saves me the trouble of unplugging an otherwise perfectly good power supply that you refuse to use (to be super clear, my 230W power supply is plugged in and airplane mode just disabled it):
Making a battery pack to act both as buffer for a smaller power supply, and as emergency external power (even power the laptop from 12v)
Anyway, back to the battery pack, I found the ISDT H605 Air lipo charger which is small enough and can charge the lipo at 5A, which should be enough to keep up with the laptop when not doing CPU crazy stuff. This also allows using a 12V power supply or a lower wattage lenovo power supply to recharge the pack while it's in use, or not:
version 1 was a bit bigger than I wanted, 90W power supply shown for scale
here, the 90W power supply is recharging the battery at 2.5A while it's being discharged at 3A on the output side, using the battery as buffer
I made version 3 a bit smaller, with a built in 12V lipo to act as buffer for a smaller power supply. Yes, it's a beautiful piece of art, I know :)
Pushed to the extreme, I can now use my original external battery pack again by having it recharge my lipo+150W step up that can output more amps than the ravpower pack can. Of couse, it's inefficient, the ravpower pack outputs 20V that gets down converted to 12V by the H605 Air lipo charger, which charges the built in 3S lipo in the box, and then gets up converted back to 20V without the amp limitation (the phone used to control the lipo charger also inside the box):
The really cool thing is that by using tlp, it's actually possible to tune the laptop down to very low power use, even when plugged in, something that windows probably can't do:
7.3W with the screen off (and around 10W with wifi off and the screen on low dim) is not bad for a laptop that big
4S Lipo vs 4x 18650 or 26650 batteries
I do have a few lipos laying around, so that's free energy for my laptop if I'm willing to carry them. I have however found that for higher draws, the step up converter doesn't quite keep up at 20V/5A+ with just 12V input (3S), but is fine with 16V input (4S):
That said, as I recently found out that 16650 (or better 26650) batteries are both lighter and smaller. The only thing the lipos do, is offer a better discharge rate, but while that's useful for a high power RC plane motor that can empty the batteries in 10mn, it's not needed for a laptop:
Outside of 26650 batteries, there are other ones like https://www.18650batterystore.com/21700-p/samsung-50e.htm .
26650s are 195 Wh/kg while the lipo I gave was 184Wh/kg. The 3rd battery listed is supposed to be 260Wh/kg which is much nicer, that said, it looks like those samsung batteries are actually smaller than 26650s, lighter, and yet offer the same 5Ah at 3.6V. If so, that's very impressive.
As of this writing, I have however not found 26650 battery holders that hold 26650 protected cells that are a bit longer. This seems to the be only one available, and it's too short to hold the batteries: https://www.amazon.com/gp/product/B074GVPWSH
A few months later, I ended up cutting them and taping them to make them longer. It doesn't work great, but it was enough for a few tests. In the end, I found that somehow I wasn't getting enough amps out of them, which surprised me, so they didn't work that well compared to a lipo:
Lenovo, please make the P73 work like the P70, and fix this airplane mode thing that turns off the external power supply. That's embarrassing...
Iwas interested in getting a decent amount of amps from my car while it's parked at home if I'm in a power emergency situation (i.e. no power) for maybe 2-3 days (as sadly is now a new "normal" in california).
I knew that this could void the warranty on some parts of the car. I was ok with that. Tesla wants me to buy a powerwall, but I think powerwalls are stupid.
I'd need to spend $30 to $40K in powerwalls to get the same amount of energy I already have in my car and I already paid for. Sorry, but I'm not spending that much for something I may need once every few years. Load shifting my solar in california is otherwise a straight loss, and PG&E forces some silly rules about not allow using powerwalls for time of use power arbitration if you accept the buying credit for them. You get penalized for helping take the peaks off the grid, yeah bureaucracy!
If tesla sold a powerwall that would allow using your car as a battery source for emergencies only (car batteries are not designed for daily cycling like powerwalls), I'd be super interested, but they do not, so I decided to make my own answer.
I knew that I could probably only get 2-3000W out of my car, honestly for emergency use (a couple of fridges and essential equipment), that's good enough. Sure, it wouldn't power all my house lights, or even my furnace for heating (which happens to use over 1000W just to run the fans), but eh, it's for emergency use only, so good enough.
Plugging into the standby 12V battery
What I knew from the beginning is that the battery in the car is way too small to power a proper size inverter (I have a 3000W one to be safe but honestly I only plan on using 1000W peak for my fridge and an average of 200W otherwise when the fridge is on). What I didn't know is that the Model 3 only provides trickle charge power to the battery, enough to charge it for normal use in the car, but not enough to recharge it if you plug a reasonable inverter into it (it will discharge quicker than it can recharge).
My plan was to connect a big GLA 12V battery in parallel with the car's battery, so that it could absorb big peaks and buffer a it longer in case the car's battery recharge didn't kick in quickly enough. I did however confirm that the car's DC-DC system only recharges the standby battery at a slow rate, so it was not adequate for my need.
Plugging into the cigarette lighter adapter
For some uses, it would work to use some DC-DC charging system to recharge a big 12V battery external to the car and try to keep the car awake as much as possible so that the 12V CLA port stays on. The only issue with that plan is that you can only get about 12A sustained from it, so if you are planning on using over 100W average, this will not work in the end. In my case, my fridge was more in the 200W range.
Tapping into the car's DC-DC system
This is where things get interesting. The car's battery pack is in the 400V range, and 400V DC will definitely kill you (DC is actually worse than AC), so don't even think about messing with that unless you are truly a trained professional.
For the rest of us, what you need to know is that the car has a DC-DC converter that turns 400V into 14V DC. This is used to power the car's systems when it's not sleeping, as well as recharge the small 12V battery that keeps things alive when the car is asleep. The idea is to tap directly into that 12V system which I'm told can provide up to 200A/2000W (which converted to 120V is really only 20A). A few things to note:
The 12V tap is available under the rear seats which you can remove by pushing to clips sideways
Connecting to ground is easy, connecting to the 12V pole is a bit more tricky. It's best to leave the current cable in there as it needs a perfect connection to conduct all the amps it's meant to carry. You can however add a 2nd connector on top of it an add a second nut on top (the bolt it long enough for this, and it seems to be purposely so)
If the DC-DC senses a short, it will shut down to protect itself. This is good, but also bad. The problem is that after it shuts down, it doesn't reset easily, or at all. Once it's shutdown, your standby 12V battery will discharge without being recharged, until it dies. You can recharge it with a 12V battery charger, but obviously this is only a temporary measure
If your DC-DC converter does not reset, you need to disconnect the 12V battery entirely, causing the entire car to shudown and reset. When I did that, my DC-DC converter came back online
Where it gets interesting, is that inverters come with a big capacitor to allow for transient loads. Those capacitors will take almost infinite energy when you connect them, causing a big spark, and looking like a short, causing the very undesirable shutdown explained above.
The solution is to wire a big resistor in front of your inverter so that it can charge its capacitor slowly
Then add a 200A relay to bypass the resistor when the inverter is 'charged'. The relay can be powered by connecting it to the inverter itself on the 12V side, making it so that when the capacitor is charged, the voltage across the inverter poles is high enough to actuate the relay and bypass the resistor.
The 2 white holes are where the clips that you need to release. are located. You can also see the black and red tap points:
resistor limits current and starts charging the capacitor in the inverter, slowly bringing the voltage across its poles from 0V to 12V
voltage across the inverter starts rising until 10V or whatever
once it's enough, the relay is energized and bypasses the resistor
now 200A can go to the inverter and no spark/current inrush was created, and your DC-DC converter doesn't shutdown when it turns on
This shows the current meter shunt connected to the bypass relay (which is powered by the connectors on the inverter side). You then see the thick 100W resistor connected in parallel with the relay. This allows current to flow more slowly and ramp up the connection:
I tested a 1300W microwave which worked without issues, so did my fridge and other devices. The pure sine wave inverter is very important for a microwave, but a cheaper inverter worked well enough for my fridge and basic loads.
Since we're talking about currents of 100A or more, we need to talk about wire gauge. The inverter I got came with 10AWG cables of about 1m. These cables are insufficient for 100A (never mind 200A), but in real life will mostly work for short distances and as long as you don't use the full power continuously (which could technically heat up the cable enough to melt its insulation and cause a short eventually). In my tests with 100A, I lost 0.7V due to inadequate wiring:
0.25V lost in each of the two 10AWG cables (good quality)
Extra wire from relay to inverter lost 0.06V
200A relay only lost 0.06V
100A shunt for power meter lost 0.1V (and gets warm)
Given that the car outputs 13.5 to 14V, this drop is not big enough to matter since the inverter works all the way down to 10V or so, but be mindful of potential heat. Here is the end result:
Keeping the DC-DC system awake
One thing that you still need, it to keep the car from going to sleep if you want the DC-DC converter to stay on. Thankfully a recent software update added camper mode. You can just go in the climate screen/fan icon, set the car in park, and set 'keep climate on' to 'Camp', turn off AC and set the temperature to something low in order to save batteries (i.e. not waste the batteries into climate control).
If you know of a more battery efficient way to keep the DC-DC system on without having to run climate or even having the control screens on, let me know (contact Email link at the bottom of this page). Hell, if you build one and get it working, shoot me an Email too :)
Backfeeding your house
If you really know what you're doing, you could use this with a custom made male-male outlet, to backfeed one or both phases of your house (it won't power anything 240V of course). The advantage is that you don't have to run extension cords and power existing lights in your house. If you do this, you must carefully disconnect utility power so that you don't backfeed the grid, as well as potential solar panels that could decide to sync with your inverter and feed more power than you're using, causing other issues you don't want to deal with. Of course, you'll find that 1000-3000W may not be enough power unless you do careful load shedding
I'm not going to give more details because there is definite potential for things going wrong in many ways, but if you absolutely know what you're doing, there you go...
The Frosted Clear Plastic Cutting Mat was good for protection, but didn't offer too much diffusion. Still, it was better than nothing, and that's what I ended up using in the front of my shirt.
The Serenity Foam Underlayment for Laminate Flooring offered better diffusion, but no protection at all. However, I figured out that if I used that, plus the cutting mat on top, I got extra diffusion and protection.
If you wonder, the demos below can be had from:
I've been going to linux.conf.au for 18 years now (since 2001), and presented a fair amount of linux talks related there, but the big change for me was the open hardware miniconf that started in 2010. Thanks to its projects every year, I got to learn a lot about microcontrollers and some about electronics.
This talk was my first non linux talk which detailled everything I learned from those miniconfs and projects I worked that stemmed from them. I presented it at LCA 2019 Christchurch.
you can find the talk pdf here: http://marc.merlins.org/linux/talks/Using_Open_Hardware/Using_Open_Hardware.pdf (you'll want this one to get all the clickable links in the slides)
you can view the talk slides in html here or below:
Talk video below:
I arrived the sunday before the conference and helped out the open hardware organizers with a bit of last minute setup. I also got to do some last minute testing and tuning of my panels:
hacked up ESP32 with level converters on breadboard to run 3x 64x32 SmartMatrix panels with SmartMatrix::GFX
64x64 P3.8 SmartMatrix::GFX panel vs 3x 64x32 SmartMatrix::GFX P4 flexible panels vs 4x 16x16 FastLED::NeoMatrix P10 panels
After finishing the code tuning and demos just in time, gave a 20mn miniconf talk on the history of linux.conf.au hardware miniconf. I went through how much I learned from those confs and what I was able to achieve as a result. I sure got to learn a lot about microcontroller and driver programming:
I wasn't able to bring my burning man 4096 neopixel matrix, it doesn't even fit in my car, but the irony is that my small 64x64 rgbpanel has the same resolution and fits easily in my backpack
The 64x64 compact display is showing the hand X-ray here
A few days later, I gave the longer version of my talk at the main conference. By then it had grown to over 160 slides in a 45mn slot, or 16 seconds per slide. Ooops...
The full talk went into details on what I learned in the hardware hacking field, a lot of it was simply electricity, U=RI, wires, pre-made components (small inline volt/amp meters, DC-DC converters, and so forth).
When you're off the grid (for many, still true at burning man, or Ephemerisle, you can:
bring big batteries (Li-Ion USB packs and/or big Lead Acid Batteries (AGM is better than car battery)
use solar panels to help recharge the batteries, but most people don't quite realize that panels need to be sufficiently big (and heavy) to charge sufficiently. You also need a charge controller.
use a generator. Generators are quite efficient and cheap for occasional use and make way more power than solar panels per unit of weight. Sadly, they are noisy and not environmentally friendly.
The ideal solution is batteries only if your event isn't too long and you've done the math that the batteries have enough Wh for your needs
Next, is usually batteries + generator that you start as needed. Solar is really the best solution, but it requires more complicated hardware and setup (charge controller, MPPT charger, etc...), but more importantly for any non trivial power need you actually need pretty bulky and heavy panels to handle the load (of course this also relies on you being able to count on enough sun during your event at that location, not an issue for burning man, but potentially an issue for a spring festival in some place that could be overcast or maybe even rainy).
Anyway, back to charging, your best bet is to use 12V lead acid (marine, or AGM are even better), and use DC to DC converters to power all your stuff. For 12V, well, you're done, just plug into that using the appropriate cabling with fuses. You will likely be happy with those two:
Now, some laptops may charge from 5V USB if you're lucky (but that will be slow). Some will charge from USB-C which may allow 12V charging or even 20V charging, but finding such a charger that works from 12V may not be trivial. In the case of my thinkpad, it just plain requires 20V, and not only that, it requires 20V at 5.5A or it will power itself, but it not charge (yes, it is stupid).
I wrote this page on how to hack a 20V power connection to look like it's at least 135W so that a thinkpad will charge, however I need to upconvert 12V up to 20V with more than 10A from the 12V source. I used a discontinued version of this boost converter, and I also have a 100Wh Li-Ion battery pack that can output enough power to sustain my laptop, but not to charge it. That one also requires 20V to charge (sadly it won't charge from 12V):
this battery pack can output 9, 12, 16, 19, or 20V
You can see the 12V being split and going into the little white box with the step up boost converter. It shows that it's taking 3.5A at 12V and the red display next to the laptop shows it's turned into 1.7A at 20V which goes both into the already charged laptop and the almost charged ravpower battery pack:
it might not look like much, but this is my new 160W laptop power supply :)
5V USB charging
Now, let's look into 5V charging, i.e. USB devices. There are plenty of ways of turning 12V into 5V, that's what all car phone chargers do, but most don't deliver many amps, and don't allow full speed charging for more than 2 or 3 devices on a good day. As a result, I'l recommend this 14 port anker USB hub where you'll ignore the USB part and simply use the fact that it has 80W of charging capacity from 12V input:
After I figured that my previous shirt was getting a bit stale, I wanted to design EDM Party Shirt v2, which both had to be easier to wash (the previous one had LED strips all over it that were too much work to remove, making the shirt not really washable), and I also wanted it to be more special.
I had been playing with Adafruit::NeoMatrix and figured it would be cool to have a NeoMatrix on my shirt (also it would be easier to remove a whole panel to wash the shirt).
So, in the great tradition of yak shaving, I first decided that I should be able to use FastLED instead of Adafruit::Neopixel. This was mainly at the time because FastLED allows parallel output and therefore allows updating a screen by segmenting it in smaller pieces that are updated in parallel. With Adafruit::NeoMatrix, my 768 pixel panel would have taken about 30ms to refresh, or only 33 frames per second, which is not a lot. With FastLED, I was able to trivially segment it in 3 and get 10ms/100fps, which is a whole lot better for animations.
Turns out, switching to FastLED also gave me access to LEDMatrix, an alternate library which while lacking Adafruit::GFX primitives, offers another nice API including better text and basic sprite support.
So, I started a port of Adafruit::NeoMatrix to FastLED and wrote FastLED::NeoMatrix. It was actually a non trivial port, which took much longer than I thought, but I got it working in the end:
by then I was already able to display with 3 data lines, one for each 32x8 panel
In the process, I managed to plug the wrong power into the panel and blew a pixel. Thankfully I was able to borrow another pixel from a strip and soldering it in place to fix it:
Once the port was done, came time to get the panels together. Wiring was a bit challenging because I had to ensure that power was injected at a mostly equal value in 9 different points (3 per panel) due to voltage sag at higher amps. I then quickly found out that with 3 data lines at high frequency, there is cross talk between the wires, so I switched to a CAT-5e cable where each data line is twisted with its ground and the remaining 2 wires are used to bring VCC (5V). Technically my 3 panels can use up to 60A at 5V at full power. Obviously many things will melt before that, and I'm using a power converter that tops out at 10A. Even 10A is too much for the wiring, but thankfully my displays don't use that much brightness (it would be blinding to people):
two 5Ah 16V lipos give about 160Wh, just enough to run 2 panels 10 to 12H
the fancy energy meter keeps track of how much time I used and how many Ah came out of the batteries. Useful to know how much time I have left. The blue meter is amps at 5V (after the power converter) and the red one amps at 16V (straight from the battery)
on the right, I have a backup ESP8266 if the main one fails, a backup BEC (5V converter) that's technically 10A capable but not meant to do more than 5A continous, and bottom right is my older 3A BEC with in line amp meter
the new tobsun 5V converter is bulky but does 10A without issues
For the back of the shirt, I got some fabric and created an inside pocket to hold the panel:
it then mirrors the front
All this crap goes into a fanny pack, and gets wired to my shirt, pants, and glasses:
the cool part is that my back also has a panel inside the shirt that uses the shirt as a diffuser
Sure, it's here: https://github.com/marcmerlin/Neopixel-IR (but go to the end of this page for more details).
So, I have 3 versions of the shirt, let's go through them depending on how complex you'd like to go:
Multi Color LED strip, non controllable
It used a 12V controllable dimmer: https://www.amazon.com/gp/product/B00MHKCTLE which can simply change the brightness of the LEDs, which are of a set color. I bought the LED strip in Akihabara Japan, but I'm guessing something similar can be found elsewhere.
they are a flat trip that doesn't really like being bent
all the LEDs are in series, so if the chain fails somewhere, nothing lights up beyond the point of failure (which is why I have extra wires soldered on to make redundant paths and get around breakage
I have had some sections of 3 LEDs where one color died
All of the controllers I tried have a dimming function, but it fails to work when I use the fade dimming patterns, which means they are full bright, suck battery and blind others. I've therefore had to add a 2nd voltage regulator where I can just dim the voltage sufficiently so that the current is then also capped by each color string and therefore the brightness is controlled (you cannot limit the global current fed to the LED controller because you don't know whether it's all fed into a single color, or shared amongst 3).
Of course the last thing is that all the LEDs for a color are in series in a single circuit, so you light up all the reds, or all the blues or greens, or none. You can't turn on one LED individuallly. This is where the next solution comes in.
ESP8266/Arduino Controlled Neopixels
To fix the issue of not being able to have custom multi color LED patterns, where each LED/pixel can be controlled separately, the solution is neopixels (aka WS2811/WS2812/WS2812B). Each LED/pixel is controllable separately, which is done by a computer, in this case the ESP8266 can run my own programs to control all the LEDs.
The ESP8266 is a 3.3V based microcontroller for low power use (good when battery powered) while the neopixels are 5V powered, but thankfully the neopixels can use 3.3V signalling from the ESP8266 while being 5V powered to light up properly. The one thing to keep in mind is that neopixels use some power even if they are not lit. In my case 200 neopixels, take about 120mA when they are off, and 4.5A when they are all lit in white on full brightness.
Neopixels are almost infinitely versatile, instead of having them in single line strips like on my shirt and pants, you can also make display matrices out of them:
The end goal was adding neopixel strips on my shirt sleeves and pant legs:
Here is a 6mn clip showing the shoes and shirt if you'd like the details:
The problem with my shirt, though, is that the colors you see on the picture are actually due to broken traces, causing the colors you see. It's better than nothing, but not what I was trying to do, and no way to create streaming effects. This is of course where neopixels come in.
I'm not going to repeat the excellent Adafruit Neopixel Uberguide here, but I have a 3mn video clip showing a standard IR RGB LED controller, compared to a neopixel strip. It also shows how I use standard remote control servo cables to wire neopixels, and how to watch out for:
signal wire being in the center, so you must not feed 5V on the middle wire like you would with RC and servos
how if you have a neopixel strip that doesn't work right, you can only connect to the first LED, and you have to start cutting off LEDs from the strip one by one until you get to the first one that works
before you start cutting, make very sure you aren't connecting to the last LED (DO vs DI)
Why IR and Neopixels at the same time, is hard
So, the main point of this page is however to look into the issues of controlling Neopixels and receiving IR signals at the same time.
It's easy to listen for IR, and then change neopixels, leave them alone, and listen for IR again. It's hard (or near impossible on some chips) to actively update neopixel strips for animations and listen for IR commands at the same time.
Why? This video explains the issue:
What's going on is on low end arduino chips (328p, leonardo, or even AT mega and all other 16 bit AVRs), neopixels are controlled by stopping chip interrupts and sending a very precisely timed signal to the neopixels. If the timing is off just a little bit, the wrong colors get sent, or nothing works at all. This is why interrupts must be disabled
Now, there are actually many other addressable multicolor LED types. The nice ones are 4 wire and work via SPI, which allows the CPU to control the timing and the clock, removing this exact bit banging timing issue. The cheaper 3 wire ones have a set clock and require that the CPU sends a very precisely timed signal, usually done while disabling interrupts. See https://github.com/FastLED/FastLED/wiki/Overview
But since neopixel strips (aka WS2811/WS2812/WS2812B) is what I already had, I now had to deal with this precise timing issue. As you can guess, disabling interrupts causes issues with the IRRemote library because it has its on interrupt handler timer that also requires being run at a special timing, or it doesn't capture proper IR signals.
The end result is that you cannot disable interrupts and receive IR signals, and if you don't disable interrupts, the neopixel signal is unstable and the colors flicker (demonstrated int the video above).
So, unless you use some special hardware to drive neopixels strips on an AVR chip, concurrent IR + neopixels is just not going to work.
an arduino nano v3 running neopixel strips
my 328p arduiny chip (equivalent to arduino nano) and anti plug backwards toothpicks :)
because my 328p chip was unprogrammed, I had to figure out direct ISP programming pinout for it and I flashed a bootloader on it
Concurrent IR + Neopixels solution #1: be fast (Teensy 3.1)
a few chips for comparison (uno, leostick, nano v3, arduiny, and Teensy 3.1 in green)
Thanks to better FastLED hardware support, when I moved my code to a Teensy 3.1 32 bit ARM CPU, the CPU was fast enough that it had time to re-enable interrupts in the middle of updating neopixels. This in turns allowed the IR Remote interrupt handler to just barely run in between pixel updates, and capture IR codes. Success!
See this video for details:
The magic code that makes this work, is here: https://github.com/FastLED/FastLED/blob/master/platforms/arm/k20/clockless_arm_k20.h#L34 sei(); delayMicroseconds(WAIT_TIME); cli();
Thanks to this re-enabling of interrupts, things work.
So at this point, someone sensible would have declared victory. However, I felt bad wasting a Teensy 3.1 on something as simple as driving a single neopixel strip (it can drive 8 in parallel) and reading from an IR receiver, when it has around 32 I/O ports. This is why I checked if I could get this to work on ESP8266 chips which are even cheaper and have much fewer I/O pins (but add Wifi)
Concurrent IR + Neopixels solution #2: don't use the CPU for neopixels (ESP8266 (I2S) and ESP32 (RMT))
I had more 32bit chips, so I thought I would give them a try. I tried the ESP8266 and ESP32:
However in my tests, the IRremoteESP8266 library was maybe a little bit too slow and caused occasional visible neopixel glitching (this has been fixed in FastLED since I originally wrote this). This is where I found this interesting library: https://github.com/JoDaNl/esp8266_ws2812_i2s/ which manages to drive the neopixels without doing bit banging with interrupts disabled ((ab)-using the I2S hardware support). It's not a very fancy library in what it offers, but it works perfectly with interrupts enabled.
There is another DMA library using the UART instead of I2S interface, that also works without affecting interrupts: https://github.com/Makuna/NeoPixelBus
Same thing for ESP32. Actually ESP32 is even more difficult to get a perfect timing out of using bit-banging given that it's a dual core CPU running on top of an RTOS, and no matter how precise your code is, you just cannot guarantee that it'll run perfectly at the timing you need all the time. I did add ESP32 support to the Adafruit Neopixel library, but it only works most of the time, which isn't really good enough.
This where its built in RMT support comes in. It can generate 8 precise signal waves, which are perfect for neopixels, so this is the way to go to animate neopixels without disabling interrupts (making IR receiving trivial). IRremote was missing ESP32 receive support, but I added it recently, so it's all working.
FastLED now supports RMT on ESP32, so you can run interrupts while talking to Neopixels.
Here's a video summary of ESP8266 and ESP32:
Software and Libraries
So, here's a summary of all the libraries I went through, 2 for IR, and 4 for Neopixels:
FastLED is a more complete library with better hardware support (both in pixels and CPUs): https://github.com/FastLED/FastLED . The big plus of this lib is that it support re-enabling interrupts on 32bit chips, allowing the IRremote ISR to run.
Instead of FastLED (which does work), on ESP8266 you can use https://github.com/JoDaNl/esp8266_ws2812_i2s/ . The support is bare, but uses an inventive (ab)use of the I2S subsystem (I2C for audio) to generate neopixel signals using an onboard co-processor unit without tying up the main CPU or requiring the disabling of interrupts.
On ESP32, FastLED wasn't supported when I wrote this blog (I added support in Adafruit-Neopixel but it require disabling interrupts at least temporarily and it's hard to do anything real time on a dual core ESP32 running on top of an RTOS). The good news however is that it has 8 RMT channels which are designed to handle precise signals like this without tying up the CPU. See this code that supports Neopixels with exact timing: https://github.com/MartyMacGyver/ESP32-Digital-RGB-LED-Drivers . After I wrote this, FastLED added RMT support on ESP32, so it "just works" now.
This is a 25mn mashup of all the video clips, including a section on flashing the arduiny via ISP (AVR 328p):
I also have a video showing the evolution of lights on my shirt from v1 (single non controllable color) to v2 (tri color, but not pixel addressable), to neopixels with cool patterns (jump to 3:50 if you'd like that):
This is what you find under the sole: everything is inside a resin and the built it lipo is too small (only 4H runtime). Two sets of 4 wires come out: one is to control the LEDs and the other one has 2 wires for the switch built in the shoe, and 2 wires for the USB power charging (which charges super slowly, about 4X slower than the speed the lipo can charge at):
The first thing to do is to open the side of the shoe to get to the switch, take it out, and turn it around so that it points away from your foot. Otherwise it's way too easy to trigger. I've also cut the yellow wire and added a small slider switch. This allows me to disable the push switch if I want the shoes to stay off, or not rotate between color patterns each time the switch gets bumped:
The lipo is totally built in and too small. Adding a second lipo in parallel is a bit difficult, I had to burn off the resin to access the lipo terminals:
it claimes 450mAh, but I think it's smaller
it's a bit difficult to solder wires on top of the lipo wires without shorting it
I then added a female connector to allow use of bigger lipos from a mobius I wasn't using
I had a few lipos to choose from, but the mobius one was the best fit for the hole in the shoe
I had to cut off a bit of plastic fit the battery
still a bit of a tight fit
My shoes now work a bit over 12H, do not turn on or off without my wanting them to, and they come with a real off switch. I did put a very solid sole insert on top though to protect the electronics and the new bigger lipo underneath. There is also a worst case scenario where it could catch fire :)
I later got another pair of shoes with dual LED pattern, the battery is still quite small (450mA), and on top of that the shoes shut off on their own every 2H. Sigh...
getting to the battery contacts is still hard
I added a direct port to the lipo for optional faster charging and charge status check
Also, the charging function is slow as crap, but the direct lipo access charging port I added lets me recharge the batteries directly in one 1h by connecting directly to a proper lipo charger. They do suck in several ways, but in the meantime, finding dual pattern LED shoes with LED strips that flex instead of breaking, wasn't trivial either...